From 14a4f822ae40b60a8084d42b303e801929817fa4 Mon Sep 17 00:00:00 2001 From: Jason Orendorff Date: Sun, 27 Oct 2013 00:01:39 -0700 Subject: [PATCH] Add a passing Lexer test. --- src/Lexer.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/Lexer.cpp b/src/Lexer.cpp index 52062a2..a8dccea 100644 --- a/src/Lexer.cpp +++ b/src/Lexer.cpp @@ -102,5 +102,15 @@ void Lexer::test() { assert(lex.next() == Symbol("$EOF$", true)); } + // Lexer produces the longest match, not the first. + { + Lexer lex; + lex.addRegEx("int"); + lex.addRegEx("(i|n|t|e)+"); + lex.setInput("intent"); + s = lex.next(); + assert(s.getName() == "(i|n|t|e)+" && s.getValue() == "intent"); + } + std::cout << "Lexer tests passed\n"; }