Пример #1
0
    def mOP_OTHERS(self, _createToken):
        _ttype = 0
        _token = None
        _begin = self.text.length()
        _ttype = OP_OTHERS
        _saveIndex = 0
        if not self.LA(2) != '=':
            raise antlr.SemanticException("self.LA(2) != '='")
        pass
        la1 = self.LA(1)
        if False:
            pass
        elif la1 and la1 in u'+':
            pass
            self.match('+')
        elif la1 and la1 in u'/':
            pass
            self.match('/')
        elif la1 and la1 in u'%':
            pass
            self.match('%')
        else:
            self.raise_NoViableAlt(self.LA(1))

        self.set_return_token(_createToken, _token, _ttype, _begin)
Пример #2
0
 def mOP_MINUS(self, _createToken):
     _ttype = 0
     _token = None
     _begin = self.text.length()
     _ttype = OP_MINUS
     _saveIndex = 0
     if not self.LA(2) != '=':
         raise antlr.SemanticException("self.LA(2) != '='")
     pass
     self.match('-')
     self.set_return_token(_createToken, _token, _ttype, _begin)
Пример #3
0
 def mLITERAL(self, _createToken):    
     _ttype = 0
     _token = None
     _begin = self.text.length()
     _ttype = LITERAL
     _saveIndex = 0
     ind = None
     if not  self.LA(1) != '\r' and self.LA(1) != '\n' :
         raise antlr.SemanticException(" self.LA(1) != '\\r' and self.LA(1) != '\\n' ")
     pass
     _cnt11= 0
     while True:
         loopStartIndex = self.text.length()
         col = self.getColumn()
         if (self.LA(1)==u'\\') and (self.LA(2)==u'$'):
             pass
             _saveIndex = self.text.length()
             self.match('\\')
             self.text.setLength(_saveIndex)
             self.match('$')
         elif (self.LA(1)==u'\\') and (self.LA(2)==u'\\') and (True) and (True) and (True) and (True) and (True):
             pass
             _saveIndex = self.text.length()
             self.match('\\')
             self.text.setLength(_saveIndex)
             self.match('\\')
         elif (self.LA(1)==u'\\') and (_tokenSet_1.member(self.LA(2))) and (True) and (True) and (True) and (True) and (True):
             pass
             self.match('\\')
             self.matchNot('$')
         elif (self.LA(1)==u'\t' or self.LA(1)==u' ') and (True) and (True) and (True) and (True) and (True) and (True):
             pass
             self.mINDENT(True)
             ind = self._returnToken
             if col == 1 and self.LA(1) == '$':
                # store indent in ASTExpr not in a literal
                self.currentIndent = ind.getText()
                # reset length to wack text
                self.text.setLength(loopStartIndex)
             else:
                self.currentIndent = None
         elif (_tokenSet_0.member(self.LA(1))) and (True) and (True) and (True) and (True) and (True) and (True):
             pass
             self.match(_tokenSet_0)
         else:
             break
         
         _cnt11 += 1
     if _cnt11 < 1:
         self.raise_NoViableAlt(self.LA(1))
     if not len(self.text.getString(_begin)):
        _ttype = SKIP # pure indent?
     self.set_return_token(_createToken, _token, _ttype, _begin)
Пример #4
0
    def mOP_OR(self, _createToken):
        _ttype = 0
        _token = None
        _begin = self.text.length()
        _ttype = OP_OR
        _saveIndex = 0
        if not self.LA(2) != '=':
            raise antlr.SemanticException("self.LA(2) != '='")
        pass
        self.match('|')
        if (self.LA(1) == u'|'):
            pass
            self.match('|')
        else:  ## <m4>
            pass

        self.set_return_token(_createToken, _token, _ttype, _begin)
Пример #5
0
    def keyValue(self):
        value = None

        s1 = None
        s2 = None
        k = None
        try:  ## for error handling
            la1 = self.LA(1)
            if False:
                pass
            elif la1 and la1 in [STRING]:
                pass
                s1 = self.LT(1)
                self.match(STRING)
                value = stringtemplate3.StringTemplate(group=self.group_,
                                                       template=s1.getText())
            elif la1 and la1 in [BIGSTRING]:
                pass
                s2 = self.LT(1)
                self.match(BIGSTRING)
                value = stringtemplate3.StringTemplate(group=self.group_,
                                                       template=s2.getText())
            elif la1 and la1 in [ID]:
                pass
                k = self.LT(1)
                self.match(ID)
                if not k.getText() == "key":
                    raise antlr.SemanticException(" k.getText() == \"key\" ")
                value = stringtemplate3.language.ASTExpr.MAP_KEY_VALUE
            elif la1 and la1 in [COMMA, RBRACK]:
                pass
            else:
                raise antlr.NoViableAltException(self.LT(1),
                                                 self.getFilename())

        except antlr.RecognitionException, ex:
            self.reportError(ex)
            self.consume()
            self.consumeUntil(_tokenSet_5)