orbitalquark / scintillua

Scintillua enables Scintilla lexers to be written in Lua, particularly using LPeg. It can also be used as a standalone Lua library for syntax highlighting support.
https://orbitalquark.github.io/scintillua
MIT License
51 stars 20 forks source link

migrate matlab lexer #102

Closed rnpnr closed 12 months ago

rnpnr commented 1 year ago

Sorry I didn't see that builtins (functions and constants) should be split up. I will do that later when I have a chance.

rnpnr commented 12 months ago

I split up the functions and variables as recommend in the upgrade legacy lexers issue. This should be good to go now.

The only problem is that MATLAB is terrible language where variables are indexed in the same way functions are called. Without language introspection you can only correctly lex one or the other. So you can keep it as I have it now and incorrectly lex variables or drop detection for normal functions and only detect methods and builtin functions.

orbitalquark commented 12 months ago

Thanks for this! I've dropped tagging of normal functions (and also methods for the sake of consistency) because tagging variables incorrectly feels wrong. I also added a separate rule for built-in constants like pi.

https://github.com/orbitalquark/scintillua/commit/b997a41a9b9f2ed27706e9e79be85db828b5c428 and https://github.com/orbitalquark/scintillua/commit/46f53f4f203d091fe0bff2e8383403abc2692c51

rnpnr commented 12 months ago

I also added a separate rule for built-in constants like pi.

Its fine but they are technically variables not constants. You can reassign values to them. As far as I know there are no constants in MATLAB.

orbitalquark commented 12 months ago

It's the same with Lua, but marking them as constants hopefully encourages good behavior :)