[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
order of productions
Hi,
I'm a beginner to SableCC. I've written a grammar for another version
of Knowledge Interchange Format (KIF), to support the Suggested Upper
Merged Ontology (SUMO). I appear to have a problem with the ordering of
production rules.
My grammar gets stuck on the following text:
(=>
(immediateInstance ?ENTITY ?CLASS)
(not (exists (?SUBCLASS) ;; problem after "?SUBCLASS"
(and
(subclass ?SUBCLASS ?CLASS)
(instance ?ENTITY ?SUBCLASS)))))
It should be applying the second option of the following rule:
quantsent = {forall} openparen forall varlist sentence closeparen |
{exists} openparen exists varlist sentence closeparen;
But instead it appears to be applying the second option of the following rule:
relsent = {relsent} openparen word term+ closeparen |
{relsentvar} openparen variable term+ closeparen;
I've ordered the rules with the "quantsent" option first, but that appears
to make no difference. I've attached the entire grammar to this message.
So, my question is,
- is the order of productions significant?
- can SableCC handle grammars of this sort?
many thanks,
Adam
Package com.articulate.kif;
Helpers
upper = ['A' .. 'Z'];
lower = ['a' .. 'z'];
digit = ['0' .. '9'];
special = '!' | '$' | '%' | '&' | '*' | '+' | '-' | '.' | '/' | '<' | '=' |
'>' | '?' | '@' | '_' | '~';
white = 32 | 9 | 13 | 10 | 8;
letter = [upper + lower];
wchar = [letter + digit];
wordchar = letter | '-' | '_';
initialchar = upper | lower;
character = [[1 .. 127] - ['"' + '\']];
cr = 13;
lf = 10;
eol = cr lf | cr | lf;
exponent = 'e' '-'? digit+;
Tokens
string = '"' character* '"';
openparen = '(';
closeparen = ')';
ampersand = '@';
equals = '=';
and = 'and';
not = 'not';
or = 'or';
fn = 'Fn';
implies = '=>';
iff = '<=>';
word = initialchar wordchar*;
variable = '?' initialchar wordchar* | '@' initialchar wordchar*;
forall = 'forall';
exists = 'exists';
white = white+;
line_comment = ';' [[0 .. 0xffff] - [cr + lf]]* eol ;
number = '-'? digit+ ('.' digit+)? exponent?;
Ignored Tokens
white, line_comment;
Productions
kiffile = result+;
result = {res} sentence;
sentence = {quant} quantsent |
{logsent} logsent |
{relsent} relsent
term = {var} variable |
{word} word |
{string} string |
{funterm} funterm |
{number} number |
{sentence} sentence;
funword = word fn;
funterm = openparen funword term+ closeparen;
lhs = term;
rhs = term;
lsent = {lsent} sentence;
rsent = {rsent} sentence;
logsent = {not} openparen not sentence closeparen |
{and} openparen and sentence+ closeparen |
{or} openparen or sentence+ closeparen |
{implies} openparen implies lsent rsent closeparen |
{iff} openparen iff lsent rsent closeparen;
varlist = openparen variable+ closeparen;
quantsent = {forall} openparen forall varlist sentence closeparen |
{exists} openparen exists varlist sentence closeparen;
relsent = {relsent} openparen word term+ closeparen |
{relsentvar} openparen variable term+ closeparen;