txt = "<no text>"; return "[@"+t.getTokenIndex()+","+ct.getStartIndex()+":"+ct.getStopIndex()+"='"+txt+"',<"+tokenNames[t.getType()]+">"+channelStr+","+t.getLine()+":"+t.getCharPositionInLine()+"]";
protected static final int[] getBounds(Token t) { if (t instanceof CommonToken) { CommonToken ct = (CommonToken) t; int[] bounds = {ct.getStartIndex(), ct.getStopIndex()}; return bounds; } return null; }
protected static final int[] getBounds(Token t) { if (t instanceof CommonToken) { CommonToken ct = (CommonToken) t; int[] bounds = {ct.getStartIndex(), ct.getStopIndex()}; return bounds; } return null; }
private int stopPos(int tkPosition) { if (tkPosition == -1) return 0; Token tk = tokens.get(tkPosition); if (tk instanceof CommonToken) return ((CommonToken)tk).getStopIndex(); return 0; } }
@Override public int getStopIndex() { int n = super.getStopIndex() - super.getStartIndex() + 1; return getStartIndex() + n - 1; }
@Override public int getStopIndex() { int n = super.getStopIndex() - super.getStartIndex() + 1; return getStartIndex() + n - 1; }
@Override public int getStopIndex() { int n = super.getStopIndex() - super.getStartIndex() + 1; return getStartIndex() + n - 1; }
@Override public int getStopIndex() { int n = super.getStopIndex() - super.getStartIndex() + 1; return getStartIndex() + n - 1; }
/** * Constructor that preserves the char offset * * @param oldToken A token to use to template the creation of this new one. */ public HibernateToken(Token oldToken) { super( oldToken ); if ( null != oldToken && CommonToken.class.isInstance( oldToken ) ) { setStartIndex( ( ( CommonToken ) oldToken ).getStartIndex() ); setStopIndex( ( ( CommonToken ) oldToken ).getStopIndex() ); } }
private static void checkForSyntaxErrors(String text, String type, org.databene.regex.antlr.RegexParser parser, ParserRuleReturnScope r) { if (parser.getNumberOfSyntaxErrors() > 0) throw new SyntaxError("Illegal " + type, text, -1, -1); CommonToken stop = (CommonToken) r.stop; if (stop.getStopIndex() < StringUtil.trimRight(text).length() - 1) { if (stop.getStopIndex() == 0) throw new SyntaxError("Syntax error after " + stop.getText(), text); else throw new SyntaxError("Syntax error", text); } }
void setEnd( BaseDescr descr ) { Token last = input.LT( -1 ); if ( descr != null && last != null ) { int endLocation = last.getText() != null ? last.getCharPositionInLine() + last.getText().length() - 1 : last.getCharPositionInLine(); descr.setEndCharacter( ((CommonToken) last).getStopIndex() + 1 ); descr.setEndLocation( last.getLine(), endLocation ); } }
public void valueChanged(TreeSelectionEvent treeSelectionEvent) { TreePath path = treeSelectionEvent.getNewLeadSelectionPath(); if ( path==null ) return; CommonTree node = (CommonTree)treeSelectionEvent.getNewLeadSelectionPath().getLastPathComponent(); //System.out.println("select AST: "+node); CommonToken a = (CommonToken)currentScope.st.impl.tokens.get(node.getTokenStartIndex()); CommonToken b = (CommonToken)currentScope.st.impl.tokens.get(node.getTokenStopIndex()); highlight(viewFrame.template, a.getStartIndex(), b.getStopIndex()); } }
public Token nextToken() { CommonToken commonToken = (CommonToken) delegate.nextToken(); commonToken.setText(commonToken.getText()); commonToken.setStartIndex(commonToken.getStartIndex()+offset); commonToken.setStopIndex(commonToken.getStopIndex()+offset); return commonToken; }
public void emit(CommonTree opAST, short opcode) { ensureCapacity(1); if ( opAST!=null ) { int i = opAST.getTokenStartIndex(); int j = opAST.getTokenStopIndex(); int p = ((CommonToken)tokens.get(i)).getStartIndex(); int q = ((CommonToken)tokens.get(j)).getStopIndex(); if ( !(p<0 || q<0) ) impl.sourceMap[ip] = new Interval(p, q); } impl.instrs[ip++] = (byte)opcode; }
public void emit(CommonTree opAST, short opcode) { ensureCapacity(1); if ( opAST!=null ) { int i = opAST.getTokenStartIndex(); int j = opAST.getTokenStopIndex(); int p = ((CommonToken)tokens.get(i)).getStartIndex(); int q = ((CommonToken)tokens.get(j)).getStopIndex(); if ( !(p<0 || q<0) ) impl.sourceMap[ip] = new Interval(p, q); } impl.instrs[ip++] = (byte)opcode; }
public void emit(CommonTree opAST, short opcode) { ensureCapacity(1); if ( opAST!=null ) { int i = opAST.getTokenStartIndex(); int j = opAST.getTokenStopIndex(); int p = ((CommonToken)tokens.get(i)).getStartIndex(); int q = ((CommonToken)tokens.get(j)).getStopIndex(); if ( !(p<0 || q<0) ) impl.sourceMap[ip] = new Interval(p, q); } impl.instrs[ip++] = (byte)opcode; }
public void error(String error, IntStream input, Token t) throws ReflexRecognitionException { CommonToken ct = (CommonToken) t; int length = ct.getStopIndex() - ct.getStartIndex() +1; int start = ct.getCharPositionInLine(); throw new ReflexRecognitionException(error+" at token "+t.getText()+" "+ErrorHandler.displayError(ct.getInputStream(), ct.getLine(), start, length), input, t); }
public void emit(CommonTree opAST, short opcode) { ensureCapacity(1); if ( opAST!=null ) { int i = opAST.getTokenStartIndex(); int j = opAST.getTokenStopIndex(); int p = ((CommonToken)tokens.get(i)).getStartIndex(); int q = ((CommonToken)tokens.get(j)).getStopIndex(); if ( !(p<0 || q<0) ) impl.sourceMap[ip] = new Interval(p, q); } impl.instrs[ip++] = (byte)opcode; }
public void emit(CommonTree opAST, short opcode) { ensureCapacity(1); if ( opAST!=null ) { int i = opAST.getTokenStartIndex(); int j = opAST.getTokenStopIndex(); int p = ((CommonToken)tokens.get(i)).getStartIndex(); int q = ((CommonToken)tokens.get(j)).getStopIndex(); if ( !(p<0 || q<0) ) impl.sourceMap[ip] = new Interval(p, q); } impl.instrs[ip++] = (byte)opcode; }
private String getCoreSQL(RuleReturnScope parsedSQL) { final CommonTree ast = (CommonTree) parsedSQL.getTree(); final CommonToken nameToken = (CommonToken) ((CommonTree) ast.getChild(1)).getToken(); final CharStream inputStream = nameToken.getInputStream(); final CommonToken stopToken = (CommonToken) parsedSQL.getStop(); return inputStream.substring(nameToken.getStartIndex(), stopToken.getStopIndex()); }