Refine search
switch ( input.LA(1) ) { case 'b': int HEX_DIGITS1StartCharPos156 = getCharPositionInLine(); mHEX_DIGITS(); HEX_DIGITS1 = new CommonToken(input, Token.INVALID_TOKEN_TYPE, Token.DEFAULT_CHANNEL, HEX_DIGITS1Start156, getCharIndex()-1); HEX_DIGITS1.setLine(HEX_DIGITS1StartLine156); HEX_DIGITS1.setCharPositionInLine(HEX_DIGITS1StartCharPos156); sb.append((char)Integer.parseInt((HEX_DIGITS1!=null?HEX_DIGITS1.getText():null), 16));
public String getTokenErrorDisplay(Token t) { if (!verboseErrors) { String s = t.getText(); if ( s==null ) { if ( t.getType()==Token.EOF ) { s = "<EOF>"; s = "<"+tokenNames[t.getType()]+">"; txt = "<no text>"; return "[@"+t.getTokenIndex()+","+ct.getStartIndex()+":"+ct.getStopIndex()+"='"+txt+"',<"+tokenNames[t.getType()]+">"+channelStr+","+t.getLine()+":"+t.getCharPositionInLine()+"]";
private CommonToken getParamListSubToken(CommonToken baseToken, String str, int typeStartIndex) { CommonToken token = new CommonToken(baseToken); token.setStartIndex(baseToken.getStartIndex() + typeStartIndex); case 'D': token.setType(PRIMITIVE_TYPE); token.setText(str.substring(typeStartIndex, typeStartIndex+1)); token.setStopIndex(baseToken.getStartIndex() + typeStartIndex); break; while (str.charAt(++i) != ';'); token.setType(CLASS_DESCRIPTOR); token.setText(str.substring(typeStartIndex, i + 1)); token.setStopIndex(baseToken.getStartIndex() + i); break; while (str.charAt(++i) == '['); token.setType(ARRAY_TYPE_PREFIX); token.setText(str.substring(typeStartIndex, i)); 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; }
protected Object getMissingSymbol(IntStream input, RecognitionException e, int expectedTokenType, BitSet follow) { String tokenText = null; if ( expectedTokenType==Token.EOF ) tokenText = "<missing EOF>"; else tokenText = "<missing "+getTokenNames()[expectedTokenType]+">"; CommonToken t = new CommonToken(expectedTokenType, tokenText); Token current = ((TokenStream)input).LT(1); if ( current.getType() == Token.EOF ) { current = ((TokenStream)input).LT(-1); } t.line = current.getLine(); t.charPositionInLine = current.getCharPositionInLine(); t.channel = DEFAULT_TOKEN_CHANNEL; return t; }
int LA14_0 = input.LA(1); if ( (LA14_0=='\"') ) { alt14=1; while (true) { int alt12=3; int LA12_0 = input.LA(1); if ( (LA12_0=='\\') ) { alt12=1; int escapedStartCharPos447 = getCharPositionInLine(); mESC(); escaped = new CommonToken(input, Token.INVALID_TOKEN_TYPE, Token.DEFAULT_CHANNEL, escapedStart447, getCharIndex()-1); escaped.setLine(escapedStartLine447); escaped.setCharPositionInLine(escapedStartCharPos447); normal= input.LA(1); if ( (input.LA(1) >= '\u0000' && input.LA(1) <= '\b')||(input.LA(1) >= '\u000B' && input.LA(1) <= '\f')||(input.LA(1) >= '\u000E' && input.LA(1) <= '!')||(input.LA(1) >= '#' && input.LA(1) <= '[')||(input.LA(1) >= ']' && input.LA(1) <= '\uFFFF') ) { input.consume(); int escapedStartCharPos536 = getCharPositionInLine(); mESC(); escaped = new CommonToken(input, Token.INVALID_TOKEN_TYPE, Token.DEFAULT_CHANNEL, escapedStart536, getCharIndex()-1); escaped.setLine(escapedStartLine536); escaped.setCharPositionInLine(escapedStartCharPos536);
public Token nextToken() { while (true) { if ( input.LA(1)==CharStream.EOF ) { Token eof = new CommonToken((CharStream)input,Token.EOF, Token.DEFAULT_CHANNEL, input.index(),input.index()); eof.setLine(getLine()); eof.setCharPositionInLine(getCharPositionInLine()); return eof;
void setEnd( DescrBuilder< ? , ? > db ) { Token last = input.LT( -1 ); if ( db != null && last != null ) { int endLocation = last.getText() != null ? last.getCharPositionInLine() + last.getText().length() - 1 : last.getCharPositionInLine(); db.endCharacter( ((CommonToken) last).getStopIndex() + 1 ).endLocation( last.getLine(), endLocation ); } }
int LA17_0 = input.LA(1); throw new FailedPredicateException(input, "JSON", " isValue() "); emit(new CommonToken(JSON, getText())); throw new FailedPredicateException(input, "JSON", " isValue() "); emit(new CommonToken(JSON, getText()));
GrammarAST actionTree) String actionText = actionTree.token.getText(); List<String> args = getListOfArgumentsFromAction(actionText,','); List<ST> translatedArgs = new ArrayList<ST>(); if ( arg!=null ) { Token actionToken = new CommonToken(ANTLRParser.ACTION,arg); ActionTranslator translator = new ActionTranslator(this,ruleName, List<Object> chunks = translator.translateToChunks(); chunks = target.postProcessAction(chunks, actionToken); ST catST = new ST(templates, "<chunks>"); catST.add("chunks", chunks); translatedArgs.add(catST);
int xStart128 = getCharIndex(); mID(); if (state.failed) return ; x = new CommonToken(input, Token.INVALID_TOKEN_TYPE, Token.DEFAULT_CHANNEL, xStart128, getCharIndex()-1); match('.'); if (state.failed) return ; int yStart134 = getCharIndex(); mID(); if (state.failed) return ; y = new CommonToken(input, Token.INVALID_TOKEN_TYPE, Token.DEFAULT_CHANNEL, yStart134, getCharIndex()-1); switch ( input.LA(1) ) { case '\t': case '\n': if ( !((enclosingRule!=null && input.LA(1)!='=' && (enclosingRule.getTokenLabel((x!=null?x.getText():null))!=null|| isTokenRefInAlt((x!=null?x.getText():null))) && AttributeScope.tokenScope.getAttribute((y!=null?y.getText():null))!=null)) ) { if (state.backtracking>0) {state.failed=true; return ;} throw new FailedPredicateException(input, "SET_TOKEN_SCOPE_ATTR", "enclosingRule!=null && input.LA(1)!='=' &&\n\t (enclosingRule.getTokenLabel($x.text)!=null||\n\t isTokenRefInAlt($x.text)) &&\n\t AttributeScope.tokenScope.getAttribute($y.text)!=null"); grammar, actionToken, (x!=null?x.getText():null), (y!=null?y.getText():null));
public final void mX() throws RecognitionException { try { int _type = X; int _channel = DEFAULT_TOKEN_CHANNEL; CommonToken x=null; // org/antlr/grammar/v3/ActionAnalysis.g:111:3: ( '$' x= ID {...}?) // org/antlr/grammar/v3/ActionAnalysis.g:111:5: '$' x= ID {...}? { match('$'); if (state.failed) return ; int xStart76 = getCharIndex(); mID(); if (state.failed) return ; x = new CommonToken(input, Token.INVALID_TOKEN_TYPE, Token.DEFAULT_CHANNEL, xStart76, getCharIndex()-1); if ( !((enclosingRule!=null && enclosingRule.getRuleLabel((x!=null?x.getText():null))!=null)) ) { if (state.backtracking>0) {state.failed=true; return ;} throw new FailedPredicateException(input, "X", "enclosingRule!=null && enclosingRule.getRuleLabel($x.text)!=null"); } if ( state.backtracking==1 ) { Grammar.LabelElementPair pair = enclosingRule.getRuleLabel((x!=null?x.getText():null)); pair.actionReferencesLabel = true; } } state.type = _type; state.channel = _channel; } finally { } } // $ANTLR end "X"
private Token newToken(int type, String text, boolean hidden) { CommonToken token = new CommonToken(type, text); if (hidden) { token.setChannel(Token.HIDDEN_CHANNEL); } token.setStartIndex(yychar); token.setStopIndex(yychar + yylength() - 1); token.setLine(getLine()); token.setCharPositionInLine(getColumn()); return token; }
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); }
/** Returns the EOF token (default), if you need * to return a custom token instead override this method. */ public Token getEOFToken() { Token eof = new CommonToken(input,Token.EOF, Token.DEFAULT_CHANNEL, input.index(),input.index()); eof.setLine(getLine()); eof.setCharPositionInLine(getCharPositionInLine()); return eof; }
/** * @param property * @param literal */ public GreaterThanEqual() { super( new CommonToken( 0, ">=" ) ); }
@Override public int getCharPositionInLine() { if ( originalTokenIndex>=0 ) return g.originalTokenStream.get(originalTokenIndex).getCharPositionInLine(); return super.getCharPositionInLine(); }
protected final ST getRuleElementST( String name, String ruleTargetName, GrammarAST elementAST, GrammarAST ast_suffix, String label ) { Rule r = grammar.getRule( currentRuleName ); String suffix = getSTSuffix(elementAST, ast_suffix, label); if ( !r.isSynPred ) { name += suffix; } // if we're building trees and there is no label, gen a label // unless we're in a synpred rule. if ( ( grammar.buildAST() || suffix.length() > 0 ) && label == null && ( r == null || !r.isSynPred ) ) { // we will need a label to do the AST or tracking, make one label = generator.createUniqueLabel( ruleTargetName ); CommonToken labelTok = new CommonToken( ANTLRParser.ID, label ); grammar.defineRuleRefLabel( currentRuleName, labelTok, elementAST ); } ST elementST = templates.getInstanceOf( name ); if ( label != null ) { elementST.add( "label", label ); } return elementST; }
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); } }