Hello,
I'm a ANTLR newbie and have a problem to define the right grammar for the
following input.
- one input line is one record
- the structure is: <fieldname> <one colon followed by one or more spaces as
delimiter> <fieldvalue> <newline>*
- the fieldnames are known
My problem is, than the fieldvalue can have colon or space characters too.
This is my grammar:
grammar Foo;
options {
output=AST;
ASTLabelType=CommonTree;
}
entry : fieldname FIELDSEPERATOR fieldvalue '\n'*
;
fieldvalue : ID
;
fieldname: NAME
|GIVENNAME
|STREET
|ZIP
|CITY
|COUNTRY
|TEXT
;
NAME : 'Name';
GIVENNAME : 'Givenname';
STREET : 'Street';
ZIP : 'Zip';
CITY : 'City';
COUNTRY : 'Country';
TEXT : 'Text';
FIELDSEPERATOR : ':' ' '+
;
ID : AllowedChars+
;
fragment
AllowedChars : 'A'..'Z'
| 'a'..'z'
| '0'..'9'
| '+'
| '-'
| ' '
// | ':'
| '#'
| '.'
;
If i try the input "Text: Free Text with # sign" it works. But if i do
not comment the ':' in the AllowedChars and try the input "Text: Free
Text with : sign" it goes wrong :-(
How can i solve this problem????
Thank's
Matthias
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"il-antlr-interest" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/il-antlr-interest?hl=en
-~----------~----~----~----~------~----~------~--~---
List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe:
http://www.antlr.org/mailman/options/antlr-interest/your-email-address