Improve rule for decimal numbers in grammar.txt#3173
Conversation
docs/grammar.txt
Outdated
|
|
||
| HexNumber = '0x' [0-9a-fA-F]+ | ||
| DecimalNumber = [0-9]+ | ||
| DecimalNumber = [0-9]+ ( '.' [0-9]+ )? ( [eE] [0-9]+ )? |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Hmm... hadn't noticed that. Fixed the grammar.
e48a3e7 to
f09ea6d
Compare
|
@axic updated. |
f09ea6d to
58a0f09
Compare
No description provided.