summaryrefslogtreecommitdiff
path: root/src/parser.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/parser.h')
-rw-r--r--src/parser.h29
1 files changed, 25 insertions, 4 deletions
diff --git a/src/parser.h b/src/parser.h
index 8e9ccd4a..7cb1cd49 100644
--- a/src/parser.h
+++ b/src/parser.h
@@ -33,6 +33,7 @@
#define _PARSER_H
#include "utils.h"
+#include "builder.h"
namespace ledger {
@@ -46,10 +47,9 @@ class parser_t
virtual bool test(std::istream& in) const = 0;
- virtual unsigned int parse(std::istream& in,
- journal_t * journal,
- account_t * master = NULL,
- const optional<path>& original = none) = 0;
+ virtual void parse(std::istream& in,
+ const path& pathname,
+ xml::builder_t& builder) = 0;
};
DECLARE_EXCEPTION(parse_error);
@@ -65,6 +65,27 @@ inline char * skip_ws(char * ptr) {
return ptr;
}
+inline char * next_element(char * buf, bool variable = false) {
+ for (char * p = buf; *p; p++) {
+ if (! (*p == ' ' || *p == '\t'))
+ continue;
+
+ if (! variable) {
+ *p = '\0';
+ return skip_ws(p + 1);
+ }
+ else if (*p == '\t') {
+ *p = '\0';
+ return skip_ws(p + 1);
+ }
+ else if (*(p + 1) == ' ') {
+ *p = '\0';
+ return skip_ws(p + 2);
+ }
+ }
+ return NULL;
+}
+
inline char peek_next_nonws(std::istream& in) {
char c = in.peek();
while (! in.eof() && std::isspace(c)) {