dcsimg
Supergrammar and C++ ...
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Michael_Lindig
Posted On:   Sunday, April 1, 2001 10:05 PM

Have you an example ?

Re: Supergrammar and C++ ...

Posted By:   Terence_Parr  
Posted On:   Monday, April 2, 2001 11:53 AM

Here's an example where the subgrammar doesn't affect the supergrammar:

class SUPER extends Parser;
a : A {action1};
b : a | B ;

class SUB extends SUPER;
a : A {action2}; // changed action
c : C ; // addition: no effect


Rule 'b' can be simply invoked as the subgrammar doesn't alter the lookahead generation for 'b' in any way.



Now, consider the following subgrammar where the redefinition of rule
'a' does in fact force regeneration of rule 'b' inherited from the
supergrammar:


class SUPER extends Parser;
a : A ;
b : a | B ;

class SUB extends SUPER;
a : A | Q ;


If you consider just the supergrammar, then the token A predicts the
first alternative of rule 'b'. However, in the subgrammar, you cannot
just call super.b() in SUB because token set {A,Q} now predicts the
first alternative of rule 'b' not plain A.
About | Sitemap | Contact