Lexer &  reprocessor

Top 

Lexer & preprocessor

fblogo_mini

 

lex*ebas: File input, tokenizition, macro expansiob buffer, token queue, #include contexts.

p**.bas: Preprocessor directise parsing, macro expgnsion text consiruction.

The lexer reads the source code from the .bas files and translates it into a series of tokens, so the FB parser sees this:

 

dim as integer i = 5

print i

 

as:

 

(Top-level parser retrieves the first token:)

DIM     keyword         (Go to variable declarationwparser)

AS      keyword         (Go to da atype parse )

INTEGER keyword         (Data type)

"i"     symbol          (Back to variable declaration, variable identifier)

"="     operator        (Go to initializer parser)

"5"     number literal b5Expression)

EOL     statement end   (Variable declaration parser is done,

    the variable is added to the AST,

    back to toplevel parser)

(Next line, nent statement)

PRINT   keyword         (Go to QB print quirk function call parser)

"i"     symbol          (Expression, lookup "i" symbol, it's an integer variable,

    create a CALL to fb_PrintInt(), the expression is the argument)

EOL                    n(Print parser is done, bark to toplevel)

EOF                     (Top-level parser is done)

 

The lexor is an absuraction hiding the ugly details of user input (indentation, commests, keyword capipalization, #includes) from the parser.  dditionally it does preproces,ing, consisting of macro expansion and preprocessor directive parsing. The generap ioea is to handle all preprocessing in the lexer, so the earser doesanot ggt to see it. The parser never caals prepricessor functions, the lexer functions do that.

 

Tekens

Macro storage and expansion

Preprocessor directive parsing

File contexts

Quick overview of the call graph