public Object LT(int k) { if ( p==-1 ) { fillBuffer(); } if ( k==0 ) { return null; } if ( k<0 ) { return LB(-k); } //System.out.print("LT(p="+p+","+k+")="); if ( (p+k-1) >= nodes.size() ) { return eof; } return nodes.get(p+k-1); }
public Object getCurrentSymbol() { return LT(1); }
@Override public int mark() { if ( p==-1 ) { fillBuffer(); } lastMarker = index(); return lastMarker; }
@Override public void consume() { if ( p==-1 ) { fillBuffer(); } p++; }
@Override public void rewind(int marker) { seek(marker); }
public void fillBuffer(Object t) { boolean nil = adaptor.isNil(t); if ( !nil ) { nodes.add(t); // add this node } // add DOWN node if t has children int n = adaptor.getChildCount(t); if ( !nil && n>0 ) { addNavigationNode(Token.DOWN); } // and now add all its children for (int c=0; c<n; c++) { Object child = adaptor.getChild(t,c); fillBuffer(child); } // add UP node if t has children if ( !nil && n>0 ) { addNavigationNode(Token.UP); } }
fillBuffer(); endTokenIndex = size()-2; // don't use EOF
@Override public String getSourceName() { return getTokenStream().getSourceName(); }
/** As we flatten the tree, we use UP, DOWN nodes to represent * the tree structure. When debugging we need unique nodes * so instantiate new ones when uniqueNavigationNodes is true. */ protected void addNavigationNode(final int ttype) { Object navNode; if ( ttype==Token.DOWN ) { if ( hasUniqueNavigationNodes() ) { navNode = adaptor.create(Token.DOWN, "DOWN"); } else { navNode = down; } } else { if ( hasUniqueNavigationNodes() ) { navNode = adaptor.create(Token.UP, "UP"); } else { navNode = up; } } nodes.add(navNode); }
/** Walk tree with depth-first-search and fill nodes buffer. * Don't do DOWN, UP nodes if its a list (t is isNil). */ protected void fillBuffer() { fillBuffer(root); //System.out.println("revIndex="+tokenTypeToStreamIndexesMap); p = 0; // buffer of nodes intialized now }
@Override public void rewind(int marker) { seek(marker); }
public void fillBuffer(Object t) { boolean nil = adaptor.isNil(t); if ( !nil ) { nodes.add(t); // add this node } // add DOWN node if t has children int n = adaptor.getChildCount(t); if ( !nil && n>0 ) { addNavigationNode(Token.DOWN); } // and now add all its children for (int c=0; c<n; c++) { Object child = adaptor.getChild(t,c); fillBuffer(child); } // add UP node if t has children if ( !nil && n>0 ) { addNavigationNode(Token.UP); } }
fillBuffer(); endTokenIndex = size()-2; // don't use EOF
@Override public String getSourceName() { return getTokenStream().getSourceName(); }
/** As we flatten the tree, we use UP, DOWN nodes to represent * the tree structure. When debugging we need unique nodes * so instantiate new ones when uniqueNavigationNodes is true. */ protected void addNavigationNode(final int ttype) { Object navNode; if ( ttype==Token.DOWN ) { if ( hasUniqueNavigationNodes() ) { navNode = adaptor.create(Token.DOWN, "DOWN"); } else { navNode = down; } } else { if ( hasUniqueNavigationNodes() ) { navNode = adaptor.create(Token.UP, "UP"); } else { navNode = up; } } nodes.add(navNode); }
@Override public void consume() { if ( p==-1 ) { fillBuffer(); } p++; }
public int mark() { if ( p==-1 ) { fillBuffer(); } lastMarker = index(); return lastMarker; }
@Override public void rewind() { seek(lastMarker); }
@Override public Object LT(int k) { if ( p==-1 ) { fillBuffer(); } if ( k==0 ) { return null; } if ( k<0 ) { return LB(-k); } //System.out.print("LT(p="+p+","+k+")="); if ( (p+k-1) >= nodes.size() ) { return eof; } return nodes.get(p+k-1); }
public void fillBuffer(Object t) { boolean nil = adaptor.isNil(t); if ( !nil ) { nodes.add(t); // add this node } // add DOWN node if t has children int n = adaptor.getChildCount(t); if ( !nil && n>0 ) { addNavigationNode(Token.DOWN); } // and now add all its children for (int c=0; c<n; c++) { Object child = adaptor.getChild(t,c); fillBuffer(child); } // add UP node if t has children if ( !nil && n>0 ) { addNavigationNode(Token.UP); } }