![]() # e+ # Match one or more occurrences of e. # e* # Match zero or more occurrences of e. In that case, a | must be used before the first # alternative, like so: # rule_name: # | first_alt # | second_alt # ( e ) # Match e (allows also to use other operators in the group like '(e)*') # or e? # Optionally match e. # The first alternative can also appear on the line after the rule name for # formatting purposes. # Grammar Syntax (see PEP 617 for more information): # rule_name: expression # Optionally, a type can be included right after the rule name, which # specifies the return type of the C or Python function corresponding to the # rule: # rule_name: expression # If the return type is omitted, then a void * is returned in C and an Any in # Python. ![]() ![]() # - The order of the alternatives involving invalid rules matter # (like any rule in PEG). # - If the parser fails in the second phase with a generic syntax error, the # location of the generic failure of the first pass will be used (this avoids # reporting incorrect locations due to the invalid rules). # - Only if the first pass fails to parse, a second pass including the invalid # rules will be executed. # PEG grammar for Python # = START OF THE GRAMMAR = # General grammatical elements and rules: # * Strings with double quotes (") denote SOFT KEYWORDS # * Strings with single quotes (') denote KEYWORDS # * Upper case names (NAME) denote tokens in the Grammar/Tokens file # * Rule names starting with "invalid_" are used for specialized syntax errors # - These rules are NOT used in the first pass of the parser. ![]()
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |