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

Law*_*ton 8 macos yacc bison flex-lexer shakespeare-lang

我想尝试使用莎士比亚编程语言,所以我从这里下载并使用Makefile执行cd spl-1.2.1 Make.

spl2c带有几个警告的执行汇编:

scanner.l:600: warning, rule cannot be matched
<stdout>:5808: warning: ‘yyunput’ defined but not used
Run Code Online (Sandbox Code Playgroud)

然后当它试图编译所有的例子时,一切都变得混乱:

../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.
Run Code Online (Sandbox Code Playgroud)

任何人都可以指出我正确的方向来解决这个问题吗?我原来的项目是学习spl,而不是倾向于调试编译器(我实际上最终想编写自己的编译器,但我现在更喜欢坚持我的初始项目).

我跑OS X 10.6.2,gcc version 4.2.1 (Apple Inc. build 5646) (dot 1),flex 2.5.35,和bison (GNU Bison) 2.3.

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

Kyl*_*ell 23

这是词法分析器中正则表达式的缺陷.

我分叉了这门语言.

我解决了这个问题.

我通知了原作者.

这是一种语言版本,其中包括您的乐趣.

仍然有一些警告,但它们似乎没有任何影响.让我知道如果你发现任何其他功能性问题,我会看看有什么我可以与他们无关.

(Roffel - 如果不是因为没有人关心这个问题,这将是一种死灵法.)

  • 说到死灵法术:实际上,这里提出的诊断是不正确的。原始正则表达式与建议的替换一样有效。但是,大约十年以来,flex 中一直存在一个错误,涉及使用带单字符不区分大小写参数的花括号重复。我在 https://github.com/westes/flex/issues/193 报告了它 (2认同)

ric*_*ici 5

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

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

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