At 05:16 22/03/2009, Sam Barnett-Cormack wrote:
 >1) All children are either ^(NAMENUM ...), ^(EXTREF ...), LCID 
or
 >NUMBER
 >2) Children are *anything* except ^(NAMENUM ...)
 >3) Children include ^(NAMENUM ...) but are not limited to those
 >mentioned in (1) (ie. the complement of the union of (1) and 
(2)).
[...]
 >valueListValue
 >  : ^(VLIST
 >    (
 >      (~(NAMENUM))*
 >      | v+=(nameAndNumberForm | LCID | NUMBER |
 >externalValueReference)+
 >        -> ^(OBJID $v+)
 >    ))
 >  ;

You should always list your more-specific alternatives above the 
less-specific ones (so have your nameAndNumberForm above the 
~NAMENUM alt).

Also, label+=(block ...) doesn't actually work -- the label always 
ends up being null.

Not sure if the following will work, but it'd be my first attempt 
to get the behaviour you're wanting:

valueListValue
scope { bool hasOther; bool hasNameNum; }
@init { $valueListValue::hasOther = false; 
$valueListValue::hasNameNum = false; }
   : ^(VLIST
     ( v+=nameAndNumberForm { $valueListValue::hasNameNum = true; 
}
     | (v+=externalValueReference | v+=LCID | v+=NUMBER)
     | . { $valueListValue::hasOther = true; }
     )+
     ( { $valueListValue::hasNameNum && $valueListValue::hasOther) 
}? { raise error; }
     | { $valueListValue::hasNameNum }? -> ^(OBJID $v+)
     )?
   ;

(I'm a little unsure about the specific syntax for that last 
bit.  But I think something like that ought to do the trick.)


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