mirror of
https://github.com/GothenburgBitFactory/timewarrior.git
synced 2025-07-07 20:06:39 +02:00
Grammar: Added regex support
This commit is contained in:
parent
ee667cb68c
commit
fa375615cd
2 changed files with 13 additions and 11 deletions
|
@ -156,7 +156,7 @@ std::string Grammar::dump () const
|
|||
{
|
||||
out << term._token;
|
||||
if (term._decoration != "")
|
||||
out << term._decoration;
|
||||
out << " " << term._decoration;
|
||||
out << " ";
|
||||
}
|
||||
|
||||
|
@ -187,7 +187,8 @@ void Grammar::validate () const
|
|||
{
|
||||
for (auto& token : production)
|
||||
{
|
||||
if (token._token.front () != '"')
|
||||
if (token._token.front () != '"' and
|
||||
token._token.front () != '/')
|
||||
allTokens.push_back (token._token);
|
||||
|
||||
if (token._token == production[0]._token &&
|
||||
|
@ -213,7 +214,8 @@ void Grammar::validate () const
|
|||
throw format ("Definition '{1}' is left recursive.", lr);
|
||||
|
||||
for (auto& r : allRules)
|
||||
if (r[0] == '"')
|
||||
if (r[0] == '"' or
|
||||
r[0] == '/')
|
||||
throw format ("Definition '{1}' must not be a literal.");
|
||||
|
||||
// Unused definitions - these are names in _rules that are never
|
||||
|
|
|
@ -18,18 +18,18 @@
|
|||
# A -> B <op> A
|
||||
# B
|
||||
|
||||
cli: "start":ai
|
||||
"stop":ai
|
||||
"track":ai
|
||||
cli: "start" :ai
|
||||
"stop" :ai
|
||||
"track" :ai
|
||||
help # Non-terminal, cannot contain є.
|
||||
є
|
||||
|
||||
|
||||
help: "help":ai topic
|
||||
"help":ai
|
||||
help: "help" :ai topic
|
||||
"help" :ai
|
||||
|
||||
topic: "usage":ai
|
||||
"dates":ai
|
||||
"times":ai
|
||||
topic: "usage" :ai
|
||||
/dates?/ :ai
|
||||
/times?/ :ai
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue