Expand description
Source-preserving syntax for MiniZinc 2.10.1.
Lexing retains trivia and erroneous input. It does not check model or data
grammar, resolve names, or evaluate literals. Interpolated strings retain
literal chunks and embedded expression tokens in the same source buffer.
Parsing supports scalar and ordinary collection declarations, domains,
indexed and matrix literals, dependent indices, cardinalities, array access,
operator expressions, calls, interpolated strings, annotations, constraints
with optional string labels, comprehensions, generator calls, conditional and let
expressions, callable/annotation declarations with generic types and parameter
defaults, enums and constructors, type aliases and type-inst concatenation,
includes, output items and all solve modes.
Compiler-supported extensions include deprecated function declarations without
function, anonymous _(expression) constructors in assignments, identifier
equality items without constraint, and predicate ann: name capture bindings.
These retain their written tokens and expose ordinary callable, call and
constraint nodes, plus a distinct annotation-capture binding in the signature.
Tuple/record types and literals and chained field access share the CST.
Data mode accepts only top-level assignments. Reserved variant_record/case
syntax remains unsupported.
Modules§
- inputs
- Read-only input discovery shared by the formatter and linter.
Structs§
- Byte
Parsed File - Exact source bytes and their syntax, with a separate UTF-8 analysis view.
- Diagnostic
- A lexical/parser error or an explicitly unsupported syntax form.
- Lexed
Source - Source text and its tokens. Read-only access keeps their ranges valid.
- Parsed
File - Owned source, its lossless tree, and lexical/parser diagnostics.
- Syntax
Node - A node’s children retain source order. Each token occurs in exactly one leaf.
- Token
- A source spelling is available by slicing the source with this byte range.
Enums§
- File
Mode - The syntax permitted at the top level of a source file.
- Node
Kind - Syntax
Element - Token
Kind - Lexical distinctions for a parser. Unicode operators share their ASCII equivalent’s kind; spelling is always retained in the source.
Functions§
- byte_
line_ column - Return one-based line and column at an original byte boundary. Valid UTF-8 scalars and invalid bytes each occupy one column; CRLF is one break. Panics for an out-of-range offset or one inside a valid UTF-8 scalar.
- is_
utf8_ boundary - Return whether an original-byte offset avoids splitting a valid UTF-8 scalar. Each invalid byte is a boundary; offsets beyond the source are not boundaries.
- lex
- Tokenize an owned UTF-8 source, retaining every byte in source order.
- lexical_
protected_ ranges - Validate the complete source and return byte ranges of comments and string chunks, including interpolated literals, without retaining every token. Expressions inside interpolation remain editable. Lexical errors, including unterminated interpolation at EOF, reject the complete result.
- literal_
include_ path - Decode a literal include path as bytes without loading files or evaluating interpolations. Unsupported paths return None; source spelling is untouched.
- parse
- Parse the supported model subset, retaining all tokens even after an error.
- parse_
bytes - Parse model bytes, accepting invalid UTF-8 only inside comments. Syntax errors remain in the analysis file’s diagnostics. Unsupported byte input returns a diagnostic at its original byte range.
- parse_
bytes_ with_ mode - Parse model or assignment-only data bytes without resolving includes. All ranges refer to the supplied bytes; a BOM is not stripped automatically.
- parse_
with_ mode - Parse model syntax or assignment-only data syntax without resolving names. Calls in data expressions are retained: determining whether an operation is user-defined requires the model and is outside syntax checking.