List of usage examples for jdk.nashorn.internal.runtime ParserException ParserException
public ParserException(final String msg)
From source file:co.kademi.kdom.RegexTokenizer.java
License:Apache License
@Override public void tokenize(String str, TokenHandler handler) { String s = str.trim();/*from w w w . j a v a 2 s . c om*/ // TODO: would be better to iterate through s, rather the chopping it. But for some reason find(start) doesnt work as expected while (!s.equals("")) { boolean match = false; for (TokenInfo info : tokenInfos) { Matcher m = info.regex.matcher(s); if (m.find()) { System.out.println("FOUND"); match = true; String tok = m.group().trim(); //start = m.end(); s = m.replaceFirst("").trim(); TokenType type = info.type; String text = tok; handler.onToken(type, text); break; } } if (!match) { throw new ParserException("Unexpected character in input: " + s); } } }