register reg.ini wrote:
> Hi everybody,
> I am trying to parse a custom configuration file format using antlr.
> This file format describes properties of several Paramaters using C 
> like structs, for example:
>
> Record
> {
>        TYPE typeid;
>        LENGHT 80;
>        PATH= pathtofile
> }
>
> . The order of the attributes is irrelevant but some of them are 
> required other are simply optional. Is it possible to embody the 
> requirement of order independent attributes directly in the parser 
> grammar, without using actions?
Probably not, but that is exactly the wrong way to do it anyway. You 
want to specify that you can have any number of options, including 0, 
and accumulate how many you get of each , with their line numbers and so 
on. Then you can tell the users: "Too many pggb options (There can be 
only one) at line 44', or "Record specs must contain a gurgle option and 
this is missing from the Record at line ...."

So you will need actions either in the parser or (better) in the tree 
walker. Remember to push as many errors as possible as high up the chain 
as they can go - overall, you have better semantic context for the 
message and your users will thank you for the better error messages.


Jim

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