Created
December 4, 2015 21:57
-
-
Save ksherlock/d45d4665730d63429f09 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <string> | |
void none(void) { | |
std::cout << "I'm none..." << std::endl; | |
} | |
void red(void) { | |
std::cout << "I'm red!" << std::endl; | |
} | |
void blue(void) { | |
std::cout << "I'm blue!" << std::endl; | |
} | |
void process(const std::string &s) { | |
%%{ | |
machine process; | |
main := | |
/red/i %{ return red(); } | |
| | |
/blue/i %{ return blue(); } | |
; | |
}%% | |
%% write data; | |
int cs; | |
const char *p = s.data(); | |
const char *pe = s.data() + s.size(); | |
const char *eof = pe; | |
%% write init; | |
%% write exec; | |
return none(); | |
} | |
int main(int argc, char **argv) { | |
std::string s; | |
while (std::cin >> s) { | |
process(s); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment