A new example and tests: leopard
This commit is contained in:
parent
83c73f1479
commit
84ea4e866c
|
@ -1,4 +1,5 @@
|
|||
add_subdirectory(keywords)
|
||||
add_subdirectory(SyntaxHighlighter)
|
||||
add_subdirectory(leopard)
|
||||
|
||||
add_custom_target(examples DEPENDS keywords highlighter)
|
||||
add_custom_target(examples DEPENDS keywords highlighter leopard)
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
find_program(LEXESIS_EXE Lexesis PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../build/bin")
|
||||
|
||||
add_custom_command(DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/lexer.lxs"
|
||||
COMMAND ${LEXESIS_EXE} ARGS -d "${CMAKE_CURRENT_BINARY_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}/lexer.lxs"
|
||||
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/Lexer.h" "${CMAKE_CURRENT_BINARY_DIR}/Lexer.cpp"
|
||||
)
|
||||
|
||||
include_directories("${CMAKE_CURRENT_BINARY_DIR}")
|
||||
|
||||
add_executable(leopard
|
||||
EXCLUDE_FROM_ALL
|
||||
main.cpp
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/Lexer.cpp"
|
||||
)
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
# https://xkcd.com/1031/
|
||||
KEYBOARD_CAP = Keyboard
|
||||
KEYBOARD = [kK][eE][yY][bB][oO][aA][rR][dD]
|
||||
OTHER = .|\n
|
|
@ -0,0 +1,30 @@
|
|||
#include "Lexer.h"
|
||||
#include <iostream>
|
||||
|
||||
int main() {
|
||||
Lexer lex(std::cin);
|
||||
try {
|
||||
while (true) {
|
||||
Lexer::Token tok = lex.nextToken();
|
||||
switch (tok.type) {
|
||||
case Lexer::KEYBOARD_CAP:
|
||||
std::cout << "Leopard";
|
||||
break;
|
||||
case Lexer::KEYBOARD:
|
||||
std::cout << "leopard";
|
||||
break;
|
||||
case Lexer::OTHER:
|
||||
std::cout << tok.content;
|
||||
break;
|
||||
case Lexer::nonmatching: case Lexer::ignore:
|
||||
std::cout << "Impossible" << std::endl;
|
||||
break; //These can never occur, just to satisfy the compiler...
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Lexer::NoMatch& err) {
|
||||
std::cout << "Impossible" << std::endl;
|
||||
}
|
||||
catch (Lexer::NoMoreTokens& err) {
|
||||
}
|
||||
}
|
|
@ -51,6 +51,7 @@ REGEXES_DATA = [ # (regexes, should be accepted)
|
|||
EXAMPLE_TESTS = { #Mapping from test name to executable and number of available test input files
|
||||
"keywords" : ("examples/keywords/keywords", 2),
|
||||
"highlighter": ("examples/SyntaxHighlighter/highlighter", 1),
|
||||
"leopard": ("examples/leopard/leopard", 8),
|
||||
}
|
||||
|
||||
def make_pipeline_test(regexes, should_accept, idx):
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
Weird, my leopard just switched to chinese.
|
|
@ -0,0 +1 @@
|
|||
Weird, my keyboard just switched to chinese.
|
|
@ -0,0 +1 @@
|
|||
I work with one Leopard on my desk and another in the leopardtray.
|
|
@ -0,0 +1 @@
|
|||
I work with one Keyboard on my desk and another in the keyboardtray.
|
|
@ -0,0 +1,2 @@
|
|||
Ever cleaned a leopard?
|
||||
They're filthy!
|
|
@ -0,0 +1,2 @@
|
|||
Ever cleaned a keyboard?
|
||||
They're filthy!
|
|
@ -0,0 +1,4 @@
|
|||
The IPhone virtual leopard is the fastest.
|
||||
IMO...
|
||||
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
The IPhone virtual keyboarD is the fastest.
|
||||
IMO...
|
||||
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
I rarely email from my phone -- I'm so slow when I am not on a leopard.
|
||||
ε
|
||||
ε
|
||||
ε
|
||||
µµµ
|
||||
ε
|
||||
ε
|
|
@ -0,0 +1,7 @@
|
|||
I rarely email from my phone -- I'm so slow when I am not on a keyboard.
|
||||
ε
|
||||
ε
|
||||
ε
|
||||
µµµ
|
||||
ε
|
||||
ε
|
|
@ -0,0 +1 @@
|
|||
My leopard died when I spilled tea on it :'(
|
|
@ -0,0 +1 @@
|
|||
My keyboARD died when I spilled tea on it :'(
|
|
@ -0,0 +1 @@
|
|||
The internet got 100 times better when, thanks to an extension with a typo'd regex, my browser started replacing the word "keybaord" with "leopard".
|
|
@ -0,0 +1 @@
|
|||
The internet got 100 times better when, thanks to an extension with a typo'd regex, my browser started replacing the word "keybaord" with "keyboard".
|
|
@ -0,0 +1 @@
|
|||
Problem Exists Between Leopard And Chair
|
|
@ -0,0 +1 @@
|
|||
Problem Exists Between Keyboard And Chair
|
Loading…
Reference in New Issue