Hi,
As I wrote in my previous e-mail, I am trying to write the Java grammar
for PetitParser. I am following "The Java Language Specification,
Third Edition",
which is the last available book written by Sun with the specification
for the whole
Java language [1]. It covers Java 1.5.
The project, PetitJava, is on SqueakSource [2].
I've just "finished" to implement the literals [3]
and I am trying it with some tests.
I find something strange, thus probably there is something
in PetitParser that I don't get.
As an example, among the primitives in PPJavaGrammar you find:
<snips>
PPJavaGrammar>>octalEscape
^ $\ asParser , ( octalDigit / (octalDigit , octalDigit) /
(zeroToThree , octalDigit , octalDigit) )
PPJavaGrammar>>octalDigit
^PPPredicateObjectParser anyOf: '01234567'
PPJavaGrammar>>zeroToThree
^PPPredicateObjectParser anyOf: '0123'
</snips>
I take some one of the failing tests as an example:
<snips>
PPJavaGrammarTest>>testOctalEscape1
self parse: '\0' rule: #octalEscape
PPJavaGrammarTest>>testOctalEscape2
self parse: '\00' rule: #octalEscape
PPJavaGrammarTest>>testOctalEscape3
self parse: '\000' rule: #octalEscape
</snips>
While the first test passes as I expected,
the second and the third ones do not.
However, they should be recognized as:
$\ , octalDigit , octalDigit
and
$\ , zeroToThree, octalDigit , octalDigit
as stated in the "octalEscape" implementation.
Is there something wrong with my implementation,
or didn't I understand correctly the '/' operator?
Thank you,
Alberto
[1]
http://java.sun.com/docs/books/jls/third_edition/html/j3TOC.html
[2]
http://www.squeaksource.com/PetitJava.html
[3]
http://java.sun.com/docs/books/jls/third_edition/html/lexical.html#3.10