mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-08-24 08:56:43 +02:00
Entities
- Added parser support for @entities, by merely allowing them to exist as terminals. - Added sample entities. - Extended grammar to test entities.
This commit is contained in:
parent
60336d6f6a
commit
ef4d318276
3 changed files with 15 additions and 9 deletions
|
@ -191,7 +191,8 @@ void Parser::checkConsistency ()
|
||||||
// Undefined value - these are definitions that appear in token, but are
|
// Undefined value - these are definitions that appear in token, but are
|
||||||
// not in _rules.
|
// not in _rules.
|
||||||
for (unsigned int i = 0; i < notDefined.size (); ++i)
|
for (unsigned int i = 0; i < notDefined.size (); ++i)
|
||||||
throw std::string ("definition '") + notDefined[i] + "' referenced, but not defined.";
|
if (notDefined[i][0] != '@')
|
||||||
|
throw std::string ("definition '") + notDefined[i] + "' referenced, but not defined.";
|
||||||
|
|
||||||
// Circular definitions - these are names in _rules that also appear as
|
// Circular definitions - these are names in _rules that also appear as
|
||||||
// token 0 in any of the alternates for that definition.
|
// token 0 in any of the alternates for that definition.
|
||||||
|
|
|
@ -80,6 +80,7 @@ int main (int argc, char** argv)
|
||||||
else if (grammarFile == "")
|
else if (grammarFile == "")
|
||||||
{
|
{
|
||||||
grammarFile = argv[i];
|
grammarFile = argv[i];
|
||||||
|
std::cout << "INFO: Using grammar file " << grammarFile << "\n";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -104,13 +105,15 @@ int main (int argc, char** argv)
|
||||||
if (verbose) p.verbose ();
|
if (verbose) p.verbose ();
|
||||||
|
|
||||||
// TODO Initialize entity lists.
|
// TODO Initialize entity lists.
|
||||||
p.addEntity ("report", "list");
|
p.addEntity ("report", "list");
|
||||||
|
p.addEntity ("writecmd", "modify");
|
||||||
|
|
||||||
// Load and verify grammar.
|
// Load and verify grammar.
|
||||||
p.grammar (grammar);
|
p.grammar (grammar);
|
||||||
if (verbose) p.dump ();
|
if (verbose) p.dump ();
|
||||||
|
|
||||||
// Either returns a parse-tree or throws.
|
// Either returns a parse-tree or throws.
|
||||||
|
std::cout << "INFO: Parsing <" << commandLine << ">\n";
|
||||||
Tree* t = p.parse (commandLine);
|
Tree* t = p.parse (commandLine);
|
||||||
if (t)
|
if (t)
|
||||||
{
|
{
|
||||||
|
|
|
@ -15,15 +15,15 @@
|
||||||
;
|
;
|
||||||
|
|
||||||
all-commands ::= report-command
|
all-commands ::= report-command
|
||||||
| read-command
|
# | read-command
|
||||||
# | write-command
|
| write-command
|
||||||
| special-command
|
# | special-command
|
||||||
;
|
;
|
||||||
|
|
||||||
report-command ::= filter @report ;
|
report-command ::= filter @report ;
|
||||||
read-command ::= filter @readcmd ;
|
# read-command ::= filter @readcmd ;
|
||||||
# write-command ::= filter @writecmd modifiers ;
|
write-command ::= filter @writecmd modifiers ;
|
||||||
special-command ::= ;
|
# special-command ::= ;
|
||||||
|
|
||||||
filter ::= expression? ;
|
filter ::= expression? ;
|
||||||
|
|
||||||
|
@ -32,7 +32,9 @@
|
||||||
| term
|
| term
|
||||||
;
|
;
|
||||||
|
|
||||||
# modifiers ::= ;
|
term ::= ;
|
||||||
|
|
||||||
|
modifiers ::= ;
|
||||||
|
|
||||||
# Low-level:
|
# Low-level:
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue