[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Grammatica-users] Constructing a new-line sensitive grammar.
From: |
[ICR] |
Subject: |
[Grammatica-users] Constructing a new-line sensitive grammar. |
Date: |
Wed, 19 Sep 2007 13:23:58 +0100 |
User-agent: |
Thunderbird 2.0.0.6 (Windows/20070728) |
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] Constructing a new-line sensitive grammar.,
[ICR] <=