npm.io
0.2.0 • Published 2 weeks ago

@nsis/parser

Licence
MIT
Version
0.2.0
Deps
0
Size
22 kB
Vulns
0
Weekly
0

@nsis/parser

Parser for NSIS scripts

License Version Build

Installation

npm install @nsis/parser

Usage

import { parse } from "@nsis/parser";

const nodes = parse(`
  Name "Demo"
  Section
    Nop
  SectionEnd
`);

Returns a flat array of CST nodes, one per logical line:

[
	{ type: "blank" },
	{ type: "instruction", keyword: "Name", args: ['"Demo"'] },
	{ type: "instruction", keyword: "Section", args: [] },
	{ type: "instruction", keyword: "Nop", args: [] },
	{ type: "instruction", keyword: "SectionEnd", args: [] },
	{ type: "blank" },
];
API
parse(input)

Parses NSIS source text into a flat list of CST nodes. Handles BOM stripping and line continuations automatically.

Throws SyntaxError if the input cannot be parsed.

Node Types
BlankNode
{
	type: "blank";
}
CommentNode
{ type: "comment", style: "hash" | "semicolon" | "block", value: string }
InstructionNode
{ type: "instruction", keyword: string, args: string[], comment?: Comment }
LabelNode
{ type: "label", name: string, comment?: Comment }

License

This work is licensed under The MIT License.

Keywords