-
-
Notifications
You must be signed in to change notification settings - Fork 174
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 float syntax rules and formatting #756
Update float syntax rules and formatting #756
Conversation
The best idea would be to take the Godot source as a reference, but sadly it's difficult to interpret the tokenizer code into a regex. But looking at the error messages, it disallows multiple adjacent You should probably replace all I tried to come up with one taking GDShader as a base and modifying it. I think these regexes work for float literals:
You can inspect and test them here (both are joined with a Note that I didn't include word boundaries, as I suppose you already have them around all identifiers and keywords. If you use this, remember to do a similar replacement also on the integer literals (binary, decimal and hex) to disallow consecutive
|
@AlfishSoftware Great info, thanks!
Very cool, I've always tried to stick to very basic regex to hopefully avoid implementation specific details, but you've convinced me to actually read the Oniguruma docs.
I'm conflicted about this because, imo, the goal of the textmate grammar is not to strictly enforce the language/interpreter rules. The exact language rules aren't formally specified, and that's a moving target, and I'm not abandoning support to Godot 3-specific syntax. Therefore, the grammar's target must be the union of all the valid syntax of all versions of Godot 3, all versions of Godot 4, plus some margin to allow for mistakes. It's also intended to be used in conjunction with the Godot LSP, which will yell about consecutive underscores anyways: |
Ah, you're completely right. I didn't test it in Godot 3 at all, just assumed it was the same. Plus, there's no harm in allowing adjacent underscores as it doesn't conflict with any other syntax. The
You're right, that's actually a good idea, as there's stuff like porting to GitHub syntax, etc. IIRC, there's not that much difference in Oniguruma; what stands out to me is mostly |
There's no harm in allowing it (and the LSP will raise an error anyway), but just in case you missed it, I think it's also matching cases with just |
Per @AlfishSoftware's feedback or #746, this PR removes the float literal rule I copied from the MagicPython grammar and (hopefully!) fixes the existing float rules.