From a3cb4c5d02f0ee75094fc27814c71f8a025d034b Mon Sep 17 00:00:00 2001 From: sbrandt Date: Wed, 3 Apr 2013 19:12:46 +0000 Subject: 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 --- src/piraha/Boundary.cc | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 src/piraha/Boundary.cc (limited to 'src/piraha/Boundary.cc') 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; +} -- cgit v1.2.3