Beispiel #1
0
    def expr_list(self,
        arg_type_list, min_argc, max_argc
    ):
        arg_cnt = None

        arg_cnt = 0
        arg_type = arg_type_list[arg_cnt]
        # print "**expr_list1[%d] req=%s" % (arg_cnt, arg_type)
        la1 = self.LA(1)
        if False:
            pass
        elif la1 and la1 in [TRUE_CONST,FALSE_CONST,STR_CONST,NUM_CONST,INT_CONST,FUNC_IF,FUNC_CHOOSE,NAME,QUOTENAME,SUB,LP,REF2D]:
            pass
            self.expr(arg_type)
            arg_cnt += 1
            while True:
                if (self.LA(1)==COMMA or self.LA(1)==SEMICOLON):
                    pass
                    if arg_cnt < len(arg_type_list):
                       arg_type = arg_type_list[arg_cnt]
                    else:
                       arg_type = arg_type_list[-1]
                    if arg_type == "+":
                       arg_type = arg_type_list[-2]
                    # print "**expr_list2[%d] req=%s" % (arg_cnt, arg_type)
                    la1 = self.LA(1)
                    if False:
                        pass
                    elif la1 and la1 in [SEMICOLON]:
                        pass
                        self.match(SEMICOLON)
                    elif la1 and la1 in [COMMA]:
                        pass
                        self.match(COMMA)
                    else:
                            raise antlr.NoViableAltException(self.LT(1), self.getFilename())

                    la1 = self.LA(1)
                    if False:
                        pass
                    elif la1 and la1 in [TRUE_CONST,FALSE_CONST,STR_CONST,NUM_CONST,INT_CONST,FUNC_IF,FUNC_CHOOSE,NAME,QUOTENAME,SUB,LP,REF2D]:
                        pass
                        self.expr(arg_type)
                    elif la1 and la1 in [RP,COMMA,SEMICOLON]:
                        pass
                        self.rpn += struct.pack("B", ptgMissArg)
                    else:
                            raise antlr.NoViableAltException(self.LT(1), self.getFilename())

                    arg_cnt += 1
                else:
                    break

        elif la1 and la1 in [RP]:
            pass
        else:
                raise antlr.NoViableAltException(self.LT(1), self.getFilename())

        return arg_cnt
Beispiel #2
0
    def list_contents(self):
        l = None

        def add_listterm(t, parent):
            child = Node(None, "structure", leaf='.', children=[t])
            parent.add_child(child)
            return child

        try:  ## for error handling
            pass
            t = self.term()
            l = Node(None, "structure", leaf='.', children=[t])
            subnode = l
            while True:
                if (self.LA(1) == COMMA):
                    pass
                    self.match(COMMA)
                    t = self.term()
                    subnode = add_listterm(t, subnode)
                else:
                    break

            la1 = self.LA(1)
            if False:
                pass
            elif la1 and la1 in [BAR]:
                pass
                self.match(BAR)
                la1 = self.LA(1)
                if False:
                    pass
                elif la1 and la1 in [VARIABLE]:
                    pass
                    t2 = self.variable()
                elif la1 and la1 in [LSQUARE]:
                    pass
                    t2 = self.prologlist()
                else:
                    raise antlr.NoViableAltException(self.LT(1),
                                                     self.getFilename())

                subnode.add_child(t2)
            elif la1 and la1 in [RSQUARE]:
                pass
            else:
                raise antlr.NoViableAltException(self.LT(1),
                                                 self.getFilename())

            if len(subnode.children) == 1:
                subnode.add_child(Node(None, "structure", leaf='.'))

        except antlr.RecognitionException, ex:
            self.reportError(ex)
            self.consume()
            self.consumeUntil(_tokenSet_10)
Beispiel #3
0
    def unary_expr(self):

        self.returnAST = None
        currentAST = antlr.ASTPair()
        unary_expr_AST = None
        try:  ## for error handling
            la1 = self.LA(1)
            if False:
                pass
            elif la1 and la1 in [PLUS, MINUS, TILDE]:
                pass
                la1 = self.LA(1)
                if False:
                    pass
                elif la1 and la1 in [MINUS]:
                    pass
                    tmp17_AST = None
                    tmp17_AST = self.astFactory.create(self.LT(1))
                    self.addASTChild(currentAST, tmp17_AST)
                    self.match(MINUS)
                elif la1 and la1 in [PLUS]:
                    pass
                    tmp18_AST = None
                    tmp18_AST = self.astFactory.create(self.LT(1))
                    self.addASTChild(currentAST, tmp18_AST)
                    self.match(PLUS)
                elif la1 and la1 in [TILDE]:
                    pass
                    tmp19_AST = None
                    tmp19_AST = self.astFactory.create(self.LT(1))
                    self.addASTChild(currentAST, tmp19_AST)
                    self.match(TILDE)
                else:
                    raise antlr.NoViableAltException(self.LT(1),
                                                     self.getFilename())

                self.primary_expr()
                self.addASTChild(currentAST, self.returnAST)
                unary_expr_AST = currentAST.root
            elif la1 and la1 in [
                    IDENT, LBRACKET, HASH, INT, ATOM, QUOTEDSTRING
            ]:
                pass
                self.primary_expr()
                self.addASTChild(currentAST, self.returnAST)
                unary_expr_AST = currentAST.root
            else:
                raise antlr.NoViableAltException(self.LT(1),
                                                 self.getFilename())

        except antlr.RecognitionException, ex:
            self.reportError(ex)
            self.consume()
            self.consumeUntil(_tokenSet_6)
    def expr_list(self, arg_type_list, min_argc, max_argc):
        arg_cnt = None

        arg_cnt = 0
        arg_type_list = arg_type_list.split()
        arg_type = arg_type_list[arg_cnt]
        la1 = self.LA(1)
        if False:
            pass
        elif la1 and la1 in [
                TRUE_CONST, FALSE_CONST, STR_CONST, NUM_CONST, INT_CONST, NAME,
                SUB, LP, REF2D
        ]:
            pass
            self.expr(arg_type)
            arg_cnt += 1
            while True:
                if (self.LA(1) == SEMICOLON):
                    pass
                    if arg_cnt < len(arg_type_list):
                        arg_type = arg_type_list[arg_cnt]
                    else:
                        arg_type = arg_type_list[-1]
                    if arg_type == "...":
                        arg_type = arg_type_list[-2]
                    self.match(SEMICOLON)
                    la1 = self.LA(1)
                    if False:
                        pass
                    elif la1 and la1 in [
                            TRUE_CONST, FALSE_CONST, STR_CONST, NUM_CONST,
                            INT_CONST, NAME, SUB, LP, REF2D
                    ]:
                        pass
                        self.expr(arg_type)
                    elif la1 and la1 in [RP, SEMICOLON]:
                        pass
                        self.rpn += struct.pack("B", ptgMissArg)
                    else:
                        raise antlr.NoViableAltException(
                            self.LT(1), self.getFilename())

                    arg_cnt += 1
                else:
                    break

        elif la1 and la1 in [RP]:
            pass
        else:
            raise antlr.NoViableAltException(self.LT(1), self.getFilename())

        return arg_cnt
Beispiel #5
0
    def scoped_name(self):

        self.returnAST = None
        currentAST = antlr.ASTPair()
        scoped_name_AST = None
        try:  ## for error handling
            pass
            if (self.LA(1) == IDENT) and (self.LA(2) == PERIOD):
                pass
                self.scope()
                self.addASTChild(currentAST, self.returnAST)
            elif (self.LA(1) == IDENT) and (_tokenSet_7.member(self.LA(2))):
                pass
            else:
                raise antlr.NoViableAltException(self.LT(1),
                                                 self.getFilename())

            self.func_name()
            self.addASTChild(currentAST, self.returnAST)
            scoped_name_AST = currentAST.root

        except antlr.RecognitionException, ex:
            self.reportError(ex)
            self.consume()
            self.consumeUntil(_tokenSet_6)
Beispiel #6
0
    def literal(self):

        self.returnAST = None
        currentAST = antlr.ASTPair()
        literal_AST = None
        try:  ## for error handling
            la1 = self.LA(1)
            if False:
                pass
            elif la1 and la1 in [INT]:
                pass
                self.integer_literal()
                self.addASTChild(currentAST, self.returnAST)
                literal_AST = currentAST.root
            elif la1 and la1 in [ATOM]:
                pass
                self.atom_literal()
                self.addASTChild(currentAST, self.returnAST)
                literal_AST = currentAST.root
            elif la1 and la1 in [QUOTEDSTRING]:
                pass
                self.string_literal()
                self.addASTChild(currentAST, self.returnAST)
                literal_AST = currentAST.root
            else:
                raise antlr.NoViableAltException(self.LT(1),
                                                 self.getFilename())

        except antlr.RecognitionException, ex:
            self.reportError(ex)
            self.consume()
            self.consumeUntil(_tokenSet_4)
Beispiel #7
0
    def input_section_description_list(self):

        self.returnAST = None
        currentAST = antlr.ASTPair()
        input_section_description_list_AST = None
        try:  ## for error handling
            pass
            _cnt40 = 0
            while True:
                if (self.LA(1) == ANY or self.LA(1) == IDENT
                        or self.LA(1) == STAR):
                    pass
                    self.input_section_description()
                    self.addASTChild(currentAST, self.returnAST)
                else:
                    break

                _cnt40 += 1
            if _cnt40 < 1:
                raise antlr.NoViableAltException(self.LT(1),
                                                 self.getFilename())
            input_section_description_list_AST = currentAST.root

        except antlr.RecognitionException, ex:
            self.reportError(ex)
            self.consume()
            self.consumeUntil(_tokenSet_0)
Beispiel #8
0
    def size_length(self):

        self.returnAST = None
        currentAST = antlr.ASTPair()
        size_length_AST = None
        try:  ## for error handling
            la1 = self.LA(1)
            if False:
                pass
            elif la1 and la1 in [INT, HEX]:
                pass
                self.max_size()
                self.addASTChild(currentAST, self.returnAST)
                size_length_AST = currentAST.root
            elif la1 and la1 in [MINUS]:
                pass
                self.length()
                self.addASTChild(currentAST, self.returnAST)
                size_length_AST = currentAST.root
            else:
                raise antlr.NoViableAltException(self.LT(1),
                                                 self.getFilename())

        except antlr.RecognitionException, ex:
            self.reportError(ex)
            self.consume()
            self.consumeUntil(_tokenSet_5)
Beispiel #9
0
    def execution_region_description(self):

        self.returnAST = None
        currentAST = antlr.ASTPair()
        execution_region_description_AST = None
        try:  ## for error handling
            pass
            self.execution_region_name()
            self.addASTChild(currentAST, self.returnAST)
            self.region_address()
            self.addASTChild(currentAST, self.returnAST)
            self.execution_attribute_list()
            self.addASTChild(currentAST, self.returnAST)
            la1 = self.LA(1)
            if False:
                pass
            elif la1 and la1 in [MINUS, INT, HEX]:
                pass
                self.size_length()
                self.addASTChild(currentAST, self.returnAST)
            elif la1 and la1 in [LCURLY]:
                pass
            else:
                raise antlr.NoViableAltException(self.LT(1),
                                                 self.getFilename())

            self.execution_region_description_a()
            self.addASTChild(currentAST, self.returnAST)
            execution_region_description_AST = currentAST.root

        except antlr.RecognitionException, ex:
            self.reportError(ex)
            self.consume()
            self.consumeUntil(_tokenSet_11)
Beispiel #10
0
    def atom(self):

        self.returnAST = None
        currentAST = antlr.ASTPair()
        atom_AST = None
        try:  ## for error handling
            la1 = self.LA(1)
            if False:
                pass
            elif la1 and la1 in [INT, HEX]:
                pass
                self.number()
                self.addASTChild(currentAST, self.returnAST)
                atom_AST = currentAST.root
            elif la1 and la1 in [LPAREN]:
                pass
                tmp8_AST = None
                tmp8_AST = self.astFactory.create(self.LT(1))
                self.addASTChild(currentAST, tmp8_AST)
                self.match(LPAREN)
                self.expr()
                self.addASTChild(currentAST, self.returnAST)
                tmp9_AST = None
                tmp9_AST = self.astFactory.create(self.LT(1))
                self.addASTChild(currentAST, tmp9_AST)
                self.match(RPAREN)
                atom_AST = currentAST.root
            else:
                raise antlr.NoViableAltException(self.LT(1),
                                                 self.getFilename())

        except antlr.RecognitionException, ex:
            self.reportError(ex)
            self.consume()
            self.consumeUntil(_tokenSet_8)
Beispiel #11
0
    def number(self):

        self.returnAST = None
        currentAST = antlr.ASTPair()
        number_AST = None
        try:  ## for error handling
            la1 = self.LA(1)
            if False:
                pass
            elif la1 and la1 in [INT]:
                pass
                tmp6_AST = None
                tmp6_AST = self.astFactory.create(self.LT(1))
                self.addASTChild(currentAST, tmp6_AST)
                self.match(INT)
                number_AST = currentAST.root
            elif la1 and la1 in [HEX]:
                pass
                tmp7_AST = None
                tmp7_AST = self.astFactory.create(self.LT(1))
                self.addASTChild(currentAST, tmp7_AST)
                self.match(HEX)
                number_AST = currentAST.root
            else:
                raise antlr.NoViableAltException(self.LT(1),
                                                 self.getFilename())

        except antlr.RecognitionException, ex:
            self.reportError(ex)
            self.consume()
            self.consumeUntil(_tokenSet_8)
Beispiel #12
0
    def region_address(self):

        self.returnAST = None
        currentAST = antlr.ASTPair()
        region_address_AST = None
        try:  ## for error handling
            la1 = self.LA(1)
            if False:
                pass
            elif la1 and la1 in [LPAREN, INT, HEX]:
                pass
                self.base_address()
                self.addASTChild(currentAST, self.returnAST)
                region_address_AST = currentAST.root
            elif la1 and la1 in [PLUS]:
                pass
                tmp2_AST = None
                tmp2_AST = self.astFactory.create(self.LT(1))
                self.addASTChild(currentAST, tmp2_AST)
                self.match(PLUS)
                self.offset()
                self.addASTChild(currentAST, self.returnAST)
                region_address_AST = currentAST.root
            else:
                raise antlr.NoViableAltException(self.LT(1),
                                                 self.getFilename())

        except antlr.RecognitionException, ex:
            self.reportError(ex)
            self.consume()
            self.consumeUntil(_tokenSet_3)
Beispiel #13
0
    def input_section_attribute_list_item(self):

        self.returnAST = None
        currentAST = antlr.ASTPair()
        input_section_attribute_list_item_AST = None
        try:  ## for error handling
            la1 = self.LA(1)
            if False:
                pass
            elif la1 and la1 in [PLUS]:
                pass
                tmp25_AST = None
                tmp25_AST = self.astFactory.create(self.LT(1))
                self.addASTChild(currentAST, tmp25_AST)
                self.match(PLUS)
                self.input_section_attribute()
                self.addASTChild(currentAST, self.returnAST)
                input_section_attribute_list_item_AST = currentAST.root
            elif la1 and la1 in [IDENT, TOKEN_GDEF]:
                pass
                self.input_symbol_pattern()
                self.addASTChild(currentAST, self.returnAST)
                input_section_attribute_list_item_AST = currentAST.root
            else:
                raise antlr.NoViableAltException(self.LT(1),
                                                 self.getFilename())

        except antlr.RecognitionException, ex:
            self.reportError(ex)
            self.consume()
            self.consumeUntil(_tokenSet_15)
Beispiel #14
0
    def monosac_modifications(self):

        t1 = None
        t2 = None
        n = None
        pass
        self.match(PIPE)
        t1 = self.LT(1)
        self.match(INTEGER)
        la1 = self.LA(1)
        if False:
            pass
        elif la1 and la1 in [COMMA]:
            pass
            self.match(COMMA)
            t2 = self.LT(1)
            self.match(INTEGER)
        elif la1 and la1 in [COLON]:
            pass
        else:
            raise antlr.NoViableAltException(self.LT(1), self.getFilename())

        self.match(COLON)
        n = self.LT(1)
        self.match(IDENTIFIER)
        self.addModification(n, t1, t2)
Beispiel #15
0
    def declaration(self):

        self.returnAST = None
        currentAST = antlr.ASTPair()
        declaration_AST = None
        try:  ## for error handling
            la1 = self.LA(1)
            if False:
                pass
            elif la1 and la1 in [IDENT]:
                pass
                self.func_decl()
                self.addASTChild(currentAST, self.returnAST)
                declaration_AST = currentAST.root
            elif la1 and la1 in [LITERAL_module]:
                pass
                self.module_decl()
                self.addASTChild(currentAST, self.returnAST)
                declaration_AST = currentAST.root
            else:
                raise antlr.NoViableAltException(self.LT(1),
                                                 self.getFilename())

        except antlr.RecognitionException, ex:
            self.reportError(ex)
            self.consume()
            self.consumeUntil(_tokenSet_1)
    def groupInterface(self, groupI):

        name = None
        self.groupI = groupI
        try:  ## for error handling
            pass
            self.match(LITERAL_interface)
            name = self.LT(1)
            self.match(ID)
            groupI.name = name.getText()
            self.match(SEMI)
            _cnt3 = 0
            while True:
                if (self.LA(1) == ID or self.LA(1) == LITERAL_optional):
                    pass
                    self.template(groupI)
                else:
                    break

                _cnt3 += 1
            if _cnt3 < 1:
                raise antlr.NoViableAltException(self.LT(1),
                                                 self.getFilename())

        except antlr.RecognitionException, ex:
            self.reportError(ex)
            self.consume()
            self.consumeUntil(_tokenSet_0)
Beispiel #17
0
    def prec2_expr(self, arg_type):

        pass
        self.prec3_expr(arg_type)
        while True:
            if (self.LA(1) == MUL or self.LA(1) == DIV):
                pass
                la1 = self.LA(1)
                if False:
                    pass
                elif la1 and la1 in [MUL]:
                    pass
                    self.match(MUL)
                    op = struct.pack('B', ptgMul)
                elif la1 and la1 in [DIV]:
                    pass
                    self.match(DIV)
                    op = struct.pack('B', ptgDiv)
                else:
                    raise antlr.NoViableAltException(self.LT(1),
                                                     self.getFilename())

                self.prec3_expr(arg_type)
                self.rpn += op
            else:
                break
Beispiel #18
0
    def sheet(self):
        ref = None

        sheet_ref_name = None
        sheet_ref_int = None
        sheet_ref_quote = None
        la1 = self.LA(1)
        if False:
            pass
        elif la1 and la1 in [NAME]:
            pass
            sheet_ref_name = self.LT(1)
            self.match(NAME)
            ref = sheet_ref_name.text
        elif la1 and la1 in [INT_CONST]:
            pass
            sheet_ref_int = self.LT(1)
            self.match(INT_CONST)
            ref = sheet_ref_int.text
        elif la1 and la1 in [QUOTENAME]:
            pass
            sheet_ref_quote = self.LT(1)
            self.match(QUOTENAME)
            ref = sheet_ref_quote.text[1:-1].replace("''", "'")
        else:
            raise antlr.NoViableAltException(self.LT(1), self.getFilename())

        return ref
Beispiel #19
0
    def basic_expr(self):
        e = None

        try:  ## for error handling
            la1 = self.LA(1)
            if False:
                pass
            elif la1 and la1 in [ATOM, VARIABLE, NUMBER, LCURLY, LSQUARE]:
                pass
                t = self.term()
                e = t
            elif la1 and la1 in [LBRACKET]:
                pass
                self.match(LBRACKET)
                o = self.expression()
                e = o
                self.match(RBRACKET)
            else:
                raise antlr.NoViableAltException(self.LT(1),
                                                 self.getFilename())

        except antlr.RecognitionException, ex:
            self.reportError(ex)
            self.consume()
            self.consumeUntil(_tokenSet_7)
Beispiel #20
0
    def prec1_expr(self, arg_type):

        pass
        self.prec2_expr(arg_type)
        while True:
            if (self.LA(1) == ADD or self.LA(1) == SUB):
                pass
                la1 = self.LA(1)
                if False:
                    pass
                elif la1 and la1 in [ADD]:
                    pass
                    self.match(ADD)
                    op = struct.pack('B', ptgAdd)
                elif la1 and la1 in [SUB]:
                    pass
                    self.match(SUB)
                    op = struct.pack('B', ptgSub)
                else:
                    raise antlr.NoViableAltException(self.LT(1),
                                                     self.getFilename())

                self.prec2_expr(arg_type)
                self.rpn += op
                # print "**prec1_expr4 %s" % arg_type
            else:
                break
Beispiel #21
0
    def relation_op(self):
        o = None

        try:  ## for error handling
            la1 = self.LA(1)
            if False:
                pass
            elif la1 and la1 in [LESSTHANOREQ]:
                pass
                self.match(LESSTHANOREQ)
                o = "lessthanorequals"
            elif la1 and la1 in [GREATERTHANOREQ]:
                pass
                self.match(GREATERTHANOREQ)
                o = "greaterthanorequals"
            elif la1 and la1 in [GREATERTHAN]:
                pass
                self.match(GREATERTHAN)
                o = "greaterthan"
            elif la1 and la1 in [LESSTHAN]:
                pass
                self.match(LESSTHAN)
                o = "lessthan"
            elif la1 and la1 in [EQUAL]:
                pass
                self.match(EQUAL)
                o = "unify"
            else:
                raise antlr.NoViableAltException(self.LT(1),
                                                 self.getFilename())

        except antlr.RecognitionException, ex:
            self.reportError(ex)
            self.consume()
            self.consumeUntil(_tokenSet_8)
Beispiel #22
0
    def not_expr(self):
        e = None

        try:  ## for error handling
            pass
            hitnot = False
            la1 = self.LA(1)
            if False:
                pass
            elif la1 and la1 in [NOT]:
                pass
                self.match(NOT)
                hitnot = True
            elif la1 and la1 in [
                    LBRACKET, ATOM, VARIABLE, NUMBER, LCURLY, LSQUARE
            ]:
                pass
            else:
                raise antlr.NoViableAltException(self.LT(1),
                                                 self.getFilename())

            e = self.relation_expr()
            if hitnot: e = Node(None, "expression", leaf="not", children=[e])

        except antlr.RecognitionException, ex:
            self.reportError(ex)
            self.consume()
            self.consumeUntil(_tokenSet_6)
Beispiel #23
0
    def structure(self):
        s = None

        f = None
        try:  ## for error handling
            pass
            s = Node(None, "structure")
            f = self.LT(1)
            self.match(ATOM)
            s.leaf = f.getText()
            self.match(LBRACKET)
            la1 = self.LA(1)
            if False:
                pass
            elif la1 and la1 in [ATOM, VARIABLE, NUMBER, LCURLY, LSQUARE]:
                pass
                t = self.termlist()
                s.children.extend(t)
            elif la1 and la1 in [RBRACKET]:
                pass
            else:
                raise antlr.NoViableAltException(self.LT(1),
                                                 self.getFilename())

            self.match(RBRACKET)

        except antlr.RecognitionException, ex:
            self.reportError(ex)
            self.consume()
            self.consumeUntil(_tokenSet_3)
    def template(self, groupI):

        opt = None
        name = None
        formalArgs = {}  # leave blank if no args
        templateName = None
        try:  ## for error handling
            pass
            la1 = self.LA(1)
            if False:
                pass
            elif la1 and la1 in [LITERAL_optional]:
                pass
                opt = self.LT(1)
                self.match(LITERAL_optional)
            elif la1 and la1 in [ID]:
                pass
            else:
                raise antlr.NoViableAltException(self.LT(1),
                                                 self.getFilename())

            name = self.LT(1)
            self.match(ID)
            self.match(LPAREN)
            la1 = self.LA(1)
            if False:
                pass
            elif la1 and la1 in [ID]:
                pass
                formalArgs = self.args()
            elif la1 and la1 in [RPAREN]:
                pass
            else:
                raise antlr.NoViableAltException(self.LT(1),
                                                 self.getFilename())

            self.match(RPAREN)
            self.match(SEMI)
            templateName = name.getText()
            groupI.defineTemplate(templateName, formalArgs, opt != None)

        except antlr.RecognitionException, ex:
            self.reportError(ex)
            self.consume()
            self.consumeUntil(_tokenSet_1)
Beispiel #25
0
    def mapPairs(self, mapping):

        try:  ## for error handling
            la1 = self.LA(1)
            if False:
                pass
            elif la1 and la1 in [STRING]:
                pass
                self.keyValuePair(mapping)
                while True:
                    if (self.LA(1) == COMMA) and (self.LA(2) == STRING):
                        pass
                        self.match(COMMA)
                        self.keyValuePair(mapping)
                    else:
                        break

                la1 = self.LA(1)
                if False:
                    pass
                elif la1 and la1 in [COMMA]:
                    pass
                    self.match(COMMA)
                    self.defaultValuePair(mapping)
                elif la1 and la1 in [RBRACK]:
                    pass
                else:
                    raise antlr.NoViableAltException(self.LT(1),
                                                     self.getFilename())

            elif la1 and la1 in [LITERAL_default]:
                pass
                self.defaultValuePair(mapping)
            else:
                raise antlr.NoViableAltException(self.LT(1),
                                                 self.getFilename())

        except antlr.RecognitionException, ex:
            self.reportError(ex)
            self.consume()
            self.consumeUntil(_tokenSet_4)
Beispiel #26
0
    def attribute_list(self):

        self.returnAST = None
        currentAST = antlr.ASTPair()
        attribute_list_AST = None
        try:  ## for error handling
            pass
            la1 = self.LA(1)
            if False:
                pass
            elif la1 and la1 in [
                    TOKEN_ABSOLUTE, TOKEN_PI, TOKEN_RELOC, TOKEN_OVERLAY
            ]:
                pass
                self.position_option()
                self.addASTChild(currentAST, self.returnAST)
            elif la1 and la1 in [TOKEN_NOCOMPRESS, LCURLY, INT, HEX]:
                pass
            else:
                raise antlr.NoViableAltException(self.LT(1),
                                                 self.getFilename())

            la1 = self.LA(1)
            if False:
                pass
            elif la1 and la1 in [TOKEN_NOCOMPRESS]:
                pass
                self.compression_option()
                self.addASTChild(currentAST, self.returnAST)
            elif la1 and la1 in [LCURLY, INT, HEX]:
                pass
            else:
                raise antlr.NoViableAltException(self.LT(1),
                                                 self.getFilename())

            attribute_list_AST = currentAST.root

        except antlr.RecognitionException, ex:
            self.reportError(ex)
            self.consume()
            self.consumeUntil(_tokenSet_4)
Beispiel #27
0
    def clause(self):
        c = None

        c = Node(None, "clause")
        try:  ## for error handling
            pass
            if (self.LA(1) == ATOM) and (self.LA(2) == LBRACKET):
                pass
                s = self.structure()
                c.add_child(s)
            elif (self.LA(1) == ATOM) and (self.LA(2) == DEFINEDAS
                                           or self.LA(2) == FULLSTOP):
                pass
                a = self.atom()
                c.add_child(a)
            elif (self.LA(1) == DEFINEDAS or self.LA(1) == FULLSTOP):
                pass
            else:
                raise antlr.NoViableAltException(self.LT(1),
                                                 self.getFilename())

            la1 = self.LA(1)
            if False:
                pass
            elif la1 and la1 in [DEFINEDAS]:
                pass
                self.match(DEFINEDAS)
                e = self.expression()
                c.add_child(e)
            elif la1 and la1 in [FULLSTOP]:
                pass
            else:
                raise antlr.NoViableAltException(self.LT(1),
                                                 self.getFilename())

            self.match(FULLSTOP)

        except antlr.RecognitionException, ex:
            self.reportError(ex)
            self.consume()
            self.consumeUntil(_tokenSet_2)
Beispiel #28
0
    def input_section_description(self):

        self.returnAST = None
        currentAST = antlr.ASTPair()
        input_section_description_AST = None
        a = None
        a_AST = None
        b = None
        b_AST = None
        c = None
        c_AST = None
        try:  ## for error handling
            la1 = self.LA(1)
            if False:
                pass
            elif la1 and la1 in [IDENT]:
                pass
                a = self.LT(1)
                a_AST = self.astFactory.create(a)
                self.addASTChild(currentAST, a_AST)
                self.match(IDENT)
                self.input_section_attribute_list()
                self.addASTChild(currentAST, self.returnAST)
                # print "IDENT input_section_description found ", a.getText()
                input_section_description_AST = currentAST.root
            elif la1 and la1 in [ANY]:
                pass
                b = self.LT(1)
                b_AST = self.astFactory.create(b)
                self.addASTChild(currentAST, b_AST)
                self.match(ANY)
                self.input_section_attribute_list()
                self.addASTChild(currentAST, self.returnAST)
                # print "ANY input_section_description found ", b.getText()
                input_section_description_AST = currentAST.root
            elif la1 and la1 in [STAR]:
                pass
                c = self.LT(1)
                c_AST = self.astFactory.create(c)
                self.addASTChild(currentAST, c_AST)
                self.match(STAR)
                self.input_section_attribute_list()
                self.addASTChild(currentAST, self.returnAST)
                # print "STAR input_section_description found ", c.getText()
                input_section_description_AST = currentAST.root
            else:
                raise antlr.NoViableAltException(self.LT(1),
                                                 self.getFilename())

        except antlr.RecognitionException, ex:
            self.reportError(ex)
            self.consume()
            self.consumeUntil(_tokenSet_13)
Beispiel #29
0
    def residue_specification(self):

        la1 = self.LA(1)
        if False:
            pass
        elif la1 and la1 in [MONOSAC_DECLARATION]:
            pass
            self.monosac_specification()
        elif la1 and la1 in [SUBSTIT_DECLARATION]:
            pass
            self.substit_specification()
        else:
            raise antlr.NoViableAltException(self.LT(1), self.getFilename())
Beispiel #30
0
    def rep_section(self):

        pass
        self.match(REP)
        _cnt14 = 0
        while True:
            if (self.LA(1) == RES):
                pass
                self.sugar()
            else:
                break

            _cnt14 += 1
        if _cnt14 < 1:
            raise antlr.NoViableAltException(self.LT(1), self.getFilename())