From 0500649992bff240c6557014a15eb9be3a7afe00 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sat, 14 Jun 2014 15:18:31 -0400 Subject: [PATCH] Parser - ::initialize now lexes all args up front. --- src/Parser.cpp | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/Parser.cpp b/src/Parser.cpp index 2c0e99767..15a6dcf98 100644 --- a/src/Parser.cpp +++ b/src/Parser.cpp @@ -76,10 +76,26 @@ void Parser::initialize (int argc, const char** argv) // Create top-level nodes. for (int i = 0; i < argc; ++i) { + std::string raw = argv[i]; Tree* branch = _tree->addBranch (new Tree (format ("arg{1}", i))); - branch->attribute ("raw", argv[i]); + branch->attribute ("raw", raw); branch->tag ("ORIGINAL"); branch->tag ("?"); + + std::vector > lexemes; + Lexer::token_split (lexemes, raw); + + std::vector >::iterator lex; + for (lex = lexemes.begin (); lex != lexemes.end (); ++lex) + { + Tree* sub = branch->addBranch (new Tree ("argSub")); + sub->attribute ("raw", lex->first); + + if (lex->second == Lexer::typeOperator) + sub->tag ("OP"); + + // TODO More types needed. + } } } @@ -166,7 +182,6 @@ Tree* Parser::parse () findMissingOperators (); validate (); - return _tree; }