blob: a01c48fda204d923f20085a1c104a7f4f3598eef (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
#include "Piraha.hpp"
using namespace piraha;
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;
}
}
|