Skip to content

Improve rule for decimal numbers in grammar.txt#3173

Merged
axic merged 1 commit intoargotorg:developfrom
federicobond:improve-number-grammar
Nov 16, 2017
Merged

Improve rule for decimal numbers in grammar.txt#3173
axic merged 1 commit intoargotorg:developfrom
federicobond:improve-number-grammar

Conversation

@federicobond
Copy link
Copy Markdown
Contributor

No description provided.

docs/grammar.txt Outdated

HexNumber = '0x' [0-9a-fA-F]+
DecimalNumber = [0-9]+
DecimalNumber = [0-9]+ ( '.' [0-9]+ )? ( [eE] [0-9]+ )?
Copy link
Copy Markdown
Contributor

@axic axic Nov 15, 2017

Choose a reason for hiding this comment

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

This is used in describing the fixed point type (see Fixed and Ufixed) so perhaps one of them should be using a different rule.

Alternatively we could remove the elevated role of built in types and just consider everything a user type in the grammar.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good catch! For now, I will change Fixed and Ufixed to use a plain [0-9]+. Then we can discuss removing built-in types. The problem with that is that parsers will be unable to distinguish UserDefinedTypeNames and will also accept built-in types as identifiers.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Just wondering if we need DecimalNumber and HexNumber as a different rule since it is only used within NumberLiteral? Though we can argue about that in a separate PR.

The problem with that is that parsers will be unable to distinguish UserDefinedTypeNames and will also accept built-in types as identifiers.

That's true, though not sure if that must be handled within the parser or the semantics. So far we tried to handle a lot in the grammar.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Another remark: 1. and 1.e10 are valid according to the compiler, the grammar should reflect that. We can start a separate discussion to argue whether that is good or bad if needed.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Hmm... hadn't noticed that. Fixed the grammar.

@federicobond federicobond force-pushed the improve-number-grammar branch from e48a3e7 to f09ea6d Compare November 15, 2017 17:57
@federicobond
Copy link
Copy Markdown
Contributor Author

@axic updated.

@axic axic merged commit 58e452d into argotorg:develop Nov 16, 2017
@federicobond federicobond deleted the improve-number-grammar branch November 16, 2017 14:58
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