Skip to content

Comments

syntax: asm: highlight C-like comments#3696

Merged
JoeKar merged 1 commit intomicro-editor:masterfrom
dmaluka:highlight-asm-c-like-comments
Mar 15, 2025
Merged

syntax: asm: highlight C-like comments#3696
JoeKar merged 1 commit intomicro-editor:masterfrom
dmaluka:highlight-asm-c-like-comments

Conversation

@dmaluka
Copy link
Collaborator

@dmaluka dmaluka commented Mar 13, 2025

Different assemblers have different syntaxes for comments: ;, #, !, |, @, * and finally C-like comments // and /* ... */.

Micro currently highlights only ;. This is causing various problems with broken highlighting with other types of comments (i.e. those not recognized by micro as comments), when the text in those comments contains special characters, causing wrong highlighting of text after them.

On the other hand, highlighting comments like #, | etc would cause conflicts with other syntax elements, e.g. constants in ARM assembly, preprocessor directives, arithmetic expressions etc.

So let's highlight at least C-like comments. They are quite commonly used and they are not so likely to cause conflicts with other syntax elements.

See also discussion in #3694.

@JoeKar
Copy link
Member

JoeKar commented Mar 14, 2025

Then we should remove the following line too, or?
https://github.com/zyedidia/micro/blob/f712cdacccd0ef5abb2d1ed6330ffb2daef5f5f6/runtime/syntax/asm.yaml#L7

Because these comments aren't any longer NASM compliant.

@dmaluka
Copy link
Collaborator Author

dmaluka commented Mar 14, 2025

Indeed. Haven't noticed this comment.

Although... this comment is about the overall syntax, not just about comments?

Different assemblers have different syntaxes for comments: ";", "#",
"!", "|", "@", "*" and finally C-like comments "//" and "/* ... */".

Micro currently highlights only ";". This is causing various problems
with broken highlighting with other types of comments (i.e. those not
recognized by micro as comments), when the text in those comments
contains special characters, causing wrong highlighting of text after
them.

On the other hand, highlighting comments like "#", "|" etc would cause
conflicts with other syntax elements, e.g. constants in ARM assembly,
preprocessor directives, arithmetic expressions etc.

So let's highlight at least C-like comments. They are quite commonly
used and they are not so likely to cause conflicts with other syntax
elements.
@dmaluka dmaluka force-pushed the highlight-asm-c-like-comments branch from f712cda to ca81a2f Compare March 14, 2025 21:50
@JoeKar
Copy link
Member

JoeKar commented Mar 15, 2025

Although... this comment is about the overall syntax, not just about comments?

Yep, it's about the overall rules inside this definition.
Your adaptation of the comment is good enough.

@JoeKar JoeKar merged commit 0b75031 into micro-editor:master Mar 15, 2025
6 checks passed
theredcmdcraft pushed a commit to theredcmdcraft/micro that referenced this pull request May 27, 2025
Different assemblers have different syntaxes for comments: ";", "#",
"!", "|", "@", "*" and finally C-like comments "//" and "/* ... */".

Micro currently highlights only ";". This is causing various problems
with broken highlighting with other types of comments (i.e. those not
recognized by micro as comments), when the text in those comments
contains special characters, causing wrong highlighting of text after
them.

On the other hand, highlighting comments like "#", "|" etc would cause
conflicts with other syntax elements, e.g. constants in ARM assembly,
preprocessor directives, arithmetic expressions etc.

So let's highlight at least C-like comments. They are quite commonly
used and they are not so likely to cause conflicts with other syntax
elements.
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