在 Mac OS X 10.6 上编译和执行莎士比亚编程语言转换器 spl2c 会导致警告/错误

发布于 2024-08-15 06:47:01 字数 2012 浏览 8 评论 0原文

我想尝试一下莎士比亚编程语言,所以我从此处 并使用 cd spl-1.2.1 Make 执行 Makefile。

spl2c 的编译执行时会出现几个警告:

scanner.l:600: warning, rule cannot be matched
<stdout>:5808: warning: ‘yyunput’ defined but not used

然后,当它尝试编译所有示例时,一切都会变得混乱:

../spl/bin/spl2c < fibonacci.spl > fibonacci.c
Warning at line 19: equality expected
Warning at line 28: equality expected
Warning at line 30: comment expected
Warning at line 30: comment expected
Warning at line 30: comment expected
Warning at line 30: comment expected
Warning at line 32: comment expected
Warning at line 32: comment expected
Warning at line 32: comment expected
Warning at line 32: comment expected
Warning at line 34: comment expected
Warning at line 34: comment expected
Warning at line 34: comment expected
Warning at line 34: comment expected
Warning at line 36: comment expected
Warning at line 36: comment expected
Warning at line 37: comment expected
Warning at line 37: comment expected
Warning at line 37: comment expected
Warning at line 37: colon expected
Warning at line 40: equality expected
Warning at line 51: comment expected
Warning at line 51: comment expected
Warning at line 51: comment expected
Warning at line 51: comment expected
Warning at line 51: comment expected
Warning at line 51: colon expected
Error at line 59: 'act [roman number]' or 'scene [roman number]' expected
1 errors and 27 warnings found. No code output.

有人能给我指出解决此问题的正确方向吗?我最初的项目是学习 spl,而不是倾向于调试编译器(我实际上想最终编写自己的编译器,但我现在更愿意坚持我最初的项目)。

我正在运行 OS X 10.6.2gcc 版本 4.2.1(Apple Inc. build 5646)(点 1)flex 2.5.35 code> 和 bison (GNU Bison) 2.3

编辑:对于不需要 goto 的简单程序(例如 hello.spl),您可以通过删除除第一个 ACT I/SCENE I 之外的所有 ACT/SCENE 行来解决该问题。

I wanted to experiment with the Shakespeare programming language, so I downloaded it from here and executed the Makefile using cd spl-1.2.1 Make.

The compilation of spl2c executes with a couple warnings:

scanner.l:600: warning, rule cannot be matched
<stdout>:5808: warning: ‘yyunput’ defined but not used

And then when it attempts to compile all the examples everything goes haywire:

../spl/bin/spl2c < fibonacci.spl > fibonacci.c
Warning at line 19: equality expected
Warning at line 28: equality expected
Warning at line 30: comment expected
Warning at line 30: comment expected
Warning at line 30: comment expected
Warning at line 30: comment expected
Warning at line 32: comment expected
Warning at line 32: comment expected
Warning at line 32: comment expected
Warning at line 32: comment expected
Warning at line 34: comment expected
Warning at line 34: comment expected
Warning at line 34: comment expected
Warning at line 34: comment expected
Warning at line 36: comment expected
Warning at line 36: comment expected
Warning at line 37: comment expected
Warning at line 37: comment expected
Warning at line 37: comment expected
Warning at line 37: colon expected
Warning at line 40: equality expected
Warning at line 51: comment expected
Warning at line 51: comment expected
Warning at line 51: comment expected
Warning at line 51: comment expected
Warning at line 51: comment expected
Warning at line 51: colon expected
Error at line 59: 'act [roman number]' or 'scene [roman number]' expected
1 errors and 27 warnings found. No code output.

Can anybody point me in the right direction for fixing this? My original project was going to be learning spl, not leaning to debug compilers (I'd actually like to write my own compiler eventually, but I'd prefer to stick with my initial project for now).

I'm running OS X 10.6.2, gcc version 4.2.1 (Apple Inc. build 5646) (dot 1), flex 2.5.35, and bison (GNU Bison) 2.3.

EDIT: For simple programs not requiring gotos (e.g. hello.spl) you can get around the issue by deleting all ACT/SCENE lines except the first ACT I/SCENE I.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

﹂绝世的画 2024-08-22 06:47:01

这是词法解析器中正则表达式的缺陷。

我分叉了该语言。

我解决了这个问题。

我通知了原始作者。

这里是包含修复程序的语言版本,供您欣赏。

仍然有一些警告,但它们似乎没有影响任何事情。如果您发现任何其他功能问题,请告诉我,我会看看如何处理它们。

(罗菲尔 - 这将是死灵术,如果不是因为没有人关心这个问题。)

This is a defect in a regular expression in the lexical parser.

I forked the language.

I fixed the issue.

I notified the original authors.

Here's a release of the language that includes the fix for your enjoyment.

There are still a few warnings, but they don't seem to affect anything. Let me know if you find any other functional problems and I'll see what I can do with them.

(Roffel - this would be necromancy, if not for the fact that nobody cares about this problem.)

过去的过去 2024-08-22 06:47:01

此问题是由 Flex 2.5.4 和 2.5.33 版本之间引入的错误引起的;也就是说,从编写莎士比亚处理器到提出这个问题之间的时间。该错误涉及在不区分大小写的正则表达式中使用带单字符参数的大括号重复运算符(例如 i{1,3},它是莎士比亚罗马数字的 Flex 规范的一部分) ;该错误的后果是不区分大小写,因此 i{1,3} 被扩展为 [iI]i?i? [iI][iI]?[iI]?。这意味着带有重复字符的大写罗马数字(这在莎士比亚源代码中是正常的)将无法被正确识别。

Kyle Cartmell 对 Marlowe 的更改在正则表达式中使用大写字母而不是小写字母,这反转了问题,以便只有大写罗马数字才能可靠地工作。

我将 Flex 错误报告为 https://github.com/westes/flex/issues/193。如果有人在正式发布之前需要它,它就是 Flex 的单行补丁。

This problem results from a bug in Flex introduced somewhere between versions 2.5.4 and 2.5.33; that is, between the time the Shakespeare processor was written and this question was asked. The bug involves the use of the braced repetition operator with single-character arguments in a case-insensitive regular expression (e.g. i{1,3}, which is part of the Shakespeare flex specification for roman numerals); the consequence of the bug is that the case-insensitivity is lost, so that i{1,3} is expanded as though it were [iI]i?i? instead of [iI][iI]?[iI]?. That means that upper-case roman numerals with repeated characters (which is normal in Shakespeare source code) will not be correctly identified.

Kyle Cartmell's change in Marlowe uses upper-case letters in the regex instead of lower-case, which inverts the issue so that only upper-case Roman numerals work reliably.

I reported the Flex bug as https://github.com/westes/flex/issues/193. It's a one-line patch to Flex if anyone needs it in advance of the official release.

仅一夜美梦 2024-08-22 06:47:01

scanner.l:600:警告,规则无法匹配的第一个问题是因为单词rotten已被添加到文件include/negative_adjective中两次。 wordlist 只需从那里删除它,第一个警告就会被删除。但这并不能解决其余问题。看看这里是否可以解决更多问题。

The first problem with scanner.l:600: warning, rule cannot be matched is because the word rotten has been added two times to the file include/negative_adjective.wordlist just remove it from there and the first warning will be removed. This does not fix the rest though. Having a look here if I can fix anything more.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文