diff options
Diffstat (limited to 'src/piraha/Boundary.cc')
-rw-r--r-- | src/piraha/Boundary.cc | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/piraha/Boundary.cc b/src/piraha/Boundary.cc new file mode 100644 index 00000000..6c34335b --- /dev/null +++ b/src/piraha/Boundary.cc @@ -0,0 +1,20 @@ +#include "Piraha.hpp" + +using namespace piraha; + +bool is_c_ident(char c) { + return ('a' <= c && c <= 'z') + || ('A' <= c && c <= 'Z') + || ('0' <= c && c <= '9') + || c == '_'; +} + +bool Boundary::match(Matcher *m) { + if(m->pos == 0 || m->pos == (int)m->input_size) + return true; + char c2 = m->input[m->pos]; + char c1 = m->input[m->pos-1]; + bool b1 = is_c_ident(c1); + bool b2 = is_c_ident(c2); + return !b1 || !b2; +} |