Class DefinitionListener

All Implemented Interfaces:
org.antlr.v4.runtime.tree.ParseTreeListener, EK9Listener

final class DefinitionListener extends AbstractEK9PhaseListener
Just go through and define the symbols and scopes putting into the ParsedModule against the appropriate context. Also define the symbol in the parent scope (though its type is still to be determined - see next phase). Check for duplicate variables/types/classes/constants and functions across parsed modules for the same module. So at the end of phase one - we will have the names of Classes/Types/Functions etc. recorded even though they won't be fully defined. This will also include the definition of generic/template types. But we cannot fully turn those into concrete versions until all modules have been parsed by phase1. Only then will all types at least be recorded. Now that if symbols are already defined we might need to push a dummy item on so the rest of the parsing can take place with push and pop of what's on the stack. Else we get out of sync. So yes we need to record errors and not put the named item on, but we need to put something in there to deal with the pushing and popping on the stack, because the rest of the code might be OK. There are a number of very simple 'early' checks used in this listener, the idea is a fail to compile as early as possible. It could be argued that you should do all the checks once you have an IR. My thought is that as soon as you can detect an error you should report it in the earliest phase as possible.