Verified Commit 1fd508ea authored by Camil Staps's avatar Camil Staps 🚀

BNF grammar in readme

parent f57625da
......@@ -55,6 +55,50 @@ be `Just []`.
If the regex would not compile (try adding a `{` at the end), the result would
be `Nothing`.
## Grammar
The following BNF grammar is recognised by `compile`:
```
<Regex> ::= <Anchor>
| <CharClass>
| '.'
| <Regex> <Quantifier> ['?']
| <Regex> <Regex>
| <Regex> '|' <Regex>
| '(?:' <Regex> ')'
| <Literal>
<Anchor> ::= '^' | '$'
<CharClass> ::= '[' ['^'] [']'] <CharRanges> ['-'] ']'
| <ShortClass>
<CharRanges> ::= <Char> <CharRanges> | <Char>
| <Char> '-' <Char> <CharRanges> | <Char> '-' <Char>
| <ShortClass> <CharRanges> | <ShortClass>
<ShortClass> ::= '\d' | '\D' | '\w' | '\W' | '\s' | '\S'
<Quantfier> ::= '?' | '*' | '+'
| '{' <Int> '}'
| '{' <Int> ',}'
| '{' <Int> ',' <Int> '}'
<Literal> ::= <Char>
| <EscapeSeq>
<EscapeSeq> ::= '\x' <HexDigit> <HexDigit>
| '\' <OctDigit> [<OctDigit> [<OctDigit>]]
| '\' <Special>
| '\' <EscapeChar>
<Special> ::= '\' | '+' | '*' | '?' | '^' | '$' | '.' | '|'
| '(' | ')' | '[' | ']' | '{' | '}'
<EscapeChar> ::= 'a' | 'b' | 'f' | 'n' | 'r' | 't' | 'v' | '\'
```
## Todo (in order of importance)
* More anchors (`\b`, `\B`, `\A`, `\Z`)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment