[jruby-joni] 143/194: refactor list node

Hideki Yamane henrich at moszumanska.debian.org
Thu Feb 1 12:04:35 UTC 2018


This is an automated email from the git hooks/post-receive script.

henrich pushed a commit to branch debian/sid
in repository jruby-joni.

commit 5363f73e03668d583cbaed426fe19b54d7243025
Author: lopex <lopx at gazeta.pl>
Date:   Thu Jan 11 09:58:10 2018 +0100

    refactor list node
---
 src/org/joni/Analyser.java         | 228 ++++++++++++++++++-------------------
 src/org/joni/ApplyCaseFold.java    |   6 +-
 src/org/joni/ApplyCaseFoldArg.java |   6 +-
 src/org/joni/ArrayCompiler.java    |  66 +++++------
 src/org/joni/AsmCompiler.java      |   4 +-
 src/org/joni/Compiler.java         |  12 +-
 src/org/joni/Parser.java           | 158 ++++++++++++-------------
 src/org/joni/ast/ListNode.java     |  92 ++++++++-------
 8 files changed, 285 insertions(+), 287 deletions(-)

diff --git a/src/org/joni/Analyser.java b/src/org/joni/Analyser.java
index 8ad20f6..2ddeb63 100644
--- a/src/org/joni/Analyser.java
+++ b/src/org/joni/Analyser.java
@@ -28,8 +28,8 @@ import static org.joni.Option.isCaptureGroup;
 import static org.joni.Option.isFindCondition;
 import static org.joni.Option.isIgnoreCase;
 import static org.joni.Option.isMultiline;
-import static org.joni.ast.ConsAltNode.newAltNode;
-import static org.joni.ast.ConsAltNode.newListNode;
+import static org.joni.ast.ListNode.newAlt;
+import static org.joni.ast.ListNode.newList;
 import static org.joni.ast.QuantifierNode.isRepeatInfinite;
 
 import java.util.HashSet;
@@ -43,7 +43,7 @@ import org.joni.ast.BackRefNode;
 import org.joni.ast.CClassNode;
 import org.joni.ast.CTypeNode;
 import org.joni.ast.CallNode;
-import org.joni.ast.ConsAltNode;
+import org.joni.ast.ListNode;
 import org.joni.ast.EncloseNode;
 import org.joni.ast.Node;
 import org.joni.ast.QuantifierNode;
@@ -178,10 +178,10 @@ final class Analyser extends Parser {
     }
 
     private void noNameDisableMapFor_cosAlt(Node node, int[]map, Ptr counter) {
-        ConsAltNode can = (ConsAltNode)node;
+        ListNode can = (ListNode)node;
         do {
-            can.setCar(noNameDisableMap(can.car, map, counter));
-        } while ((can = can.cdr) != null);
+            can.setValue(noNameDisableMap(can.value, map, counter));
+        } while ((can = can.tail) != null);
     }
 
     private void noNameDisableMapFor_quantifier(Node node, int[]map, Ptr counter) {
@@ -243,10 +243,10 @@ final class Analyser extends Parser {
         switch (node.getType()) {
         case NodeType.LIST:
         case NodeType.ALT:
-            ConsAltNode can = (ConsAltNode)node;
+            ListNode can = (ListNode)node;
             do {
-                renumberByMap(can.car, map);
-            } while ((can = can.cdr) != null);
+                renumberByMap(can.value, map);
+            } while ((can = can.tail) != null);
             break;
 
         case NodeType.QTFR:
@@ -276,10 +276,10 @@ final class Analyser extends Parser {
         switch (node.getType()) {
         case NodeType.LIST:
         case NodeType.ALT:
-            ConsAltNode can = (ConsAltNode)node;
+            ListNode can = (ListNode)node;
             do {
-                numberedRefCheck(can.car);
-            } while ((can = can.cdr) != null);
+                numberedRefCheck(can.value);
+            } while ((can = can.tail) != null);
             break;
 
         case NodeType.QTFR:
@@ -349,11 +349,11 @@ final class Analyser extends Parser {
         switch(node.getType()) {
         case NodeType.LIST:
         case NodeType.ALT:
-            ConsAltNode can = (ConsAltNode)node;
+            ListNode can = (ListNode)node;
             do {
-                int v = quantifiersMemoryInfo(can.car);
+                int v = quantifiersMemoryInfo(can.value);
                 if (v > info) info = v;
-            } while ((can = can.cdr) != null);
+            } while ((can = can.tail) != null);
             break;
 
         case NodeType.CALL:
@@ -442,23 +442,23 @@ final class Analyser extends Parser {
             break;
 
         case NodeType.LIST:
-            ConsAltNode can = (ConsAltNode)node;
+            ListNode can = (ListNode)node;
             do {
-                min += getMinMatchLength(can.car);
-            } while ((can = can.cdr) != null);
+                min += getMinMatchLength(can.value);
+            } while ((can = can.tail) != null);
             break;
 
         case NodeType.ALT:
-            ConsAltNode y = (ConsAltNode)node;
+            ListNode y = (ListNode)node;
             do {
-                Node x = y.car;
+                Node x = y.value;
                 int tmin = getMinMatchLength(x);
                 if (y == node) {
                     min = tmin;
                 } else if (min > tmin) {
                     min = tmin;
                 }
-            } while ((y = y.cdr) != null);
+            } while ((y = y.tail) != null);
             break;
 
         case NodeType.STR:
@@ -521,19 +521,19 @@ final class Analyser extends Parser {
 
         switch (node.getType()) {
         case NodeType.LIST:
-            ConsAltNode ln = (ConsAltNode)node;
+            ListNode ln = (ListNode)node;
             do {
-                int tmax = getMaxMatchLength(ln.car);
+                int tmax = getMaxMatchLength(ln.value);
                 max = MinMaxLen.distanceAdd(max, tmax);
-            } while ((ln = ln.cdr) != null);
+            } while ((ln = ln.tail) != null);
             break;
 
         case NodeType.ALT:
-            ConsAltNode an = (ConsAltNode)node;
+            ListNode an = (ListNode)node;
             do {
-                int tmax = getMaxMatchLength(an.car);
+                int tmax = getMaxMatchLength(an.value);
                 if (max < tmax) max = tmax;
-            } while ((an = an.cdr) != null);
+            } while ((an = an.tail) != null);
             break;
 
         case NodeType.STR:
@@ -639,20 +639,20 @@ final class Analyser extends Parser {
 
         switch(node.getType()) {
         case NodeType.LIST:
-            ConsAltNode ln = (ConsAltNode)node;
+            ListNode ln = (ListNode)node;
             do {
-                int tlen = getCharLengthTree(ln.car, level);
+                int tlen = getCharLengthTree(ln.value, level);
                 if (returnCode == 0) len = MinMaxLen.distanceAdd(len, tlen);
-            } while (returnCode == 0 && (ln = ln.cdr) != null);
+            } while (returnCode == 0 && (ln = ln.tail) != null);
             break;
 
         case NodeType.ALT:
-            ConsAltNode an = (ConsAltNode)node;
+            ListNode an = (ListNode)node;
             boolean varLen = false;
 
-            int tlen = getCharLengthTree(an.car, level);
-            while (returnCode == 0 && (an = an.cdr) != null) {
-                int tlen2 = getCharLengthTree(an.car, level);
+            int tlen = getCharLengthTree(an.value, level);
+            while (returnCode == 0 && (an = an.tail) != null) {
+                int tlen2 = getCharLengthTree(an.value, level);
                 if (returnCode == 0) {
                     if (tlen != tlen2) varLen = true;
                 }
@@ -937,7 +937,7 @@ final class Analyser extends Parser {
             break;
 
         case NodeType.LIST:
-            n = getHeadValueNode(((ConsAltNode)node).car, exact);
+            n = getHeadValueNode(((ListNode)node).value, exact);
             break;
 
         case NodeType.STR:
@@ -1005,10 +1005,10 @@ final class Analyser extends Parser {
         switch(node.getType()) {
         case NodeType.LIST:
         case NodeType.ALT:
-            ConsAltNode can = (ConsAltNode)node;
+            ListNode can = (ListNode)node;
             do {
-                invalid = checkTypeTree(can.car, typeMask, encloseMask, anchorMask);
-            } while (!invalid && (can = can.cdr) != null);
+                invalid = checkTypeTree(can.value, typeMask, encloseMask, anchorMask);
+            } while (!invalid && (can = can.tail) != null);
             break;
 
         case NodeType.QTFR:
@@ -1044,26 +1044,26 @@ final class Analyser extends Parser {
         switch (node.getType()) {
         case NodeType.LIST:
             int min;
-            ConsAltNode x = (ConsAltNode)node;
+            ListNode x = (ListNode)node;
             do {
-                int ret = subexpInfRecursiveCheck(x.car, head);
+                int ret = subexpInfRecursiveCheck(x.value, head);
                 if (ret == RECURSION_INFINITE) return ret;
                 r |= ret;
                 if (head) {
-                    min = getMinMatchLength(x.car);
+                    min = getMinMatchLength(x.value);
                     if (min != 0) head = false;
                 }
-            } while ((x = x.cdr) != null);
+            } while ((x = x.tail) != null);
             break;
 
         case NodeType.ALT:
-            ConsAltNode can = (ConsAltNode)node;
+            ListNode can = (ListNode)node;
             r = RECURSION_EXIST;
             do {
-                int ret = subexpInfRecursiveCheck(can.car, head);
+                int ret = subexpInfRecursiveCheck(can.value, head);
                 if (ret == RECURSION_INFINITE) return ret;
                 r &= ret;
-            } while ((can = can.cdr) != null);
+            } while ((can = can.tail) != null);
             break;
 
         case NodeType.QTFR:
@@ -1116,10 +1116,10 @@ final class Analyser extends Parser {
         switch (node.getType()) {
         case NodeType.LIST:
         case NodeType.ALT:
-            ConsAltNode can = (ConsAltNode)node;
+            ListNode can = (ListNode)node;
             do {
-                r = subexpInfRecursiveCheckTrav(can.car);
-            } while (r == 0 && (can = can.cdr) != null);
+                r = subexpInfRecursiveCheckTrav(can.value);
+            } while (r == 0 && (can = can.tail) != null);
             break;
 
         case NodeType.QTFR:
@@ -1162,10 +1162,10 @@ final class Analyser extends Parser {
         switch (node.getType()) {
         case NodeType.LIST:
         case NodeType.ALT:
-            ConsAltNode can = (ConsAltNode)node;
+            ListNode can = (ListNode)node;
             do {
-                r |= subexpRecursiveCheck(can.car);
-            } while ((can = can.cdr) != null);
+                r |= subexpRecursiveCheck(can.value);
+            } while ((can = can.tail) != null);
             break;
 
         case NodeType.QTFR:
@@ -1217,14 +1217,14 @@ final class Analyser extends Parser {
         switch (node.getType()) {
         case NodeType.LIST:
         case NodeType.ALT:
-            ConsAltNode can = (ConsAltNode)node;
+            ListNode can = (ListNode)node;
             do {
-                int ret = subexpRecursiveCheckTrav(can.car);
+                int ret = subexpRecursiveCheckTrav(can.value);
                 if (ret == FOUND_CALLED_NODE) {
                     r = FOUND_CALLED_NODE;
                 }
                 // else if (ret < 0) return ret; ???
-            } while ((can = can.cdr) != null);
+            } while ((can = can.tail) != null);
             break;
 
         case NodeType.QTFR:
@@ -1281,17 +1281,17 @@ final class Analyser extends Parser {
 
         switch(node.getType()) {
         case NodeType.LIST:
-            ConsAltNode ln = (ConsAltNode)node;
+            ListNode ln = (ListNode)node;
             do {
-                setupSubExpCall(ln.car);
-            } while ((ln = ln.cdr) != null);
+                setupSubExpCall(ln.value);
+            } while ((ln = ln.tail) != null);
             break;
 
         case NodeType.ALT:
-            ConsAltNode can = (ConsAltNode)node;
+            ListNode can = (ListNode)node;
             do {
-                setupSubExpCall(can.car);
-            } while ((can = can.cdr) != null);
+                setupSubExpCall(can.value);
+            } while ((can = can.tail) != null);
             break;
 
         case NodeType.QTFR:
@@ -1357,7 +1357,7 @@ final class Analyser extends Parser {
         AnchorNode an = (AnchorNode)node;
         int anchorType = an.type;
         Node head = an.target;
-        Node np = ((ConsAltNode)head).car;
+        Node np = ((ListNode)head).value;
 
         swap(node, head);
 
@@ -1365,21 +1365,21 @@ final class Analyser extends Parser {
         node = head;
         head = tmp;
 
-        ((ConsAltNode)node).setCar(head);
+        ((ListNode)node).setValue(head);
         ((AnchorNode)head).setTarget(np);
         np = node;
 
-        while ((np = ((ConsAltNode)np).cdr) != null) {
+        while ((np = ((ListNode)np).tail) != null) {
             AnchorNode insert = new AnchorNode(anchorType);
-            insert.setTarget(((ConsAltNode)np).car);
-            ((ConsAltNode)np).setCar(insert);
+            insert.setTarget(((ListNode)np).value);
+            ((ListNode)np).setValue(insert);
         }
 
         if (anchorType == AnchorType.LOOK_BEHIND_NOT) {
             np = node;
             do {
-                ((ConsAltNode)np).toListNode(); /* alt -> list */
-            } while ((np = ((ConsAltNode)np).cdr) != null);
+                ((ListNode)np).toListNode(); /* alt -> list */
+            } while ((np = ((ListNode)np).tail) != null);
         }
 
         return node;
@@ -1545,44 +1545,44 @@ final class Analyser extends Parser {
             }
         }
 
-        ConsAltNode varANode = null, altNode, listNode;
+        ListNode varANode = null, altNode, listNode;
         if (varlen) {
-            node.p = varANode = newAltNode(null, null);
+            node.p = varANode = newAlt(null, null);
 
-            listNode = newListNode(null, null);
-            varANode.setCar(listNode);
+            listNode = newList(null, null);
+            varANode.setValue(listNode);
 
-            altNode = newAltNode(null, null);
-            listNode.setCar(altNode);
+            altNode = newAlt(null, null);
+            listNode.setValue(altNode);
         } else {
-            node.p = altNode = newAltNode(null, null);
+            node.p = altNode = newAlt(null, null);
         }
 
         StringNode snode = new StringNode(bytes, p, p + slen);
-        altNode.setCar(snode);
+        altNode.setValue(snode);
 
         for (int i=0; i<itemNum; i++) {
             snode = new StringNode();
 
             for (int j = 0; j < items[i].code.length; j++) snode.catCode(items[i].code[j], enc);
 
-            ConsAltNode an = newAltNode(null, null);
+            ListNode an = newAlt(null, null);
             if (items[i].byteLen != slen) {
                 int q = p + items[i].byteLen;
                 if (q < end) {
                     Node rem = expandCaseFoldMakeRemString(bytes, q, end);
 
-                    listNode = ConsAltNode.listAdd(null, snode);
-                    ConsAltNode.listAdd(listNode, rem);
-                    an.setCar(listNode);
+                    listNode = ListNode.listAdd(null, snode);
+                    ListNode.listAdd(listNode, rem);
+                    an.setValue(listNode);
                 } else {
-                    an.setCar(snode);
+                    an.setValue(snode);
                 }
-                varANode.setCdr(an);
+                varANode.setTail(an);
                 varANode = an;
             } else {
-                an.setCar(snode);
-                altNode.setCdr(an);
+                an.setValue(snode);
+                altNode.setTail(an);
                 altNode = an;
             }
         }
@@ -1600,7 +1600,7 @@ final class Analyser extends Parser {
         int end = sn.end;
         int altNum = 1;
 
-        ConsAltNode topRoot = null, root = null;
+        ListNode topRoot = null, root = null;
         ObjPtr<Node> prevNode = new ObjPtr<Node>();
         StringNode stringNode = null;
 
@@ -1611,12 +1611,12 @@ final class Analyser extends Parser {
             if (items.length == 0 || !isCaseFoldVariableLength(items.length, items, len)) {
                 if (stringNode == null) {
                     if (root == null && prevNode.p != null) {
-                        topRoot = root = ConsAltNode.listAdd(null, prevNode.p);
+                        topRoot = root = ListNode.listAdd(null, prevNode.p);
                     }
 
                     prevNode.p = stringNode = new StringNode(); // onig_node_new_str(NULL, NULL);
 
-                    if (root != null) ConsAltNode.listAdd(root, stringNode);
+                    if (root != null) ListNode.listAdd(root, stringNode);
 
                 }
 
@@ -1630,19 +1630,19 @@ final class Analyser extends Parser {
                 }
 
                 if (root == null && prevNode.p != null) {
-                    topRoot = root = ConsAltNode.listAdd(null, prevNode.p);
+                    topRoot = root = ListNode.listAdd(null, prevNode.p);
                 }
 
                 if (expandCaseFoldStringAlt(items.length, items, bytes, p, len, end, prevNode)) { // if (r == 1)
                     if (root == null) {
-                        topRoot = (ConsAltNode)prevNode.p;
+                        topRoot = (ListNode)prevNode.p;
                     } else {
-                        ConsAltNode.listAdd(root, prevNode.p);
+                        ListNode.listAdd(root, prevNode.p);
                     }
 
-                    root = (ConsAltNode)((ConsAltNode)prevNode.p).car;
+                    root = (ListNode)((ListNode)prevNode.p).value;
                 } else { /* r == 0 */
-                    if (root != null) ConsAltNode.listAdd(root, prevNode.p);
+                    if (root != null) ListNode.listAdd(root, prevNode.p);
                 }
                 stringNode = null;
             }
@@ -1658,13 +1658,13 @@ final class Analyser extends Parser {
             Node srem = expandCaseFoldMakeRemString(bytes, p, end);
 
             if (prevNode.p != null && root == null) {
-                topRoot = root = ConsAltNode.listAdd(null, prevNode.p);
+                topRoot = root = ListNode.listAdd(null, prevNode.p);
             }
 
             if (root == null) {
                 prevNode.p = srem;
             } else {
-                ConsAltNode.listAdd(root, srem);
+                ListNode.listAdd(root, srem);
             }
         }
         /* ending */
@@ -1687,20 +1687,20 @@ final class Analyser extends Parser {
 
         switch (node.getType()) {
         case NodeType.LIST:
-            ConsAltNode ln = (ConsAltNode)node;
+            ListNode ln = (ListNode)node;
 
             do {
-                r = setupCombExpCheck(ln.car, r);
-                //prev = ((ConsAltNode)node).car;
-            } while (r >= 0 && (ln = ln.cdr) != null);
+                r = setupCombExpCheck(ln.value, r);
+                //prev = ((ConsAltNode)node).value;
+            } while (r >= 0 && (ln = ln.tail) != null);
             break;
 
         case NodeType.ALT:
-            ConsAltNode an = (ConsAltNode)node;
+            ListNode an = (ListNode)node;
             do {
-                ret = setupCombExpCheck(an.car, state);
+                ret = setupCombExpCheck(an.value, state);
                 r |= ret;
-            } while (ret >= 0 && (an = an.cdr) != null);
+            } while (ret >= 0 && (an = an.tail) != null);
             break;
 
         case NodeType.QTFR:
@@ -1811,22 +1811,22 @@ final class Analyser extends Parser {
         restart: while (true) {
         switch (node.getType()) {
         case NodeType.LIST:
-            ConsAltNode lin = (ConsAltNode)node;
+            ListNode lin = (ListNode)node;
             Node prev = null;
             do {
-                setupTree(lin.car, state);
+                setupTree(lin.value, state);
                 if (prev != null) {
-                    nextSetup(prev, lin.car);
+                    nextSetup(prev, lin.value);
                 }
-                prev = lin.car;
-            } while ((lin = lin.cdr) != null);
+                prev = lin.value;
+            } while ((lin = lin.tail) != null);
             break;
 
         case NodeType.ALT:
-            ConsAltNode aln = (ConsAltNode)node;
+            ListNode aln = (ListNode)node;
             do {
-                setupTree(aln.car, (state | IN_ALT));
-            } while ((aln = aln.cdr) != null);
+                setupTree(aln.value, (state | IN_ALT));
+            } while ((aln = aln.tail) != null);
             break;
 
         case NodeType.CCLASS:
@@ -2010,26 +2010,26 @@ final class Analyser extends Parser {
             OptEnvironment nenv = new OptEnvironment();
             NodeOptInfo nopt = new NodeOptInfo();
             nenv.copy(oenv);
-            ConsAltNode lin = (ConsAltNode)node;
+            ListNode lin = (ListNode)node;
             do {
-                optimizeNodeLeft(lin.car, nopt, nenv);
+                optimizeNodeLeft(lin.value, nopt, nenv);
                 nenv.mmd.add(nopt.length);
                 opt.concatLeftNode(nopt, enc);
-            } while ((lin = lin.cdr) != null);
+            } while ((lin = lin.tail) != null);
             break;
         }
 
         case NodeType.ALT: {
             NodeOptInfo nopt = new NodeOptInfo();
-            ConsAltNode aln = (ConsAltNode)node;
+            ListNode aln = (ListNode)node;
             do {
-                optimizeNodeLeft(aln.car, nopt, oenv);
+                optimizeNodeLeft(aln.value, nopt, oenv);
                 if (aln == node) {
                     opt.copy(nopt);
                 } else {
                     opt.altMerge(nopt, oenv);
                 }
-            } while ((aln = aln.cdr) != null);
+            } while ((aln = aln.tail) != null);
             break;
         }
 
diff --git a/src/org/joni/ApplyCaseFold.java b/src/org/joni/ApplyCaseFold.java
index 496ff71..af755ec 100644
--- a/src/org/joni/ApplyCaseFold.java
+++ b/src/org/joni/ApplyCaseFold.java
@@ -22,7 +22,7 @@ package org.joni;
 import org.jcodings.ApplyAllCaseFoldFunction;
 import org.jcodings.Encoding;
 import org.joni.ast.CClassNode;
-import org.joni.ast.ConsAltNode;
+import org.joni.ast.ListNode;
 import org.joni.ast.StringNode;
 
 final class ApplyCaseFold implements ApplyAllCaseFoldFunction {
@@ -90,12 +90,12 @@ final class ApplyCaseFold implements ApplyAllCaseFoldFunction {
                     node.catCode(to[i], enc);
                 }
 
-                ConsAltNode alt = ConsAltNode.newAltNode(node, null);
+                ListNode alt = ListNode.newAlt(node, null);
 
                 if (arg.tail == null) {
                     arg.altRoot = alt;
                 } else {
-                    arg.tail.setCdr(alt);
+                    arg.tail.setTail(alt);
                 }
                 arg.tail = alt;
             }
diff --git a/src/org/joni/ApplyCaseFoldArg.java b/src/org/joni/ApplyCaseFoldArg.java
index ec7cbaa..79385d9 100644
--- a/src/org/joni/ApplyCaseFoldArg.java
+++ b/src/org/joni/ApplyCaseFoldArg.java
@@ -20,13 +20,13 @@
 package org.joni;
 
 import org.joni.ast.CClassNode;
-import org.joni.ast.ConsAltNode;
+import org.joni.ast.ListNode;
 
 public final class ApplyCaseFoldArg {
     final ScanEnvironment env;
     final CClassNode cc, ascCc;
-    ConsAltNode altRoot;
-    ConsAltNode tail;
+    ListNode altRoot;
+    ListNode tail;
 
     public ApplyCaseFoldArg(ScanEnvironment env, CClassNode cc, CClassNode ascCc) {
         this.env = env;
diff --git a/src/org/joni/ArrayCompiler.java b/src/org/joni/ArrayCompiler.java
index 69b8909..e10f6d5 100644
--- a/src/org/joni/ArrayCompiler.java
+++ b/src/org/joni/ArrayCompiler.java
@@ -31,7 +31,7 @@ import org.joni.ast.BackRefNode;
 import org.joni.ast.CClassNode;
 import org.joni.ast.CTypeNode;
 import org.joni.ast.CallNode;
-import org.joni.ast.ConsAltNode;
+import org.joni.ast.ListNode;
 import org.joni.ast.EncloseNode;
 import org.joni.ast.Node;
 import org.joni.ast.QuantifierNode;
@@ -79,32 +79,32 @@ final class ArrayCompiler extends Compiler {
     }
 
     @Override
-    protected void compileAltNode(ConsAltNode node) {
-        ConsAltNode aln = node;
+    protected void compileAltNode(ListNode node) {
+        ListNode aln = node;
         int len = 0;
 
         do {
-            len += compileLengthTree(aln.car);
-            if (aln.cdr != null) {
+            len += compileLengthTree(aln.value);
+            if (aln.tail != null) {
                 len += OPSize.PUSH + OPSize.JUMP;
             }
-        } while ((aln = aln.cdr) != null);
+        } while ((aln = aln.tail) != null);
 
         int pos = codeLength + len;  /* goal position */
 
         aln = node;
         do {
-            len = compileLengthTree(aln.car);
-            if (aln.cdr != null) {
+            len = compileLengthTree(aln.value);
+            if (aln.tail != null) {
                 regex.requireStack = true;
                 addOpcodeRelAddr(OPCode.PUSH, len + OPSize.JUMP);
             }
-            compileTree(aln.car);
-            if (aln.cdr != null) {
+            compileTree(aln.value);
+            if (aln.tail != null) {
                 len = pos - (codeLength + OPSize.JUMP);
                 addOpcodeRelAddr(OPCode.JUMP, len);
             }
-        } while ((aln = aln.cdr) != null);
+        } while ((aln = aln.tail) != null);
     }
 
     private boolean isNeedStrLenOpExact(int op) {
@@ -862,14 +862,14 @@ final class ArrayCompiler extends Compiler {
         case EncloseType.CONDITION:
             len = OPSize.CONDITION;
             if (node.target.getType() == NodeType.ALT) {
-                ConsAltNode x = (ConsAltNode)node.target;
-                tlen = compileLengthTree(x.car); /* yes-node */
+                ListNode x = (ListNode)node.target;
+                tlen = compileLengthTree(x.value); /* yes-node */
                 len += tlen + OPSize.JUMP;
-                if (x.cdr == null) newInternalException(ERR_PARSER_BUG);
-                x = x.cdr;
-                tlen = compileLengthTree(x.car); /* no-node */
+                if (x.tail == null) newInternalException(ERR_PARSER_BUG);
+                x = x.tail;
+                tlen = compileLengthTree(x.value); /* no-node */
                 len += tlen;
-                if (x.cdr != null) newSyntaxException(ERR_INVALID_CONDITION_PATTERN);
+                if (x.tail != null) newSyntaxException(ERR_INVALID_CONDITION_PATTERN);
             } else {
                 newInternalException(ERR_PARSER_BUG);
             }
@@ -958,18 +958,18 @@ final class ArrayCompiler extends Compiler {
             addOpcode(OPCode.CONDITION);
             addMemNum(node.regNum);
             if (node.target.getType() == NodeType.ALT) {
-                ConsAltNode x = (ConsAltNode)node.target;
-                len = compileLengthTree(x.car); /* yes-node */
-                if (x.cdr == null) newInternalException(ERR_PARSER_BUG);
-                x = x.cdr;
-                int len2 = compileLengthTree(x.car); /* no-node */
-                if (x.cdr != null) newSyntaxException(ERR_INVALID_CONDITION_PATTERN);
-                x = (ConsAltNode)node.target;
+                ListNode x = (ListNode)node.target;
+                len = compileLengthTree(x.value); /* yes-node */
+                if (x.tail == null) newInternalException(ERR_PARSER_BUG);
+                x = x.tail;
+                int len2 = compileLengthTree(x.value); /* no-node */
+                if (x.tail != null) newSyntaxException(ERR_INVALID_CONDITION_PATTERN);
+                x = (ListNode)node.target;
                 addRelAddr(len + OPSize.JUMP);
-                compileTree(x.car); /* yes-node */
+                compileTree(x.value); /* yes-node */
                 addOpcodeRelAddr(OPCode.JUMP, len2);
-                x = x.cdr;
-                compileTree(x.car); /* no-node */
+                x = x.tail;
+                compileTree(x.value); /* no-node */
             } else {
                 newInternalException(ERR_PARSER_BUG);
             }
@@ -1128,19 +1128,19 @@ final class ArrayCompiler extends Compiler {
 
         switch (node.getType()) {
         case NodeType.LIST:
-            ConsAltNode lin = (ConsAltNode)node;
+            ListNode lin = (ListNode)node;
             do {
-                len += compileLengthTree(lin.car);
-            } while ((lin = lin.cdr) != null);
+                len += compileLengthTree(lin.value);
+            } while ((lin = lin.tail) != null);
             break;
 
         case NodeType.ALT:
-            ConsAltNode aln = (ConsAltNode)node;
+            ListNode aln = (ListNode)node;
             int n = 0;
             do {
-                len += compileLengthTree(aln.car);
+                len += compileLengthTree(aln.value);
                 n++;
-            } while ((aln = aln.cdr) != null);
+            } while ((aln = aln.tail) != null);
             len += (OPSize.PUSH + OPSize.JUMP) * (n - 1);
             break;
 
diff --git a/src/org/joni/AsmCompiler.java b/src/org/joni/AsmCompiler.java
index e39dc05..64fadc4 100644
--- a/src/org/joni/AsmCompiler.java
+++ b/src/org/joni/AsmCompiler.java
@@ -24,7 +24,7 @@ import org.joni.ast.BackRefNode;
 import org.joni.ast.CClassNode;
 import org.joni.ast.CTypeNode;
 import org.joni.ast.CallNode;
-import org.joni.ast.ConsAltNode;
+import org.joni.ast.ListNode;
 import org.joni.ast.EncloseNode;
 import org.joni.ast.QuantifierNode;
 
@@ -56,7 +56,7 @@ final class AsmCompiler extends AsmCompilerSupport {
     }
 
     @Override
-    protected void compileAltNode(ConsAltNode node) {
+    protected void compileAltNode(ListNode node) {
     }
 
     @Override
diff --git a/src/org/joni/Compiler.java b/src/org/joni/Compiler.java
index d226946..bd2d9ad 100644
--- a/src/org/joni/Compiler.java
+++ b/src/org/joni/Compiler.java
@@ -25,7 +25,7 @@ import org.joni.ast.BackRefNode;
 import org.joni.ast.CClassNode;
 import org.joni.ast.CTypeNode;
 import org.joni.ast.CallNode;
-import org.joni.ast.ConsAltNode;
+import org.joni.ast.ListNode;
 import org.joni.ast.EncloseNode;
 import org.joni.ast.Node;
 import org.joni.ast.QuantifierNode;
@@ -55,7 +55,7 @@ abstract class Compiler implements ErrorMessages {
     protected abstract void prepare();
     protected abstract void finish();
 
-    protected abstract void compileAltNode(ConsAltNode node);
+    protected abstract void compileAltNode(ListNode node);
 
     private void compileStringRawNode(StringNode sn) {
         if (sn.length() <= 0) return;
@@ -107,14 +107,14 @@ abstract class Compiler implements ErrorMessages {
     protected final void compileTree(Node node) {
         switch (node.getType()) {
         case NodeType.LIST:
-            ConsAltNode lin = (ConsAltNode)node;
+            ListNode lin = (ListNode)node;
             do {
-                compileTree(lin.car);
-            } while ((lin = lin.cdr) != null);
+                compileTree(lin.value);
+            } while ((lin = lin.tail) != null);
             break;
 
         case NodeType.ALT:
-            compileAltNode((ConsAltNode)node);
+            compileAltNode((ListNode)node);
             break;
 
         case NodeType.STR:
diff --git a/src/org/joni/Parser.java b/src/org/joni/Parser.java
index 1bcf6f8..20b3f1e 100644
--- a/src/org/joni/Parser.java
+++ b/src/org/joni/Parser.java
@@ -40,7 +40,7 @@ import org.joni.ast.CClassNode.CCStateArg;
 import org.joni.ast.CClassNode.CCVALTYPE;
 import org.joni.ast.CTypeNode;
 import org.joni.ast.CallNode;
-import org.joni.ast.ConsAltNode;
+import org.joni.ast.ListNode;
 import org.joni.ast.EncloseNode;
 import org.joni.ast.Node;
 import org.joni.ast.QuantifierNode;
@@ -712,7 +712,7 @@ class Parser extends Lexer {
                 env.setMemNode(en.regNum, en);
             } else if (en.type == EncloseType.CONDITION) {
                 if (target.getType() != NodeType.ALT) { /* convert (?(cond)yes) to (?(cond)yes|empty) */
-                    en.setTarget(ConsAltNode.newAltNode(target, ConsAltNode.newAltNode(StringNode.EMPTY, null)));
+                    en.setTarget(ListNode.newAlt(target, ListNode.newAlt(StringNode.EMPTY, null)));
                 }
             }
         }
@@ -897,7 +897,7 @@ class Parser extends Lexer {
         }
         /* (?>...) */
         EncloseNode en = new EncloseNode(EncloseType.STOP_BACKTRACK);
-        en.setTarget(ConsAltNode.newAltNode(left, ConsAltNode.newAltNode(right, null)));
+        en.setTarget(ListNode.newAlt(left, ListNode.newAlt(right, null)));
         return en;
     }
 
@@ -960,7 +960,7 @@ class Parser extends Lexer {
     }
 
     private Node parseExtendedGraphemeCluster() {
-        ConsAltNode alt;
+        ListNode alt;
         if (Config.USE_UNICODE_PROPERTIES && enc.isUnicode()) {
             int sbOut = enc.minLength() > 1 ? 0x00 : 0x80;
             int extend = GraphemeNames.nameToCtype(enc, GraphemeNames.Grapheme_Cluster_Break_Extend);
@@ -970,7 +970,7 @@ class Parser extends Lexer {
             cc.addCodeRange(env, 0x200D, 0x200D);
             QuantifierNode qn = new QuantifierNode(0, QuantifierNode.REPEAT_INFINITE, false);
             qn.setTarget(cc);
-            ConsAltNode list = ConsAltNode.newListNode(qn, null);
+            ListNode list = ListNode.newList(qn, null);
 
             /* ( RI-sequence | Hangul-Syllable | !Control ) */
 
@@ -987,7 +987,7 @@ class Parser extends Lexer {
                 cc.bs.clear(0x0d);
             }
 
-            alt = ConsAltNode.newAltNode(cc, null);
+            alt = ListNode.newAlt(cc, null);
 
             /* Hangul-Syllable
              *  := L* V+ T*
@@ -1001,14 +1001,14 @@ class Parser extends Lexer {
             cc.addCType(GraphemeNames.nameToCtype(enc, GraphemeNames.Grapheme_Cluster_Break_T), false, false, env, this);
             qn = new QuantifierNode(1, QuantifierNode.REPEAT_INFINITE, false);
             qn.setTarget(cc);
-            alt = ConsAltNode.newAltNode(qn, alt);
+            alt = ListNode.newAlt(qn, alt);
 
             /* L+ */
             cc = new CClassNode();
             cc.addCType(GraphemeNames.nameToCtype(enc, GraphemeNames.Grapheme_Cluster_Break_L), false, false, env, this);
             qn = new QuantifierNode(1, QuantifierNode.REPEAT_INFINITE, false);
             qn.setTarget(cc);
-            alt = ConsAltNode.newAltNode(qn, alt);
+            alt = ListNode.newAlt(qn, alt);
 
             /* L* LVT T* */
             cc = new CClassNode();
@@ -1016,66 +1016,66 @@ class Parser extends Lexer {
             qn = new QuantifierNode(0, QuantifierNode.REPEAT_INFINITE, false);
             qn.setTarget(cc);
 
-            ConsAltNode list2;
-            list2 = ConsAltNode.newListNode(qn, null);
+            ListNode list2;
+            list2 = ListNode.newList(qn, null);
 
             cc = new CClassNode();
             cc.addCType(GraphemeNames.nameToCtype(enc, GraphemeNames.Grapheme_Cluster_Break_LVT), false, false, env, this);
-            list2 = ConsAltNode.newListNode(cc, list2);
+            list2 = ListNode.newList(cc, list2);
 
             cc = new CClassNode();
             cc.addCType(GraphemeNames.nameToCtype(enc, GraphemeNames.Grapheme_Cluster_Break_L), false, false, env, this);
             qn = new QuantifierNode(0, QuantifierNode.REPEAT_INFINITE, false);
             qn.setTarget(cc);
-            list2 = ConsAltNode.newListNode(qn, list2);
+            list2 = ListNode.newList(qn, list2);
 
-            alt = ConsAltNode.newAltNode(list2, alt);
+            alt = ListNode.newAlt(list2, alt);
 
             /* L* LV V* T* */
             cc = new CClassNode();
             cc.addCType(GraphemeNames.nameToCtype(enc, GraphemeNames.Grapheme_Cluster_Break_T), false, false, env, this);
             qn = new QuantifierNode(0, QuantifierNode.REPEAT_INFINITE, false);
             qn.setTarget(cc);
-            list2 = ConsAltNode.newListNode(qn, null);
+            list2 = ListNode.newList(qn, null);
 
             cc = new CClassNode();
             cc.addCType(GraphemeNames.nameToCtype(enc, GraphemeNames.Grapheme_Cluster_Break_V), false, false, env, this);
             qn = new QuantifierNode(0, QuantifierNode.REPEAT_INFINITE, false);
             qn.setTarget(cc);
-            list2 = ConsAltNode.newListNode(qn, list2);
+            list2 = ListNode.newList(qn, list2);
 
             cc = new CClassNode();
             cc.addCType(GraphemeNames.nameToCtype(enc, GraphemeNames.Grapheme_Cluster_Break_LV), false, false, env, this);
-            list2 = ConsAltNode.newListNode(cc, list2);
+            list2 = ListNode.newList(cc, list2);
 
             cc = new CClassNode();
             cc.addCType(GraphemeNames.nameToCtype(enc, GraphemeNames.Grapheme_Cluster_Break_L), false, false, env, this);
             qn = new QuantifierNode(0, QuantifierNode.REPEAT_INFINITE, false);
             qn.setTarget(cc);
-            list2 = ConsAltNode.newListNode(qn, list2);
+            list2 = ListNode.newList(qn, list2);
 
-            alt = ConsAltNode.newAltNode(list2, alt);
+            alt = ListNode.newAlt(list2, alt);
 
             /* L* V+ T* */
             cc = new CClassNode();
             cc.addCType(GraphemeNames.nameToCtype(enc, GraphemeNames.Grapheme_Cluster_Break_T), false, false, env, this);
             qn = new QuantifierNode(0, QuantifierNode.REPEAT_INFINITE, false);
             qn.setTarget(cc);
-            list2 = ConsAltNode.newListNode(qn, null);
+            list2 = ListNode.newList(qn, null);
 
             cc = new CClassNode();
             cc.addCType(GraphemeNames.nameToCtype(enc, GraphemeNames.Grapheme_Cluster_Break_V), false, false, env, this);
             qn = new QuantifierNode(1, QuantifierNode.REPEAT_INFINITE, false);
             qn.setTarget(cc);
-            list2 = ConsAltNode.newListNode(qn, list2);
+            list2 = ListNode.newList(qn, list2);
 
             cc = new CClassNode();
             cc.addCType(GraphemeNames.nameToCtype(enc, GraphemeNames.Grapheme_Cluster_Break_L), false, false, env, this);
             qn = new QuantifierNode(0, QuantifierNode.REPEAT_INFINITE, false);
             qn.setTarget(cc);
-            list2 = ConsAltNode.newListNode(qn, list2);
+            list2 = ListNode.newList(qn, list2);
 
-            alt = ConsAltNode.newAltNode(list2, alt);
+            alt = ListNode.newAlt(list2, alt);
 
             /* Emoji sequence := (E_Base | EBG) Extend* E_Modifier?
              *                   (ZWJ (Glue_After_Zwj | EBG Extend* E_Modifier?) )* */
@@ -1086,33 +1086,33 @@ class Parser extends Lexer {
             cc.addCType(GraphemeNames.nameToCtype(enc, GraphemeNames.Grapheme_Cluster_Break_E_Modifier), false, false, env, this);
             qn = new QuantifierNode(0, 1, false);
             qn.setTarget(cc);
-            list2 = ConsAltNode.newListNode(qn, null);
+            list2 = ListNode.newList(qn, null);
 
             cc = new CClassNode();
             cc.addCType(extend, false, false, env, this);
             qn = new QuantifierNode(0, QuantifierNode.REPEAT_INFINITE, false);
             qn.setTarget(cc);
-            list2 = ConsAltNode.newListNode(qn, list2);
+            list2 = ListNode.newList(qn, list2);
 
             cc = new CClassNode();
             cc.addCType(GraphemeNames.nameToCtype(enc, GraphemeNames.Grapheme_Cluster_Break_E_Base_GAZ), false, false, env, this);
-            list2 = ConsAltNode.newListNode(cc, list2);
+            list2 = ListNode.newList(cc, list2);
 
-            ConsAltNode alt2 = ConsAltNode.newAltNode(list2, null);
+            ListNode alt2 = ListNode.newAlt(list2, null);
 
             /* Glue_After_Zwj */
             cc = new CClassNode();
             cc.addCType(extend, false, false, env, this);
             qn = new QuantifierNode(0, QuantifierNode.REPEAT_INFINITE, false);
             qn.setTarget(cc);
-            list2 = ConsAltNode.newListNode(qn, null);
+            list2 = ListNode.newList(qn, null);
 
             cc = new CClassNode();
             cc.addCTypeByRange(-1, false, enc, sbOut, GraphemeNames.Glue_After_Zwj_Ranges);
             cc.addCType(GraphemeNames.nameToCtype(enc, GraphemeNames.Grapheme_Cluster_Break_Glue_After_Zwj), false, false, env, this);
-            list2 = ConsAltNode.newListNode(cc, list2);
+            list2 = ListNode.newList(cc, list2);
 
-            alt2 = ConsAltNode.newAltNode(list2, alt2);
+            alt2 = ListNode.newAlt(list2, alt2);
 
             /* Emoji variation sequence
              * http://unicode.org/Public/emoji/4.0/emoji-zwj-sequences.txt
@@ -1123,48 +1123,48 @@ class Parser extends Lexer {
             str.setRaw();
             qn = new QuantifierNode(0, 1, false);
             qn.setTarget(str);
-            list2 = ConsAltNode.newListNode(qn, null);
+            list2 = ListNode.newList(qn, null);
 
             cc = new CClassNode();
             cc.addCTypeByRange(-1, false, enc, sbOut, GraphemeNames.Emoji_Ranges);
-            list2 = ConsAltNode.newListNode(cc, list2);
+            list2 = ListNode.newList(cc, list2);
 
-            alt2 = ConsAltNode.newAltNode(list2, alt2);
+            alt2 = ListNode.newAlt(list2, alt2);
 
-            list2 = ConsAltNode.newListNode(alt2, null);
+            list2 = ListNode.newList(alt2, null);
 
             /* ZWJ */
             str = new StringNode();
             str.catCode(0x200D, enc);
             str.setRaw();
-            list2 = ConsAltNode.newListNode(str, list2);
+            list2 = ListNode.newList(str, list2);
 
             qn = new QuantifierNode(0, QuantifierNode.REPEAT_INFINITE, false);
             qn.setTarget(list2);
-            list2 = ConsAltNode.newListNode(qn, null);
+            list2 = ListNode.newList(qn, null);
 
             /* E_Modifier? */
             cc = new CClassNode();
             cc.addCType(GraphemeNames.nameToCtype(enc, GraphemeNames.Grapheme_Cluster_Break_E_Modifier), false, false, env, this);
             qn = new QuantifierNode(0, 1, false);
             qn.setTarget(cc);
-            list2 = ConsAltNode.newListNode(qn, list2);
+            list2 = ListNode.newList(qn, list2);
 
             /* Extend* */
             cc = new CClassNode();
             cc.addCType(extend, false, false, env, this);
             qn = new QuantifierNode(0, QuantifierNode.REPEAT_INFINITE, false);
             qn.setTarget(cc);
-            list2 = ConsAltNode.newListNode(qn, list2);
+            list2 = ListNode.newList(qn, list2);
 
             /* (E_Base | EBG) */
             cc = new CClassNode();
             cc.addCTypeByRange(-1, false, enc, sbOut, GraphemeNames.E_Base_Ranges);
             cc.addCType(GraphemeNames.nameToCtype(enc, GraphemeNames.Grapheme_Cluster_Break_E_Base), false, false, env, this);
             cc.addCType(GraphemeNames.nameToCtype(enc, GraphemeNames.Grapheme_Cluster_Break_E_Base_GAZ), false, false, env, this);
-            list2 = ConsAltNode.newListNode(cc, list2);
+            list2 = ListNode.newList(cc, list2);
 
-            alt = ConsAltNode.newAltNode(list2, alt);
+            alt = ListNode.newAlt(list2, alt);
 
             /* ZWJ (E_Base_GAZ | Glue_After_Zwj) E_Modifier? */
             /* a sequence starting with ZWJ seems artificial, but GraphemeBreakTest
@@ -1175,37 +1175,37 @@ class Parser extends Lexer {
             cc.addCType(GraphemeNames.nameToCtype(enc, GraphemeNames.Grapheme_Cluster_Break_E_Modifier), false, false, env, this);
             qn = new QuantifierNode(0, 1, false);
             qn.setTarget(cc);
-            list2 = ConsAltNode.newListNode(qn, null);
+            list2 = ListNode.newList(qn, null);
 
             cc = new CClassNode();
             cc.addCType(GraphemeNames.nameToCtype(enc, GraphemeNames.Grapheme_Cluster_Break_Glue_After_Zwj), false, false, env, this);
             cc.addCType(GraphemeNames.nameToCtype(enc, GraphemeNames.Grapheme_Cluster_Break_E_Base_GAZ), false, false, env, this);
-            list2 = ConsAltNode.newListNode(cc, list2);
+            list2 = ListNode.newList(cc, list2);
 
             str = new StringNode();
             str.catCode(0x200D, enc);
             str.setRaw();
-            list2 = ConsAltNode.newListNode(str, list2);
+            list2 = ListNode.newList(str, list2);
 
-            alt = ConsAltNode.newAltNode(list2, alt);
+            alt = ListNode.newAlt(list2, alt);
 
             /* RI-Sequence := Regional_Indicator{2} */
             cc = new CClassNode();
             cc.addCodeRange(env, 0x1F1E6, 0x1F1FF);
             qn = new QuantifierNode(2, 2, false);
             qn.setTarget(cc);
-            list2 = ConsAltNode.newListNode(qn, null);
+            list2 = ListNode.newList(qn, null);
 
-            alt = ConsAltNode.newAltNode(list2, alt);
+            alt = ListNode.newAlt(list2, alt);
 
-            list = ConsAltNode.newListNode(alt, list);
+            list = ListNode.newList(alt, list);
 
             /* Prepend* */
             cc = new CClassNode();
             cc.addCType(GraphemeNames.nameToCtype(enc, GraphemeNames.Grapheme_Cluster_Break_Prepend), false, false, env, this);
             qn = new QuantifierNode(0, QuantifierNode.REPEAT_INFINITE, false);
             qn.setTarget(cc);
-            list = ConsAltNode.newListNode(qn, list);
+            list = ListNode.newList(qn, list);
 
             /* PerlSyntax: (?s:.), RubySyntax: (?m:.) */
             AnyCharNode any = new AnyCharNode();
@@ -1213,7 +1213,7 @@ class Parser extends Lexer {
             EncloseNode enclose = EncloseNode.newOption(option);
             enclose.setTarget(any);
 
-            alt = ConsAltNode.newAltNode(enclose, null);
+            alt = ListNode.newAlt(enclose, null);
 
             /* Prepend+ */
             str = new StringNode();
@@ -1221,24 +1221,24 @@ class Parser extends Lexer {
             str.setRaw();
             qn = new QuantifierNode(0, 1, false);
             qn.setTarget(str);
-            list2 = ConsAltNode.newListNode(qn, null);
+            list2 = ListNode.newList(qn, null);
 
             cc = new CClassNode();
             cc.addCType(GraphemeNames.nameToCtype(enc, GraphemeNames.Grapheme_Cluster_Break_Prepend), false, false, env, this);
             qn = new QuantifierNode(1, QuantifierNode.REPEAT_INFINITE, false);
             qn.setTarget(cc);
-            list2 = ConsAltNode.newListNode(qn, list2);
+            list2 = ListNode.newList(qn, list2);
 
-            alt = ConsAltNode.newAltNode(list2, alt);
+            alt = ListNode.newAlt(list2, alt);
 
-            alt = ConsAltNode.newAltNode(list, alt);
+            alt = ListNode.newAlt(list, alt);
         } else {
             /* PerlSyntax: (?s:.), RubySyntax: (?m:.) */
             AnyCharNode any = new AnyCharNode();
             int option = bsOnOff(env.option, Option.MULTILINE, false);
             EncloseNode enclose = EncloseNode.newOption(option);
             enclose.setTarget(any);
-            alt = ConsAltNode.newAltNode(enclose, null);
+            alt = ListNode.newAlt(enclose, null);
         }
 
         /* \x0D\x0A */
@@ -1246,7 +1246,7 @@ class Parser extends Lexer {
         str.catCode(0x0D, enc);
         str.catCode(0x0A, enc);
         str.setRaw();
-        alt = ConsAltNode.newAltNode(str, alt);
+        alt = ListNode.newAlt(str, alt);
 
         /* (?>\x0D\x0A|...) */
         EncloseNode enclose = new EncloseNode(EncloseNode.STOP_BACKTRACK);
@@ -1338,8 +1338,8 @@ class Parser extends Lexer {
             if (ret == 0 || (syntax.op3OptionECMAScript() && ret == 1)) {
                 target = qn;
             } else if (ret == 2) { /* split case: /abc+/ */
-                target = ConsAltNode.newListNode(target, null);
-                ConsAltNode tmp = ((ConsAltNode)target).setCdr(ConsAltNode.newListNode(qn, null));
+                target = ListNode.newList(target, null);
+                ListNode tmp = ((ListNode)target).setTail(ListNode.newList(qn, null));
 
                 fetchToken();
                 return parseExpRepeatForCar(target, tmp, group);
@@ -1349,16 +1349,16 @@ class Parser extends Lexer {
         return target;
     }
 
-    private Node parseExpRepeatForCar(Node top, ConsAltNode target, boolean group) {
+    private Node parseExpRepeatForCar(Node top, ListNode target, boolean group) {
         while (token.type == TokenType.OP_REPEAT || token.type == TokenType.INTERVAL) { // repeat:
-            if (isInvalidQuantifier(target.car)) newSyntaxException(ERR_TARGET_OF_REPEAT_OPERATOR_INVALID);
+            if (isInvalidQuantifier(target.value)) newSyntaxException(ERR_TARGET_OF_REPEAT_OPERATOR_INVALID);
 
             QuantifierNode qtfr = new QuantifierNode(token.getRepeatLower(),
                                                      token.getRepeatUpper(),
                                                      token.type == TokenType.INTERVAL);
 
             qtfr.greedy = token.getRepeatGreedy();
-            int ret = qtfr.setQuantifier(target.car, group, env, bytes, getBegin(), getEnd());
+            int ret = qtfr.setQuantifier(target.value, group, env, bytes, getBegin(), getEnd());
             Node qn = qtfr;
 
             if (token.getRepeatPossessive()) {
@@ -1368,7 +1368,7 @@ class Parser extends Lexer {
             }
 
             if (ret == 0) {
-                target.setCar(qn);
+                target.setValue(qn);
             } else if (ret == 2) { /* split case: /abc+/ */
                 assert false;
             }
@@ -1380,7 +1380,7 @@ class Parser extends Lexer {
     private boolean isInvalidQuantifier(Node node) {
         if (Config.USE_NO_INVALID_QUANTIFIER) return false;
 
-        ConsAltNode consAlt;
+        ListNode consAlt;
         switch(node.getType()) {
         case NodeType.ANCHOR:
             return true;
@@ -1391,17 +1391,17 @@ class Parser extends Lexer {
             break;
 
         case NodeType.LIST:
-            consAlt = (ConsAltNode)node;
+            consAlt = (ListNode)node;
             do {
-                if (!isInvalidQuantifier(consAlt.car)) return false;
-            } while ((consAlt = consAlt.cdr) != null);
+                if (!isInvalidQuantifier(consAlt.value)) return false;
+            } while ((consAlt = consAlt.tail) != null);
             return false;
 
         case NodeType.ALT:
-            consAlt = (ConsAltNode)node;
+            consAlt = (ListNode)node;
             do {
-                if (isInvalidQuantifier(consAlt.car)) return true;
-            } while ((consAlt = consAlt.cdr) != null);
+                if (isInvalidQuantifier(consAlt.value)) return true;
+            } while ((consAlt = consAlt.tail) != null);
             break;
 
         default:
@@ -1452,7 +1452,7 @@ class Parser extends Lexer {
         ApplyCaseFoldArg arg = new ApplyCaseFoldArg(env, cc, ascCc);
         enc.applyAllCaseFold(env.caseFoldFlag, ApplyCaseFold.INSTANCE, arg);
         if (arg.altRoot != null) {
-            node = ConsAltNode.newAltNode(node, arg.altRoot);
+            node = ListNode.newAlt(node, arg.altRoot);
         }
         return node;
     }
@@ -1551,19 +1551,19 @@ class Parser extends Lexer {
         if (token.type == TokenType.EOT || token.type == term || token.type == TokenType.ALT) {
             return node;
         } else {
-            ConsAltNode top = ConsAltNode.newListNode(node, null);
-            ConsAltNode t = top;
+            ListNode top = ListNode.newList(node, null);
+            ListNode t = top;
 
             while (token.type != TokenType.EOT && token.type != term && token.type != TokenType.ALT) {
                 node = parseExp(term);
                 if (node.getType() == NodeType.LIST) {
-                    t.setCdr((ConsAltNode)node);
-                    while (((ConsAltNode)node).cdr != null ) node = ((ConsAltNode)node).cdr;
+                    t.setTail((ListNode)node);
+                    while (((ListNode)node).tail != null ) node = ((ListNode)node).tail;
 
-                    t = ((ConsAltNode)node);
+                    t = ((ListNode)node);
                 } else {
-                    t.setCdr(ConsAltNode.newListNode(node, null));
-                    t = t.cdr;
+                    t.setTail(ListNode.newList(node, null));
+                    t = t.tail;
                 }
             }
             return top;
@@ -1577,14 +1577,14 @@ class Parser extends Lexer {
         if (token.type == term) {
             return node;
         } else if (token.type == TokenType.ALT) {
-            ConsAltNode top = ConsAltNode.newAltNode(node, null);
-            ConsAltNode t = top;
+            ListNode top = ListNode.newAlt(node, null);
+            ListNode t = top;
             while (token.type == TokenType.ALT) {
                 fetchToken();
                 node = parseBranch(term);
 
-                t.setCdr(ConsAltNode.newAltNode(node, null));
-                t = t.cdr;
+                t.setTail(ListNode.newAlt(node, null));
+                t = t.tail;
             }
 
             if (token.type != term) parseSubExpError(term);
diff --git a/src/org/joni/ast/ListNode.java b/src/org/joni/ast/ListNode.java
index cb39146..1423c32 100644
--- a/src/org/joni/ast/ListNode.java
+++ b/src/org/joni/ast/ListNode.java
@@ -25,34 +25,34 @@ import org.joni.WarnCallback;
 import org.joni.exception.ErrorMessages;
 import org.joni.exception.InternalException;
 
-public final class ConsAltNode extends Node {
-    public Node car;
-    public ConsAltNode cdr;
+public final class ListNode extends Node {
+    public Node value;
+    public ListNode tail;
 
-    private ConsAltNode(Node car, ConsAltNode cdr, int type) {
+    private ListNode(Node value, ListNode tail, int type) {
         super(type);
-        this.car = car;
-        if (car != null) car.parent = this;
-        this.cdr = cdr;
-        if (cdr != null) cdr.parent = this;
+        this.value = value;
+        if (value != null) value.parent = this;
+        this.tail = tail;
+        if (tail != null) tail.parent = this;
     }
 
-    public static ConsAltNode newAltNode(Node left, ConsAltNode right) {
-        return new ConsAltNode(left, right, ALT);
+    public static ListNode newAlt(Node value, ListNode tail) {
+        return new ListNode(value, tail, ALT);
     }
 
-    public static ConsAltNode newListNode(Node left, ConsAltNode right) {
-        return new ConsAltNode(left, right, LIST);
+    public static ListNode newList(Node value, ListNode tail) {
+        return new ListNode(value, tail, LIST);
     }
 
-    public static ConsAltNode listAdd(ConsAltNode list, Node x) {
-        ConsAltNode n = newListNode(x, null);
+    public static ListNode listAdd(ListNode list, Node value) {
+        ListNode n = newList(value, null);
 
         if (list != null) {
-            while (list.cdr != null) {
-                list = list.cdr;
+            while (list.tail != null) {
+                list = list.tail;
             }
-            list.setCdr(n);
+            list.setTail(n);
         }
         return n;
     }
@@ -67,24 +67,24 @@ public final class ConsAltNode extends Node {
 
     @Override
     protected void setChild(Node newChild) {
-        car = newChild;
+        value = newChild;
     }
 
     @Override
     protected Node getChild() {
-        return car;
+        return value;
     }
 
     @Override
     public void swap(Node with) {
-        if (cdr != null) {
-            cdr.parent = with;
-            if (with instanceof ConsAltNode) {
-                ConsAltNode withCan = (ConsAltNode)with;
-                withCan.cdr.parent = this;
-                ConsAltNode tmp = cdr;
-                cdr = withCan.cdr;
-                withCan.cdr = tmp;
+        if (tail != null) {
+            tail.parent = with;
+            if (with instanceof ListNode) {
+                ListNode withCan = (ListNode)with;
+                withCan.tail.parent = this;
+                ListNode tmp = tail;
+                tail = withCan.tail;
+                withCan.tail = tmp;
             }
         }
         super.swap(with);
@@ -94,31 +94,31 @@ public final class ConsAltNode extends Node {
     public void verifyTree(Set<Node> set, WarnCallback warnings) {
         if (!set.contains(this)) {
             set.add(this);
-            if (car != null) {
-                if (car.parent != this) {
-                    warnings.warn("broken list car: " + this.getAddressName() + " -> " +  car.getAddressName());
+            if (value != null) {
+                if (value.parent != this) {
+                    warnings.warn("broken list value: " + this.getAddressName() + " -> " +  value.getAddressName());
                 }
-                car.verifyTree(set,warnings);
+                value.verifyTree(set,warnings);
             }
-            if (cdr != null) {
-                if (cdr.parent != this) {
-                    warnings.warn("broken list cdr: " + this.getAddressName() + " -> " +  cdr.getAddressName());
+            if (tail != null) {
+                if (tail.parent != this) {
+                    warnings.warn("broken list tail: " + this.getAddressName() + " -> " +  tail.getAddressName());
                 }
-                cdr.verifyTree(set,warnings);
+                tail.verifyTree(set,warnings);
             }
         }
     }
 
-    public Node setCar(Node ca) {
-        car = ca;
+    public Node setValue(Node ca) {
+        value = ca;
         ca.parent = this;
-        return car;
+        return value;
     }
 
-    public ConsAltNode setCdr(ConsAltNode cd) {
-        cdr = cd;
+    public ListNode setTail(ListNode cd) {
+        tail = cd;
         cd.parent = this;
-        return cdr;
+        return tail;
     }
 
     @Override
@@ -135,11 +135,9 @@ public final class ConsAltNode extends Node {
 
     @Override
     public String toString(int level) {
-        StringBuilder value = new StringBuilder();
-        value.append("\n  car: " + pad(car, level + 1));
-        value.append("\n  cdr: " + (cdr == null ? "NULL" : cdr.toString()));
-
-        return value.toString();
+        StringBuilder sb = new StringBuilder();
+        sb.append("\n  value: " + pad(value, level + 1));
+        sb.append("\n  tail: " + (tail == null ? "NULL" : tail.toString()));
+        return sb.toString();
     }
-
 }

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-java/jruby-joni.git



More information about the pkg-java-commits mailing list