def _seq_15(self):
     return Sequence(self.BUILTIN(), self.ID('chip'), self.SEMICOLON())
 def _seq_2(self):
     return Sequence(self.IN(), self.inout('in'), Many(self._seq_3()),
                     self.SEMICOLON())
Esempio n. 3
0
 def _seq_2(self):
     return Sequence(self.LPAR(), self.DEFINE(), self.LPAR(),
                     self.IDENT('name'), Many(self.IDENT('param')),
                     Optional(self.VARARG('vararg')), self.RPAR(),
                     Many(self.definition('localdef')),
                     OneOrMore(self.expr('body')), self.RPAR())
 def _seq_14(self):
     return Sequence(self.LBRACKET(), self.INT('from'), self.DOT2(),
                     self.INT('to'), self.RBRACKET())
 def _seq_7(self):
     return Sequence(self.COMMA(), self.inout('out'))
 def _seq_9(self):
     return Sequence(self.ID('chip'), self.LPAR(), self.connection('conn'),
                     Many(self._seq_10()), self.RPAR(), self.SEMICOLON())
Esempio n. 7
0
 def _seq_8(self):
     return Sequence(self.LPAR(), OneOrMore(self.list_item('li')),
                     self.RPAR())
 def _seq_5(self):
     return Sequence(self.LBRACKET(), self.POS_INT('size'), self.RBRACKET())
Esempio n. 9
0
 def _seq_6(self):
     return Sequence(self.LPAR(), self._oneof_5(), Many(self.expr('arg')),
                     self.RPAR())
Esempio n. 10
0
 def _seq_7(self):
     return Sequence(self.LIST_BEGIN(), OneOrMore(self.list_item('li')),
                     self.RPAR())
Esempio n. 11
0
 def _seq_5(self):
     return Sequence(self.LSQBR(), self.expr('test'),
                     self.expr('consequent'), self.RSQBR())
Esempio n. 12
0
 def _seq_4(self):
     return Sequence(self.LPAR(), self.COND(),
                     OneOrMore(self.cond_branch('branch')), self.RPAR())
Esempio n. 13
0
 def _seq_3(self):
     return Sequence(self.LPAR(), self.IF(), self.expr('test'),
                     self.expr('consequent'), self.expr('alternate'),
                     self.RPAR())
 def _seq_3(self):
     return Sequence(self.COMMA(), self.inout('in'))
 def _seq_1(self):
     return Sequence(self.CHIP(), self.ID('name'), self.LBRACE(),
                     OneOrMore(self._oneof_1()), self._oneof_2(),
                     self.RBRACE())
 def _seq_4(self):
     return Sequence(self.ID(), Optional(self._seq_5()))
 def _seq_10(self):
     return Sequence(self.COMMA(), self.connection('conn'))
 def _seq_6(self):
     return Sequence(self.OUT(), self.inout('out'), Many(self._seq_7()),
                     self.SEMICOLON())
 def _seq_11(self):
     return Sequence(self.ID('param'), Optional(self._seq_12()), self.EQ(),
                     self.value())
 def _seq_8(self):
     return Sequence(self.PARTS(), self.COLON(),
                     OneOrMore(self.part('part')))
 def _seq_13(self):
     return Sequence(self.ID('pin'), Optional(self._seq_14()))
    def _init_rules(self):

        self.rule('komparse_grammar',
                  OneOrMore(
                      OneOf(self.configstmt(), self.tokenrule(),
                            self.productionrule())),
                  is_root=True)

        self.rule('configstmt', OneOf(self.case_sensitive(),
                                      self.whitespace()))

        self.rule(
            'case_sensitive',
            Sequence(self.CASE_SENSITIVE(), OneOf(self.ON(), self.OFF()),
                     self.SEMICOLON()))

        self.rule(
            'whitespace',
            Sequence(self.WHITESPACE(), self.STR('wschars'),
                     Many(Sequence(self.COMMA(), self.STR('wschars'))),
                     self.SEMICOLON()))

        self.rule('tokenrule',
                  OneOf(self.commentdef(), self.stringdef(), self.tokendef()))

        self.rule(
            'commentdef',
            Sequence(self.COMMENT(), self.STR('start'), self.STR('end'),
                     Optional(self.NESTABLE('nestable')), self.SEMICOLON()))

        self.rule(
            'stringdef',
            Sequence(self.STRING(), self.STR('start'), self.STR('end'),
                     Optional(self.STR('escape')),
                     Optional(self.TOKEN_ID('token_id')), self.SEMICOLON()))

        self.rule(
            'tokendef',
            Sequence(self.TOKEN(), self.TOKEN_ID('token_id'),
                     self.STR('regex'), self.SEMICOLON()))

        self.rule(
            'productionrule',
            Sequence(Optional(self.annotation('annot')),
                     self.RULE_ID('rule_id'), self.ARROW(),
                     self.branches('rhs'), self.SEMICOLON()))

        self.rule('annotation', Sequence(self.AT(), self.START()))

        self.rule(
            'branches',
            Sequence(self.branch('branch'),
                     Many(Sequence(self.PIPE(), self.branch('branch')))))

        self.rule(
            'branch',
            OneOrMore(
                Sequence(
                    OneOf(self.STR("keyword"), self.tokenref(), self.ruleref(),
                          self.group()), Optional(self.cardinality('card')))))

        self.rule(
            'tokenref',
            OneOf(Sequence(self.ID('id'), self.HASH(), self.TOKEN_ID()),
                  self.TOKEN_ID()))

        self.rule(
            'ruleref',
            OneOf(Sequence(self.ID('id'), self.HASH(), self.RULE_ID()),
                  self.RULE_ID()))

        self.rule('group', Sequence(self.LPAR(), self.branches(), self.RPAR()))

        self.rule('cardinality',
                  OneOf(self.QUESTION_MARK(), self.PLUS(), self.ASTERISK()))

        self._init_transforms()
Esempio n. 23
0
 def _seq_1(self):
     return Sequence(self.LPAR(), self.DEFINE(), self.IDENT('name'),
                     self.expr('value'), self.RPAR())