grammars: nit

This commit is contained in:
Olivier Chafik 2024-04-12 16:15:24 +01:00
parent de0fd3f7f0
commit 9d9b5a34f6
2 changed files with 4 additions and 2 deletions

View file

@ -98,7 +98,7 @@ namespace grammar_parser {
pos++; pos++;
} }
if (pos == src) { if (pos == src) {
throw std::runtime_error(std::string("expecting name at ") + src); throw std::runtime_error(std::string("expecting integer at ") + src);
} }
return pos; return pos;
} }
@ -159,6 +159,8 @@ namespace grammar_parser {
throw std::runtime_error(std::string("expecting preceding item to */+/?/{ at ") + pos); throw std::runtime_error(std::string("expecting preceding item to */+/?/{ at ") + pos);
} }
// apply transformation to previous symbol (last_sym_start to end) according to
// the following rewrite rules:
// S* --> S{0,} // S* --> S{0,}
// S+ --> S{1,} // S+ --> S{1,}
// S? --> S{0,1} // S? --> S{0,1}

View file

@ -64,7 +64,7 @@ Parentheses `()` can be used to group sequences, which allows for embedding alte
- `?` makes the preceding symbol or sequence optional (equivalent to `{0,1}`). - `?` makes the preceding symbol or sequence optional (equivalent to `{0,1}`).
- `{m}` repeats the precedent symbol or sequence exactly `m` times - `{m}` repeats the precedent symbol or sequence exactly `m` times
- `{m,}` repeats the precedent symbol or sequence at least `m` times - `{m,}` repeats the precedent symbol or sequence at least `m` times
- `{m,n}` repeats the precedent symbol or sequence at betwen `m` and `n` (included) times (included) - `{m,n}` repeats the precedent symbol or sequence at betwen `m` and `n` times (included)
- `{,n}` repeats the precedent symbol or sequence at most `n` times (included) - `{,n}` repeats the precedent symbol or sequence at most `n` times (included)
## Comments and newlines ## Comments and newlines