def visit_prefix(self, node, children): if len(children) == 2: if children[0] == NOT: retval = Not() else: retval = And() if type(children[1]) is list: retval.nodes = children[1] else: retval.nodes = [children[1]] else: # If there is no optional prefix reduce. retval = children[0] return retval
def visit_expression(self, node, children): if len(children) == 1: return children[0] if children[0] == '!': return Not(nodes=[children[1]]) else: return And(nodes=[children[1]])
def expression(): return [ # regex, arg_identifier, (OPEN, ordered_choice, CLOSE), str_match ], Not(ASSIGNMENT)
def function_type_args() -> GrammarType: return Optional([ # The `Not` rule is necessary to prevent the full_type rule to match, that prevents Arpeggio # to try the variadic dots rule Sequence(OneOrMore(full_type, Not('...'), sep=','), Optional(',', Optional(full_type), function_variadic_dots)), Sequence(Optional(full_type), function_variadic_dots) ]), trailing_comma
def expression_SA(parser, node, children): if len(children) > 1: if children[0] == '!': return Not(nodes=[children[1]]) else: return And(nodes=[children[1]]) else: return children[0]
def option_help(): return Sequence(( Not(space), any_until_eol, ), rule_name='option_help')
def MyNum(): return ( Not('0'), RegExMatch('[0-9]+'), )
def case_value(): return Not( 'Else' ), expr # Any expr but the keyword 'Else' # Def<Type> rules def range_type_decl(): return var_type, var_ranges
def Identifier(): return (Not(ReservedWord), RegExMatch(r'[A-Za-z_][A-Za-z0-9_]*'))
def grammar(): return [Not(['two', 'three']), 'one', 'two'], _(r'\w+')
def HelpCommand(): return Combine(['help', 'h', '?'], Not(Identifier))
def grammar(): return ['one', Not('two')], _(r'\w+')
def function_declaration() -> GrammarType: return Optional('cdecl'), function_prototype, Not('{')
def QuitCommand(): return Combine(['quit', 'exit', 'q'], Not(Identifier))
def pattern_identifier(): return Not(ellipsis), symbol def ellipsis(): return "..."
def variable(): return Not(syntactic_keyword), identifier def literal(): return [quotation , self_valuating]
def ListVarsCommand(): return Combine(['variables', 'vars', 'v'], Not(Identifier))
def identifier() -> GrammarType: return Not(builtin_keyword), [builtin_type, RegExMatch(r'[A-Za-z_][A-Za-z0-9_]*', str_repr='identifier')]
def expression(): return [regex, rule_crossref, (OPEN, ordered_choice, CLOSE), str_match], Not(ASSIGNMENT)
def option_description_intro(): # return OneOrMore ( Sequence ( ( Not(option_line_start), wx, text_line ) ), return OneOrMore(Sequence( (Not(option_line_start), wx, any_until_end_of_line)), rule_name='option_description_intro', skipws=False)
def print_expr(): return Not( 'Using' ), expr # Any expr but the keyword 'Using' def print_sep(): return [ ',', ';' ]
def grammar(): return Not('one'), Not('two'), _(r'\w+')
def case_block(): return Not([ ( 'End', 'Select' ), 'Case' ]), [ ( labels, statement ), statement ], ZeroOrMore( statement_sep, case_block ) def end_case_block(): return And( new_line, [ ( 'End', 'Select' ), 'Case' ] )
def grammar(): return "a", Not("b"), ["b", "c"], EOF
def case_intvl_value(): return Not( 'To' ), expr # Any expr but the keyword 'To' def case_value(): return Not( 'Else' ), expr # Any expr but the keyword 'Else'
def ol_space(): return Sequence(space, Not(space), rule_name='ol_space', skipws=False)
def expression(): return [regex, rule_crossref, (OPEN, ordered_choice, CLOSE), str_match], Not(ASSIGNMENT) # PEG Lexical rules def regex(): return [("r'", _(r'''[^'\\]*(?:\\.[^'\\]*)*'''), "'"),