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_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 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 term_end_lookahead(): return And([space, ')', EOF])
def grammar(): return "a", And("b"), ["c", "b"], EOF
def sub_body(): return [ ( labels, sub_body_stmt ), sub_body_stmt ], ZeroOrMore( statement_sep, sub_body ), And( statement_sep, sub_end ) def sub_end(): return 'End', 'Sub'
def ref_insert_middle(): return [(literal('['), identifier, literal(']')), (literal('{'), identifier, literal('}'))], And(literal('<'))
def until_block_maybe(): return __(r'.*?(?=>)'), And(literal('>'))
def control_structure_potential_closing_brace() -> GrammarType: return [And(RegExMatch('[^{}]*}')), RegExMatch('[^{}]*')]
def ref_insert_start(): return literal('>'), And([literal('['), literal('{')])
def skip_to_end_of_file(): return __(r'.+'), And(EOF)
def disambiguated_prefix_operator_value() -> GrammarType: return "", Sequence(['++', '--'], And(['ref', compound_identifier]), skipws=False)
def do_stmt_block(): return [ ( labels, do_stmt ), do_stmt ], ZeroOrMore( statement_sep, do_stmt_block ), And( statement_sep, 'Loop' ) def do_stmt(): return [ ( 'Exit', 'Do' ), statement ]
def func_body(): return [ ( labels, func_body_stmt ), func_body_stmt ], ZeroOrMore( statement_sep, func_body ), And( statement_sep, func_end_stmt ) def func_exit_stmt(): return 'Exit', 'Function'
def end_case_block(): return And( new_line, [ ( 'End', 'Select' ), 'Case' ] ) #def end_case_block(): return And( [ ( 'End', 'Select' ), 'Case' ] ) #def end_case_block(): return And( Optional( new_line ), [ ( 'End', 'Select' ), 'Case' ] ) def case_exprs(): return [ case_comparison, case_interval, case_value ], ZeroOrMore( ',', case_exprs )
def else_clauses(): return [ ( labels, statement ), statement ], ZeroOrMore( statement_sep, else_clauses ), And([( statement_sep, end_if_stmt ), end_if_stmt ]) def end_if_stmt(): return 'End', 'If'
def then_clauses(): return [ ( labels, statement ), statement ], ZeroOrMore( statement_sep, then_clauses ), And([ statement_sep, 'Else' ]) def else_clauses(): return [ ( labels, statement ), statement ], ZeroOrMore( statement_sep, else_clauses ), And([( statement_sep, end_if_stmt ), end_if_stmt ])
def inln_else_clauses(): return Optional( inln_stmts ), And([ EOF, new_line ]) def inln_stmts(): return statement, ZeroOrMore( ':', inln_stmts )
def inln_then_clauses(): return Optional( inln_stmts ), And( 'Else' ) def inln_else_clauses(): return Optional( inln_stmts ), And([ EOF, new_line ])