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

ds::extractPairs() can not handle nested expressions #97

Open
paulhoux opened this issue Nov 6, 2023 · 1 comment
Open

ds::extractPairs() can not handle nested expressions #97

paulhoux opened this issue Nov 6, 2023 · 1 comment

Comments

@paulhoux
Copy link
Contributor

paulhoux commented Nov 6, 2023

In string_util.cpp, the function ds::extractPairs is not able to handle the following expression:
#expr{ #expr{ 300 * 0.7 } * 0.7 } with leftDelim = #expr{ and rightDelim = }.

The above expression can occur in the following case:

$_title_font_size = 300
$_header_font_size = #expr{ $_title_font_size * 0.7 }
$_body_font_size = #expr{ $header_font_size * 0.7 } # <-- there it is

It incorrectly stops at the first right bracket } and returns #expr{ 300 * 0.7 as a subvalue. Nested expressions should be detected and in this case #expr{ 300 * 0.7 } * 0.7 should be returned.

When fixing this issue, be careful not to break support for the following unnested example: #expr{ 200 + 50 }, #expr{ 300 + 100 }

@paulhoux
Copy link
Contributor Author

paulhoux commented Nov 6, 2023

While you're at it, consider using output.emplace_back(0, thing) instead of output.push_back(std::make_pair(0, thing))

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

No branches or pull requests

1 participant