diff --git a/src/Parser.cpp b/src/Parser.cpp index 848e431a6..ab647459a 100644 --- a/src/Parser.cpp +++ b/src/Parser.cpp @@ -30,6 +30,7 @@ #include #include #include +#include #include #include #include @@ -461,8 +462,18 @@ void Parser::injectDefaults () if (defaultCommand != "") { context.debug ("No command or sequence found - assuming default.command."); - Tree* t = captureFirst (defaultCommand); - t->tag ("DEFAULT"); + + // Split the defaultCommand into args, and add them in reverse order, + // because captureFirst inserts args immediately after the command, and + // so has the effect of reversing the list. + std::vector args; + Lexer::split (args, defaultCommand); + std::vector ::reverse_iterator r; + for (r = args.rbegin (); r != args.rend (); ++r) + { + Tree* t = captureFirst (*r); + t->tag ("DEFAULT"); + } std::string combined; std::vector ::iterator i;