Skip to content

Conversation

@lizdulac
Copy link
Contributor

@lizdulac lizdulac commented May 8, 2024

Related to PR #4145

Create a function that returns a single line string representation of a derived expression. This is mainly for bpls since one line has a more user friendly format.

ExpressionTree to String Expression:
ADD({sim1/Ux},{sim1/Uy},{sim1/Uz})

$ ./bin/bpls expAdd.bp --show-derived -l
  float    derived/addU  2*{10, 3, 6} = 2.98842 / 28.085
    Derived variable with expression: ADD({sim1/Ux},{sim1/Uy},{sim1/Uz})
  float    sim1/Ux       2*{10, 3, 6} = 0.000224775 / 9.94031
  float    sim1/Uy       2*{10, 3, 6} = 0.0201616 / 9.83318
  float    sim1/Uz       2*{10, 3, 6} = 0.0031 / 9.95085

The current solution is not the best. We do not create derived variables on the read side so the BP5Reader provides an internal function to get the expression string from the deserializer, create an expression on it, and call the pretty-print function on the expression (which is overly complicated). I would still merge this PR like this. We will start creating derived variables on the read side and we can replace the logic with something cleaner at that point. This PR is one step in this direction since it moves the string conversion on the Expression class.

@lizdulac lizdulac requested a review from anagainaru May 8, 2024 17:20
@lizdulac lizdulac marked this pull request as draft May 8, 2024 17:23
@lizdulac
Copy link
Contributor Author

Translating an ExpressionTree object instead of an ASTNode object to a single line string expression allows for expressions with the same operator to be merged.

Example:
ASTNode to String Expression:
+( +( {sim1/Ux},{sim1/Uy} ),{sim1/Uz} )

ExpressionTree to String Expression:
ADD({sim1/Ux},{sim1/Uy},{sim1/Uz})

@anagainaru anagainaru force-pushed the ASTNodeToString branch 3 times, most recently from 2d87f00 to a22462b Compare May 17, 2024 13:49
@anagainaru anagainaru changed the title ASTNode to string Compress the expression string into one line for bpls May 18, 2024
@anagainaru anagainaru marked this pull request as ready for review May 18, 2024 01:43
@anagainaru anagainaru requested a review from eisenhauer May 18, 2024 19:54
@anagainaru anagainaru merged commit bcefc17 into ornladios:master May 18, 2024
@anagainaru anagainaru added this to the v2.10.1 milestone May 28, 2024
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.

3 participants