I’m working on the analyzer for the puny python interpreter ex34. It’s making sense to me except for one thing right now (setting aside recursion and indent levels).
Maybe I’m implementing functions totally wrong, but my function definition productions have a visitor method which ‘declares’ the function in the world.functions dict. Similarly, The formal arguments for those function definitions are declaring themselves in the world.variables dict.
Unfortunately, the demo code calls a print() function which hasn’t been defined. This is breaking my analyzer. Am I supposed to write a definition for this print function, or should there be another production type for handling the language’s built-in functions?
Here is the demo code I’m analyzing…
script = [
FuncDef("hello",
ArgsFormal([
ArgF('x'), ArgF('y')
]),
Body([
FuncCall("print",
Params([
ExprPlus(ExprVariable('x'), ExprVariable('y'))
])
)
])),
FuncCall("hello",
Params([ExprNumber(10), ExprNumber(20)])
)
]
I figure it’d make most sense to write a definition for it, but that wasn’t in the exercise/demo so I’m asking here.