Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parse params #1706

Merged
merged 2 commits into from
May 10, 2019
Merged

Parse params #1706

merged 2 commits into from
May 10, 2019

Conversation

bendudson
Copy link
Contributor

Adds the capability to put parameters in expressions, which are looked up when the value is generated. This allows values generated at run-time to be combined using expressions in the input file.

Braces `{}` in an expression surround a string containing any characters except
 '}'. This string is stored in a `FieldParam` object, and will be used to look up
an expression input parameter. This needs a little modification to the
 `Position` class before it actually works.
Expressions can now contain values in braces `{name}` which are looked up in the
given `Position` object passed into `generate`. This can be used to pass in
parameters to expressions.
@dschwoerer
Copy link
Contributor

I tried passing by const reference, as that makes more sense - even if real() as modifier is chosen, it is easy enough to take a non-const copy, and pass that on. However, that does not silence the warnings ...

This patch makes the output acceptable:

--- a/tests/unit/quiet.sh
+++ b/tests/unit/quiet.sh
@@ -4,13 +4,23 @@ set -o pipefail
 for cmd in $@
 do
     $cmd | awk '{
+    if (match($0,"WARNING: Accessing zero value")) {
+      samecount = samecount + 1
+    } else {
+      if (samecount) {
+         print running
+         print samecount, "WARNING: Accessing zero value"
+        samecount = 0
+      }
+
     if (match($0,"^$")) {
         empty=1
         #print "empty", $0
-        if (running)
+        if (running) {
             out=1
-        else
+        } else {
             out=0
+        }
         
     } else {
         if (match($0,"\\[ *RUN *\\]")) {
@@ -41,6 +51,7 @@ do
         }
         empty=0
     }
+    }
     if (out)
         print $0
 }' || exit

@@ -129,7 +129,7 @@ private:

LexInfo(const std::string& input, const std::string& reserved_chars = "");

/// Current token. -1 for number, -2 for string, 0 for "end of input"
/// Current token. -1 for number, -2 for symbol, -3 for {string}, 0 for "end of input"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Idea for future PR: make this variant<signed char, enum{Number, Symbol, String, EOF}>?

@ZedThree
Copy link
Member

ZedThree commented May 3, 2019

With this change, Position feels like a bit of a misnomer. Maybe something like Context, or GeneratorContext would be more appropriate?

@bendudson bendudson merged commit 8430a94 into ynorm2 May 10, 2019
@bendudson bendudson deleted the parse-params branch May 10, 2019 21:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants