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

expr: improved parser #879

Merged
merged 2 commits into from
Dec 17, 2024
Merged

expr: improved parser #879

merged 2 commits into from
Dec 17, 2024

Conversation

mknos
Copy link
Contributor

@mknos mknos commented Dec 17, 2024

  • The old expression parser didn't work for some basic expressions I tested
  • It was a bit confusing to debug the old code because everything happened in the one evaluate() function
  • Replace the code with a parser based on the OpenBSD version
  • Different operator priorities are delegated to different functions so overall this is a little clearer
  • Add COPYRIGHT and AUTHOR sections in pod
%perl expr \( 1 \+ 1 \) \* 200
400
%perl expr "true" '&' ''
0
%perl expr 0 '|' 'true'
true
%perl expr 2 '*' 3 '+' 4
10
%perl expr 2 '+' 3 '*' 4
14
%perl expr "hotel" \: "ho"
2
%perl expr "hotel" \: "tel" # no match: regex is implicitly tied to start of string
0

* The old expression parser didn't work for some basic expressions I tested, and it was a bit difficult to debug because everything happened in the one evaluate() function
* Replace the code with a parser based on the OpenBSD version
* Parsing different operator priorities is delegated to different functions so overall this is a little clearer
* Add COPYRIGHT and AUTHOR sections in pod

%perl expr \( 1 \+ 1 \) \* 200
400
%perl expr "true" '&' ''
0
%perl expr 0 '|' 'true'
true
%perl expr 2 '*' 3 '+' 4
10
%perl expr 2 '+' 3 '*' 4
14
%perl expr "hotel" \: "ho"
2
%perl expr "hotel" \: "tel" # no match: regex is implicitly tied to start of string
0
@mknos mknos temporarily deployed to automated_testing December 17, 2024 09:10 — with GitHub Actions Inactive
@github-actions github-actions bot added Type: enhancement improve a feature that already exists Priority: low get to this whenever labels Dec 17, 2024
@mknos mknos temporarily deployed to automated_testing December 17, 2024 09:10 — with GitHub Actions Inactive
@github-actions github-actions bot added the Program: expr The expr program label Dec 17, 2024
@mknos mknos temporarily deployed to automated_testing December 17, 2024 09:10 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing December 17, 2024 09:10 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing December 17, 2024 09:10 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing December 17, 2024 09:10 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing December 17, 2024 09:10 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing December 17, 2024 09:10 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing December 17, 2024 09:10 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing December 17, 2024 09:10 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing December 17, 2024 09:10 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing December 17, 2024 09:10 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing December 17, 2024 09:10 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing December 17, 2024 09:10 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing December 17, 2024 09:10 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing December 17, 2024 09:10 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing December 17, 2024 09:10 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing December 17, 2024 09:10 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing December 17, 2024 09:10 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing December 17, 2024 09:10 — with GitHub Actions Inactive
@coveralls
Copy link

coveralls commented Dec 17, 2024

Pull Request Test Coverage Report for Build 12379350747

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.7%) to 72.464%

Totals Coverage Status
Change from base Build 12366204341: -0.7%
Covered Lines: 350
Relevant Lines: 483

💛 - Coveralls

Michael Mikonos is responsible for a significant portion of the code so he gets credit too.
@briandfoy briandfoy temporarily deployed to automated_testing December 17, 2024 18:41 — with GitHub Actions Inactive
@briandfoy briandfoy temporarily deployed to automated_testing December 17, 2024 18:41 — with GitHub Actions Inactive
@briandfoy briandfoy temporarily deployed to automated_testing December 17, 2024 18:41 — with GitHub Actions Inactive
@briandfoy briandfoy temporarily deployed to automated_testing December 17, 2024 18:41 — with GitHub Actions Inactive
@briandfoy briandfoy temporarily deployed to automated_testing December 17, 2024 18:41 — with GitHub Actions Inactive
@briandfoy briandfoy temporarily deployed to automated_testing December 17, 2024 18:41 — with GitHub Actions Inactive
@briandfoy briandfoy temporarily deployed to automated_testing December 17, 2024 18:41 — with GitHub Actions Inactive
@briandfoy briandfoy temporarily deployed to automated_testing December 17, 2024 18:41 — with GitHub Actions Inactive
@briandfoy briandfoy temporarily deployed to automated_testing December 17, 2024 18:41 — with GitHub Actions Inactive
@briandfoy briandfoy temporarily deployed to automated_testing December 17, 2024 18:41 — with GitHub Actions Inactive
@briandfoy briandfoy merged commit c878ba0 into briandfoy:master Dec 17, 2024
20 of 21 checks passed
@briandfoy briandfoy self-assigned this Dec 17, 2024
@briandfoy briandfoy added Status: accepted The fix is accepted Type: modernization updating programs to current practices and removed Type: enhancement improve a feature that already exists Priority: low get to this whenever labels Dec 17, 2024
@briandfoy briandfoy added Status: released there is a new release with this fix and removed Status: accepted The fix is accepted labels Feb 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Program: expr The expr program Status: released there is a new release with this fix Type: modernization updating programs to current practices
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants