27char RegexParser::peek() {
28 if (fIndex >= fSource.size()) {
31 return fSource[fIndex];
34void RegexParser::expect(
char c) {
35 if (this->peek() != c) {
36 printf(
"expected '%c' at index %d, but found '%c'", c, (
int) fIndex, this->peek());
48void RegexParser::term() {
49 switch (this->peek()) {
50 case '(': this->group();
break;
51 case '[': this->set();
break;
52 case '.': this->dot();
break;
53 default: this->literal();
break;
57void RegexParser::quantifiedTerm() {
59 switch (this->peek()) {
67void RegexParser::sequence() {
68 this->quantifiedTerm();
70 switch (this->peek()) {
71 case END: [[fallthrough]];
72 case '|': [[fallthrough]];
84RegexNode RegexParser::escapeSequence(
char c) {
94void RegexParser::literal() {
95 char c = this->peek();
98 fStack.push(this->escapeSequence(peek()));
107void RegexParser::dot() {
112void RegexParser::group() {
118void RegexParser::setItem() {
120 if (this->peek() ==
'-') {
136void RegexParser::set() {
138 size_t depth = fStack.size();
140 if (this->peek() ==
'^') {
142 set.fPayload.fBool =
true;
145 set.fPayload.fBool =
false;
148 switch (this->peek()) {
151 while (fStack.size() > depth) {
152 set.fChildren.push_back(this->pop());
154 fStack.push(std::move(set));
157 printf(
"unterminated character set\n");
166void RegexParser::regex() {
168 switch (this->peek()) {
static bool left(const SkPoint &p0, const SkPoint &p1)
static bool right(const SkPoint &p0, const SkPoint &p1)
RegexNode parse(std::string source)
std::string printf(const char *fmt,...) SK_PRINTF_LIKE(1