From 11a2c767cc474a3a8c1f3b831d5a67b7e7449c72 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Mon, 21 Jul 2014 12:50:29 +0200 Subject: [PATCH] some argument parsing cleanup --- components/compiler/exprparser.cpp | 30 +++++++++++++++++++----------- components/compiler/extensions.hpp | 2 +- 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/components/compiler/exprparser.cpp b/components/compiler/exprparser.cpp index d0cda0ec2..6e29626b1 100644 --- a/components/compiler/exprparser.cpp +++ b/components/compiler/exprparser.cpp @@ -777,11 +777,22 @@ namespace Compiler ++optionalCount; } } + else if (*iter=='X') + { + parser.reset(); + + parser.setOptional (true); + + scanner.scan (parser); + + if (optional && parser.isEmpty()) + break; + } else { parser.reset(); - if (optional || *iter == 'X') + if (optional) parser.setOptional (true); scanner.scan (parser); @@ -789,20 +800,17 @@ namespace Compiler if (optional && parser.isEmpty()) break; - if (*iter != 'X') - { - std::vector tmp; + std::vector tmp; - char type = parser.append (tmp); + char type = parser.append (tmp); - if (type!=*iter) - Generator::convert (tmp, type, *iter); + if (type!=*iter) + Generator::convert (tmp, type, *iter); - stack.push (tmp); + stack.push (tmp); - if (optional) - ++optionalCount; - } + if (optional) + ++optionalCount; } } diff --git a/components/compiler/extensions.hpp b/components/compiler/extensions.hpp index d229751de..aa62fd0eb 100644 --- a/components/compiler/extensions.hpp +++ b/components/compiler/extensions.hpp @@ -21,7 +21,7 @@ namespace Compiler s - Short
S - String, case preserved
x - Optional, ignored string argument - X - Optional, ignored integer argument + X - Optional, ignored float argument **/ typedef std::string ScriptArgs;