...
grammar fragment | code |
---|
A | Code Block |
---|
kids.add(_adaptor.create($A));
if ( root==null && kids.size()>0 ) root = _adaptor.nil();
_adaptor.addChildren(root, kids); // A
_localctx.tree = root;
|
|
A B | Code Block |
---|
kids.add(_adaptor.create($A));
kids.add(_adaptor.create($B));
if ( root==null && kids.size()>0 ) root = _adaptor.nil();
_adaptor.addChildren(root, kids); // ^(nil A B)
_localctx.tree = root;
|
|
A^ B | Code Block |
---|
root = root==null ? $A : _adaptor.becomeRoot(root, $A, kids);
kids.add(_adaptor.create($B));
if ( root==null && kids.size()>0 ) root = _adaptor.nil();
_adaptor.addChildren(root, kids); // ^(A B)
_localctx.tree = root;
|
|
A B^ | Code Block |
---|
kids.add(_adaptor.create($A));
root = root==null ? $B : _adaptor.becomeRoot(root, $B, kids);
if ( root==null && kids.size()>0 ) root = _adaptor.nil();
_adaptor.addChildren(root, kids); // ^(B A)
_localctx.tree = root;
|
|
A B^ C | Code Block |
---|
kids.add(_adaptor.create($A));
root = root==null ? $B : _adaptor.becomeRoot(root, $B, kids);
kids.add(_adaptor.create($C));
if ( root==null && kids.size()>0 ) root = _adaptor.nil();
_adaptor.addChildren(root, kids); // ^(B A C)
_localctx.tree = root;
|
|
A B^ C^ D | Code Block |
---|
kids.add(_adaptor.create($A));
root = root==null ? $B : _adaptor.becomeRoot(root, $B, kids);
root = root==null ? $C : _adaptor.becomeRoot(root, $C, kids);
kids.add(_adaptor.create($D));
if ( root==null && kids.size()>0 ) root = _adaptor.nil();
_adaptor.create(root, kids); // ^(C ^(B A) D)
_localctx.tree = root;
|
|
a^ b | Code Block |
---|
root = root==null ? $a.tree : _adaptor.becomeRoot(root, $a.tree, kids);
kids.add($b);
if ( root==null && kids.size()>0 ) root = _adaptor.nil();
_adaptor.addChildren(root, kids); // ^(A B)
_localctx.tree = root;
|
|
Rewrites
Code gen templates for rewrite rules; assume root=_adaptor.nil(), kids is _adaptor.createChildList(). assume we can't distinguish statically single vs multi-valued elements from left of -> for now.
...