Syntax Highlighting for ASL (ACPI)

本文分享了如何为ACPI源语言(ASL)代码配置语法高亮,包括在SlickEdit和Notepad++等编辑器中的具体设置,并提供下载链接以方便读者快速应用。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Syntax Highlighting for ASL (ACPI)

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?

From Wikipedia:

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:

Before:

image

After:

image

 

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.”

 

Spec Revision

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)

 

Download

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.

 

SlickEdit .zip:

https://github.com/WilliamLeara/BasicInputOutput/blob/master/SyntaxHighlight/SlickEditAcpiOptions20.zip

 

Notepad++ XML:

https://github.com/WilliamLeara/BasicInputOutput/blob/master/SyntaxHighlight/asl.xml

 

Token Files (Editor-Agnostic)

https://github.com/WilliamLeara/BasicInputOutput/tree/master/SyntaxHighlight/tokens/asl

 

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:

http://www.basicinputoutput.com/2015/05/syntax-highlighting-for-edkii-files-dec.html

 

Did you find syntax highlighting for ASL helpful?  Leave a comment, thanks!



Reprinted from:

http://www.basicinputoutput.com/2016/07/syntax-highlighting-for-asl-acpi.html


backup notepad++ use file

https://download.youkuaiyun.com/download/mini92/10343953

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值