skeeto / nasm-mode

Major mode for editing NASM assembly programs
The Unlicense
79 stars 17 forks source link

Automatically generated token lists available #14

Open hpax opened 1 year ago

hpax commented 1 year ago

Hi,

As you might know, I'm the NASM maintainer. I'm also a pretty avid Emacs user. I thought I might help by making it possible for the token lists to be automatically generated, so I added a Perl script to do so (misc/emacstbl.pl) and put it in the "emacs" branch of the main NASM repository, https://github.com/netwide-assembler/nasm.

It probably takes a bit of hacking to accept the output of this file, and I would certainly accept changes to the script as needed, but I would suggest using (require) to load this file separately from the actual code, to decouple it from maintaining your code.

I have attached a sample output. nasmtbl.el.txt

hpax commented 1 year ago

(Added .txt to the filename due to github drain bramage)

hpax commented 1 year ago

Tidied up the output slightly and added it to the Makefile system. The updated file is generated in misc/nasmtok.el. If this meets your needs, let me know, and I will add it to the official NASM release distribution.

nasmtok.el.txt

hpax commented 1 year ago

On top of the fixed token lists, I would suggest highlighting a keyword-like token of the form \\_<__\\s_+?__\\_> and %[[:alpha:]]\\w*?\\_> as being likely macros and preprocessor functions, respectively.

(I'm assuming here word = [[:alnum:]_] and symbol = [[:word:]$@.#~])

hpax commented 5 months ago

I should mention that this file has been included with the NASM distribution since 2.16.01, and as it is auto-generated, will continue to be included and valid. That being said, if you need changes to it then please go ahead and request.

8dcc commented 2 months ago

Hello, @hpax. Sorry for the late reply.

On top of the fixed token lists, I would suggest highlighting a keyword-like token of the form \\_<__\\s_+?__\\_> and %[[:alpha:]]\\w*?\\_> as being likely macros and preprocessor functions, respectively.

(I'm assuming here word = [[:alnum:]_] and symbol = [[:word:]$@.#~])

Could you check if this has been fixed in master? Specifically, since #15 and #17.

I should mention that this file has been included with the NASM distribution since 2.16.01, and as it is auto-generated, will continue to be included and valid. That being said, if you need changes to it then please go ahead and request.

I think it would be a good idea to use the file you are providing. If you can make a pull request with the necessary changes, I would be happy to merge them. This would also close #18.