- edited description
Make syn NTA and abstract grammar NTA equivalent
Issue #228
new
JastAdd2 2.1.11-32-geb021ae
Make the syn NTAs and abstract grammar NTAs equivalent. Below follows differences between the two different notations.
Abstract grammar NTAs require the attribute to be specified as lazy
See issue #72
Generated methods
When an NTA is declared in the abstract grammar, several methods are generated. This is not the case for the syn NTAs.
Single node NTA
A ::= /B/;
=>
public B getBNoTransform()
protected int getBChildPosition()
List NTA
A ::= /B*/;
=>
private void getB_reset()
public int getNumB()
public int getNumBNoTransform()
public B getB(int i)
public boolean hasB2()
public void addB(B node)
public void addBNoTransform(B node)
public void setB(B node, int i)
protected int getBListChildPosition()
public List<B> getBListNoTransform()
public List<B> getBs()
public List<B> getBsNoTransform()
private void getB_reset()
Inherited attributes
Equations for inherited attributes for syn ntas and abstract grammar ntas.
List NTA:
// Abstract grammar NTA
A ::= /B*/;
syn lazy List<B> A.getBList() = ...
inh int B.index();
eq A.getB().index() = -1; // OK
eq A.getB(int i).index() = i; // OK
// Syn NTA
A; B;
syn nta List<B> A.bs() = ...
eq A.bs().index() = -1; // OK
eq A.bs(int i).index() = i; // ERROR. Java compile error
Syn NTA name starting with get does not work
// NTA name starting with get
syn nta B A.getB() = new B();
inh int B.index();
eq A.getB().index() = -1; // ERROR
=>
Error at jrag.jrag:X: inherited equation for unknown child B in class A
// NTA name not starting with get
syn nta B A.B() = new B();
inh int B.index();
eq A.B().index() = -1; // OK
Comments (6)
-
reporter -
reporter - edited description
-
reporter - edited description
-
reporter - edited description
-
Note also that there are also some peculiarities on how the node is stored - _value/_computed fields are created in both cases, but when adding to the grammar and using lazy, then the node is stored in the children array.
Issue #215 is also related.
-
- edited description
Added affected JastAdd version.
- Log in to comment