public void expect(String s, int... tokens) { Lexer lexer = createLexer(s); for (int token : tokens) { Token t = lexer.nextToken(); assertThat(t.getType()).isEqualTo(token) .withFailMessage("Expected %s, got %s, with '%s'", nameOf(token), nameOf(t.getType()), t.getText()); } }
public Token nextToken() { super.nextToken(); if (tokens.size() == 0) return new CommonToken(Token.EOF); return tokens.remove(0); }
public Token nextToken() { super.nextToken(); if (tokens.size() == 0) return new CommonToken(Token.EOF); return tokens.remove(0); }
public Token nextToken() { super.nextToken(); if (tokens.size() == 0) return new CommonToken(Token.EOF); return tokens.remove(0); }
public Token nextToken() { super.nextToken(); if (tokens.size() == 0) return new CommonToken(Token.EOF); return tokens.remove(0); }
public Token nextToken() { super.nextToken(); if (tokens.size() == 0) return new CommonToken(Token.EOF); return tokens.remove(0); }
public Token nextToken() { super.nextToken(); if ( tokens.size()==0 ) { return getEOFToken(); } return (Token)tokens.remove(0); } //add new field
public Token nextToken() { super.nextToken(); if (tokens.size() == 0) return new CommonToken(Token.EOF); return tokens.remove(0); }
@Override public Token nextToken() { super.nextToken(); Token t = tokens.isEmpty() ? getEOFToken() : tokens.poll(); return t; }
@Override public Token nextToken() { super.nextToken(); Token t = tokens.isEmpty() ? getEOFToken() : tokens.poll(); return t; }
@Override public Token nextToken() { Token token = super.nextToken(); while (token.getType() == STRAY_BRACKET) { ErrorManager.syntaxError( ErrorManager.MSG_SYNTAX_ERROR, null, token, "antlr: dangling ']'? make sure to escape with \\]", null); // skip this token token = super.nextToken(); } return token; }
@Override public Token nextToken() { Token token = super.nextToken(); while (token.getType() == STRAY_BRACKET) { ErrorManager.syntaxError( ErrorManager.MSG_SYNTAX_ERROR, null, token, "antlr: dangling ']'? make sure to escape with \\]", null); // skip this token token = super.nextToken(); } return token; }
public Token nextToken(){ Token token = super.nextToken(); if(token.getType() == Token.EOF && !includes.empty()){ // We've got EOF and have non empty stack. SaveStruct ss = includes.pop(); setCharStream(ss.input); input.rewind(ss.marker); //this should be used instead of super [like below] to handle exits from nested includes //it matters, when the 'include' token is the last in previous stream (using super, lexer 'crashes' returning EOF token) token = this.nextToken(); } // Skip first token after switching on another input. // You need to use this rather than super as there may be nested include files if(((CommonToken)token).getStartIndex() < 0) { token = this.nextToken(); } return token; }
public void expect(String s, int... tokens) throws Exception { Lexer lexer = createLexer(s); for (int token : tokens) { Token t = lexer.nextToken(); assertEquals(String.format("Expected %s, got %s, with '%s'", nameOf(token), nameOf(t.getType()), t.getText()), token, t.getType()); } }
public void expect(String s, int... tokens) throws Exception { Lexer lexer = createLexer(s); for (int token : tokens) { Token t = lexer.nextToken(); assertEquals(String.format("Expected %s, got %s, with '%s'", nameOf(token), nameOf(t.getType()), t.getText()), token, t.getType()); } }
public Token nextToken(){ //The following code was pulled out from super.nextToken() if (input.index() == 0) { try { state.token = null; state.channel = Token.DEFAULT_CHANNEL; state.tokenStartCharIndex = input.index(); state.tokenStartCharPositionInLine = input.getCharPositionInLine(); state.tokenStartLine = input.getLine(); state.text = null; mFirstBodyString(); state.type = BodyString; emit(); return state.token; } catch (NoViableAltException nva) { reportError(nva); recover(nva); // throw out current char and try again } catch (RecognitionException re) { reportError(re); // match() routine has already called recover() } } return super.nextToken(); }
public Token nextToken(){ //The following code was pulled out from super.nextToken() if (input.index() == 0) { try { state.token = null; state.channel = Token.DEFAULT_CHANNEL; state.tokenStartCharIndex = input.index(); state.tokenStartCharPositionInLine = input.getCharPositionInLine(); state.tokenStartLine = input.getLine(); state.text = null; mFirstBodyString(); state.type = BodyString; emit(); return state.token; } catch (NoViableAltException nva) { reportError(nva); recover(nva); // throw out current char and try again } catch (RecognitionException re) { reportError(re); // match() routine has already called recover() } } return super.nextToken(); }