示例#1
0
def make_token( text, tp, line = None, column = None ):
    ret = CommonToken()
    ret.setText( text )
    ret.setType( tp )
    if line is not None:
        ret.setLine( line )
    if column is not None:
        ret.setColumn( column )
    return ret
示例#2
0
 def line(self):    
     t = None
     
     linenum = None
     colnum = None
     content = None
     try:      ## for error handling
         pass
         linenum = self.LT(1)
         self.match(NUMBER)
         self.match(COLON)
         colnum = self.LT(1)
         self.match(NUMBER)
         self.match(SPACES)
         symbol=self.tokenName()
         la1 = self.LA(1)
         if False:
             pass
         elif la1 and la1 in [CONTENT]:
             pass
             content = self.LT(1)
             self.match(CONTENT)
         elif la1 and la1 in [NEWLINE]:
             pass
             self.match(NEWLINE)
         else:
                 raise antlr.NoViableAltException(self.LT(1), self.getFilename())
             
         from antlr import CommonToken
         import PepperParser
         t = CommonToken(
            type = PepperParser._tokenNames.index( symbol.getText() ) )
         if content is not None:
            t.setText( content.getText() )
         t.setLine( int( linenum.getText() ) )
         t.setColumn( int( colnum.getText() ) )
     
     except antlr.RecognitionException, ex:
         return None
def _new_newline( tok ):
    ret = CommonToken()
    ret.setType( PepperLexer.NEWLINE )
    ret.setLine( tok.getLine() )
    ret.setColumn( tok.getColumn() )
    return ret
def _new_dedent( tok ):
    ret = CommonToken()
    ret.setType( PepperLexer.DEDENT )
    ret.setLine( tok.getLine() )
    ret.setColumn( tok.getColumn() )
    return ret