[antlr-interest] syntacsis vs. semantic

alekseyandreev andreev at quorum.ru
Tue Sep 24 00:46:04 PDT 2002


Is there any recomendations about such common problem ?

There is ABSTRACT grammar:
 rule:  
      (A)? (B)? X
    | (B)? (C)? Y
    | (A)? (B)? (C)? Z
   ;

SYNTACTIC implementation of this grammar look like this:
 a: (A)?;
 b: (B)?;
 c: (C)?;
 rule:
    ( a b X ) => a b X
   |( b c Y ) => b c Y
   |( a b c Z ) => a b c Z
   ; 

SEMANTIC implementation of this grammar look like this:
 rule:
   ( (a:A)? (b:B)? (c:C)? )
   (
      X { c == null }? 
    | Y { a == null }? 
    | Z
   )
   ;

When is better use first solution and when second?



 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 



More information about the antlr-interest mailing list