Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

grammar fragment

code

A

Code Block
kids.add(_adaptor.create($A));
_localctx.tree = _adaptor.addChildren(root, kids); // A
_localctx.tree = _root0;

A B

Code Block
kids.add(_adaptor.create($A));
kids.add(_adaptor.create($B));
_localctx.tree =
_adaptor.addChildren(root, kids); // ^(nil A B)
_localctx.tree = _root0;

A^ B

Code Block
root = root==null ? $A : _adaptor.becomeRoot(root, $A, kids);
kids.add($ID(_adaptor.create($A));
_localctx.tree = _adaptor.addChildren(root, kids); // ^(A B)
_localctx.tree = _root0;

A B^

Code Block
kids.add(_adaptor.create($A));
root = root==null ? $B : _adaptor.becomeRoot(root, $B, kids);
_localctx.tree = _adaptor.addChildren(root, kids); // ^(B A)
_localctx.tree = _root0;

A B^ C

Code Block
kids.add(_adaptor.create($A));
root = root==null ? $B : _adaptor.becomeRoot(root, $B, kids);
kids.add($C);
_localctx.tree
= _adaptor.addChildren(root, kids); // ^(B A C)
_localctx.tree = _root0;

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($D);
_localctx.tree
= _adaptor.create(root, kids); // ^(C ^(B A) D)
_localctx.tree = _root0;

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.

...