I'm fairly new to writing grammar files. I have succeeded in writing a
grammar file that seems to parse correctly, however I want to adapt it
to be sensitive to newlines. Below is a simplified version of my grammar
file:
%header%
GRAMMARTYPE = "LL"
%tokens%
ENTRY = "$entry"
IDENT = <<[a-zA-Z0-9_-]+>>
WHITESPACE = <<[ \t]+>> %ignore%
%productions%
File = EntryStatement Pairing ;
EntryStatement = ENTRY IDENT ;
Pairing = IDENT IDENT [Pairing] ;
I have tried the following and variations, but they do not seem to work:
%header%
GRAMMARTYPE = "LL"
%tokens%
NEWLINE = <<\n\r|[\n\r]>>
ENTRY = "$entry"
IDENT = <<[a-zA-Z0-9_-]+>>
WHITESPACE = <<[ \t]+>> %ignore%
%productions%
File = EntryStatement NEWLINE Pairing ;
EntryStatement = ENTRY IDENT ;
Pairing = IDENT IDENT [NEWLINE Pairing] ;
But I get the error:
unexpected token "\r" <NEWLINE>, expected < IDENT>, on line: 1 column: 13
unexpected token "(...)" <NEWLINE>, expected < IDENT>, on line: 2
column: 13
unexpected token "(...)" <NEWLINE>, expected < IDENT>, on line: 4
column: 13
etc.
on the input:
$entry TESTA
TESTA TESTB
TESTB TESTC
TESTC TESTD
etc.
_______________________________________________
Grammatica-users mailing list
address@hidden
http://lists.nongnu.org/mailman/listinfo/grammatica-users