8

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.

3 Answers 3

22

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
  • Ditto-eth. Thanks Kyle. Marlowe has been embedded in OpenCOBOL, COBILL. Feb 27, 2013 at 11:25
  • 2
    Speaking of necromancy: actually, the diagnosis presented here is incorrect. The original regular expression would work as well as the suggested replacement. However, there has been a bug in flex for about a decade now involving the use of braced repeats with single-character case-insensitive arguments. I reported it at github.com/westes/flex/issues/193
    – rici
    Apr 8, 2017 at 14:44
5

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.

1

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.

4
  • Have looked a little now. The scanner seem to mix roman numbers for "scenes" and "acts". Looked into rewriting the grammar to have separate parts but then it mixed with the first person "I" token. Well, I'd say something is depending on the scanner and grammer they used when creating this thing...would have been fun to see working :)
    – epatel
    Dec 22, 2009 at 23:37
  • "scanner and grammer" -- I mean the bison and flex version
    – epatel
    Dec 22, 2009 at 23:37
  • Well, that's a good start. When I have time I may try to take a look at it as well. Or perhaps some other helpful soul will come in and take it up. I agree that it would be entertaining to see working.
    – Redwood
    Dec 23, 2009 at 0:15
  • Oh carp. I didn't include the "rotten" fix in the 1.0 marlowe release. I'll make a note of it and fix it if there's ever a reason to do another release. Dec 11, 2010 at 18:39

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.