Skip to content

Conversation

@Timmmm
Copy link

@Timmmm Timmmm commented Jul 15, 2025

This adds a basic lexer for RISC-V assembly. Like all assembly (as far as I know) there isn't really a formal grammar, and compilers just kind of do whatever, so this is a best effort. There may be valid assembly it does not highlight properly.

I have tested it on several random samples from the internet and it seems to be ok though.

The included demo is from the RISC-V ISA manual: https://riscv-specs.timhutt.co.uk/spec/20240411/unpriv-isa-asciidoc.html#_sgemm_example

@Timmmm
Copy link
Author

Timmmm commented Jul 15, 2025

One thing I wasn't quite sure about - there's armasm which claims .s files, but they can also be RISC-V assembly (or any kind of assembly). Is it ok to have multiple lexers claiming the same extension? I saw one part of the docs saying this is for when the extension unambiguously identifies the language which isn't the case here.

Also more testing & suggestions very welcome!

Tim Hutt added 2 commits July 28, 2025 11:00
This adds a basic lexer for RISC-V assembly. Like all assembly (as far as I know) there isn't really a formal grammar, and compilers just kind of do whatever, so this is a best effort. There may be valid assembly it does not highlight properly.

I have tested it on several random samples from the internet and it seems to be ok though.

The included demo is from the RISC-V ISA manual: https://riscv-specs.timhutt.co.uk/spec/20240411/unpriv-isa-asciidoc.html#_sgemm_example
Sets are the preferred method. I also reorganised the states a bit to make things work slightly more nicely (e.g. it highlights registers in preprocessor definitions).
@Timmmm
Copy link
Author

Timmmm commented Oct 7, 2025

@tancnle any chance you could review this?

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