simpleparse.common.strings | index /usr/src/tmp/python3-module-simpleparse-buildroot/usr/lib/python3/site-packages/simpleparse/common/strings.py |
Python string parsers with escape characters
Python-string-like operation as much as possible, this includes:
support for single and double-quoted strings
support for triple-quoted versions of the same
support for special character escapes as seen in 8-bit python strings
support for octal and hexidecimal character escapes
string_single_quote
string_double_quote
string_triple_single
string_triple_double
Individual string types with the above features
string
Any of the above string types, in a simple FirstOf group
with the triple-quoted types first, then the single quoted
i.e. generated with this grammar:
string_triple_double/string_triple_single/string_double_quote/string_single_quote
Interpreters:
StringInterpreter
Interprets any/all of the above as a normal (non-Raw) Python
regular (non-unicode) string. Hopefully the action is identical
to doing eval( matchedString, {},{}), without the negative security
implications of that approach. Note that you need to make the
interpreter available under each name you use directly in your
grammar, so if you use string_single_quote and string_double_quote
directly, then you need to add:
string_single_quote = myStringInterpreterInstance
string_double_quote = myStringInterpreterInstance
to your processor class.
Modules | ||||||
|
Classes | ||||||||||
|
Data | ||
__file__ = '/usr/src/tmp/python3-module-simpleparse-buildroo...thon3/site-packages/simpleparse/common/strings.py' __name__ = 'simpleparse.common.strings' __package__ = 'simpleparse.common' _p = <simpleparse.parser.Parser object> _stringTypeData = [('string_double_quote', '\n<delimiter> := \'"\'\nnondelimiter...\\\\"]+\nstring_special_escapes := [\\\\abfnrtv"]\n'), ('string_single_quote', '\n<delimiter> := "\'"\nnondelimiter...\\\\\']+\nstring_special_escapes := [\\\\abfnrtv\']\n'), ('string_triple_single', '\nnondelimiter := -"\'\'\'"\n<delimite...\\\\\']+\nstring_special_escapes := [\\\\abfnrtv\']\n'), ('string_triple_double', '\nnondelimiter := -\'"""\'\n<delimite...\\\\"]+\nstring_special_escapes := [\\\\abfnrtv"]\n')] c = {'string': LibraryElement(value='string',report=True,negati...,repeating=False,expanded=False,lookahead=False ), 'string_double_quote': LibraryElement(value='str',report=True,negative=...,repeating=False,expanded=False,lookahead=False ), 'string_single_quote': LibraryElement(value='str',report=True,negative=...,repeating=False,expanded=False,lookahead=False ), 'string_triple_double': LibraryElement(value='str',report=True,negative=...,repeating=False,expanded=False,lookahead=False ), 'string_triple_single': LibraryElement(value='str',report=True,negative=...,repeating=False,expanded=False,lookahead=False )} name = 'string_triple_double' partial = '\nnondelimiter := -\'"""\'\n<delimite...\\\\"]+\nstring_special_escapes := [\\\\abfnrtv"]\n' stringDeclaration = '\n# note that non-delimiter can never be hit by n...# i.e. a backslash preceding a non-special char\n\n' |