Hello everybody

 I'm very new to ANTLR and so far I have been able to achieve what I want.  
Before I go a head with the problem, a little background to what I'm trying to 
do.  I have a number of text based document files, into which I have inserted 
expressions into the text to insert dates, names and figures.  I'm using ANTLR 
to tranform the text  file into a populated text file.  An typical example of 
the expressions would be:
 
[. insert.date.today/]
 
The lexer and the parser correctly finds and evaluates any expression that is 
on its own.  My problem is this, I can have expressions embedded within text.  
I want to retain the text and to evaluate the expression.  An example of what 
I'm using is:
 
'Your next appointment date is [. insert.date.nextAppointmentDate/] and you 
will be seen
by [. insert avaliable.consultant.fullName/].  Please, bring along your [. 
insert careerDocumentList/]
to help with you career choice.'
 
However, what is happening is that expressions embedded in the text are being 
ignored and all you get is:
 
'Your next appointment date is   and you will be seen
by  .  Please, bring along your  
to help with you career choice.'
 
I have successfully got everything working the way I want it, and the Lexer and 
tree diagram clearly indentifies the embedded expressions.  To cater for the 
text I have used the following rule:
 
everything_else
  :(IDENTIFIER | SYMBOLS) (options {greedy=false;} :.*) ;
 
I believe that the problem is caused by the (options {greedy=false;} :.*).  The 
wildcard '.*' is accepting all of the text, as text, and ignoring the embedded 
expressions.
 
The lexer rules I have used are:
 
EXPRESSION_ALPHA: ('a'..'z' | 'A'..'Z' | '.');
 
NUMBER: ('0'..'9');
 
LEFT_PAREN: '[.';
 
RIGHT_PAREN:  '\\]'| ']';
 
WS:  (' ' | '\t' | '\u000C' | '\r' | '\n' )* {$channel = HIDDEN;};
 
IDENTIFIER: (EXPRESSION_ALPHA|NUMBER)+;
 
Many thanks
 
Jay

List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe: 
http://www.antlr.org/mailman/options/antlr-interest/your-email-address

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to