问题标签 [re2c]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
185 浏览

parsing - How to match whitespace and comments with re2c

I started very recently to use bison for writing small compiler exercises. I am having some issues with white spaces ans comments. I was trying to debug the problem and I arrived to this source that looks like what I am looking for. I tried to chnage and erase some characters as advised but didn't work. Also during compilation I have the following error: re2c: error: line 2963, column 0: can only difference char sets. Below the part of the code:

Thank you very much for pointing in the right direction or shading some lights on why this error could be solved.

0 投票
1 回答
111 浏览

parsing - 具有 void * 类型的柠檬解析器标记值

我试图为我的柠檬解析器使用 void* 类型,但我遇到了一些奇怪的问题。

最初我使用自定义标记类型,一个结构来保存标记的值,然后我切换到 void* 因为我的标记值类型不同。

这是我的一些解析器代码;

这是我的词法分析器,它是 re2c 文件;

sy[size].val是双重类型。

但是当我运行它时1+2返回4,当我运行1+4它时返回8

我的猜测是解析器将最正确的值放入它的堆栈中,并在它看到令牌参数的任何地方使用它。

0 投票
1 回答
99 浏览

re2c - re2c:尝试匹配字符串时出现语法错误

我正在尝试使用 re2c,但它给了我这个正则表达式的语法错误:

它出什么问题了?这应该匹配双引号或单引号字符串