Compiling and executing the Shakespeare Programming Language translator spl2c on Mac OS X 10.6 results in warnings/errors

六眼飞鱼酱① 提交于 2019-12-12 07:56:40

问题


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.


回答1:


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.)




回答2:


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.




回答3:


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.



来源:https://stackoverflow.com/questions/1948372/compiling-and-executing-the-shakespeare-programming-language-translator-spl2c-on

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!