Go API Reference

The reference of the public Go API, generated from the source of this version of SyntaxIR. The reference of released versions is also on pkg.go.dev.

PackageSynopsis
syntaxir.dev/sxir/pkg/compilerPackage compiler makes executable artifacts from SyntaxIR grammars: parsers that run on the bytecode VM (Compile, CompileGrammar), the reference parser that differential tests compare with (NewReferenceParser), compiled grammar files (Marshal), Go and TypeScript parser source (GenerateGo, GenerateTypeScript) and output schemas (OutputSchema).
syntaxir.dev/sxir/pkg/runtimePackage runtime defines what a parse runs under and reports that every SyntaxIR parser shares: the limits of a parse and its limit errors, the stream iterator, and the statistics of a Document.
syntaxir.dev/sxir/pkg/runtime/vmPackage vm runs grammars compiled to bytecode on the SyntaxIR virtual machine.
syntaxir.dev/sxir/pkg/runtime/inputPackage input defines how a parse sees its input: the position unit of offsets, source locations, the text edits of a Document and the kinds of its change notifications.
syntaxir.dev/sxir/pkg/runtime/valuePackage value defines the values a parse produces: nodes with their kinds, fields and JSON form, traversal and cursors, and syntax errors, including the errors that recovery records in the tree.
syntaxir.dev/sxir/pkg/runtime/instrumentPackage instrument defines the observation of a parse: trace events of rule calls, their call sites, and profiles that aggregate them.
syntaxir.dev/sxir/pkg/grammarPackage grammar loads, validates, formats and converts SyntaxIR grammars.
syntaxir.dev/sxir/pkg/grammar/astPackage ast defines the abstract syntax tree (AST) of SyntaxIR grammars.
syntaxir.dev/sxir/pkg/runtime/value/implPackage valueimpl is the implementation of value.Node that the runtime packages, the engine and the generated Go parsers share: the node data, its kinds and fields, and the code that builds and reads them.
syntaxir.dev/sxir/pkg/runtime/libgoPackage libgo is the library of Go parsers generated by sxir gen.
syntaxir.dev/sxir/pkg/bytecodePackage bytecode defines the module that a SyntaxIR grammar compiles to, which the bytecode VM runs, and its compiled-file format: the tables of a module (Module and the Info types), Flow bodies (Flow) and their instruction set (FlowOp, FlowInstr), action code (Action), the encoding of the compiled-file format (Encoder, Decoder, WriteModule, ReadModule, FileMagic) and the load-time validation of a module (ValidateModule).
syntaxir.dev/sxir/pkg/lintPackage lint reports likely mistakes in SyntaxIR grammars: rules and alternatives that can never match, expressions that have no effect, captures that are never read, and grammar shapes that defeat incremental parsing.
syntaxir.dev/sxir/pkg/runtime/schemaPackage schema describes the values a grammar can produce, independently of a parse: the output schema that runtime.Parser.OutputSchema exports, its JSON form and its validation, and Compare, which reports how two schemas differ.
syntaxir.dev/sxir/pkg/runtime/queryPackage query matches structural patterns against parse results.
syntaxir.dev/sxir/pkg/samplePackage sample generates inputs that a grammar accepts, for testing code that consumes parse results and for seeding fuzz tests.
syntaxir.dev/sxir/pkg/editfuzzPackage editfuzz checks incremental parsing with a grammar against fresh parses by applying sequences of edits to a Document, and saves a failing sequence as a file that replays it exactly.

For the command-line tool, see the CLI Reference.