private CommonToken getParamListSubToken(CommonToken baseToken, String str, int typeStartIndex) { CommonToken token = new CommonToken(baseToken); token.setStartIndex(baseToken.getStartIndex() + typeStartIndex); token.setStopIndex(baseToken.getStartIndex() + typeStartIndex); break; token.setStopIndex(baseToken.getStartIndex() + i); break; token.setStopIndex(baseToken.getStartIndex() + i - 1); break;
private CommonTree parseParamList(CommonToken paramListToken) { String paramList = paramListToken.getText(); CommonTree root = new CommonTree(); int startIndex = paramListToken.getStartIndex(); int i=0; while (i<paramList.length()) { CommonToken token = getParamListSubToken(paramListToken, paramList, i); root.addChild(new CommonTree(token)); i += token.getText().length(); } if (root.getChildCount() == 0) { return null; } return root; }
txt = "<no text>"; return "[@"+t.getTokenIndex()+","+ct.getStartIndex()+":"+ct.getStopIndex()+"='"+txt+"',<"+tokenNames[t.getType()]+">"+channelStr+","+t.getLine()+":"+t.getCharPositionInLine()+"]";
/** * @param t the token * @return the offset of the token or <code>-1</code> if the {@link Token} t was <code>null</code> or the token did not provide offset information. */ public static int getOffset(Token t) { if (t instanceof CommonToken) { return ((CommonToken)t).getStartIndex(); } return -1; }
@Override public int getStartIndex() { if ( originalTokenIndex>=0 ) { return ((CommonToken)g.originalTokenStream.get(originalTokenIndex)).getStartIndex(); } return super.getStartIndex(); }
@Override public int getStartIndex() { if ( originalTokenIndex>=0 ) { return ((CommonToken)g.originalTokenStream.get(originalTokenIndex)).getStartIndex(); } return super.getStartIndex(); }
@Override public int getStartIndex() { if ( originalTokenIndex>=0 ) { return ((CommonToken)g.originalTokenStream.get(originalTokenIndex)).getStartIndex(); } return super.getStartIndex(); }
private int startPos(int tkPosition) { if (tkPosition == -1) return 0; Token tk = tokens.get(tkPosition); if (tk instanceof CommonToken) return ((CommonToken)tk).getStartIndex(); return 0; }
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; }
SemanticException(IntStream input, Token token, String errorMessage, Object... messageArguments) { super(); this.input = input; this.token = token; this.index = ((CommonToken)token).getStartIndex(); this.line = token.getLine(); this.charPositionInLine = token.getCharPositionInLine(); this.errorMessage = String.format(errorMessage, messageArguments); }
@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() ); } }
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 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 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); }