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

def literal(): return [quotation , self_valuating]
Ejemplo n.º 18
0
def ListVarsCommand():
    return Combine(['variables', 'vars', 'v'], Not(Identifier))
Ejemplo n.º 19
0
def identifier() -> GrammarType:
    return Not(builtin_keyword), [builtin_type,
                                  RegExMatch(r'[A-Za-z_][A-Za-z0-9_]*', str_repr='identifier')]
Ejemplo n.º 20
0
def expression():
    return [regex, rule_crossref, (OPEN, ordered_choice, CLOSE),
            str_match], Not(ASSIGNMENT)
Ejemplo n.º 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)
Ejemplo n.º 22
0
def print_expr():       return Not( 'Using' ), expr # Any expr but the keyword 'Using'
def print_sep():        return [ ',', ';' ]
Ejemplo n.º 23
0
 def grammar():
     return Not('one'), Not('two'), _(r'\w+')
Ejemplo n.º 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
Ejemplo n.º 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'
Ejemplo n.º 27
0
def ol_space():
    return Sequence(space, Not(space), rule_name='ol_space', skipws=False)
Ejemplo n.º 28
0
def expression():       return [regex, rule_crossref,
                                (OPEN, ordered_choice, CLOSE),
                                str_match], Not(ASSIGNMENT)

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