summaryrefslogtreecommitdiff
path: root/src/piraha/ILiteral.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/piraha/ILiteral.cc')
-rw-r--r--src/piraha/ILiteral.cc22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/piraha/ILiteral.cc b/src/piraha/ILiteral.cc
new file mode 100644
index 00000000..f56d4414
--- /dev/null
+++ b/src/piraha/ILiteral.cc
@@ -0,0 +1,22 @@
+#include "Piraha.hpp"
+
+ILiteral::ILiteral(char b) : lc(lc_(b)), uc(uc_(b)) {}
+
+bool ILiteral::match(Matcher *m) {
+ if(m->pos >= (int)m->input_size )
+ return false;
+ char c = m->input[m->pos];
+ if(c == uc || c == lc) {
+ m->max_pos = std::max(m->pos,m->max_pos);
+ m->pos++;
+ return true;
+ } else {
+ if(m->pos == m->max_pos+1) {
+ Bracket bex;
+ bex.addRange(lc,lc);
+ bex.addRange(uc,uc);
+ m->fail(&bex);
+ }
+ return false;
+ }
+}