-
Notifications
You must be signed in to change notification settings - Fork 2
Parser Symbols
The syms
package defines a Symbol
type that has basic Name / Kind info about a symbol, along with pointers into the source code and relevant scoping information for where that symbol is used. Each symbol also has a map
of Children
for all the symbols that are directly under it (e.g., for a package
symbol, all the top-level vars, types, etc in the package).
Symbols are maintained in SymMap
map that automatically enforces uniqueness of names and provides fast lookup. Maps can be converted to slices and sorted for output etc.
The FileState maintains a master SymMap of Symbols relevant for a given file being processed. Typically it is good to organize all of those symbols under a single master scope -- this happens automatically in Go with the package
rule that creates a corresponding master scope symbol, and everything thereafter goes into that scope.
The Symbol also maintains a TypeMap
of Type
structs for encoding everything about the types within the scope of this symbol. Each Symbol has a Type string that should resolve to a relevant Type value. See FileState for more about overall organization of larger type spaces.