Update method names for parser and add 2 docstrings.
This commit is contained in:
parent
abebb940f6
commit
8128f72264
21
parser.py
21
parser.py
|
@ -466,12 +466,25 @@ class LLVMParser(object):
|
||||||
self.tokens += self.reserved.values()
|
self.tokens += self.reserved.values()
|
||||||
|
|
||||||
def build(self, **kwargs):
|
def build(self, **kwargs):
|
||||||
|
"""
|
||||||
|
Build the parser.
|
||||||
|
|
||||||
|
This method builds the parsing tables and initializes the
|
||||||
|
internal lexer and parser variables. This method must be
|
||||||
|
called prior to parsing.
|
||||||
|
|
||||||
|
"""
|
||||||
self.lexer = lex.lex(module=self, **kwargs)
|
self.lexer = lex.lex(module=self, **kwargs)
|
||||||
self.parser = yacc.yacc(module=self, **kwargs)
|
self.parser = yacc.yacc(module=self, **kwargs)
|
||||||
|
|
||||||
def test(self, data):
|
def parse(self, text):
|
||||||
result = self.parser.parse(data, lexer=self.lexer)
|
"""
|
||||||
print(result)
|
Generate AST from text.
|
||||||
|
|
||||||
|
Return a AST representation of the llvm program from text.
|
||||||
|
|
||||||
|
"""
|
||||||
|
return self.parser.parse(text, lexer=self.lexer)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
@ -483,4 +496,4 @@ define void @tigermain (i64 %U_mainSL_8, i64 %U_mainDummy_9) {
|
||||||
ret i64 %a
|
ret i64 %a
|
||||||
}
|
}
|
||||||
'''
|
'''
|
||||||
p.test(data)
|
print(p.parse(data))
|
||||||
|
|
Loading…
Reference in New Issue
Block a user