示例#1
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
示例#2
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
示例#3
0
 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]])
示例#4
0
def expression():
    return [
        # regex,
        arg_identifier,
        (OPEN, ordered_choice, CLOSE),
        str_match
    ], Not(ASSIGNMENT)
示例#5
0
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
示例#6
0
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]
示例#7
0
def option_help():
    return Sequence((
        Not(space),
        any_until_eol,
    ), rule_name='option_help')
示例#8
0
def MyNum():
    return (
        Not('0'),
        RegExMatch('[0-9]+'),
    )
示例#9
0
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
示例#10
0
def Identifier():
    return (Not(ReservedWord), RegExMatch(r'[A-Za-z_][A-Za-z0-9_]*'))
 def grammar():
     return [Not(['two', 'three']), 'one', 'two'], _(r'\w+')
示例#12
0
def HelpCommand():
    return Combine(['help', 'h', '?'], Not(Identifier))
 def grammar():
     return ['one', Not('two')], _(r'\w+')
示例#14
0
def function_declaration() -> GrammarType:
    return Optional('cdecl'), function_prototype, Not('{')
示例#15
0
def QuitCommand():
    return Combine(['quit', 'exit', 'q'], Not(Identifier))
示例#16
0
def pattern_identifier(): return Not(ellipsis), symbol
def ellipsis(): return "..."
示例#17
0
def variable(): return Not(syntactic_keyword), identifier

def literal(): return [quotation , self_valuating]
示例#18
0
def ListVarsCommand():
    return Combine(['variables', 'vars', 'v'], Not(Identifier))
示例#19
0
def identifier() -> GrammarType:
    return Not(builtin_keyword), [builtin_type,
                                  RegExMatch(r'[A-Za-z_][A-Za-z0-9_]*', str_repr='identifier')]
示例#20
0
def expression():
    return [regex, rule_crossref, (OPEN, ordered_choice, CLOSE),
            str_match], Not(ASSIGNMENT)
示例#21
0
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)
示例#22
0
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+')
示例#24
0
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
示例#26
0
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'
示例#27
0
def ol_space():
    return Sequence(space, Not(space), rule_name='ol_space', skipws=False)
示例#28
0
def expression():       return [regex, rule_crossref,
                                (OPEN, ordered_choice, CLOSE),
                                str_match], Not(ASSIGNMENT)

# PEG Lexical rules
def regex():            return [("r'", _(r'''[^'\\]*(?:\\.[^'\\]*)*'''), "'"),