At 09:20 14/10/2008, `VL wrote:
>I need to parse a file with quite simple syntax, but it has one
>caveat: file can include environment variables in a form of
$(VAR)
>at any place inside. This is not a problem for software that
uses
>it since it just evaluates values and parses results.
[...]
>DIR=/some/path
>DOCS=/home/$(USER)/docs
>
>Say, i have such simple rule for absolute path:
>
>fragment PATH: ( '/' (ID|INT)* )+;
>
>I thought that i can match path with $(VAR) embedded somewhere
>inside it with something like this:
>
>fragment ENVAR: '$' '(' ID ')';
>ENPATH: ( ENVAR* PATH* ENVAR* )+ ;
The problem with this approach is it doesn't consider the case
where the environment variable contains a /, or where it forms
only part of the path (eg. "/home/user-$(USER)/docs".
A better combination that supports these as well would be:
fragment ENVAR : '$' '(' ID ')';
PATH : ( '/' (ID|INT|ENVAR)* )+;
On the other hand, the file structure given above is simple enough
that using ANTLR seems like overkill. Why not just read each line
and split it at the first '='?
List: http://www.antlr.org:8080/mailman/listinfo/antlr-interest
Unsubscribe:
http://www.antlr.org:8080/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
-~----------~----~----~----~------~----~------~--~---