mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-07-07 20:06:36 +02:00
Enhancements - Nibbler + parsing
- New Nibbler object greatly assists in FF4 parsing. - Unit tests for Nibbler. - Record now parses itself. - Att now parses itself.
This commit is contained in:
parent
7c0aee4a5f
commit
5263147c83
12 changed files with 623 additions and 77 deletions
|
@ -25,9 +25,11 @@
|
|||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <stdlib.h>
|
||||
#include "util.h"
|
||||
#include "Nibbler.h"
|
||||
#include "Record.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -84,19 +86,34 @@ std::string Record::composeF4 ()
|
|||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// start --> [ --> name --> : --> " --> value --> " --> ] --> end
|
||||
// ^ |
|
||||
// |________________________________|
|
||||
// start --> name --> : --> " --> value --> " --> end
|
||||
// ^ |
|
||||
// |________________________________|
|
||||
//
|
||||
void Record::parse (const std::string& input)
|
||||
{
|
||||
if (input[0] == '[' && input[input.length () - 1] == ']')
|
||||
Nibbler n (input);
|
||||
std::string line;
|
||||
if (n.skip ('[') && n.getUntilChar (']', line))
|
||||
{
|
||||
Nibbler nl (line);
|
||||
|
||||
bool first = true;
|
||||
Att a;
|
||||
while (a.parse (nl))
|
||||
{
|
||||
if (first)
|
||||
first = false;
|
||||
else
|
||||
nl.skip (' ');
|
||||
|
||||
(*this)[a.name ()] = a;
|
||||
}
|
||||
|
||||
|
||||
throw std::string ("unimplemented Record:parse");
|
||||
std::string remainder;
|
||||
nl.getUntilEOS (remainder);
|
||||
if (remainder.length ())
|
||||
throw std::string ("Unrecognized garbage at end of line");
|
||||
}
|
||||
else
|
||||
throw std::string ("Record not recognized as FF4");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue