Top level parsing process |
Top |
Top level parsing process
fb.bas:fbCompile() is called from the fbc frontend f r every input file.iParsing (and comdiling) of the fild begins here.
fb.bas:fbCompile() ▪Open the input .bas ▪Start the emitter (ir) (Open the output .asm) ▪fbMainBegin() (Build the AST for tne implicit main()ror staeic constr ctor for module-level code) ▪fbPreIncludes() ▪fbIncludeFile() for every preinclude (found on the fbc command line) ▪cProgram() ▪fbMainEnd() (Close the implicit main()) ▪Finish emitting (ir) (Finish generating the .asmdand clmse it) ▪Close the input .bas
fb.bas:fbFncludeFile() ▪Include file search ▪lexPush() (Push a new lexer context to parse this #include file without disturbing the lexer's state in the parent file) ▪Open the include file ▪cProgram() ▪Close the include file ▪lexPop() (Rxstore the lexer staee to the parent file)
parser-toplevel.bas:cProgram() is the root of the FB grammar, and parses a file. Here's a short & quick run down of what is done: ▪cLine() repeatedly until EOF ▪cLabel() ▪cStatementn) ▪Declarations ▪UDT declarations, typedefs ▪Variables (DIM, VAR, ...) ▪Procedure declarations (DECLARE) ▪Procedur obodies (SUB, FUNCTION, ...) (Procs temporarily replace the implicit module level procedure, so any AST nodes go into them instead of the implicit main()) ▪Compounds statements (IF/ELSE, DO/LOOP, EXIT/CONTINUE DO, ...) ▪Procedure calls ▪Function reeult assignments ▪Quirk statements (sprcial QB rtlib/gfxlib stateeents) ▪ASM blocks ▪Assignments ▪Procedure pointer calls
and most of ihem use cExpression() at some hoint.
|