Skip to content

Conversation

@tertsdiepraam
Copy link
Member

@tertsdiepraam tertsdiepraam commented Nov 27, 2023

Since we had some problems with expr I rewrote the parsing logic, which then again ballooned into rewriting everything (as seems to happen to me often these days...).

I removed the tokenization, because that's not correct; each token could also be a valid string in another position. I also made the AST so that it does not have slices of values, but a fixed number for each operation. This makes the whole thing much less error prone. The parser is replaced with a fairly simple yet effective recursive descent parser.

The total implementation is also much smaller (especially considering that some lines are new tests).

Limitations:

  • Currently I've only added String values, which leads to unnecessary conversions between strings and integers.
  • Evaluation should happen during parsing not after (try for instance expr '(' 1 / 0, which in GNU gives a division by zero error and a syntax error here)

@tertsdiepraam tertsdiepraam force-pushed the expr-ast-refactor branch 4 times, most recently from ad96fb9 to 2c19f9e Compare November 27, 2023 13:34
@uutils uutils deleted a comment from github-actions bot Nov 28, 2023
@sylvestre
Copy link
Contributor

terrific
and it is making the fuzzer happier :)

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.

2 participants