lex*.bas:文件输入,标记化,宏扩展缓冲区,令牌队列,#include上下文。
pp*.bas:预处理器指令解析,宏扩展文本构造。
词法分析器从.bas文件中读取源代码,并将其转换为一系列令牌,因此FB解析器看到:
dim as integer i = 5
print i
as:
(Top-level parser retrieves the first token:)
DIM keyword (Go to variable declaration parser)
AS keyword (Go to datatype parser)
INTEGER keyword (Data type)
"i" symbol (Back to variable declaration, variable identifier)
"=" operator (Go to initializer parser)
"5" number literal (Expression)
EOL statement end (Variable declaration parser is done,
the variable is added to the AST,
back to toplevel parser)
(Next line, next 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 (Print parser is done, back to toplevel)
EOF (Top-level parser is done)词法分析器是从解析器中隐藏用户输入(缩进,注释,关键字大写,#includes)的丑陋细节的抽象。此外,它还进行预处理,由宏扩展和预处理器指令解析组成。一般的想法是处理词法分析器中的所有预处理,因此解析器不会看到它。解析器从不调用预处理函数,词法分析器的功能就是这样做。
令牌
宏存储和扩展
预处理器指令解析
文件上下文
调用图快速概述