145afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org#!/usr/bin/env python 245afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org""" cdecl.py - parse c declarations 345afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 445afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org(c) 2002, 2003, 2004, 2005 Simon Burton <simon@arrowtheory.com> 545afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgReleased under GNU LGPL license. 645afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 745afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgversion 0.xx 845afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 945afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org""" 1045afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 1145afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgimport sys 1245afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgimport string 1345afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgimport types 1445afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgimport copy 1545afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 1645afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org#from cparse import BasicType, Qualifier, StorageClass, Typedef, Ellipses, GCCBuiltin 1745afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org#from cparse import * 1845afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 1945afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgimport cparse as host 2045afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 2145afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgclass LexError(Exception): 2245afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org pass 2345afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 2445afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgclass Lexer(object): 2545afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org def __init__(self,s="",verbose=0,**kw): 2645afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org self.verbose = verbose 2745afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org self.lookup = {} # a map for keywords and typedefs 2845afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org for t in \ 2945afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org "float double void char int".split(): 3045afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org self.lookup[t] = host.BasicType( t ) 3145afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org for t in \ 3245afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org "register signed unsigned short long const volatile inline".split(): # inline here ??? 3345afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org self.lookup[t] = host.Qualifier( t ) 3445afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org for t in "extern static auto".split(): 3545afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org self.lookup[t] = host.StorageClass( t ) 3645afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org self.lookup['typedef'] = host.Typedef() 3745afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org #self.lookup['__inline__'] = host.GCCBuiltin('__inline__') 3845afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org #self.lookup['__extension__'] = host.Qualifier('__extension__') 3945afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org self.lookup['...'] = host.Ellipses() 4045afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org if s: 4145afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org self.lex(s) 4245afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org for key in kw.keys(): 4345afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org self.__dict__[key] = kw[key] 4445afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 4545afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org def lex(self,s): 4645afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org self.stack = None 4745afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org self.lines = s.splitlines() 4845afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org self.set_state("","",0,0) 4945afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org self.so_file = "" 5045afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org self._newline() 5145afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org self.get_token() # start 5245afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 5345afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org def mktypedef(self,tok,node): 5445afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org if self.verbose: 5545afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org print "%s.mktypedef(%s,%s)"%(self,tok,node) 5645afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org self.lookup[ tok ] = node 5745afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 5845afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org def rmtypedef(self,tok): 5945afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org " used in round trip testing " 6045afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org# print "# rmtypedef(%s)"%tok 6145afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org assert isinstance( self.lookup[ tok ], host.Node ) # existance 6245afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org del self.lookup[ tok ] 6345afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 6445afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org def _get_kind(self,tok): 6545afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org #print '_get_kind(%s)'%tok,self.lookup 6645afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org try: 6745afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org return self.lookup[tok] 6845afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org #return self.lookup[tok].clone() 6945afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org except KeyError: 7045afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org if tok.startswith("__builtin"): 7145afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org node = host.GCCBuiltin(tok) 7245afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org self.lookup[tok] = node 7345afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org return node 7445afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org #elif tok in ( "__extension__", ): 7545afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org #node = GCCBuiltin(tok) 7645afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org #self.lookup[tok] = node 7745afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org #return node 7845afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org return None 7945afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 8045afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org def _newline(self): 8145afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org while self.lno < len(self.lines): 8245afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org line = self.lines[self.lno] 8345afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org if not line or line[0] != "#": 8445afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org break 8545afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org l = line.split('"') 8645afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org assert len(l)>=2 8745afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org self.so_file = l[1] 8845afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org #self.so_lno = int( l[0].split()[1] ) 8945afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org #sys.stderr.write("# %s %s: %s\n"%(so_lno,so_file,l)) 9045afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org self.lno+=1 9145afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 9245afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org def get_brace_token( self ): 9345afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org self.push_state() 9445afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org ident_chars0 = string.letters+"_" 9545afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org ident_chars1 = string.letters+string.digits+"_" 9645afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org tok, kind = "", "" 9745afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org while self.lno < len(self.lines): 9845afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org s = self.lines[self.lno] 9945afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org i=self.col 10045afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org while i < len(s): 10145afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org if s[i] not in '{}': 10245afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org i=i+1 10345afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org continue 10445afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org else: 10545afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org tok = s[i] 10645afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org kind = tok 10745afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org self.col = i+1 10845afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org break 10945afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org # keep moving 11045afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org #sys.stderr.write( "lexer ignoring '%s'\n"%s[i] ) 11145afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org i=i+1 11245afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org if i==len(s): 11345afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org # nothing found 11445afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org assert tok == "" 11545afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org self.col=0 11645afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org self.lno+=1 11745afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org self._newline() 11845afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org else: 11945afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org assert tok 12045afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org break 12145afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org self.set_state(tok,kind,self.lno,self.col) 12245afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 12345afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org def get_token(self): 12445afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org self.push_state() 12545afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org ident_chars0 = string.letters+"_" 12645afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org ident_chars1 = string.letters+string.digits+"_" 12745afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org tok, kind = "", "" 12845afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org while self.lno < len(self.lines): 12945afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org s = self.lines[self.lno] 13045afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org i=self.col 13145afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org while i < len(s): 13245afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org if s[i].isspace(): 13345afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org i=i+1 13445afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org continue 13545afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org #if s[i] in ident_chars0: 13645afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org if s[i].isalpha() or s[i]=='_': 13745afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org # identifier 13845afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org j=i+1 13945afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org while j<len(s): 14045afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org if s[j] in ident_chars1: 14145afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org j=j+1 14245afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org else: 14345afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org break 14445afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org tok = s[i:j] 14545afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org self.col = j 14645afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org kind = self._get_kind(tok) 14745afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org break 14845afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org if s[i].isdigit() or \ 14945afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org (i+1<len(s) and s[i] in '+-.' and s[i+1].isdigit()): 15045afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org # number literal 15145afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org is_float = s[i]=='.' 15245afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org is_hex = s[i:i+2]=='0x' 15345afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org if is_hex: 15445afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org i=i+2 15545afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org assert s[i].isdigit() or s[i] in "abcdefABCDEF", self.err_string() 15645afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org j=i+1 15745afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org while j<len(s): 15845afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org #print "lex ",repr(s[i]),is_float 15945afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org if s[j].isdigit() or (is_hex and s[j] in "abcdefABCDEF"): 16045afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org j=j+1 16145afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org elif s[j]=='.' and not is_float: 16245afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org assert not is_hex 16345afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org j=j+1 16445afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org is_float=1 16545afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org else: 16645afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org break 16745afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org tok = s[i:j] 16845afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org self.col = j 16945afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org if is_float: 17045afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org kind = float(tok) 17145afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org elif is_hex: 17245afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org kind = int(tok,16) 17345afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org else: 17445afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org kind = int(tok) 17545afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org break 17645afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org if s[i:i+3]=='...': 17745afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org # ellipses 17845afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org #sys.stderr.write( "ELLIPSES "+str(self.get_state()) ) 17945afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org tok = s[i:i+3] 18045afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org kind = self._get_kind(tok) 18145afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org self.col = i+3 18245afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org break 18345afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org if s[i] in '*/{}()[]:;,=+-~.<>|&': 18445afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org tok = s[i] 18545afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org kind = tok 18645afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org self.col = i+1 18745afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org break 18845afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org if s[i] == "'": 18945afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org j = i+2 19045afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org while j<len(s) and s[j]!="'": 19145afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org j+=1 19245afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org if j==len(s): 19345afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org raise LexError( self.err_string() + "unterminated char constant" ) 19445afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org tok = s[i:j+1] 19545afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org self.col = j+1 19645afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org kind = s[i:j+1] 19745afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org break 19845afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org # keep moving 19945afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org #sys.stderr.write( "lexer ignoring '%s'\n"%s[i] ) 20045afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org sys.stderr.write( "lexer ignoring '%s' lno=%d\n"%(s[i],self.lno+1) ) 20145afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org i=i+1 20245afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org # end while i < len(s) 20345afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org if i==len(s): 20445afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org # nothing found, go to next line 20545afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org assert tok == "" 20645afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org self.col=0 20745afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org self.lno+=1 20845afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org self._newline() 20945afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org else: 21045afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org # we got one 21145afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org assert tok 21245afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org break 21345afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org # end while self.lno < len(self.lines): 21445afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org self.set_state(tok,kind,self.lno,self.col) 21545afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 21645afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org def err_string(self): 21745afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org "Return helpful error string :)" 21845afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org return self.lines[self.lno]+"\n"+" "*self.col+"^\n" 21945afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 22045afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org def push_state(self): 22145afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org self.stack = self.get_state() # a short stack :) 22245afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org #self.stack.push( self.get_state() ) 22345afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 22445afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org def unget_token(self): 22545afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org assert self.stack is not None 22645afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org self.set_state(*self.stack) 22745afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org self.stack = None 22845afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 22945afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org def set_state(self,tok,kind,lno,col): 23045afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org if self.verbose: 23145afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org print "tok,kind,lno,col = ",(tok,kind,lno,col) 23245afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org self.tok = tok 23345afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org self.kind = kind 23445afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org self.lno = lno # line 23545afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org self.col = col # column 23645afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 23745afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org def get_state(self): 23845afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org return self.tok,self.kind,self.lno,self.col 23945afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 24045afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org def get_file(self): 24145afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org return self.so_file 24245afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 24345afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org################################################################### 24445afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org# 24545afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org################################################################### 24645afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org# 24745afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 24845afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 249