SpartanJ / ecode

Lightweight multi-platform code editor designed for modern hardware with a focus on responsiveness and performance.
MIT License
908 stars 13 forks source link

FR: syntax highlighting for Modula-2 and Modula-3 #251

Open ghost opened 4 months ago

ghost commented 4 months ago

List of text editors support Modula-3:

https://github.com/modula3/cm3/discussions/1130

Scintillua lexers for Modula-2 and Modula-3:

https://github.com/paaguti/textadept-modula-lexers

ghost commented 4 months ago

I'm unable to make the lexers myself. Waiting for the developer.

SpartanJ commented 4 months ago

You're confusing me. You deleted your comments (try not to because it's hard to follow), but I have the notifications so let me answer: if it's not possible with Lua Patterns it will be probably possible with with a regex. I don't see anything particularly impossible with Lua Patterns there though, only that some will require more than one pattern to be solvable.

ghost commented 4 months ago

You're confusing me. You deleted your comments (try not to because it's hard to follow), but I have the notifications so let me answer: if it's not possible with Lua Patterns it will be probably possible with with a regex. I don't see anything particularly impossible with Lua Patterns there though, only that some will require more than one pattern to be solvable.

I'm confused, too. I don't know what I'm doing. I open/close this issue and post/delete comments like crazy.

ghost commented 4 months ago

Modula-2 weirdness:

The numerical literals part, you might be read the document wrong.

Numbers are (unsigned) integers or real numbers. Integers are sequences of digits. If the number is followed by the letter B, it is taken as an octal number; if it is followed by the letter H, it is taken as a hexadecimal number; if it is followed by the letter C, it denotes the character with the given (octal) ordinal number (and is of type CHAR).

https://www.modula2.org/reference/vocabulary.php

Taken from your code: local modula_octal = R("07")^1*R("BC")

Please pardon me as I don't understand Lua, but only with either B or C is enough for it to be an octal number, not needed to be both BC. In case it has both B, C and H then it will be a hex number.

Note: please notice on the examples on the document, B and C will never go together unless they are also go with H. I don't understand EBNF, but I think | is or so it's B or C not B and C.

(source: https://github.com/paaguti/textadept-modula-lexers/issues/2)

Modula-3 weirdness:

http://modula3.github.io/cm3/reference/complete/html/2_6_4Numeric_literals.html

SpartanJ commented 4 months ago

Something ending optionally with B or C in Lua Patterns is as simple as [BC]?, for octal would be just [0-7]+[BC]?H?. I don't see anything particularly complicated.

ghost commented 4 months ago

Something ending optionally with B or C in Lua Patterns is as simple as [BC]?, for octal would be just [0-7]+[BC]?H?. I don't see anything particularly complicated.

If all B, C, and H are available, then it's no longer an octal, as it's now a hex!

ghost commented 4 months ago

I still think Modula-3's syntax for numerical literals is weird until I know the syntax for numerical literals in Ada!

https://www.adacore.com/gems/ada-gem-7

SpartanJ commented 3 months ago

Sometimes you don't need to be 100% perfect but have a close enough implementation that doesn't have false-positives. Anyway, I have no idea about Modula-2 and 3 besides what I've seen because you mentioned, I think copying the scintillua implementation should be good enough for a niche language, if any Modula user feels the need to improve that implementation it can send a PR with improvements, that should be the spirit of open-source project.