...
Code gen templates for operators; assume root=null (not nil node), kids=_adaptor.createChildList()
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 = _root0root;
|
|
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 = _root0root;
|
|
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 = _root0root;
|
|
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 = _root0root;
|
|
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 = _root0root;
|
|
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 = _root0root;
|
|
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.
...