chroma
chroma copied to clipboard
GAS highlighter is unable to recognize comments in code
Describe the bug I wanted to share some code in assembly, but I discovered Chroma's GAS highlighters failed to recognize the comments and marks them as syntax error.
Fixing this problem may not be easy, as far as I know, GNU as supports different comment styles on different platforms, sometimes the comment on one platform can be legitimate code on another platform.
Multiline comment aren't supported
In GNU as, multiline comments are supported on all platforms.
/* comment */
Chroma thinks it's a syntax error.
Hash symbols (#) comments are buggy
Hash symbols are used for inline comments on i386, x86-64, i960, 68HC11, 68HC12, VAX, V850, M32R, PowerPC, MIPS, M680x0, and RISC-V.
xor %eax, %eax # comment
xor %eax, %eax # comment
Chroma correctly highlights the first line, but it thinks the comment in the second line is a syntax error.
Care must be taken while trying to fix this issue, since some platforms may use the hash symbol to indicate an immediate value in assembly code. How to solve this problem? Should we use a separate file for it?
Semicolons (;) comments are buggy
Semicolon comments are used on AMD 29k family, ARC, H8/300 family, HPPA, PDP-11, picoJava, Motorola, and M32C. It has the same problem like the hash symbol.
"At" sign (@) inline comments are not supported
The at sign (@) comment is used on the ARM platform.
add r0, r2, r3 @ comment
Chroma thinks it's a syntax error. Care must be taken while trying to fix this issue, at least one platform (PDP-11, DEC syntax) uses it to indicate memory dereference in assembly code. How to solve this problem? Should we use a separate file for it?
Double slash (//) comments are not supported
Double slash (//) comments are used on the AArch64 platform.
// comment
Chroma thinks it's a syntax error.
Vertical bar (|) comment are not supported
Vertical bars are used on the Motorola 68000.
| comment
Chroma thinks it's a syntax error.
exclamation mark (!) comments are not supported
Exclamation marks are used on SuperH.
! comment
Chroma thinks it's a syntax error.
To Reproduce
- Copy all of the examples above in a Chroma previewer, like this one: https://swapoff.org/chroma/playground/
- Check the output.