Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support for regex grammar (need to be checked).
- Loading branch information
Hana Dusíková
committed
Aug 20, 2018
1 parent
1611603
commit 90ac938
Showing
10 changed files
with
429 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#include <ctre.hpp> | ||
|
||
std::optional<std::string_view> match(std::string_view sv) { | ||
if (auto match = regex<"^(name:[a-z]+):">(sv); match) { | ||
return {true, match.get<"name">().first()}; | ||
} else { | ||
return std::nullopt; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
backslash = {\\} | ||
dot = {.} | ||
dolar = {$} | ||
open = {(} | ||
close = {)} | ||
questionmark = {?} | ||
colon = {:} | ||
sopen = {[} | ||
sclose = {]} | ||
plus = {+} | ||
star = {*} | ||
copen = {{} | ||
cclose = {}} | ||
num = {0,1,2,3,4,5,6,7,8,9} | ||
comma = {\,} | ||
pipe = {|} | ||
caret = {^} | ||
minus = {-} | ||
hexdec = {0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F,a,b,c,d,e,f} | ||
octal = {0,1,2,3,4,5,6,7} | ||
nonspecial = {\,,-,0,1,2,3,4,5,6,7,8,9,:,A,B,C,D,E,F,X,],a,b,c,d,e,f,x} | ||
nonspecial2 = {0,1,2,3,4,5,6,7,8,9,:,A,B,C,D,E,F,X,a,b,c,d,e,f,x} | ||
|
||
S -> epsilon | [addchar],other,<repeat>,<string2>,<alt2> | [addchar],nonspecial,<repeat>,<string2>,<alt2> | \\,<B>,<repeat>,<string2>,<alt2> | dot,[any],<repeat>,<string2>,<alt2> | caret,[insert_begin],<repeat>,<string2>,<alt2> | dolar,[insert_end],<repeat>,<string2>,<alt2> | (,<C>,<repeat>,<string2>,<alt2> | [,<D>,<repeat>,<string2>,<alt2> | ||
A -> [repeat_exactly],cclose | \,,<H> | ||
alt2 -> pipe,<alt> | epsilon | ||
alt -> [addchar],other,<repeat>,<string2>,<alt2> | [addchar],nonspecial,<repeat>,<string2>,<alt2> | \\,<B>,<repeat>,<string2>,<alt2> | dot,[any],<repeat>,<string2>,<alt2> | caret,[insert_begin],<repeat>,<string2>,<alt2> | dolar,[insert_end],<repeat>,<string2>,<alt2> | (,<C>,<repeat>,<string2>,<alt2> | [,<D>,<repeat>,<string2>,<alt2> | ||
altB -> epsilon | [addchar],other,<repeat>,<string2>,<alt2> | [addchar],nonspecial,<repeat>,<string2>,<alt2> | \\,<B>,<repeat>,<string2>,<alt2> | dot,[any],<repeat>,<string2>,<alt2> | caret,[insert_begin],<repeat>,<string2>,<alt2> | dolar,[insert_end],<repeat>,<string2>,<alt2> | (,<C>,<repeat>,<string2>,<alt2> | [,<D>,<repeat>,<string2>,<alt2> | ||
B -> a | 0,[odigit],octal,[odigit],octal,[odigit],octal | x,<G> | dot | sopen | copen | cclose | open | close | backslash | star | plus | questionmark | pipe | caret | dolar | d | ||
C -> questionmark,colon,<altB>,close | [addchar],other,<repeat>,<string2>,<alt2>,[make_catch],close | [addchar],nonspecial,<repeat>,<string2>,<alt2>,[make_catch],close | \\,<B>,<repeat>,<string2>,<alt2>,[make_catch],close | dot,[any],<repeat>,<string2>,<alt2>,[make_catch],close | caret,[insert_begin],<repeat>,<string2>,<alt2>,[make_catch],close | dolar,[insert_end],<repeat>,<string2>,<alt2>,[make_catch],close | (,<C>,<repeat>,<string2>,<alt2>,[make_catch],close | [,<D>,<repeat>,<string2>,<alt2>,[make_catch],close | [empty],[make_catch],close | ||
D -> caret,[set_neg_start],<set>,sclose | [addchar],other,<range>,<set2>,sclose | [addchar],nonspecial2,<range>,<set2>,sclose | [addchar],dot,<range>,<set2>,sclose | \\,<E>,<set2>,sclose | ||
E -> b | a | 0,[odigit],octal,[odigit],octal,[odigit],octal | x,<G> | dot | sopen | copen | cclose | open | close | backslash | star | plus | questionmark | pipe | caret | dolar | ||
F -> [insert_range],other | [insert_range],nonspecial2 | ||
G -> [hdigit],hexdec,[hdigit],hexdec | copen,[hdigit],hexdec,[hdigit],hexdec,[hdigit],hexdec,[hdigit],hexdec,cclose | ||
H -> [repeat_at_least],cclose,<mod> | [digit],num,<number2>,[insert_number],[repeat_ab],cclose,<mod> | ||
mod -> epsilon | questionmark | plus | ||
number2 -> epsilon | [digit],num,<number2> | ||
number -> [digit],num,<number2> | ||
range -> epsilon | -,<F> | ||
repeat -> epsilon | plus,[plus],<mod> | star,[star],<mod> | questionmark,[optional],<mod> | {,<number>,<A> | ||
set2 -> epsilon | [addchar],other,<range>,[set_combine],<set2> | [addchar],nonspecial2,<range>,[set_combine],<set2> | [addchar],dot,<range>,[set_combine],<set2> | \\,<E>,[set_combine],<set2> | ||
set -> [addchar],other,<range>,<set2> | [addchar],nonspecial2,<range>,<set2> | [addchar],dot,<range>,<set2> | \\,<E>,<set2> | ||
string2 -> epsilon | [addchar],other,<repeat>,<string2> | [addchar],nonspecial,<repeat>,<string2> | \\,<B>,<repeat>,<string2> | dot,[any],<repeat>,<string2> | caret,[insert_begin],<repeat>,<string2> | dolar,[insert_end],<repeat>,<string2> | (,<C>,<repeat>,<string2> | [,<D>,<repeat>,<string2> | ||
|
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
backslash={\\} | ||
dot={.} | ||
dolar={$} | ||
open={(} | ||
close={)} | ||
questionmark={?} | ||
colon={:} | ||
sopen={[} | ||
sclose={]} | ||
plus={+} | ||
star={*} | ||
copen={\{} | ||
cclose={\}} | ||
num={0,1,2,3,4,5,6,7,8,9} | ||
comma={\,} | ||
pipe={|} | ||
caret={^} | ||
minus={-} | ||
|
||
hexdec={0,1,2,3,4,5,6,7,8,9,a,b,c,d,e,f,A,B,C,D,E,F} | ||
octal={0,1,2,3,4,5,6,7} | ||
nonspecial={a,b,c,d,e,f,A,B,C,D,E,F,x,X,:,],0,1,2,3,4,5,6,7,8,9,\,,-} | ||
nonspecial2={a,b,c,d,e,f,A,B,C,D,E,F,x,X,:,0,1,2,3,4,5,6,7,8,9} | ||
|
||
S-><alt> | epsilon | ||
|
||
alt-><string>,<alt2> | ||
altB-><string>,<alt2> | epsilon,[empty] | ||
alt2->pipe,<alt>,[alternate] | epsilon | ||
|
||
string-><atom_repeat>,<string2> | ||
string2-><atom_repeat>,<string2>,[create_sequence] | epsilon | ||
|
||
atom_repeat-><atom>,<repeat> | ||
|
||
atom-><character>|<nonchar>|<block>|<character_class> | ||
|
||
repeat->epsilon | plus,[plus],<mod>|star,[star],<mod>|questionmark,[optional],<mod> | ||
repeat->copen,<number>,[repeat_exactly],cclose | ||
repeat->copen,<number>,comma,[repeat_at_least],cclose,<mod> | ||
repeat->copen,<number>,comma,<number>,[repeat_ab],cclose,<mod> | ||
mod->epsilon | questionmark,[nongreedy] | plus,[possessive] | ||
|
||
number->[digit],num,<number2>,[insert_number] | ||
number2->epsilon | [digit],num,<number2> | ||
|
||
block->open,<altB>,[make_catch],close | open,questionmark,colon,<altB>,close | ||
|
||
character_class->sopen,[set_start],<set>,sclose,[set_finish]|sopen,caret,[set_neg_start],<set>,sclose,[set_finish] | ||
set-><setitem>,<set2> | ||
set2-><setitem>,[set_combine],<set2>|epsilon | ||
|
||
setitem->[addchar],other,<range> | [addchar],nonspecial2,<range> | [addchar],dot,<range> | ||
range->epsilon|minus,[insert_range],other|minus,[insert_range],nonspecial2 | ||
|
||
setitem->backslash,<backslash> | backslash,b,[backb] | ||
|
||
backslash->[addchar],<special> | ||
special->dot|sopen|copen|cclose|open|close|backslash|star|plus|questionmark|pipe|caret|dolar | ||
|
||
backslash->a,[backa] | ||
backslash->x,[hdigit],hexdec,[hdigit],hexdec,[hexdec2] | ||
backslash->x,copen,[hdigit],hexdec,[hdigit],hexdec,[hdigit],hexdec,[hdigit],hexdec,cclose,[hexdec4] | ||
backslash->0,[odigit],octal,[odigit],octal,[odigit],octal,[octal3] | ||
backslash_char->d,[class_digit] | ||
|
||
character->[addchar],other | [addchar],nonspecial | dot,[any] | backslash,<backslash> | backslash,<backslash_char> | ||
nonchar->caret,[insert_begin] | dolar,[insert_end] |
Oops, something went wrong.