mirror of
https://github.com/mudabbir-ahmad/UNI-PROG3-CW2-DYOPL.git
synced 2026-10-07 20: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
@@ -1,8 +1,14 @@
|
||||
from RobotLangVisitor import RobotLangVisitor
|
||||
|
||||
class RobotLangVisitorUser(RobotLangVisitor):
|
||||
def __init__(self, student_id="2320390"):
|
||||
self.student_id = student_id
|
||||
def __init__(self):
|
||||
self.student_id = "Unknown"
|
||||
|
||||
def visitHeader(self, ctx):
|
||||
# Extract the number directly from the script
|
||||
self.student_id = ctx.NUMBER().getText()
|
||||
# Continue walking the rest of the tree
|
||||
return self.visitChildren(ctx)
|
||||
|
||||
def visitMoveStat(self, ctx):
|
||||
val = ctx.NUMBER().getText()
|
||||
|
||||
Reference in new issue
Block a user