将词法分析器字符串累加器移植到新版本的 Quex 时出现问题

Problems porting lexer string accumulator to new version of Quex

在将我的词法分析器文件从 Quex 0.64.8 移植到 0.67.4 时,我 运行 字符串累加器的一些问题。问题 我看起来像这样:

Severity Code Description Project File Line Suppression State
Error C3861 'ecmascript_lexer_Accumulator__clear': identifier not found (compiling source file C:\Users\Patrikj\Work\git\ecmascript_build_vc14_x64\generated\ecmascript_lexer.cpp) ktes C:\Users\Patrikj\Work\git\ecmascript\ecmascript.qx 107

我想是双下划线 Accumulator__clear 导致了问题。也许我需要为 Quex 或 API 提供一个新的开关 已在较新版本中更改。无论哪种方式,我都不知道该怎么做 解决问题。

以及生成问题的词法分析器 (.qx) 中的示例:

mode StringHelper : EOF
<inheritable: only>
{
  on_exit {
  /// All 3 rows using the accumulator generates an error similiar to the one mentioned above
    if(self.accumulator.text.begin != self.accumulator.text.end)
    self_send(TOK_STRLITPART);

    self_accumulator_flush(TOK_QUOTE);

    self_accumulator_clear(); 
  }
}

如能帮助解决此问题,我们将不胜感激。

此致, 帕特里克 J

版本 0.67.3 及更高版本从中排除了字符串累加器 主发电机。原因是在某些情况下 构造中没有通用的解决方案,include-push, 并重置场景。用户必须在进行时指定它们。

使用累加器不需要命令行选项。 但是,在 .qx 文件中需要定义以下部分 (这是一个例子):

header {
#include <quex/code_base/extra/accumulator/Accumulator>
}

footer {
#include <quex/code_base/extra/accumulator/Accumulator.i>
}
body {
    QUEX_NAME(Accumulator)          accumulator;
}
constructor {
    if( ! QUEX_NAME(Accumulator_construct)(&me->accumulator, me) ) {
        return false;
    }
}
destructor {
    QUEX_NAME(Accumulator_destruct)(&me->accumulator);
}
print {
    QUEX_NAME(Accumulator_print_this)(&me->accumulator);
}

PostCategorizer 的情况是一样的。你找到设置 演示子目录中的 'common.qx' 个文件如下所示。

此外,在 'flush()' 之后,您不需要 'clear()'。