i'm implementing an IDE for scheme in eclipse using DLTK. So far, i am programming the grammar to recognize the lexical structure.
i'm following the official EBNF which can be viewed here:
http://rose-r5rs.googlecode.com/hg/doc/r5rs-grammar.html
i can't get a simple form of the numbers grammar getting worked. for example the decimal numbers, i have
grammar r5rsnumbers;
options {
language = Java;
}
program:
NUMBER;
// NUMBERS
NUMBER : /*NUM_2 | NUM_8 |*/ NUM_10; //| NUM_16;
fragment NUM_10 : PREFIX_10 COMPLEX_10;
fragment COMPLEX_10
: REAL_10 (
'@' REAL_10
| '+' (
UREAL_10 'i'
| 'i'
)?
| '-' (
UREAL_10 'i'
| 'i'
)?
)?
| '+' (
UREAL_10 'i'
| 'i'
)?
| '-' (
UREAL_10 'i'
| 'i'
)?;
fragment REAL_10 : SIGN UREAL_10;
fragment UREAL_10
: UINTEGER_10 ('/' UINTEGER_10)?
| DECIMAL_10;
fragment UINTEGER_10 : DIGIT_10+ '#'*;
fragment DECIMAL_10
: UINTEGER_10 SUFFIX
| '.' DIGIT_10+ '#'* SUFFIX
| DIGIT_10+ '.' DIGIT_10* '#'* SUFFIX
| DIGIT_10+ '#'+ '.' '#'* SUFFIX;
fragment PREFIX_10
: RADIX_10 EXACTNESS
| EXACTNESS RADIX_10;
fragment DIGIT : '0'..'9';
fragment EMPTY : '""'; // empty is the empty string
fragment SUFFIX : EMPTY | EXPONENT_MARKER SIGN DIGIT_10+;
fragment EXPONENT_MARKER : 'e' | 's' | 'f' | 'd' | 'l';
fragment SIGN : EMPTY | '+' | '-';
fragment EXACTNESS : EMPTY | '#i' | '#e';
fragment RADIX_10 : EMPTY | '#d';
fragment DIGIT_10 : DIGIT;
the problem is, it is not recognizing anything. i don't understand the warning i get from the PREFIX_10 or how to solve it. if i don't use fragment in the rules, the file isn't compiling since he complains about the DIGIT_10 rule matching the same input as almost all other prior rules.
it's the same with num_2, num_8 and num_16
plus, i am not sure with my solution of the empty-string.
how do i get around here?