Skip to content
| Marketplace
Sign in
Visual Studio Code>Programming Languages>Dzx ASL FormatNew to Visual Studio Code? Get it now.
Dzx ASL Format

Dzx ASL Format

DazhaoXu

| (0) | Free
Dzx formatter for ACPI Source Language (ASL) files.
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

Dzx ASL Format

Dzx ASL Format 是用于 ACPI Source Language(ASL)的 VS Code 文档格式化扩展。 它注册 .asl、.dsl、.dslx 和 .acpi 文件,并支持 VS Code 的 Format Document、 Format on Save 以及命令面板中的 ASL Format: Format ASL Document。

格式规则

格式器以 ACPI Specification 6.6 第 19 章的 ASL 词法和语法为边界:() 是固定参数列表, {} 是可变子对象列表,逗号分隔列表;支持 ASL 2.0 的符号运算符。

ACPI 规范规定空白、逗号、圆括号和换行都是 token 分隔符,但没有规定唯一的排版风格。因此本扩展采用 规范示例及 ACPICA 工具常见的保守样式:

  • DefinitionBlock 的固定参数每行一个;
  • 每个 {} 块独占行,并按层级缩进;
  • 可变对象列表中的逗号后换行;普通固定参数列表使用 , ;
  • ASL 2.0 二元及赋值运算符两边空格,路径中的 . 不加空格;
  • #if、#ifdef、#ifndef、#elif、#else、#endif 始终顶格;
  • 原样保留字符串、名称大小写、数值、预处理指令和注释内容,不做语义转换或编译。

例如,格式化前:

DefinitionBlock("DSDT.aml","DSDT",2,"OEM","TABLE",0x1){Scope(\_SB){Device(PCI0){Name(_HID,EisaId("PNP0A08"))Method(_STA,0,NotSerialized){If(Arg0==Zero){Return(One)}Else{Return(Zero)}}}}}

格式化后:

DefinitionBlock (
    "DSDT.aml",
    "DSDT",
    2,
    "OEM",
    "TABLE",
    0x1
)
{
    Scope (\_SB)
    {
        Device (PCI0)
        {
            Name (_HID, EisaId ("PNP0A08"))
            Method (_STA, 0, NotSerialized)
            {
                If (Arg0 == Zero)
                {
                    Return (One)
                }
                Else
                {
                    Return (Zero)
                }
            }
        }
    }
}

设置

设置 默认值 说明
aslFormat.indentSize 2 每级缩进的列数(1–16)
aslFormat.insertSpaces true 使用空格;关闭时使用制表符
aslFormat.keepBlankLines true 在声明和注释组之间保留最多一个空行

条件编译块

将光标放在 #if、#ifdef、#ifndef、#elif、#else 或 #endif 上时,编辑器会高亮同一层级匹配的全部条件编译指令(嵌套块单独匹配)。 语言折叠也支持从 #if 到匹配的 #endif。

执行 ASL Format: Select Matching Preprocessor Block 可选中完整的 #if … #endif 块;默认快捷键为 Ctrl+Alt+Shift+](Windows/Linux)。

规范依据

  • ACPI Specification 6.6, Chapter 19 — ASL Reference
  • ACPI Specification 6.6, ASL Language Grammar (§19.2)

该扩展是格式化器,不是 iasl 的替代品;请继续用 ACPICA iasl 对固件交付物做语法、命名空间和 AML 编译验证。

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
  • Your Privacy Choices
  • Consumer Health Privacy
© 2026 Microsoft