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

Define digit in formal grammar #236

Merged
merged 1 commit into from
Feb 19, 2022
Merged

Define digit in formal grammar #236

merged 1 commit into from
Feb 19, 2022

Conversation

CAD97
Copy link
Contributor

@CAD97 CAD97 commented Oct 13, 2021

digit is used as a subtraction in bare-identifier, but never defined.


An alternate change:

decimal := integer ('.' digit digit_*)? exponent?
exponent := ('e' | 'E') integer
integer := sign? digit digit_*
digit := [0-9]
digit_ := [0-9_]
sign := '+' | '-'

(NOTE: this has now flip-flopped to opposite what it was when @tabatkins made their comment.)

I think I slightly prefer the PR'd version, but it changes the implied grammar tree structure more significantly. This change "just" gives names to the [0-9] and [0-9_] productions.

@tabatkins
Copy link
Contributor

Afaict both the PR and the alternate change are correct and produce no normative change beyond solving the original issue 👍

I actually slightly prefer the alternate change; I know that I initially missed that an exponent could have a sign when I was implementing, and so I like being more explicit with where exactly a sign is allowed in a number. It also avoids defining a digit_, which I slightly prefer.

`digit` is used as a subtraction in bare-identifier, but never defined.
@CAD97
Copy link
Contributor Author

CAD97 commented Oct 20, 2021

Swapped in the preferred change instead of the less desirable minimal one

integer := sign? [0-9] [0-9_]*
decimal := sign? integer ('.' integer)? exponent?
exponent := ('e' | 'E') sign? integer
integer := digit (digit | '_')*
Copy link
Member

Choose a reason for hiding this comment

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

can we call this something other than integer? decimal-component or something?

@zkat zkat merged commit 8976e2d into kdl-org:main Feb 19, 2022
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