I’ve been writing some ACPI Source Language (ASL) code for a project recently, and so I went through the exercise of configuring syntax highlighting for my text editor. I share my configuration below, for the SlickEdit and Notepad++ text editors, and offer a head-start in configuring any other text editor.
What is Syntax Highlighting?
Syntax highlighting is a feature of text editors that are used for programming, scripting, or markup languages, such as HTML. The feature displays text, especially source code, in different colors and fonts according to the category of terms. This feature facilitates writing in a structured language such as a programming language or a markup language as both structures and syntax errors are visually distinct. Highlighting does not affect the meaning of the text itself; it is intended only for human readers.
I love syntax highlighting, and can’t live without it. Here’s a before and after screenshot of the file Tpm.asl from the EDK:
The color helps your eye to quickly pick apart the various tokens that make up ASL: keywords, operators, library symbols, etc. The coloring alerts you to possible errors before you commit your work because the code may not “look quite right.”
I used ACPI Spec v6.1 to gather the various ASL tokens into meaningful categories in order to generate the syntax highlighting; mainly §19 of the Spec. It is NOT an exact science—also, I find that SlickEdit has much better support for this type of thing than Notepad++ does. If you can improve upon what I did, please do! Everything’s on Github. (see below)
Unfortunately, every text editor has its own way of handling syntax highlighting. I’ve included a .zip file for my text editor, SlickEdit. If you use SlickEdit, (I use v20) you can simply click:
Tools/Options/Export-Import Options/Import Options
… and direct the dialog to the .zip file.
Realizing that Notepad++ is popular, I also configured it for ASL and saved the configuration as an .XML file. If you use Notepad++, click:
Language/Define Your Language…/Import
… and direct the dialog to the .xml file. Notepad++’s user defined language facility has some rough edges, but I did the best I could.
Lastly, if you use another text editor, you can download the text files I created to break down all the different keywords/reserved words into six different groupings. Then, use your text editor’s facility for inputting these word tokens.
Token Files (Editor-Agnostic)
Finally, awhile back I went through a similar exercise for all the various little languages that make up the EDK: .dec, .dsc, .fdf, .inf, .uni, and .vfr. You may find that post useful:
Did you find syntax highlighting for ASL helpful? Leave a comment, thanks!