Sam Barnett-Cormack wrote:
Sam Barnett-Cormack wrote:
  
Sam Barnett-Cormack wrote:
    

type : ((typeWithConstraint)=>typeWithConstraint | builtinType | 
referencedType) constraint* ;

And a load of parser warnings and errors that it wasn't bothering to 
generate before... *sigh*
    

Or even *lexer* warnings and errors

  
I think that you need to start again and go a lot more slowly in building up your grammar. There is no point asking about each and every error you are getting, as you won't learn anything. Do this:

1) Do not use 'xxxx' type things in the parser rules;
2) Start with a blank lexer and parser;
3) Build the parser rules for expressions, by starting with the primary elements and gradually inserting rules in the _expression_ tree one at a time - compile and test after each rule, fix issue as soon as you see them, do not leave them to accumulate as you will get nowhere;
4) Now add one parser rule at a time (you will sometimes need a few at once of course) and compile and test after each change - compile and test after each rule, fix issue as soon as you see them, do not leave them to accumulate as you will get nowhere;

The things you are seeing are standard things that happen when you start out by typing in a grammar from the normative grammar of some language spec. Such language specs are not really written with writing a parser spec in mind (most say this) and even if they are they are usually written with yacc/bison in mind. Consequently they are full of ambiguities that you must left factor as you go.

Unless you have built a lot of grammars, that is why you need to do this in small steps - otherwise you will end up turning on backtracking and adorning the grammar with predicates that include entire rules such as (typeWithConstraint)=> when the real issue is that you have not left factored the grammar correctly.

Get a copy of the book if you can, it will help a lot, and read through as much of the Wiki as you can before your fingers itch to get back at the keyboard.

Jim

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

Reply via email to