-
Notifications
You must be signed in to change notification settings - Fork 2
FileState
The pi.FileState
is the master state record for all GoPi information relevant for a given file.
FileState contains the full lexing and parsing state information for a given file. It is the master state record for everything that happens in GoPi. One of these should be maintained for each file -- giv.TextBuf
has one as PiState field.
Separate State structs are maintained for each stage (Lexing, PassTwo, Parsing) and the final output of Parsing goes into the Ast and Syms fields.
The Src lex.File field maintains all the info about the source file, and the basic tokenized version of the source produced initially by lexing and updated by the remaining passes. It has everything that is maintained at a line-by-line level.
GoPi is organized so that Lexing and Parsing are each independent and self-contained, using their own specific State structures. Each of those States has a pointer to the overall Src struct. This may make things somewhat confusing with the redundancy and indirection to the same Src, but the advantages of having separate lex
and parse
packages is useful and makes those usable in other contexts.