summaryrefslogtreecommitdiff
path: root/src/piraha/Boundary.cc
diff options
context:
space:
mode:
authorsbrandt <sbrandt@17b73243-c579-4c4c-a9d2-2d5706c11dac>2013-04-03 19:12:46 +0000
committersbrandt <sbrandt@17b73243-c579-4c4c-a9d2-2d5706c11dac>2013-04-03 19:12:46 +0000
commita3cb4c5d02f0ee75094fc27814c71f8a025d034b (patch)
tree1dd1af38bf8ad0318f07dd2c8ae00216e942efb0 /src/piraha/Boundary.cc
parent069e8f1d570cc373c843673be0acf7bc4dd10b6e (diff)
Add the basic grammar files, and the changes
to the piraha code necessary to parse all of Cactus. git-svn-id: http://svn.cactuscode.org/flesh/trunk@4990 17b73243-c579-4c4c-a9d2-2d5706c11dac
Diffstat (limited to 'src/piraha/Boundary.cc')
-rw-r--r--src/piraha/Boundary.cc20
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;
+}