Add lexer support for complex literals.#594
Conversation
They are part of the current C2y ISO draft (included by N3298 [1]). [1] https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3298.htm
| _bad_string_literal = '"' + _string_char + "*" + _bad_escape + _string_char + '*"' | ||
|
|
||
| # floating constants (K&R2: A.2.5.3) | ||
| _floating_suffix_opt = r"([FfLl][iIjJ]?|[iIjJ][FfLl]?)?" |
There was a problem hiding this comment.
Since we're following the standards now (rather than K&R2), could you ask you to follow the clauses listed in the linked doc?
I.e. break it to floating-suffix, real-floating-suffix, complex-suffix, etc.
There was a problem hiding this comment.
Does this apply to whole floating-literal, or just floating-suffix?
There was a problem hiding this comment.
I’m unsure whether and how to change the comment “# floating constants (K&R2: A.2.5.3)” in this case.
Another issue: The aforementioned standard also contains decimal literals (suffixes df, dd, dl, DF, DD, DL; orthogonal to complex suffixes). They were added to C23, i.e. before complex literals.
If following standards, it would be consistent to support them in the lexer as well. This could be introduced in the same or a separate commit. Alternatively, I can use the names of the clauses from the standards but omit the decimal suffixes for now.
There was a problem hiding this comment.
I’m unsure whether and how to change the comment “# floating constants (K&R2: A.2.5.3)” in this case.
Feel free to omit it or point to the new draft PDF. Unfortunately the link to open-std.org almost always fails to open in my browser; are you aware of an alternative place where we can point?
Another issue: The aforementioned standard also contains decimal literals (suffixes df, dd, dl, DF, DD, DL; orthogonal to complex suffixes). They were added to C23, i.e. before complex literals.
This can be done in either the same PR or a separate PR, whatever you feel is right. My only request is that each PR on its own is self-contained.
They are part of the current C2y ISO draft (included by N3298 [1]).
[1] https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3298.htm