public void recover(LexerNoViableAltException e) { throw e; } }; lexer.removeErrorListeners(); lexer.addErrorListener(new XPathLexerErrorListener()); CommonTokenStream tokenStream = new CommonTokenStream(lexer); try { int pos = lexer.getCharPositionInLine(); String msg = "Invalid tokens or characters at index "+pos+" in path '"+path+"'"; throw new IllegalArgumentException(msg, e);
switch ( _input.LA(1) ) { case '/': consume(); if ( _input.LA(1)=='/' ) { consume(); t = new CommonToken(ANYWHERE, "//"); consume(); t = new CommonToken(WILDCARD, "*"); break; case '!': consume(); t = new CommonToken(BANG, "!"); break; case '\'': String s = matchString(); t = new CommonToken(STRING, s); break; return new CommonToken(EOF, "<EOF>"); default: if ( isNameStartChar(_input.LA(1)) ) { String id = matchID(); if ( Character.isUpperCase(id.charAt(0)) ) t = new CommonToken(TOKEN_REF, id); else t = new CommonToken(RULE_REF, id);
public String matchID() { int start = _input.index(); consume(); // drop start char while ( isNameChar(_input.LA(1)) ) { consume(); } return _input.getText(Interval.of(start,_input.index()-1)); }
@Override public void action(RuleContext _localctx, int ruleIndex, int actionIndex) { switch (ruleIndex) { case 4: ID_action((RuleContext)_localctx, actionIndex); break; } } private void ID_action(RuleContext _localctx, int actionIndex) {
@Override public void action(RuleContext _localctx, int ruleIndex, int actionIndex) { switch (ruleIndex) { case 4: ID_action((RuleContext)_localctx, actionIndex); break; } } private void ID_action(RuleContext _localctx, int actionIndex) {
public void recover(LexerNoViableAltException e) { throw e; } }; lexer.removeErrorListeners(); lexer.addErrorListener(new XPathLexerErrorListener()); CommonTokenStream tokenStream = new CommonTokenStream(lexer); try { int pos = lexer.getCharPositionInLine(); String msg = "Invalid tokens or characters at index "+pos+" in path '"+path+"'"; throw new IllegalArgumentException(msg, e);
switch ( _input.LA(1) ) { case '/': consume(); if ( _input.LA(1)=='/' ) { consume(); t = new CommonToken(ANYWHERE, "//"); consume(); t = new CommonToken(WILDCARD, "*"); break; case '!': consume(); t = new CommonToken(BANG, "!"); break; case '\'': String s = matchString(); t = new CommonToken(STRING, s); break; return new CommonToken(EOF, "<EOF>"); default: if ( isNameStartChar(_input.LA(1)) ) { String id = matchID(); if ( Character.isUpperCase(id.charAt(0)) ) t = new CommonToken(TOKEN_REF, id); else t = new CommonToken(RULE_REF, id);
public String matchID() { int start = _input.index(); consume(); // drop start char while ( isNameChar(_input.LA(1)) ) { consume(); } return _input.getText(Interval.of(start,_input.index()-1)); }
@Override public void action(RuleContext _localctx, int ruleIndex, int actionIndex) { switch (ruleIndex) { case 4: ID_action(_localctx, actionIndex); break; } } private void ID_action(RuleContext _localctx, int actionIndex) {
public void recover(LexerNoViableAltException e) { throw e; } }; lexer.removeErrorListeners(); lexer.addErrorListener(new XPathLexerErrorListener()); CommonTokenStream tokenStream = new CommonTokenStream(lexer); try { int pos = lexer.getCharPositionInLine(); String msg = "Invalid tokens or characters at index "+pos+" in path '"+path+"'"; throw new IllegalArgumentException(msg, e);
public void recover(LexerNoViableAltException e) { throw e; } }; lexer.removeErrorListeners(); lexer.addErrorListener(new XPathLexerErrorListener()); CommonTokenStream tokenStream = new CommonTokenStream(lexer); try { int pos = lexer.getCharPositionInLine(); String msg = "Invalid tokens or characters at index "+pos+" in path '"+path+"'"; throw new IllegalArgumentException(msg, e);
public void recover(LexerNoViableAltException e) { throw e; } }; lexer.removeErrorListeners(); lexer.addErrorListener(new XPathLexerErrorListener()); CommonTokenStream tokenStream = new CommonTokenStream(lexer); try { int pos = lexer.getCharPositionInLine(); String msg = "Invalid tokens or characters at index "+pos+" in path '"+path+"'"; throw new IllegalArgumentException(msg, e);
public void recover(LexerNoViableAltException e) { throw e; } }; lexer.removeErrorListeners(); lexer.addErrorListener(new XPathLexerErrorListener()); CommonTokenStream tokenStream = new CommonTokenStream(lexer); try { int pos = lexer.getCharPositionInLine(); String msg = "Invalid tokens or characters at index "+pos+" in path '"+path+"'"; throw new IllegalArgumentException(msg, e);