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

improve number highlighting for c #1752

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

thacuber2a03
Copy link
Contributor

  • don't highlight improper usage of unsigned and float suffixes
  • highlight octal literals' trailing 0 at the beginning (seriously why the designers of the language thought prefixing an octal literal with 0 would be a good idea)

in an off-topic note, why is language_c not in the plugins repo, and how long has it been since it was removed from there?

@takase1121 takase1121 added this to PR in Bugfix Release Tracker via automation Mar 23, 2024
@takase1121 takase1121 moved this from PR to Freeze in Bugfix Release Tracker Mar 25, 2024
Copy link
Member

@takase1121 takase1121 left a comment

Choose a reason for hiding this comment

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

Doesn't seem to support the l and ll suffix?

https://en.cppreference.com/w/c/language/integer_constant

@thacuber2a03
Copy link
Contributor Author

whoops, I'll fix that rq

@@ -1,6 +1,11 @@
-- mod-version:3
local syntax = require "core.syntax"

-- integer suffix combinations as a regex
local isuf = [[(?:[lL][uU]|ll[uU]|LL[uU]|[uU][lL]\b|[uU]ll|[uU]LL|[uU]|[lL]\b|ll|LL)?]]
Copy link
Member

Choose a reason for hiding this comment

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

You can probably simplify this by enabling case insensitiveness with like (?i:this IS case INSENSITIVE).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

for some odd reason, the two Ls in long long have to have the same case for the literal to be valid

Copy link
Member

Choose a reason for hiding this comment

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

if it can't be fixed easily, let's just keep this as is.

Copy link
Member

Choose a reason for hiding this comment

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

What about the \b? Why is it needed only in some cases?

Copy link
Member

Choose a reason for hiding this comment

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

@thacuber2a03 can you answer this question? I will merge if this conversation is resolved.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oh, yeah, sorry
about the \b, I have it there to avoid having an l alongside another one with a different case be highlighted
which, honestly, I think it's overkill, but compilers actually don't compile programs with stuff like UlL or Ll

Copy link
Contributor Author

Choose a reason for hiding this comment

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

in whatever case, I'm not sure whether I care that much anymore, so you can merge with or without that big ass regex

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@takase1121 almost forgot the mention

@takase1121
Copy link
Member

Any updates on this PR?

@thacuber2a03
Copy link
Contributor Author

no, as far as I'm concerned, it's done

jgmdev pushed a commit to pragtical/pragtical that referenced this pull request Jun 13, 2024
* add unsigned suffix
* add long suffixes
* reorder octal literals and add suffix for hex numbers
* fix integer and float suffixes too many characters, send help
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

Successfully merging this pull request may close these issues.

None yet

3 participants