public String toString() { String channelStr = ""; if ( channel>0 ) { channelStr=",channel="+channel; } String txt = getText(); if ( txt!=null ) { txt = txt.replaceAll("\n","\\\\n"); txt = txt.replaceAll("\r","\\\\r"); txt = txt.replaceAll("\t","\\\\t"); } else { txt = "<no text>"; } return "[@"+getTokenIndex()+","+start+":"+stop+"='"+txt+"',<"+type+">"+channelStr+","+line+":"+getCharPositionInLine()+"]"; } }
@Override public String toString() { String channelStr = ""; if ( channel>0 ) { channelStr=",channel="+channel; } String txt = getText(); if ( txt!=null ) { txt = txt.replaceAll("\n","\\\\n"); txt = txt.replaceAll("\r","\\\\r"); txt = txt.replaceAll("\t","\\\\t"); } else { txt = "<no text>"; } return "[@"+getTokenIndex()+","+start+":"+stop+"='"+txt+"',<"+type+">"+channelStr+","+line+":"+getCharPositionInLine()+"]"; } }
@Override public int getCharPositionInLine() { if ( originalTokenIndex>=0 ) return g.originalTokenStream.get(originalTokenIndex).getCharPositionInLine(); return super.getCharPositionInLine(); }
@Override public String toString() { String channelStr = ""; if ( channel>0 ) { channelStr=",channel="+channel; } String txt = getText(); if ( txt!=null ) { txt = txt.replaceAll("\n","\\\\n"); txt = txt.replaceAll("\r","\\\\r"); txt = txt.replaceAll("\t","\\\\t"); } else { txt = "<no text>"; } return "[@"+getTokenIndex()+","+start+":"+stop+"='"+txt+"',<"+type+">"+channelStr+","+line+":"+getCharPositionInLine()+"]"; } }
@Override public String toString() { String channelStr = ""; if ( channel>0 ) { channelStr=",channel="+channel; } String txt = getText(); if ( txt!=null ) { txt = txt.replaceAll("\n","\\\\n"); txt = txt.replaceAll("\r","\\\\r"); txt = txt.replaceAll("\t","\\\\t"); } else { txt = "<no text>"; } return "[@"+getTokenIndex()+","+start+":"+stop+"='"+txt+"',<"+type+">"+channelStr+","+line+":"+getCharPositionInLine()+"]"; } }
@Override public String toString() { String channelStr = ""; if ( channel>0 ) { channelStr=",channel="+channel; } String txt = getText(); if ( txt!=null ) { txt = txt.replaceAll("\n","\\\\n"); txt = txt.replaceAll("\r","\\\\r"); txt = txt.replaceAll("\t","\\\\t"); } else { txt = "<no text>"; } return "[@"+getTokenIndex()+","+start+":"+stop+"='"+txt+"',<"+type+">"+channelStr+","+line+":"+getCharPositionInLine()+"]"; } }
@Override public int getCharPositionInLine() { if ( originalTokenIndex>=0 ) return g.originalTokenStream.get(originalTokenIndex).getCharPositionInLine(); return super.getCharPositionInLine(); }
@Override public String toString() { String channelStr = ""; if ( channel>0 ) { channelStr=",channel="+channel; } String txt = getText(); if ( txt!=null ) { txt = txt.replaceAll("\n","\\\\n"); txt = txt.replaceAll("\r","\\\\r"); txt = txt.replaceAll("\t","\\\\t"); } else { txt = "<no text>"; } return "[@"+getTokenIndex()+","+start+":"+stop+"='"+txt+"',<"+type+">"+channelStr+","+line+":"+getCharPositionInLine()+"]"; } }
@Override public int getCharPositionInLine() { if ( originalTokenIndex>=0 ) return g.originalTokenStream.get(originalTokenIndex).getCharPositionInLine(); return super.getCharPositionInLine(); }
@Override public int getCharPositionInLine() { if ( originalTokenIndex>=0 ) return g.originalTokenStream.get(originalTokenIndex).getCharPositionInLine(); return super.getCharPositionInLine(); }
@Override public int getCharPositionInLine() { if ( originalTokenIndex>=0 ) return g.originalTokenStream.get(originalTokenIndex).getCharPositionInLine(); return super.getCharPositionInLine(); }
public String getInfoString() { StringBuilder info = new StringBuilder(); Object payload = getPayload(); if(payload instanceof CommonToken) { CommonToken t = (CommonToken)payload; info.append("Type: ").append(grammar.getTokenDisplayName(t.getType())).append("\n"); info.append("Text: ").append(t.getText()).append("\n"); info.append("Line: ").append(t.getLine()).append("\n"); info.append("Char: ").append(t.getCharPositionInLine()).append("\n"); info.append("Channel: ").append(t.getChannel()).append("\n"); } else if(payload instanceof NoViableAltException) { NoViableAltException e = (NoViableAltException)payload; info.append("Description: ").append(e.grammarDecisionDescription).append("\n"); info.append("Descision: ").append(e.decisionNumber).append("\n"); info.append("State: ").append(e.stateNumber).append("\n"); } else { if(isLeaf()) info.append(payload.toString()); else info.append("Rule: ").append(payload.toString()); } return info.toString(); }
private static ParsePosition get_token_start_position( TokenStream tokenStream, int tokenIndex) { CommonToken token = (CommonToken) tokenStream.get(tokenIndex); int line = token.getLine(); int column = token.getCharPositionInLine(); return new ParsePosition(line, column); }
stream = token.getInputStream(); line = token.getLine(); position = token.getCharPositionInLine(); length = token.getStopIndex() - token.getStartIndex();
protected void assignComment(AST root, CommonToken comment) { for (AST ast : root.getDescendants()) { Position start = ast.getRegion().getStart(); if (!ast.isImaginary() && comment.getLine() <= start.getLine() && comment.getCharPositionInLine() <= start.getColumn()) { ast.getCommentTokens().add(comment); return; } } }
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); }
private static Location get_tree_position(TokenStream tokenStream, BaseTree tree) { int startIndex; int stopIndex; CommonToken stopToken; int stopColumn; ParsePosition end_position = null; startIndex = tree.getTokenStartIndex(); ParsePosition start_position = null; try { start_position = get_token_start_position(tokenStream, startIndex); } catch (RuntimeException e) { return null; } stopIndex = tree.getTokenStopIndex(); stopToken = (CommonToken) tokenStream.get(stopIndex); stopColumn = stopToken.getCharPositionInLine(); if (stopColumn == -1) { int end_line = tree.getLine(); int end_column = tree.getCharPositionInLine(); end_position = adjust_position(new ParsePosition(end_line, end_column), tree.getText().toCharArray()); } else { end_position = get_token_end_position(tokenStream, stopIndex); } return new Location(start_position, end_position); }
start = startToken.getStartIndex(); line = startToken.getLine(); column = startToken.getCharPositionInLine() + 1;
start = startToken.getStartIndex(); line = startToken.getLine(); column = startToken.getCharPositionInLine() + 1;
start = startToken.getStartIndex(); line = startToken.getLine(); column = startToken.getCharPositionInLine() + 1;