CssDroidLexer { public void tokenize(String input) { input = input.trim(); tokens.clear(); while (!input.isEmpty()) { boolean match = false; for (Lexem info : grammar.getLexems()) { Matcher matcher = info.regex.matcher(input); if (matcher.find()) { match = true; String tok = matcher.group(0).trim(); input = matcher.replaceFirst("").trim(); tokens.add(new Token(info.token, tok)); break; } } if (!match) { throw new LexerException("Unexpected character in input: (" + input + ")"); } } } CssDroidLexer(); void tokenize(String input); List<Token> getTokens();  }
@Test(expected = LexerException.class) public void shouldThrowExceptionOnNoMatchToken() { lexer.tokenize("@@notmatch: 11xp:)"); }