是生成C 野牛解析器的重点

Is generated C++ Bison parser re-entrant?

本文关键字:      更新时间:2023-10-16

我正在研究一个爱好项目,该项目使用Flex/Bison生成C 扫描仪/解析器。因为有数十亿个解析对象。解析本身是令人尴尬的平行问题。我想汇总几个现成的扫描仪/解析器对象,让它们并行运行。

我阅读了Flex和Bison官方文档,并通过其生成的代码浏览。

我可以从FLEX文档及其代码中确认生成C 扫描仪是重新输入的。

但是,我很难从野牛文件中确认这一点。它确实有文件说明如何在野牛建造一个重点c解析器。但是,这并不明确表示如果您构建C 解析器,则是重新入选。我在Bison生成的解析器标题文件中找到了几个静态类成员,这使我对此问题感到关注:

// Tables.
// YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
// STATE-NUM.
static const short int yypact_[];
// YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM.
// Performed when YYTABLE does not specify something else to do.  Zero
// means the default is an error.
static const unsigned char yydefact_[];
// YYPGOTO[NTERM-NUM].
static const signed char yypgoto_[];
// YYDEFGOTO[NTERM-NUM].
static const signed char yydefgoto_[];
// YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM.  If
// positive, shift that token.  If negative, reduce the rule whose
// number is the opposite.  If YYTABLE_NINF, syntax error.
static const short int yytable_[];
static const short int yycheck_[];
// YYSTOS[STATE-NUM] -- The (internal number of the) accessing
// symbol of state STATE-NUM.
static const unsigned char yystos_[];
// YYR1[YYN] -- Symbol number of symbol that rule YYN derives.
static const unsigned char yyr1_[];
// YYR2[YYN] -- Number of symbols on the right hand side of rule YYN.
static const unsigned char yyr2_[];

是生成C 野牛解析器的重点?

这些都是static const,与重新输入完全兼容。该表定义了解析器的过渡规则,并且与解析器的可执行代码没有根本不同,该代码也是静态且不可变的。

相关文章:
  • 没有找到相关文章