mirror of
https://github.com/mudabbir-ahmad/UNI-PROG3-CW2-DYOPL.git
synced 2026-10-08 04:00:20 +00:00
Add TreesUser class for improved tree representation and update grammar rules
This commit is contained in:
1 parent
5b36426dc4
commit
ad6935723e
3 files changed
+33
-8
No files matched your search
@@ -5,21 +5,19 @@ from RobotLangParser import RobotLangParser
|
||||
from RobotLangVisitorUser import RobotLangVisitorUser
|
||||
|
||||
def main(argv):
|
||||
# Determine if reading from a file or standard input
|
||||
if len(argv) == 1:
|
||||
inpstream = StdinStream()
|
||||
else:
|
||||
inpname = argv[1]
|
||||
inpstream = FileStream(inpname)
|
||||
# Lexer analyses the characters
|
||||
lexer = RobotLangLexer(inpstream)
|
||||
# Create a stream of tokens
|
||||
#Create a stream of tokens
|
||||
tokstream = CommonTokenStream(lexer)
|
||||
# Parser produces the abstract syntax tree
|
||||
#Parser produces the abstract syntax tree
|
||||
parser = RobotLangParser(tokstream)
|
||||
# Start parsing from the top rule
|
||||
#Start parsing from the top rule
|
||||
tree = parser.prog()
|
||||
|
||||
#execute script
|
||||
visitor = RobotLangVisitorUser()
|
||||
visitor.visit(tree)
|
||||
|
||||
|
||||
Reference in new issue
Block a user