mirror of
https://github.com/mudabbir-ahmad/UNI-PROG3-CW2-DYOPL.git
synced 2026-10-08 04:00:20 +00:00
Enhance RobotLang grammar and visitor to support student ID extraction
This commit is contained in:
1 parent
3fc4eac47b
commit
936f807449
4 files changed
+34
-16
No files matched your search
+6
-10
@@ -9,22 +9,18 @@ def main(argv):
|
||||
if len(argv) == 1:
|
||||
inpstream = StdinStream()
|
||||
else:
|
||||
inpname = argv[9]
|
||||
inpname = argv[1]
|
||||
inpstream = FileStream(inpname)
|
||||
# 1. Lexer analyses the characters
|
||||
# Lexer analyses the characters
|
||||
lexer = RobotLangLexer(inpstream)
|
||||
# 2. Create a stream of tokens
|
||||
# Create a stream of tokens
|
||||
tokstream = CommonTokenStream(lexer)
|
||||
# 3. Parser produces the abstract syntax tree
|
||||
# Parser produces the abstract syntax tree
|
||||
parser = RobotLangParser(tokstream)
|
||||
# 4. Start parsing from the top rule ('prog' in your grammar)
|
||||
# Start parsing from the top rule
|
||||
tree = parser.prog()
|
||||
|
||||
# Printing the parse tree using Marina's PrettyPrint and toStringTree methods (Not-needed for the assignment)
|
||||
# print(TreesUser.toStringTree(tree, None, parser))
|
||||
# print(TreesUser.PrettyPrint(tree, None, parser))
|
||||
|
||||
visitor = RobotLangVisitorUser("2320390")
|
||||
visitor = RobotLangVisitorUser()
|
||||
visitor.visit(tree)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
Reference in new issue
Block a user