Class keywordsPrepare

Object
keywordsPrepare

public class keywordsPrepare extends Object
收到新关键字列表后的处理流程,关键字分为 reserved words 和 non-reserved keywords 两种 这两类都是用逗号隔开的字符串表示,如果收到的是 同时包含 reserved words 和 non-reserved keywords 的列表, 需要先分成这两类独立的列表。 可以调用 extractNonReservedKeywords() 把 non-reserved keywords 从 full list 中分类出来。 1. 处理 reserved words 1.1 根据提供的 keyword list 列表, 确保当前 lexer 中已有的对应keyword 类型一致。调用 adjustKeywords() 实现 1.2 根据提供的 keyword list 列表, 把不在当前 lexer 中的 keyword 加入到 lexer keyword 列表中。调用 addNewKeywords() 实现 新增的 keyword 需要在 .y 文件中也加一下。 1.3 移除在 lexer 中的 keyword,但不在提供的 keyword list 列表中的 keyword, 考虑到这些 keyword 可能在 y 文件中使用, 不进行实际的移除,只是把类型从 ttreserved 改为 ttidentifier 通过调用 checkFalseKeywords() 实现 2. 处理 non-reserved keywords 2.1 根据提供的 non-keyword list 列表, 确保当前 lexer 中已有的对应 keyword 类型一致。调用 adjustKeywords() 实现 2.2 根据提供的 non-keyword list 列表, 把不在当前 lexer 中的 keyword 加入到 lexer keyword 列表中。调用 addNewKeywords() 实现 新增的 keyword 需要在 .y 文件中也加一下,并且在 rule 中要加入成为 ident。 2.3 移除在 lexer 中的 keyword,但不在提供的 non-keyword list 列表中的 keyword, 考虑到这些 keyword 可能在 y 文件中使用, 不进行实际的移除,只是把类型从 ttkeyword 改为 ttidentifier 通过调用 checkFalseKeywords() 实现 3. 检查处理结果 3.1 调用 adjustKeywords(), keywords num with different type 应该为零。 3.2 调用 addNewKeywords(), 新增的 keyword num 应该为零。 3.3 调用 checkFalseKeywords(), 发现的 false keyword 应该为零。