I'm wondering how should I look up symbols at runtime :)
Let me explain. My program may have two type of functions: 1) defined in a program and 2) implicitly loaded from the run-time library. Functions defined in a program have names (Symbol objects) created by ParsingContext.Symbols at compile-time. Run-time
library functions are registered at runtime and their names are created by EvaluationContext.Symbols. So symbol "div" registered in parser's symbol table is not the same as symbol "div" from the run-time library. Text strings are equal,
but Symbol objects are different.
When the interpreter encounters symbol "div", it takes symbol created by ParsingContext.Symbols (it is stored as FunctionName in my AST node) and looks up current EvaluationContext.Symbols. EvaluationContext has also symbol "div",
but since it is registered at runtime, it is not the same symbol. So for the interpreter it's an undefined symbol :)
I worked around this by keeping parser's symbol table and using it to generate symbol names for library functions in runtime. It works quite well, but I think doing so is apparently wrong. For example, my interpreter could deserialize AST from some external
source (compile -> save to XML -> load from XML), so it won't have access to the parser's symbol table anymore.
Please explain how to deal with two different symbol tables in such a case. Thanks :)