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

update Lexer to use Errors and add some support for C23 stuffs #489

Merged
merged 26 commits into from
Feb 28, 2024

Conversation

NiumXp
Copy link
Contributor

@NiumXp NiumXp commented Feb 12, 2024

On progress

  • Add to support others prefixes for chars/strings like u and u8
  • (Maybe) Add to support ' (sigle quote) to separate integers digits
  • Add extensive tests about new lexer methods
    • Add preprocessors tokens tests
    • Add float (hexadecimal, etc.) tests
  • Remove or replace cast calls to # type: ignore
  • Remove assert statements

Errors instead of Exceptions

I removed all exceptions from Lexer (I'm yet adding tests to make it no error-prone) and added Errors instead, it will show more user-friendly error messages to users (and highlights soon). We don't need to stop the norminette when a float is correct in syntax but not in semantics (I added 8 errors about floats/integers).

Alternative lexemes

Norminette will do some translations like <% and ??< to LBRACE ({). Note that strings with digraphs and trigraphs will be translated as well like #486 did in comments.

Escaped newline

This PRs is removing the <ESCAPED_NEWLINE> token, it means that codes using it will be buggy, like CheckLineCount (I pretend to fix it with others rules in a separated PR).

Chars as Strings, Escape sequences

If the user writes a string with ' (single quote) like 'hello', it will see an error noticing it. Another cool thing is about writing bad escape sequences like \m, \xGG, etc. that will shows an error.

Suffix in numeric literals

Added i64 (Microsoft-specific), wb (_BigInt(N)) and z (size_t) suffixes for integer literals and for float literals: d* (_DecimalN) and i with j for complex literals (_Complex).

Others

  • Moved tests related to lexer to test_lexer.py
  • Removed the TokenError exception completly

- add variable annotation for 'name' field in '_formatter' class
- fix runtime type checking in '__init__' of '_formatter' class
- fix wrong type in 'json.dumps' calls that use 'separators' parameter
  with a string
- add 'add_error' method in 'Errors' class
- add to repr of 'Errors' be the same than the inner list
- add 'add_highlight' method in 'Error' dataclass
@NiumXp NiumXp marked this pull request as ready for review February 13, 2024 23:40
@matthieu42Network
Copy link
Contributor

Hello, I didn't review because of the 6/7 validated but is it over?

@NiumXp
Copy link
Contributor Author

NiumXp commented Feb 26, 2024

Hello, I didn't review because of the 6/7 validated but is it over?

Yes, it is

@matthieu42Network matthieu42Network merged commit a9e1a3d into 42School:master Feb 28, 2024
4 checks passed
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.

2 participants