Languages¶
Every target language is a class in literalizer.languages.
You import the class, optionally configure it, and pass an instance to literalize().
Selecting a language¶
Each language class lives in literalizer.languages and is listed in ALL_LANGUAGES.
Create an instance with its defaults, or override individual format options:
"""Select and configure a language."""
from literalizer import InputFormat, literalize
from literalizer.languages import Python
# Use all defaults
result = literalize(
source='{"x": 1}',
input_format=InputFormat.JSON,
language=Python(),
)
# Override specific formats
result = literalize(
source='{"x": 1}',
input_format=InputFormat.JSON,
language=Python(
sequence_format=Python.sequence_formats.LIST,
string_format=Python.string_formats.SINGLE,
trailing_comma=Python.trailing_commas.NO,
),
)
Format options¶
Language classes define nested Enum classes that control how each data type is rendered.
The available enums vary by language, but the most common ones are:
Enum |
Controls |
|---|---|
|
How |
|
How |
|
Bytes encoding (hex, base64, or language-native). |
|
Collection type for lists (e.g. |
|
Collection type for sets (e.g. |
|
Map type (e.g. |
|
Quote style ( |
|
Numeric base ( |
|
Float rendering ( |
|
Comment syntax ( |
|
Variable declaration keyword ( |
|
Whether to emit a trailing comma in multi-line collections. |
|
Statement terminator ( |
Access a language’s enum members through the class itself, e.g. Go.sequence_formats.SLICE for Go slices or Go.date_formats.GO for the time.Date(...) constructor.
Each __init__ parameter has a sensible default, so you only need to specify the options you want to change.
Float emission scope¶
literalizer emits a syntactically valid source literal for any finite IEEE 754 double the target language accepts.
Scientific-notation output always uses a dotted mantissa (1.0e+16 rather than 1e+16) so the result parses as a float in languages whose grammars reject a bare integer mantissa (Ada, Cobol, Elixir, Erlang, Gleam, Nix, YAML).
Gleam additionally strips the + from positive exponents because its parser rejects the explicit sign; other languages keep the + because YAML’s resolver regex requires it to recognize the literal as a float.
Whether a round-trip through a target ecosystem’s JSON encoder preserves edge values such as DBL_MAX is governed by that ecosystem’s encoder (precision, integer-vs-float rendering, Inf coercion) and is out of scope for the formatter.
Special floats (inf / nan) follow each language’s supports_special_floats policy; targets that have no expression for them (e.g. Gleam’s Erlang target) raise UnrepresentableSpecialFloatError.
Heterogeneous values¶
When the input data mixes value types that the target language’s natural collection type cannot hold, a heterogeneous_strategy constructor argument controls the outcome.
Every language defaults to ERROR; some expose richer strategies such as TAGGED_ENUM or RECORD.
See Heterogeneous strategies for the strategies, worked examples, and the per-language support matrix.
JSON value types¶
Some languages also have a single runtime JSON value type that is a better fit than native narrow collection types.
These languages support this through the json_type constructor argument, accessed as <Language>.json_types.<VALUE>.
See also
Heterogeneous strategies for the statically typed alternative, and its “Which should I use?” note comparing the two approaches.
Rust is the worked example:
"""Render Rust data as serde_json::Value."""
from literalizer import InputFormat, NewVariable, literalize
from literalizer.languages import Rust
result = literalize(
source='{"id": 1, "tags": ["red", 2]}',
input_format=InputFormat.JSON,
language=Rust(json_type=Rust.json_types.SERDE_JSON_VALUE),
variable_form=NewVariable(name="payload"),
)
This emits serde_json::json!(...) expressions, relaxes Rust’s homogeneous Vec<T> / HashMap<K, V> checks, and requires dict keys to be strings so they remain valid JSON object keys.
Every mode requires dict keys to be strings for the same reason. The remaining languages differ only in the emitted form and a few extra constraints:
Language |
|
Emitted form |
Notable constraints |
|---|---|---|---|
Crystal |
|
|
Rejects characters that break the |
Java |
|
|
|
Kotlin |
|
|
|
Scala |
|
|
None beyond string keys. |
C# |
|
|
Dates / datetimes / times become ISO 8601 strings; the |
F# |
|
|
Dates / datetimes / times become ISO 8601 strings unless |
Nim |
|
|
Dates / datetimes become ISO 8601 strings; |
Haskell |
|
|
None beyond string keys. |
Zig |
|
|
Dates / datetimes / times / bytes fold into strings; |
C++ |
|
|
Input must not encode the raw-string terminator |
Gleam |
|
|
Adds an |
Elm |
|
|
Adds an |
PureScript |
|
|
Special floats ( |
Scheme |
|
Association lists |
Resolves the default mode’s object/array ambiguity; special floats ( |
Erlang |
|
UTF-8 binary literals ( |
Requires the |
Odin |
|
JSON text parsed at runtime by a package-scope |
Dates / datetimes / times / bytes fold into strings; |
C |
|
A |
Integers render through |
Cobol |
|
The same |
Integers are stored in a |
Two cases are unusual enough to keep as prose.
OCaml’s YOJSON_SAFE_T mode emits Yojson.Safe.t polymorphic-variant literals directly, keyed by the standard yojson tag set (Bool, Int, Float, String, Null, List, Assoc, Intlit), so the rendered binding has the static type Yojson.Safe.t instead of OCaml’s generated val_t algebraic type, and the type val_t = ... preamble drops out entirely:
let payload : Yojson.Safe.t = `Assoc [
("id", `Int 1);
("tags", `List [`String "red"; `Int 2])
]
Dates, datetimes, times, and bytes fold into JSON-friendly strings; integers that exceed OCaml’s native int range route through the Intlit arbitrary-precision escape hatch (a string-tagged JSON number) instead of raising.
D’s polarity is reversed from the others: its default already renders every value through std.json.JSONValue, so the json_type constructor argument selects the inverse mode.
D.json_types.STD_JSON_VALUE is the default and matches the other languages’ opt-in JSON value rendering; passing json_type=None instead activates a narrow-typed mode that mirrors the typed-collection defaults the other languages provide:
"""Render D data through narrow native collections."""
from literalizer import InputFormat, NewVariable, literalize
from literalizer.languages import D
result = literalize(
source='{"a": 1, "b": 2}',
input_format=InputFormat.JSON,
language=D(json_type=None),
variable_form=NewVariable(name="counts"),
)
This emits raw D scalars, T[] array literals, and V[K] associative-array literals (auto counts = ["a": 1, "b": 2];) without the JSONValue wrapper.
Inputs that have no narrow form, a heterogeneous list, a heterogeneous-valued dict, an empty list or dict (D’s auto cannot infer an element type for an empty literal), a set, an ordered map, or a non-record dict, are rejected with UnrepresentableInputError.
The RECORD heterogeneous_strategy is also rejected because it already renders record-shaped dicts as generated struct literals, which conflicts with narrow mode’s associative-array form.
Empty mappings on Ada, Lua, PHP, and R¶
Ada, Lua, PHP, and R all have a runtime representation that cannot distinguish an empty mapping from an empty sequence.
Lua’s table, PHP’s array, and R’s list() each serialize an empty mapping the same way their JSON encoders serialize an empty sequence (typically []).
The Ada literalizer’s unified A_Val aggregate likewise collapses an empty AMap'[] and an empty AList'[] to the same runtime value, so the mapping/sequence distinction is lost on round-trip.
literalize refuses to emit a literal that cannot round-trip and raises UnrepresentableEmptyDictError on those four languages whenever an empty mapping appears at any depth in the input.
Empty sequences are unambiguous and are still accepted.
"""Ada, Lua, PHP, and R reject empty mappings."""
import contextlib
import json
from literalizer import InputFormat, NewVariable, literalize
from literalizer.exceptions import UnrepresentableEmptyDictError
from literalizer.languages import Lua
# Strip or replace the empty mapping before retrying on a real input.
with contextlib.suppress(UnrepresentableEmptyDictError):
literalize(
source=json.dumps(obj={"outer": {}}),
input_format=InputFormat.JSON,
language=Lua(),
variable_form=NewVariable(name="my_data"),
)
Forth visitor stream¶
Forth has no native mapping or sequence type, so the Forth language does not emit a data literal. Instead it emits a colon definition that executes a sequence of small constructor words, one per structural event in the document:
Word |
Stack effect |
Meaning |
|---|---|---|
|
|
start of an object |
|
|
end of an object |
|
|
start of an array |
|
|
end of an array |
|
|
a member name |
|
|
an integer value |
|
|
a floating-point value |
|
|
a string value |
|
|
a boolean value |
|
|
a null value |
For example, {"name": "Alice", "tags": [1, 2]} is literalized to:
: my_data
+obj
s\" name" +key s\" Alice" +str
s\" tags" +key +arr 1 +int 2 +int -arr
-obj
;
The constructor words are the protocol; the caller supplies their bindings.
The Forth language ships a default binding in src/literalizer/languages/forth_prelude.fs that writes JSON to a shared output stream through the Forth Foundation Library jos module, so loading the prelude and then running my_data prints the document as JSON out of the box:
include forth_prelude.fs
\ ... the literalized : my_data ... ; definition ...
my_data json-out str-get type
To consume the same definition another way – to build a Forth-side data structure, walk into custom storage, compute over the values, or emit a different format – redefine any of the constructor words before running the definition. Nothing in the definition is tied to JSON beyond the bindings the caller chooses to load.
Custom language implementations¶
To support a language that is not built in, create a class that satisfies the Language protocol, using metaclass=LanguageCls and defining the required nested enum classes and attributes.
When an attribute is part of the Language protocol but should resolve to None, expose that value through a descriptor or property instead of storing literal None on the class.
CPython treats class-level None as “attribute is not implemented” during runtime protocol checks, which can prevent ABC cache warming for large @runtime_checkable protocols; see python/cpython#102433.
Built-in languages use shared descriptors such as no_pygments_name and no_format_integer_widened for this pattern.
Look at any built-in language module under literalizer/languages/ for a complete working example.
The Language protocol documents every required attribute.
Language-definition API¶
These symbols are only needed when defining a language that is not built in.
Everything here is importable directly from the top-level literalizer package.
Formatting configuration¶
Building blocks used when defining how a language renders collections, comments and scalars.
- class literalizer.CollectionLayout(*values)¶
Controls how nested collections are rendered.
- COMPACT = 'compact'¶
Render nested collections on one line.
- MULTILINE = 'multiline'¶
Render nested collections with one element per line.
- class literalizer.TrailingCommaConfig(multiline_trailing_comma: bool)¶
Configuration for trailing-comma behavior.
When
multiline_trailing_commaisTrue, trailing commas are added to multiline collections where the chosen format supports them. Some sequence formats (e.g. Java’sList.of()) do not support trailing commas; in those cases the trailing comma is omitted regardless of this setting.- multiline_trailing_comma: bool¶
- class literalizer.CommentConfig(prefix: str, suffix: str)¶
Configuration for language comment syntax.
- prefix: str¶
- suffix: str¶
- class literalizer.SequenceFormatConfig(sequence_open: Callable[[list[Value]], str], close: str, supports_heterogeneity: bool, single_element_trailing_comma: bool, supports_trailing_comma: bool, empty_sequence: str | None, preamble_lines: tuple[str, ...], format_entry: Callable[[Value, str], str], typed_opener_fallback: str | None, uses_typed_literal_for_scalars: bool, requires_uniform_record_shapes: bool, declared_type: str | None, narrowed_empty_form: Callable[[Sequence[list[Value]]], str] | None)¶
Configuration for a single sequence format.
- close: str¶
- declared_type: str | None¶
- empty_sequence: str | None¶
- format_entry: Callable[[Value, str], str]¶
- narrowed_empty_form: Callable[[Sequence[list[Value]]], str] | None¶
- preamble_lines: tuple[str, ...]¶
- requires_uniform_record_shapes: bool¶
- sequence_open: Callable[[list[Value]], str]¶
- single_element_trailing_comma: bool¶
- supports_heterogeneity: bool¶
- supports_trailing_comma: bool¶
- typed_opener_fallback: str | None¶
- uses_typed_literal_for_scalars: bool¶
- class literalizer.SetFormatConfig(set_open: Callable[[list[Value]], str], close: str, empty_set: str | None, preamble_lines: tuple[str, ...], set_opener_template: str, supports_heterogeneity: bool, supports_trailing_comma: bool)¶
Configuration for a single set format.
- close: str¶
- empty_set: str | None¶
- preamble_lines: tuple[str, ...]¶
- set_open: Callable[[list[Value]], str]¶
- set_opener_template: str¶
- supports_heterogeneity: bool¶
- supports_trailing_comma: bool¶
- with_typed_opener(*, type_to_opener: Callable[[type | ListType | DictType], str | None], fallback: str) SetFormatConfig¶
Return a copy with
set_openreplaced by a typed opener.The type_to_opener callable is used to infer the opener from the element type. When inference fails, fallback is used instead.
- class literalizer.DictFormatConfig(dict_open: Callable[[dict[Scalar, Value]], str], close: str, format_entry: Callable[[str, Value, str], str], empty_dict: str | None, preamble_lines: tuple[str, ...], narrowed_open: str | None, supports_trailing_comma: bool)¶
Configuration for dict formatting.
- close: str¶
- dict_open: Callable[[dict[Scalar, Value]], str]¶
- empty_dict: str | None¶
- format_entry: Callable[[str, Value, str], str]¶
- narrowed_open: str | None¶
- preamble_lines: tuple[str, ...]¶
- supports_trailing_comma: bool¶
- class literalizer.OrderedMapFormatConfig(ordered_map_open: Callable[[dict[Scalar, Value]], str], close: str, preamble_lines: tuple[str, ...])¶
Configuration for ordered-map formatting.
- close: str¶
- ordered_map_open: Callable[[dict[Scalar, Value]], str]¶
- preamble_lines: tuple[str, ...]¶
- class literalizer.DateFormatConfig(formatter: ~collections.abc.Callable[[~datetime.date], str], preamble_lines: tuple[str, ...] = (), type_produced: type = <class 'datetime.date'>)¶
Configuration for a single date format.
- formatter: Callable[[date], str]¶
- preamble_lines: tuple[str, ...] = ()¶
- type_produced¶
alias of
date
- class literalizer.DatetimeFormatConfig(formatter: ~collections.abc.Callable[[~datetime.datetime], str], preamble_lines: tuple[str, ...] = (), type_produced: type = <class 'datetime.datetime'>)¶
Configuration for a single datetime format.
- formatter: Callable[[datetime], str]¶
- preamble_lines: tuple[str, ...] = ()¶
- type_produced¶
alias of
datetime
- literalizer.fixed_open(*, open_str: str) Callable[[list[Value] | dict[Scalar, Value]], str]¶
Return an opener callable that always returns open_str.
Use this as
sequence_open,set_open,dict_open, orordered_map_openwhen the opening delimiter is a fixed string that does not depend on the collection contents.Example:
fixed_open(open_str="[")([1, 2, 3])->"[".
Defining a language¶
The Language protocol describes how a language formats literals.
The members below are the contract each built-in language implements.
- class literalizer.Language(*args, **kwargs)¶
Protocol describing how a language formats scalar literals and sequences.
Predefined instances for common languages are available as module-level constants in
literalizer.languages(e.g.PYTHON,JAVASCRIPT). To support additional languages or override defaults, write a class that provides all the required attributes.- property allows_empty_call_parens: bool¶
Whether an empty argument list is written as
().
- property bool_formats: type[Enum]¶
Enum class whose members list the boolean format options this language supports.
Languages without alternative boolean formats expose an empty enum so consumers can enumerate options uniformly without reflection.
- property bytes_formats: type[Enum]¶
Enum class whose members list the bytes formats this language supports.
- property call_data_dependent_preamble: Callable[[Value], tuple[str, ...]]¶
Data-dependent preamble lines used for call rendering.
Most languages set this to the same callable as
data_dependent_preamble. Languages whose declaration preamble does not apply to inline call arguments override it.
- property call_returns_expression: bool¶
Whether a function call in this language is an expression whose value can be consumed by an enclosing expression. When
False,literalize_call()rejects acall_transform(whose output wraps the call as a value) withUnsupportedCallShapeError.
- property call_style_config: PositionalCallStyle | KeywordCallStyle | ObjectCallStyle | PostfixCallStyle | PrefixCallStyle | CommandCallStyle | CallSupport¶
Describes how this language passes arguments in function calls.
Returns a
CallStylevariant for supported languages, or aCallSupportsentinel for languages with an emptyCallStylesenum (distinguishing whether the language has no call syntax at all, or literalizer has not yet implemented call rendering for it).
- property call_styles: type[Enum]¶
Enum class whose members list the call style options this language supports.
- property comment_config: CommentConfig¶
Configuration for the language’s comment syntax.
- property comment_format: Enum¶
The comment format chosen for this language instance.
- property comment_formats: type[Enum]¶
Enum class whose members list the comment formats this language supports.
- property compute_body_preamble: Callable[[frozenset[type], Value], tuple[str, ...]]¶
Computes body-preamble lines based on which types are present in the data. Most languages build this from
scalar_body_preamble; Haskell overrides it to compose thedata Valdeclaration and imports dynamically.The second argument is the original data value, allowing implementations to inspect actual values when needed (e.g. to determine whether datetime microsecond-precision imports are required).
- property consumable_ref_value_inhibits_consuming_form: Callable[[Value], bool]¶
Predicate deciding whether a ref’s underlying value type makes the language’s consume form illegal.
Returns
Truewhen the consume operator (e.g. Mojo^) would be rejected for value, in which case the call site routes the ref throughformat_call_arg_ref_identifierinstead offormat_call_arg_ref_identifier_consumable.Most languages set this to
never_inhibits_consuming_form. Mojo overrides it: applying^to a register-trivial scalar (Int,Bool,Float64) is a hard error under--Werror, so those value types inhibit the consume form.
- property data_dependent_preamble: Callable[[Value], tuple[str, ...]]¶
Callable that receives the original data value and returns extra preamble lines that depend on data content rather than just which scalar types are present.
Most languages use
no_data_preamble()(returns()); C++ uses this to conditionally emit itsAnyhelper struct only when the data contains heterogeneous collections.
- property date_format: Enum¶
The date format chosen for this language instance.
- property date_formats: type[Enum]¶
Enum class whose members list the date formats this language supports.
- property datetime_format: Enum¶
The datetime format chosen for this language instance.
- property datetime_formats: type[Enum]¶
Enum class whose members list the datetime formats this language supports.
- property declaration_style: Enum¶
The declaration style chosen for this language instance.
- property declaration_styles: type[Enum]¶
Enum class whose members list the declaration style options this language supports.
- property dict_entry_style: Enum¶
The dict entry style chosen for this language instance.
- property dict_entry_styles: type[Enum]¶
Enum class whose members list the dict entry style options this language supports.
- property dict_format: Enum¶
The dict/map format chosen for this language instance.
- property dict_format_config: DictFormatConfig¶
Configuration for dict formatting.
- property dict_formats: type[Enum]¶
Enum class whose members list the dict/map format options this language supports.
- dict_supports_heterogeneous_values: bool¶
Whether the language’s dict format can represent values spanning multiple type families (e.g. Python’s
dict, JavaScript’s object literal). WhenFalse(e.g. Rust’sHashMap), inputs with heterogeneous dict values raiseMixedDictValuesError.
- property element_separator: str¶
The separator placed between elements in inline sequences.
- extension: str¶
The file extension for this language, including the leading dot.
- property false_literal: str¶
The literal representing false/False.
- property float_format: Enum¶
The float format chosen for this language instance.
- property float_formats: type[Enum]¶
Enum class whose members list the float format options this language supports.
- property format_bytes: Callable[[bytes], str]¶
Callable that formats a
bytesvalue as a string literal.
- property format_call_arg: FormatCallArg¶
Rewrite a formatted direct call argument.
Called as
format_call_arg(value, formatted)after value has been formatted as a literal or reference. Languages that do not need wrapping set this toidentity_call_arg; languages such as C and Objective-C override this to wrap each argument in a canonical parameter type.
- property format_call_arg_ref_identifier: Callable[[str, Value | None], str]¶
Rewrite a
{"$ref": "name"}identifier used as a direct call argument (vialiteralize_call()).In the call-argument context the referenced variable has already been emitted at the same top-level scope, so some languages that reject
$refin the value context (seeformat_call_ref_identifier) can accept it here.The default implementation (provided by every language class) delegates to
format_call_ref_identifier. Override this to allow call-argument$refvalues that would otherwise be rejected.
- property format_call_arg_ref_identifier_consumable: Callable[[str, Value | None], str]¶
Rewrite a
{"$ref": "name"}call-argument identifier the caller authorized as consumable onliteralize_call().Used only for refs the caller listed in
consumable_refsand that appear in exactly one call argument across the rendered calls, so the consuming form cannot strand a later use.The default implementation (provided by every language class) delegates to
format_call_arg_ref_identifier. Languages whose call-argument$refsemantics consume the variable (notably C++std::move) override this.
- format_call_binding_body_preamble() tuple[str, ...]¶
Module-internal body-preamble lines required only when a top-level binding holds an inference-bound call result.
Most languages need none and return
()viano_call_binding_body_preamble. PureScript overrides this withimport Prelude(its call stub returnsUnit).
- format_call_binding_file_pragmas() tuple[str, ...]¶
File-level compiler-pragma lines required only when a top-level binding holds an inference-bound call result.
Most languages need none and return
()viano_call_binding_file_pragmas. Haskell overrides this to suppress-Wmissing-signaturesfor the binding, whose type the renderer cannot annotate.
- property format_call_preamble_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]¶
Like
format_call_stubbut the lines are placed before the language wrapper — at file, package, or module scope.Most languages return an empty tuple here and put all stubs in
format_call_stub. Languages like Go that cannot declare types inside function bodies use this instead.
- property format_call_ref_identifier: Callable[[str, Value | None], str]¶
Rewrite a
{"$ref": "name"}identifier into the form required by this language’s call expression syntax.Used when a
$refappears as a value inside a data structure (e.g. an element of a list passed toliteralize()). Languages that cannot support bare variable references in that context raiseCallArgNotSupportedErrorhere.Called after
literalize_call()’sref_casenormalization, so name is already in the requested identifier case. The second positional argument is theValuedeclared elsewhere for that ref (taken from the caller’sref_valuesmapping), orNonewhen the caller did not supply the value. Most languages emit ref identifiers bare and useidentity_call_ref_identifier; languages that wrap the identifier in a type-sensitive way (V’s.clone()for non-scalars) inspect the value to choose the right form.
- property format_call_statement: Callable[[str], str]¶
Rewrite an assembled call expression into a valid statement.
Languages that allow bare call statements set this to
identity_call_statement; languages that need a wrapper such aslet _ = ...override it.
- property format_call_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]¶
Return stub declaration lines for a name used in a call expression.
parts is a sequence of name parts – a single element for simple function calls (e.g.
("process",)), multiple for method calls (e.g.("throttler", "check")). The second argument is the list of parameter names (e.g.["user_id", "ts"]) so that keyword-style languages can generate stubs with matching named parameters. stub_return controls the return type of the generated stub:StubReturn.VALUEwhen the call expression’s return value is consumed (e.g. passed as an argument to a transform wrapper),StubReturn.VOIDotherwise. The fourth argument is the parsed call argument data: one entry per rendered call, where each entry is the arguments row for that call (a single value for one-parameter calls, a list of values for multi-parameter calls). Languages whose stubs need to be typed (e.g. Mojo) infer parameter types from this; other languages ignore it.Stub lines are placed inside the language wrapper (e.g. inside
func main()for Go, insideclass Checkfor Java). Languages that need stubs at file/package scope should useformat_call_preamble_stubinstead.Returns an empty tuple when no stub is needed (e.g. for built-in functions, or in languages whose lint checks only verify syntax).
- property format_call_target: Callable[[Sequence[str]], str]¶
Rewrite a sequence of call target parts into the form required by this language’s call expression syntax.
Most languages accept dotted member-access as-is and use
identity_call_target. PHP overrides this to produce$app->client->fetch.
- property format_call_variable_assignment: Callable[[str, str, Value], str]¶
Callable that formats an
ExistingVariablebinding whose right-hand side is a call expression rather than a literal.The call-expression counterpart of
format_variable_assignment; seeformat_call_variable_declaration. Languages with no value-type tag reuseformat_variable_assignmentunchanged viadefault_format_call_variable_assignment.
- property format_call_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]¶
Callable that formats a
NewVariabledeclaration whose right-hand side is a call expression rather than a literal.Languages whose literal-binding declaration injects a value-type-derived tag (Haskell’s
x :: Val, F#’sx: Val = FInt ...) override this to drop the tag and let the compiler infer the call’s return type. Languages with no such tag reuseformat_variable_declarationunchanged viadefault_format_call_variable_declaration.
- property format_constructor_target: Callable[[str], str]¶
Return a zero-argument constructor target for class_name.
The returned string is intended to be passed to
literalize_call()astarget_function. Most languages call constructors asClassName()and useidentity_constructor_target; languages with constructor syntax outside regular function names override this to produce targets such asnew ClassName,NewClassName,ClassName.new, orClassName::new.
- property format_date: Callable[[date], str]¶
Callable that formats a
datetime.dateas a string literal.
- property format_datetime: Callable[[datetime], str]¶
Callable that formats a
datetime.datetimeas a string literal.
- property format_float: Callable[[float], str]¶
Callable that formats a float value as a literal.
- property format_integer: Callable[[int], str]¶
Callable that formats an int value as a literal.
- property format_integer_widened: Callable[[int], str] | None¶
Widened-integer formatter for mixed-magnitude int collections, or
Nonewhen the language has no widening behavior.Used only when a sequence/set mixes integers that do not all fit one fixed-width type (e.g. an
i32and a value pasti32’s range); the formatter then casts every element to the wider type. Languages with no such widening (the common case) returnNoneviano_format_integer_widened.
- property format_ordered_map_entry: Callable[[str, Value, str], str]¶
Callable that formats one ordered-map entry.
- property format_sequence_entry: Callable[[Value, str], str]¶
Callable that formats a sequence entry.
- property format_set_entry: Callable[[Value, str], str]¶
Callable that formats a set entry.
- property format_string: Callable[[str], str]¶
Callable that formats a string value as a quoted literal.
- property format_time: Callable[[time], str]¶
Callable that formats a
datetime.timeas a string literal.
- property format_variable_assignment: Callable[[str, str, Value], str]¶
Callable that formats an assignment to an existing variable.
Called as
format_variable_assignment(name, value, data)where name is the variable name, value is the already-formatted literal value, and data is the original parsed data structure.
- property format_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]¶
Callable that formats a new variable declaration.
Called as
format_variable_declaration(name, value, data, modifiers)where name is the variable name, value is the already-formatted literal value, data is the original parsed data structure, and modifiers is the set of modifier enum values requested by the caller. Each language exposes its modifier vocabulary as its nestedModifiersenum; values that are not members of that enum are silently ignored.
- has_free_function_calls: bool¶
Whether the language has a free function call syntax (i.e. the ability to call a function by a bare name with no dot). Metadata for callers and the test harness, which use it to decide whether a generated bare-wrapper stub can compile in this language;
literalize_call()does not inspect it.
- property heterogeneous_behavior: HeterogeneousBehavior¶
Describes how this language handles heterogeneous scalar collections.
Languages that don’t wrap heterogeneous values expose
NO_HETEROGENEOUS_BEHAVIOR. Languages that wrap them (e.g. Rust’sHeterogeneousStrategies.TAGGED_ENUM) return aHeterogeneousBehaviorwhosewrap_scalarandcompute_wrap_idsimplement the wrapping.
- property heterogeneous_strategies: type[Enum]¶
Enum class whose members list the heterogeneous-scalar strategies this language supports.
Languages that only know how to raise on heterogeneous scalar collections expose a single-member enum whose only option is
ERROR. Languages with richer strategies (e.g. Rust’sTAGGED_ENUM) expose additional members.
- property heterogeneous_strategy: Enum¶
The heterogeneous-scalar strategy chosen for this language instance.
- property identifier_cases: tuple[IdentifierCase, ...]¶
Identifier case conventions idiomatic for this language.
Ordered by stylistic preference – the first element is the language’s default/idiomatic case for generated defaults and golden fixtures. This list is not used to validate user
ref_casechoices; that role belongs tosupported_ref_cases. A language may prefer onlySNAKEwhile still syntactically supportingCAMEL,PASCAL, andUPPER_SNAKE.
- property indent: str¶
The indentation step for elements inside delimiters in multi-line structures (e.g.
" "for 4-space indent).
- property indent_closing_delimiter: bool¶
Whether to indent the closing delimiter of multi-line structures by one
indentstep.
- property integer_format: Enum¶
The integer format chosen for this language instance.
- property integer_formats: type[Enum]¶
Enum class whose members list the integer format options this language supports.
- property integer_width_strategies: type[Enum]¶
Enum class whose members list the integer-width rendering strategies this language supports.
Most languages support only
BareIntegerWidthStrategies.BARE(a bare numeric literal). Languages whose native scalar integer type silently loses precision past a fixed mantissa (notably Perl past2**53) expose additional opt-in strategies that wrap wide values in an arbitrary-precision constructor.
- property integer_width_strategy: Enum¶
The integer-width strategy chosen for this language instance.
- property json_types: type[Enum]¶
Enum class whose members list the JSON value-type options this language supports.
Languages without a JSON value-type representation expose an empty enum so consumers can enumerate options uniformly without reflection.
- property language_version: Enum¶
The selected version of the target language.
- property leading_preamble: LeadingPreamble¶
Callable returning preamble lines that must come before
static_preamble(and every other preamble line).Receives the original data value and whether a new variable is being declared. Most languages use
no_leading_preamble(always()); Python uses it to emitfrom __future__ import annotationsonly when the rendered code actually contains an annotation, since that import must be the first statement.
- property max_call_parameters: int¶
Maximum parameter count the language’s call syntax accepts.
NO_CALL_PARAMETER_LIMITfor languages with no fixed limit. Whenliteralize_call()is given moreparameter_namesthan this, it raisesUnsupportedCallShapeError.
- property modifiers: type[Enum]¶
Enum class whose members list the declaration modifiers this language supports.
Languages without modifier vocabulary expose an empty enum.
- property null_literal: str¶
The literal representing null/None.
- property numeric_literal_suffix: Enum¶
The numeric literal suffix chosen for this language instance.
- property numeric_literal_suffixes: type[Enum]¶
Enum class whose members list the numeric literal suffix options this language supports.
- property numeric_separator: Enum¶
The numeric separator option chosen for this language instance.
- property numeric_separators: type[Enum]¶
Enum class whose members list the numeric separator options this language supports.
- property numeric_style: Enum¶
The numeric literal style chosen for this language instance.
- property numeric_styles: type[Enum]¶
Enum class whose members list the numeric literal style options this language supports.
- property ordered_map_format_config: OrderedMapFormatConfig¶
Configuration for ordered-map formatting.
- property pygments_name: str | None¶
The Pygments lexer short name for syntax highlighting.
Noneif Pygments does not support this language.
- property reserved_identifiers: frozenset[str]¶
Identifiers that are reserved by the language and therefore cannot appear as the innermost segment of
target_function.literalize_call()rejects such targets withUnsupportedCallShapeError.
- property scalar_body_preamble: dict[type, tuple[str, ...]]¶
Maps Python scalar types to body-preamble lines that are prepended to the generated code.
Most languages leave this empty. Haskell uses it for typeclass instance definitions.
- property scalar_preamble: dict[type, tuple[str, ...]]¶
Maps Python scalar types to the preamble lines required when that type appears in the data. For example, a language that needs
import datetimewhen dates are present would include{datetime.date: ("import datetime",)}.
- sequence_binding_declarations(declarations: tuple[str, ...]) str¶
Combine the per-binding
bare_codesnippets of a multi-binding file into one body.Most languages join the snippets with newlines via
default_sequence_binding_declarations. Languages that need ordering (Fortran: every specification statement before every executable one) or structural nesting (Nix’s chainedlet) override this.
- property sequence_format: Enum¶
The sequence format chosen for this language instance.
sequence_format_configexposes the format-specific configuration (e.g.supports_heterogeneity).
- property sequence_format_config: SequenceFormatConfig¶
Configuration for the chosen sequence format.
- property sequence_formats: type[Enum]¶
Enum class whose members list the sequence formats this language supports.
- property sequence_open: Callable[[list[Value]], str]¶
Callable that returns the opening delimiter for a sequence.
Receives the list of items about to be formatted, so the delimiter can depend on the element types when needed. For a fixed delimiter use
fixed_open().
- property set_format: Enum¶
The set format chosen for this language instance.
- property set_format_config: SetFormatConfig¶
Configuration for the chosen set format.
- property set_formats: type[Enum]¶
Enum class whose members list the set formats this language supports.
- property skip_null_dict_values: bool¶
Whether to omit dict entries whose value is
None.
- property special_float_preamble: tuple[str, ...]¶
Preamble lines added only when special float values (inf, -inf, nan) appear in the data. Most languages set this to
(). Languages whose special-float literals require imports (e.g. Go needsimport "math") populate this field so the import is only emitted when actually needed.
- property statement_terminator: str¶
String appended to each call expression to form a complete statement.
Most C-family languages use
";". Python, Ruby, and other languages where a bare expression is a valid statement use"".
- property statement_terminator_style: Enum¶
The statement terminator option chosen for this language instance.
- property statement_terminator_styles: type[Enum]¶
Enum class whose members list the statement terminator options this language supports.
- property static_body_preamble: Sequence[str]¶
Lines that are always prepended to the generated code, regardless of what types appear in the data. Appears after the header preamble but before the code body. Use an empty sequence when none are needed.
- property static_preamble: Sequence[str]¶
Lines (imports, package declarations, etc.) that are always emitted before the generated code, regardless of what types appear in the data. Use an empty sequence when none are needed.
- property string_format: Enum¶
The string format chosen for this language instance.
- property string_formats: type[Enum]¶
Enum class whose members list the string format options this language supports.
- property supported_ref_cases: frozenset[IdentifierCase]¶
Identifier cases that produce a syntactically legal identifier in this language.
Used solely for correctness validation: passing a
IdentifierCasenot in this set toliteralize()orliteralize_call()viaref_caseis rejected withUnsupportedIdentifierCaseError. Independent ofidentifier_cases, which records stylistic preference rather than syntactic validity.
- property supports_collection_comments: bool¶
Whether the language supports comments inside collection initializers.
When
False, YAML comments on collection elements are emitted as standalone comment lines immediately before the collection (or before the variable declaration when a variable name is supplied) rather than being placed inside the{...}block.
- supports_dict_literal_as_free_expression: bool¶
Whether a dict/map literal can appear as a free-standing expression (e.g. spliced as a call argument) rather than only on the right-hand side of a typed assignment. Metadata for the test harness only;
literalize_call()does not inspect it.Falsefor languages whose map-literal syntax needs a typed left-hand side to be sized – e.g. SystemVerilog'{...}assignment patterns.
- supports_dotted_call_stub: bool¶
Whether the language can declare a stub for a dotted call wrapper name (e.g.
tracer.emit).literalize_call()no longer inspects this (a context-awarecall_transformis opaque); it is metadata for callers and the test harness, which use it to decide whether a generated dotted-wrapper stub can compile in this language.
- supports_dotted_calls: bool¶
Whether the language accepts dotted
target_functionvalues (e.g."module.fn") inliteralize_call(). WhenFalse, dotted targets are rejected withDottedCallTargetNotSupportedError.
- property supports_inline_multiline_dict_args: bool¶
Whether the language can render a call argument as an inline dict literal that spans multiple lines. When
False,literalize_call()rejects inputs that would produce a multi-key dict argument withUnsupportedCallShapeError.
- supports_multi_param_call_wrapper_stub: bool¶
Whether the language can declare, and positionally invoke, a harness wrapper stub that receives the call’s result alongside one or more additional positional arguments. Metadata for the test harness only;
literalize_call()does not inspect it.Falsefor languages whose generated multi-parameter stub cannot accept the call expression positionally – e.g. a strongly typed stub fed avoid-returning call, or an object-style stub that rejects a positional multi-argument invocation.
- supports_no_variable_wrap_in_file: bool¶
Whether the language can represent a bare value (no variable binding) at file-statement scope. When
False,literalize()rejectswrap_in_file=Truewithvariable_form=NonewithWrapInFileWithoutVariableNotSupportedEr ror, rather than silently emitting a file whose top-level item is a bare expression (a syntax error in strict-typed languages like Rust, C, Haskell, Swift, Ada, D, Dart, C#, Elm, Mojo, Nim, Objective-C, Odin, SML, V, Zig, etc.).Languages with no variable-name syntax at all (
supports_variable_namesisFalse) must set this toTrue: theirwrap_in_fileoutput has no other shape.
- supports_non_string_dict_keys: bool¶
Whether the language can represent a dict whose keys include values that are not strings. When
False,literalize()rejects such inputs at the formatting boundary withUnrepresentableInputError.Most languages allow scalar dict keys natively; pure data formats whose surface syntax only admits string keys (JSON-family, TOML) set this to
False.
- property supports_scalar_before_comments: bool¶
Whether the language supports a line comment between the assignment operator and the value on the next line.
For example, in JavaScript
const x = // note\n42;is valid because the parser continues the incomplete expression past the line comment. In Pythonx = # note\n42is a syntax error because the#comment terminates the statement.When
False, YAML comments that appear before a scalar value are emitted as standalone comment lines immediately before the variable declaration rather than between the=and the value.
- property supports_scalar_inline_comments: bool¶
Whether the language supports a trailing line comment on a scalar value without breaking surrounding syntax.
For example, in JavaScript
const x = 42 // noteis valid because no closing token follows on the same line. In C((_CVal){.i = 42 // note});is a syntax error because the//comment consumes the closing});.When
False, YAML inline comments on scalar values are emitted as standalone comment lines immediately before the variable declaration rather than being appended after the value.
- property supports_standalone_comments_in_wrapped_calls: bool¶
Whether manually wrapped call output can contain standalone comment lines between call statements.
- supports_variable_names: bool¶
Whether the language supports wrapping output in a named variable via the
variable_formargument toliteralize(). WhenFalse, passing anyNewVariable,ExistingVariable, orBothVariableFormsis rejected withVariableNameNotSupportedError.
- property supports_zero_parameter_calls: bool¶
Whether the language can render a function call with no parameters. When
False,literalize_call()rejects emptyparameter_nameswithUnsupportedCallShapeError.
- property trailing_comma: Enum¶
The trailing comma option chosen for this language instance.
- property trailing_comma_config: TrailingCommaConfig¶
Configuration for trailing-comma behavior.
Trailing commas are only added to collection formats that support them. See
TrailingCommaConfigfor details.
- property trailing_commas: type[Enum]¶
Enum class whose members list the trailing comma options this language supports.
- property true_literal: str¶
The literal representing true/True.
- property type_hint_collection_preamble_lines: Callable[[frozenset[type]], tuple[str, ...]]¶
Callable that receives the set of collection types that have empty instances in the data and returns preamble lines needed for type-hint annotations.
Most languages return
()unconditionally; Python uses this to emitfrom typing import Anyonly when the specific empty collection types present actually require it.
- property validate_call_arg: Callable[[Value], None]¶
Validate a direct call argument after references are removed.
Languages that accept every supported literal set this to
no_validate_call_arg; languages with additional call argument restrictions override it.
- validate_spec_for_data(data: Value) None¶
Raise if the spec cannot produce valid code for data.
Languages whose output depends on format/data combinations that cannot produce valid code (e.g. Rust
CONST+ a dict value) override this method to raiseIncompatibleFormatsErrorat literalize time. Languages with no such constraints assignno_validate_spec_for_data()as a no-op.
- property variable_type_hints: Enum¶
The variable type hint option chosen for this language instance.
- property variable_type_hints_formats: type[Enum]¶
Enum class whose members list the variable type hint options this language supports.
Every language exposes
NEVER(no annotations, let the language infer),ALWAYS(annotate every variable), andSAFE.SAFEannotates only when the language’s own inference would widen the variable to a permissive type (e.g.unknown[]for an empty TypeScript array,Object[]for an empty Java array); for languages without a custom predicate it produces the same output asNEVER.
- property version_formats: type[Enum]¶
Enum class whose members list the target language versions this language class supports.
- wrap_calls_with_declarations(declarations: tuple[str, ...], calls: str, body_preamble: tuple[str, ...]) str¶
Wrap a sequence of top-level declarations (each one a full
literalizebare_codefor a$reftarget) alongside a block of bare call expressions in a complete, valid file.Most languages can splice the declarations directly in front of the calls and route through
wrap_in_file()in call mode; they assigndefault_wrap_calls_with_declarationsas a no-op wrapper. Languages whose call-mode wrapping moves bare expressions into a different scope than top-level bindings (e.g. Haskell’smain = doblock, where bindings belong at module scope) override this method.
- wrap_combined_in_file(declaration: str, assignment: str, variable_name: str, body_preamble: tuple[str, ...]) str¶
Wrap a declaration and assignment in a complete, valid file.
- wrap_in_file(content: str, variable_name: str, body_preamble: tuple[str, ...]) str¶
Wrap a code snippet in a complete, valid file.
- class literalizer.LanguageCls¶
Meta-class that declares the nested format Enum class attributes.
Language classes use
metaclass=LanguageClsso that downstream code can writedict[str, LanguageCls]and accesscls.DateFormats,cls.SequenceFormats, etc. withoutcastortype: ignore.
Built-in languages¶
Built-in language specifications for common programming languages.
- class literalizer.languages.Ada(*args: object, **kwargs: object)¶
Ada language specification.
- class BoolFormats(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
Empty: this language has no alternative boolean formats.
- class BytesFormats(*values)¶
Bytes formatting options.
- BASE64 = <function format_bytes_base64>¶
- HEX = <function format_bytes_hex>¶
- class CommentFormats(*values)¶
Comment style options.
- DOUBLE_DASH = CommentConfig(prefix='--', suffix='')¶
- class DateFormats(*values)¶
Date format options for Ada.
- ISO = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- class DatetimeFormats(*values)¶
Datetime format options for Ada.
- EPOCH = DatetimeFormatConfig(formatter=<function format_datetime_epoch>, preamble_lines=(), type_produced=<class 'int'>)¶
- ISO = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- class DeclarationStyles(*values)¶
Declaration style options.
- DECLARE = DeclarationStyleConfig(formatter=<function _format_variable_declaration>, supports_redefinition=True)¶
- class FloatFormats(*values)¶
Float format options.
- FIXED = <function format_float_fixed>¶
- REPR = <function format_float_repr>¶
- SCIENTIFIC = <function format_float_scientific>¶
- class HeterogeneousStrategies(*values)¶
Heterogeneous-scalar strategy options — this language only supports raising.
- ERROR = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)¶
- class JsonTypes(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
Empty: this language has no JSON value-type variants.
- class Modifiers(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
C++/Java/C#-style declaration modifiers: this language has none.
- class SequenceFormats(*values)¶
Sequence type options for Ada.
- LIST = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=']', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence="AList'[]", preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)¶
- class SetFormats(*values)¶
Set type options for Ada.
- SET = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close=']', empty_set="ASet'[]", preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)¶
- class TrailingCommas(*values)¶
Trailing comma options.
- NO = TrailingCommaConfig(multiline_trailing_comma=False)¶
- allows_empty_call_parens = False¶
- bool_formats¶
alias of
BoolFormats
- bytes_format: BytesFormats = <function format_bytes_hex>¶
- bytes_formats¶
alias of
BytesFormats
- property call_data_dependent_preamble: Callable[[Value], tuple[str, ...]]¶
Return data-dependent preamble lines for call rendering.
- call_returns_expression = True¶
- call_style: CallStyles = KeywordCallStyle(separator=' => ')¶
- property call_style_config: PositionalCallStyle | KeywordCallStyle | ObjectCallStyle | PostfixCallStyle | PrefixCallStyle | CommandCallStyle¶
Configuration for the chosen call style.
- call_styles¶
alias of
CallStyles
- property comment_config: CommentConfig¶
Configuration for the language’s comment syntax.
- comment_format: CommentFormats = CommentConfig(prefix='--', suffix='')¶
- comment_formats¶
alias of
CommentFormats
- property compute_body_preamble: Callable[[frozenset[type], Value], tuple[str, ...]]¶
Emit local IEEE-special constants when needed.
Ada has no portable inline literal for
+Inf,-InforNaN: GNAT statically rejects1.0 / 0.0withstatic expression fails Constraint_Check. When the data contains one of these IEEE specials, declare matching local constants in the enclosing procedure’s declarative part using a volatile zero denominator so GNAT cannot constant-fold the division, and suppressDivision_Checkso the IEEE result propagates instead of raisingConstraint_Errorat runtime.
- property consumable_ref_value_inhibits_consuming_form: Callable[[Value], bool]¶
Predicate deciding whether a ref’s underlying value type inhibits the consume form.
Delegates to
never_inhibits_consuming_form. Languages whose consume operator rejects certain value types (notably the Mojo^on register-trivial scalars) override this.
- property data_dependent_preamble: Callable[[Value], tuple[str, ...]]¶
Return data-dependent preamble lines.
- date_format: DateFormats = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- date_formats¶
alias of
DateFormats
- datetime_format: DatetimeFormats = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- datetime_formats¶
alias of
DatetimeFormats
- declaration_style: DeclarationStyles = DeclarationStyleConfig(formatter=<function _format_variable_declaration>, supports_redefinition=True)¶
- declaration_styles¶
alias of
DeclarationStyles
- dict_entry_style: DictEntryStyles = 1¶
- dict_entry_styles¶
alias of
DictEntryStyles
- dict_format: DictFormats = 1¶
- property dict_format_config: DictFormatConfig¶
Configuration for dict formatting.
- dict_formats¶
alias of
DictFormats
- dict_supports_heterogeneous_values = True¶
- element_separator: ClassVar[str] = ', '¶
- empty_dict_keys¶
alias of
EmptyDictKey
- extension = '.adb'¶
- false_literal: ClassVar[str] = 'ABool (False)'¶
- float_format: FloatFormats = <function format_float_repr>¶
- float_formats¶
alias of
FloatFormats
- property format_bytes: Callable[[bytes], str]¶
Callable that formats a bytes value as a string literal.
- property format_call_arg: Callable[[Value, str], str]¶
Wrap a call argument in the appropriate A_Val constructor.
- property format_call_arg_ref_identifier: Callable[[str, Value | None], str]¶
Rewrite a
{"$ref": "name"}identifier in a call-argument context.Delegates to
format_call_ref_identifier. Override this to allow call-argument$refvalues that would otherwise be rejected.
- property format_call_arg_ref_identifier_consumable: Callable[[str, Value | None], str]¶
Format a
$refthe caller authorized as consumable.Delegates to
format_call_arg_ref_identifier. Override this to opt into a consuming form (e.g. C++std::move).
- format_call_binding_body_preamble() tuple[str, ...]¶
Default
format_call_binding_body_preamble– no extra body preamble lines for an inference-bound call result.
- format_call_binding_file_pragmas() tuple[str, ...]¶
Default
format_call_binding_file_pragmas– no file-level compiler-pragma line for an inference-bound call result.
- property format_call_preamble_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]¶
Return file-scope stubs for a call expression.
- property format_call_ref_identifier: Callable[[str, Value | None], str]¶
Rewrite a
{"$ref": "name"}identifier into the language’s call expression syntax.
- property format_call_statement: Callable[[str], str]¶
Return call-statement formatting for this language.
- property format_call_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]¶
Return stub declarations for a call expression.
- property format_call_target: Callable[[Sequence[str]], str]¶
Rewrite a dotted call target into the language’s call syntax.
- property format_call_variable_assignment: Callable[[str, str, Value], str]¶
Callable that formats an assignment binding a call result.
The call-expression counterpart of
format_call_variable_declaration; theA_Valconstructor wrapping is dropped since the call already yields anA_Val.
- property format_call_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]¶
Callable that formats a declaration binding a call result.
Unlike
format_variable_declaration, the call result is opaque (it is whatever theA_Val-returning call stub returns), so the call result is bound directly with a plainA_Valdeclaration and noA_Valconstructor wrapping.
- static format_constructor_target(class_name: str, /) str¶
Return class_name as a zero-argument constructor call target.
- property format_date: Callable[[date], str]¶
Callable that formats a date as a string literal.
- property format_datetime: Callable[[datetime], str]¶
Callable that formats a datetime as a string literal.
- property format_float: Callable[[float], str]¶
Callable that formats a float value as a literal.
- property format_integer: Callable[[int], str]¶
Format an int value as a literal.
- property format_integer_widened: None¶
Default
format_integer_widened– no mixed-magnitude integer widening, so the renderer keeps the normal integer formatter.
- property format_ordered_map_entry: Callable[[str, Value, str], str]¶
Callable that formats one ordered-map entry.
- property format_sequence_entry: Callable[[Value, str], str]¶
Format a sequence entry.
- property format_set_entry: Callable[[Value, str], str]¶
Format a set entry.
- property format_string: Callable[[str], str]¶
Callable that formats a string value as a quoted literal.
Ada distinguishes
StringfromCharacter, so a literal consisting solely ofCharacter'Val(N)would not satisfy theAStr (S : String)constructor. Prepend an empty string in that case so the&operator widens the result toString.
- property format_time: Callable[[time], str]¶
Callable that formats a time as a string literal.
- property format_variable_assignment: Callable[[str, str, Value], str]¶
Format an assignment to an existing variable.
- property format_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]¶
Callable that formats a new variable declaration.
- has_free_function_calls = True¶
- property heterogeneous_behavior: HeterogeneousBehavior¶
Return the heterogeneous-behavior config.
- heterogeneous_strategies¶
alias of
HeterogeneousStrategies
- heterogeneous_strategy: HeterogeneousStrategies = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)¶
- identifier_cases: ClassVar[tuple[IdentifierCase, ...]] = (IdentifierCase.SNAKE, IdentifierCase.UPPER_SNAKE)¶
- indent: str = ' '¶
- indent_closing_delimiter: ClassVar[bool] = False¶
- integer_format: IntegerFormats = 1¶
- integer_formats¶
alias of
IntegerFormats
- integer_width_strategies¶
alias of
BareIntegerWidthStrategies
- integer_width_strategy: BareIntegerWidthStrategies = 1¶
- language_version: VersionFormats = 1¶
- property leading_preamble: LeadingPreamble¶
Default
leading_preamble– no preamble lines that must precedeLanguage.static_preamble.
- max_call_parameters = 9223372036854775807¶
- modifier_combinations: ClassVar[tuple[ModifierCombination, ...]] = ()¶
- module_name: str = 'Check'¶
- module_name_case: ClassVar[IdentifierCase] = 'pascal'¶
- null_literal: ClassVar[str] = 'ANull'¶
- numeric_literal_suffix: NumericLiteralSuffixes = 1¶
- numeric_literal_suffixes¶
alias of
NumericLiteralSuffixes
- numeric_separator: NumericSeparators = 1¶
- numeric_separators¶
alias of
NumericSeparators
- numeric_style: NumericStyles = 1¶
- numeric_styles¶
alias of
NumericStyles
- property ordered_map_format_config: OrderedMapFormatConfig¶
Configuration for ordered-map formatting.
- pygments_name = 'ada'¶
- reserved_identifiers: ClassVar[frozenset[str]] = frozenset({})¶
- property scalar_body_preamble: dict[type, tuple[str, ...]]¶
Per-instance scalar body preamble (Ada needs none).
- property scalar_preamble: dict[type, tuple[str, ...]]¶
Per-instance scalar preamble (Ada needs none).
- sequence_binding_declarations(declarations: tuple[str, ...]) str¶
Default
sequence_binding_declarations– join the per-binding snippets with newlines.
- sequence_format: SequenceFormats = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=']', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence="AList'[]", preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)¶
- property sequence_format_config: SequenceFormatConfig¶
Configuration for the chosen sequence format.
- sequence_formats¶
alias of
SequenceFormats
- property sequence_open: Callable[[list[Value]], str]¶
Callable that returns the opening delimiter for a sequence.
- set_format: SetFormats = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close=']', empty_set="ASet'[]", preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)¶
- property set_format_config: SetFormatConfig¶
Configuration for the chosen set format.
- set_formats¶
alias of
SetFormats
- skip_null_dict_values: ClassVar[bool] = False¶
- special_float_preamble: ClassVar[tuple[str, ...]] = ()¶
- statement_terminator: ClassVar[str] = ';'¶
- statement_terminator_style: StatementTerminatorStyles = 1¶
- statement_terminator_styles¶
alias of
StatementTerminatorStyles
- static_body_preamble: ClassVar[Sequence[str]] = ()¶
- static_preamble: ClassVar[Sequence[str]] = ()¶
- string_format: StringFormats = 1¶
- string_formats¶
alias of
StringFormats
- supported_ref_cases: ClassVar[frozenset[IdentifierCase]] = frozenset({IdentifierCase.CAMEL, IdentifierCase.PASCAL, IdentifierCase.SNAKE, IdentifierCase.UPPER_SNAKE})¶
- supports_call_style = True¶
- supports_collection_comments: ClassVar[bool] = True¶
- supports_default_dict_key_type = False¶
- supports_default_dict_value_type = False¶
- supports_default_ordered_map_value_type = False¶
- supports_default_sequence_element_type = False¶
- supports_default_set_element_type = False¶
- supports_dict_literal_as_free_expression = True¶
- supports_dotted_call_stub = False¶
- supports_dotted_calls = True¶
- supports_empty_dict_key = False¶
- supports_inline_multiline_dict_args = True¶
- supports_module_name = True¶
- supports_multi_param_call_wrapper_stub = True¶
- supports_no_variable_wrap_in_file = False¶
- supports_non_string_dict_keys = False¶
- supports_record_shape_names = False¶
- supports_record_struct_name_prefix = False¶
- supports_scalar_before_comments: ClassVar[bool] = True¶
- supports_scalar_inline_comments: ClassVar[bool] = False¶
- supports_special_floats = True¶
- supports_standalone_comments_in_wrapped_calls = True¶
- supports_variable_names = True¶
- supports_zero_parameter_calls = True¶
- trailing_comma: TrailingCommas = TrailingCommaConfig(multiline_trailing_comma=False)¶
- property trailing_comma_config: TrailingCommaConfig¶
Configuration for trailing-comma behavior.
- trailing_commas¶
alias of
TrailingCommas
- true_literal: ClassVar[str] = 'ABool (True)'¶
- property type_hint_collection_preamble_lines: Callable[[frozenset[type]], tuple[str, ...]]¶
Return preamble lines for empty-collection type hints.
- property validate_call_arg: Callable[[Value], None]¶
Return call-argument validation for this language.
- static validate_spec_for_data(data: Value) None¶
Reject inputs containing an empty mapping on Ada.
The Ada runtime stub renders empty container aggregates (
AList'[],AMap'[]) by sharing a singleAggregateaspect on the unifiedA_Valprivate type, so an empty mapping and an empty sequence collapse to the same value at run time and the mapping/sequence distinction is lost on round-trip. Reject the empty mapping at literalize time rather than emit a literal that silently degrades.
- variable_type_hints: VariableTypeHints = 1¶
- variable_type_hints_formats¶
alias of
VariableTypeHints
- version_formats¶
alias of
VersionFormats
- wrap_calls_with_declarations(declarations: tuple[str, ...], calls: str, body_preamble: tuple[str, ...]) str¶
Wrap Ada call stubs and variable declarations alongside calls.
Stubs and variable declarations go in the declarative section; call expressions go in the executable section.
- wrap_combined_in_file(declaration: str, assignment: str, variable_name: str, body_preamble: tuple[str, ...]) str¶
Wrap Ada declaration + assignment in a single procedure.
Earlier revisions wrapped each form in its own nested
Check_Declaration/Check_Assignmentprocedure, but the assignment then referencedmy_datafrom a sibling scope and only compiled because the lint job did syntax-only checking. Putting both in one procedure keeps the variable in scope so the fixture compiles and runs end-to-end.
- wrap_in_file(content: str, variable_name: str, body_preamble: tuple[str, ...]) str¶
Wrap an Ada object declaration or call block inside a procedure.
When variable_name is non-empty (variable declaration mode), body_preamble and content go in the declarative section and the executable section contains only
null;. When variable_name is empty (call mode), body_preamble (stubs) goes in the declarative section and content (calls) goes in the executable section.
- class literalizer.languages.Bash(*args: object, **kwargs: object)¶
Bash language specification.
- class BoolFormats(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
Empty: this language has no alternative boolean formats.
- class BytesFormats(*values)¶
Bytes formatting options.
- BASE64 = <function format_bytes_base64>¶
- HEX = <function format_bytes_hex>¶
- class DateFormats(*values)¶
Date format options for Bash.
- ISO = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- class DatetimeFormats(*values)¶
Datetime format options for Bash.
- EPOCH = DatetimeFormatConfig(formatter=<function format_datetime_epoch>, preamble_lines=(), type_produced=<class 'int'>)¶
- ISO = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- class DeclarationStyles(*values)¶
Declaration style options.
- DECLARE = DeclarationStyleConfig(formatter=<function _format_variable_declaration>, supports_redefinition=True)¶
- class FloatFormats(*values)¶
Float format options.
- FIXED = <function format_float_fixed>¶
- REPR = <function format_float_repr>¶
- SCIENTIFIC = <function format_float_scientific>¶
- class HeterogeneousStrategies(*values)¶
Heterogeneous-scalar strategy options — this language only supports raising.
- ERROR = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)¶
- class JsonTypes(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
Empty: this language has no JSON value-type variants.
- class Modifiers(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
C++/Java/C#-style declaration modifiers: this language has none.
- class SequenceFormats(*values)¶
Sequence type options for Bash.
- ARRAY = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=')', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)¶
- class SetFormats(*values)¶
Set type options for Bash.
- SET = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close=')', empty_set=None, preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)¶
- class StringFormats(*values)¶
String format options.
- DOUBLE = <function _build_backslash_formatter.<locals>._format>¶
- SINGLE = <function format_string_bash_single>¶
- class TrailingCommas(*values)¶
Trailing comma options.
- NO = TrailingCommaConfig(multiline_trailing_comma=False)¶
- allows_empty_call_parens = True¶
- bool_formats¶
alias of
BoolFormats
- bytes_format: BytesFormats = <function format_bytes_hex>¶
- bytes_formats¶
alias of
BytesFormats
- property call_data_dependent_preamble: Callable[[Value], tuple[str, ...]]¶
Return data-dependent preamble lines for call rendering.
- call_returns_expression = True¶
- call_style: CallStyles = CommandCallStyle(arg_separator=' ')¶
- property call_style_config: PositionalCallStyle | KeywordCallStyle | ObjectCallStyle | PostfixCallStyle | PrefixCallStyle | CommandCallStyle¶
Configuration for the chosen call style.
- call_styles¶
alias of
CallStyles
- property comment_config: CommentConfig¶
Configuration for the language’s comment syntax.
- comment_format: CommentFormats = CommentConfig(prefix='#', suffix='')¶
- comment_formats¶
alias of
CommentFormats
- property compute_body_preamble: Callable[[frozenset[type], Value], tuple[str, ...]]¶
Compute body-preamble lines from the scalar map.
- property consumable_ref_value_inhibits_consuming_form: Callable[[Value], bool]¶
Predicate deciding whether a ref’s underlying value type inhibits the consume form.
Delegates to
never_inhibits_consuming_form. Languages whose consume operator rejects certain value types (notably the Mojo^on register-trivial scalars) override this.
- property data_dependent_preamble: Callable[[Value], tuple[str, ...]]¶
Return data-dependent preamble lines.
- date_format: DateFormats = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- date_formats¶
alias of
DateFormats
- datetime_format: DatetimeFormats = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- datetime_formats¶
alias of
DatetimeFormats
- declaration_style: DeclarationStyles = DeclarationStyleConfig(formatter=<function _format_variable_declaration>, supports_redefinition=True)¶
- declaration_styles¶
alias of
DeclarationStyles
- dict_entry_style: DictEntryStyles = 1¶
- dict_entry_styles¶
alias of
DictEntryStyles
- dict_format: DictFormats = 1¶
- property dict_format_config: DictFormatConfig¶
Configuration for dict formatting.
- dict_formats¶
alias of
DictFormats
- dict_supports_heterogeneous_values = True¶
- element_separator: ClassVar[str] = ' '¶
- empty_dict_keys¶
alias of
EmptyDictKey
- extension = '.sh'¶
- false_literal: ClassVar[str] = 'false'¶
- float_format: FloatFormats = <function format_float_repr>¶
- float_formats¶
alias of
FloatFormats
- property format_bytes: Callable[[bytes], str]¶
Callable that formats a bytes value as a string literal.
- static format_call_arg(_value: Value, formatted: str, /) str¶
Callable that rewrites a formatted direct call argument.
- property format_call_arg_ref_identifier: Callable[[str, Value | None], str]¶
Rewrite a
{"$ref": "name"}identifier in a call-argument context.Delegates to
format_call_ref_identifier. Override this to allow call-argument$refvalues that would otherwise be rejected.
- property format_call_arg_ref_identifier_consumable: Callable[[str, Value | None], str]¶
Format a
$refthe caller authorized as consumable.Delegates to
format_call_arg_ref_identifier. Override this to opt into a consuming form (e.g. C++std::move).
- format_call_binding_body_preamble() tuple[str, ...]¶
Default
format_call_binding_body_preamble– no extra body preamble lines for an inference-bound call result.
- format_call_binding_file_pragmas() tuple[str, ...]¶
Default
format_call_binding_file_pragmas– no file-level compiler-pragma line for an inference-bound call result.
- property format_call_preamble_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]¶
Return file-scope stubs for a call expression.
- property format_call_ref_identifier: Callable[[str, Value | None], str]¶
Rewrite a
{"$ref": "name"}identifier into the language’s call expression syntax.
- property format_call_statement: Callable[[str], str]¶
Return call-statement formatting for this language.
- property format_call_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]¶
Return stub declarations for a call expression.
- property format_call_target: Callable[[Sequence[str]], str]¶
Rewrite a dotted call target into the language’s call syntax.
- property format_call_variable_assignment: Callable[[str, str, Value], str]¶
Callable that formats an assignment binding a call expression.
The existing-variable counterpart of
format_call_variable_declaration: a barename="$(...)"with nodeclarekeyword, matching the literal-binding assignment template.
- property format_call_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]¶
Callable that formats a declaration binding a call expression.
The literal-binding template assigns the right-hand side as a value word; a call result must be command-substituted with
"$(...)"so the shell runs the command and captures its output instead of assigning the command name verbatim.
- static format_constructor_target(class_name: str, /) str¶
Return class_name as a zero-argument constructor call target.
- property format_date: Callable[[date], str]¶
Callable that formats a date as a string literal.
- property format_datetime: Callable[[datetime], str]¶
Callable that formats a datetime as a string literal.
- property format_float: Callable[[float], str]¶
Callable that formats a float value as a literal.
- property format_integer: Callable[[int], str]¶
Format an int value as a literal.
- property format_integer_widened: None¶
Default
format_integer_widened– no mixed-magnitude integer widening, so the renderer keeps the normal integer formatter.
- property format_ordered_map_entry: Callable[[str, Value, str], str]¶
Callable that formats one ordered-map entry.
- property format_sequence_entry: Callable[[Value, str], str]¶
Format a sequence entry.
- property format_set_entry: Callable[[Value, str], str]¶
Format a set entry.
- property format_string: Callable[[str], str]¶
Callable that formats a string value as a quoted literal.
- property format_time: Callable[[time], str]¶
Callable that formats a time as a string literal.
- property format_variable_assignment: Callable[[str, str, Value], str]¶
Callable that formats an assignment to an existing variable.
- property format_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]¶
Callable that formats a new variable declaration.
- has_free_function_calls = True¶
- property heterogeneous_behavior: HeterogeneousBehavior¶
Return the heterogeneous-behavior config.
- heterogeneous_strategies¶
alias of
HeterogeneousStrategies
- heterogeneous_strategy: HeterogeneousStrategies = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)¶
- identifier_cases: ClassVar[tuple[IdentifierCase, ...]] = (IdentifierCase.SNAKE, IdentifierCase.UPPER_SNAKE)¶
- indent: str = ' '¶
- indent_closing_delimiter: ClassVar[bool] = False¶
- integer_format: IntegerFormats = 1¶
- integer_formats¶
alias of
IntegerFormats
- integer_width_strategies¶
alias of
BareIntegerWidthStrategies
- integer_width_strategy: BareIntegerWidthStrategies = 1¶
- language_version: VersionFormats = 1¶
- property leading_preamble: LeadingPreamble¶
Default
leading_preamble– no preamble lines that must precedeLanguage.static_preamble.
- max_call_parameters = 9223372036854775807¶
- modifier_combinations: ClassVar[tuple[ModifierCombination, ...]] = ()¶
- null_literal: ClassVar[str] = '""'¶
- numeric_literal_suffix: NumericLiteralSuffixes = 1¶
- numeric_literal_suffixes¶
alias of
NumericLiteralSuffixes
- numeric_separator: NumericSeparators = 1¶
- numeric_separators¶
alias of
NumericSeparators
- numeric_style: NumericStyles = 1¶
- numeric_styles¶
alias of
NumericStyles
- property ordered_map_format_config: OrderedMapFormatConfig¶
Configuration for ordered-map formatting.
- pygments_name = 'bash'¶
- reserved_identifiers: ClassVar[frozenset[str]] = frozenset({})¶
- property scalar_body_preamble: dict[type, tuple[str, ...]]¶
Per-instance scalar body preamble (Bash needs none).
- property scalar_preamble: dict[type, tuple[str, ...]]¶
Per-instance scalar preamble (Bash needs none).
- sequence_binding_declarations(declarations: tuple[str, ...]) str¶
Default
sequence_binding_declarations– join the per-binding snippets with newlines.
- sequence_format: SequenceFormats = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=')', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)¶
- property sequence_format_config: SequenceFormatConfig¶
Configuration for the chosen sequence format.
- sequence_formats¶
alias of
SequenceFormats
- property sequence_open: Callable[[list[Value]], str]¶
Callable that returns the opening delimiter for a sequence.
- set_format: SetFormats = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close=')', empty_set=None, preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)¶
- property set_format_config: SetFormatConfig¶
Configuration for the chosen set format.
- set_formats¶
alias of
SetFormats
- skip_null_dict_values: ClassVar[bool] = False¶
- special_float_preamble: ClassVar[tuple[str, ...]] = ()¶
- statement_terminator: ClassVar[str] = ''¶
- statement_terminator_style: StatementTerminatorStyles = 1¶
- statement_terminator_styles¶
alias of
StatementTerminatorStyles
- static_body_preamble: ClassVar[Sequence[str]] = ()¶
- static_preamble: ClassVar[Sequence[str]] = ()¶
- string_format: StringFormats = <function _build_backslash_formatter.<locals>._format>¶
- string_formats¶
alias of
StringFormats
- supported_ref_cases: ClassVar[frozenset[IdentifierCase]] = frozenset({IdentifierCase.CAMEL, IdentifierCase.PASCAL, IdentifierCase.SNAKE, IdentifierCase.UPPER_SNAKE})¶
- supports_call_style = True¶
- supports_collection_comments: ClassVar[bool] = True¶
- supports_default_dict_key_type = False¶
- supports_default_dict_value_type = False¶
- supports_default_ordered_map_value_type = False¶
- supports_default_sequence_element_type = False¶
- supports_default_set_element_type = False¶
- supports_dict_literal_as_free_expression = True¶
- supports_dotted_call_stub = True¶
- supports_dotted_calls = True¶
- supports_empty_dict_key = False¶
- supports_inline_multiline_dict_args = True¶
- supports_module_name = False¶
- supports_multi_param_call_wrapper_stub = True¶
- supports_no_variable_wrap_in_file = False¶
- supports_non_string_dict_keys = True¶
- supports_record_shape_names = False¶
- supports_record_struct_name_prefix = False¶
- supports_scalar_before_comments: ClassVar[bool] = False¶
- supports_scalar_inline_comments: ClassVar[bool] = True¶
- supports_special_floats = True¶
- supports_standalone_comments_in_wrapped_calls = True¶
- supports_variable_names = True¶
- supports_zero_parameter_calls = True¶
- trailing_comma: TrailingCommas = TrailingCommaConfig(multiline_trailing_comma=False)¶
- property trailing_comma_config: TrailingCommaConfig¶
Configuration for trailing-comma behavior.
- trailing_commas¶
alias of
TrailingCommas
- true_literal: ClassVar[str] = 'true'¶
- property type_hint_collection_preamble_lines: Callable[[frozenset[type]], tuple[str, ...]]¶
Return preamble lines for empty-collection type hints.
- static validate_call_arg(value: Value) None¶
Reject list, dict, and set values as Bash call arguments.
Bash commands take space-separated positional arguments and have no syntax for inline compound literals —
cmd (1 2 3)parses ascmdfollowed by a nested(...)child-process group, andcmd (["k"]=v)likewise. Callers that need to pass a collection must declare it as a variable first and pass the name via a$refmarker.
- validate_spec_for_data(data: Value) None¶
Raise for dict keys that Bash cannot represent.
- variable_type_hints: VariableTypeHints = 1¶
- variable_type_hints_formats¶
alias of
VariableTypeHints
- version_formats¶
alias of
VersionFormats
- wrap_calls_with_declarations(declarations: tuple[str, ...], calls: str, body_preamble: tuple[str, ...]) str¶
Default
wrap_calls_with_declarations— concatenate the declarations and calls and route throughwrap_in_file()in call mode.
- static wrap_combined_in_file(declaration: str, assignment: str, variable_name: str, body_preamble: tuple[str, ...]) str¶
Wrap declaration and assignment in a valid file (no-op).
- static wrap_in_file(content: str, variable_name: str, body_preamble: tuple[str, ...]) str¶
Wrap code in a valid file (no-op).
- class literalizer.languages.C(*args: object, **kwargs: object)¶
C language specification.
- class BoolFormats(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
Empty: this language has no alternative boolean formats.
- class BytesFormats(*values)¶
Bytes formatting options.
- BASE64 = <function format_bytes_base64>¶
- HEX = <function format_bytes_hex>¶
- class CallStyles(*values)¶
C call style options.
- POSITIONAL = PositionalCallStyle(arg_separator=', ', parenthesize_each_arg=False)¶
- class CommentFormats(*values)¶
Comment style options.
- BLOCK = CommentConfig(prefix='/*', suffix=' */')¶
- DOUBLE_SLASH = CommentConfig(prefix='//', suffix='')¶
- class DateFormats(*values)¶
Date format options for C.
- ISO = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- class DatetimeFormats(*values)¶
Datetime format options for C.
- EPOCH = DatetimeFormatConfig(formatter=<function format_datetime_epoch>, preamble_lines=(), type_produced=<class 'int'>)¶
- ISO = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- class DeclarationStyles(*values)¶
Declaration style options.
- TYPED = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=True)¶
- class FloatFormats(*values)¶
Float format options.
- FIXED = <function format_float_fixed>¶
- REPR = <function format_float_repr>¶
- SCIENTIFIC = <function format_float_scientific>¶
- class HeterogeneousStrategies(*values)¶
Heterogeneous-scalar strategy options.
C represents heterogeneous scalar collections with its tagged
CValunion by default (ERROR).RECORDinstead renders each record-shaped dict (non-empty, string-keyed) as a generated aggregatestructdeclared in the preamble plus a matching(struct Record0){.field = value, ...}designated-initializer compound literal, so a field may be a cleanly-typed scalar or a nestedstructrather than aCValunion slot.- ERROR = 1¶
- RECORD = 2¶
- class IntegerFormats(*values)¶
Integer format options.
- DECIMAL = <class 'str'>¶
- HEX = <function format_integer_hex>¶
- class JsonTypes(*values)¶
JSON value type options for C.
- CJSON = 'cJSON'¶
The
cJSONlibrary’scJSON *dynamic JSON value type from<cjson/cJSON.h>.
- class Modifiers(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
C++/Java/C#-style declaration modifiers: this language has none.
- class SequenceFormats(*values)¶
Sequence type options for C.
- ARRAY = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close='}})', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)¶
- class SetFormats(*values)¶
Set type options for C.
- SET = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close='}})', empty_set=None, preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)¶
- class TrailingCommas(*values)¶
Trailing comma options.
- NO = TrailingCommaConfig(multiline_trailing_comma=False)¶
- YES = TrailingCommaConfig(multiline_trailing_comma=True)¶
- allows_empty_call_parens = True¶
- array_field: str = 'a'¶
- bool_field: str = 'b'¶
- bool_formats¶
alias of
BoolFormats
- bytes_format: BytesFormats = <function format_bytes_hex>¶
- bytes_formats¶
alias of
BytesFormats
- property call_data_dependent_preamble: Callable[[Value], tuple[str, ...]]¶
Return data-dependent preamble lines for call rendering.
- call_returns_expression = True¶
- call_style: CallStyles = PositionalCallStyle(arg_separator=', ', parenthesize_each_arg=False)¶
- property call_style_config: PositionalCallStyle¶
Configuration for the chosen call style.
- call_styles¶
alias of
CallStyles
- property comment_config: CommentConfig¶
Configuration for the language’s comment syntax.
- comment_format: CommentFormats = CommentConfig(prefix='//', suffix='')¶
- comment_formats¶
alias of
CommentFormats
- property compute_body_preamble: Callable[[frozenset[type], Value], tuple[str, ...]]¶
Compute body-preamble lines from the scalar map.
- property consumable_ref_value_inhibits_consuming_form: Callable[[Value], bool]¶
Predicate deciding whether a ref’s underlying value type inhibits the consume form.
Delegates to
never_inhibits_consuming_form. Languages whose consume operator rejects certain value types (notably the Mojo^on register-trivial scalars) override this.
- property data_dependent_preamble: Callable[[Value], tuple[str, ...]]¶
Return data-dependent preamble lines.
Under
RECORDthese are the generatedstruct RecordNdeclarations, emitted after the staticCVal/CKVtype declarations (a record field may itself beconst CVal *).
- date_format: DateFormats = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- date_formats¶
alias of
DateFormats
- datetime_format: DatetimeFormats = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- datetime_formats¶
alias of
DatetimeFormats
- declaration_style: DeclarationStyles = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=True)¶
- declaration_styles¶
alias of
DeclarationStyles
- dict_entry_style: DictEntryStyles = 1¶
- dict_entry_styles¶
alias of
DictEntryStyles
- dict_format: DictFormats = 1¶
- property dict_format_config: DictFormatConfig¶
Configuration for dict formatting.
- dict_formats¶
alias of
DictFormats
- dict_supports_heterogeneous_values = True¶
- element_separator: ClassVar[str] = ', '¶
- empty_dict_keys¶
alias of
EmptyDictKey
- extension = '.c'¶
- property false_literal: str¶
Literal representing
False.Bare
falseunderRECORD(a cleanboolrecord field);_format_entryre-wraps it forCValcontexts.
- float_field: str = 'f'¶
- float_format: FloatFormats = <function format_float_repr>¶
- float_formats¶
alias of
FloatFormats
- property format_bytes: Callable[[bytes], str]¶
Callable that formats a bytes value as a string literal.
- property format_call_arg: Callable[[Value, str], str]¶
Wrap each call argument in the
CValunion so call sites match the concrete prototype emitted by_c_call_stub().Under
json_type=CJSONa scalar argument is rendered inline as a singlecJSON_Create*(...)expression instead (the renderedCValtext is discarded), matching thecJSON *stub prototype.
- property format_call_arg_ref_identifier: Callable[[str, Value | None], str]¶
Rewrite a
{"$ref": "name"}identifier in a call-argument context.Delegates to
format_call_ref_identifier. Override this to allow call-argument$refvalues that would otherwise be rejected.
- property format_call_arg_ref_identifier_consumable: Callable[[str, Value | None], str]¶
Format a
$refthe caller authorized as consumable.Delegates to
format_call_arg_ref_identifier. Override this to opt into a consuming form (e.g. C++std::move).
- format_call_binding_body_preamble() tuple[str, ...]¶
Default
format_call_binding_body_preamble– no extra body preamble lines for an inference-bound call result.
- format_call_binding_file_pragmas() tuple[str, ...]¶
Default
format_call_binding_file_pragmas– no file-level compiler-pragma line for an inference-bound call result.
- property format_call_preamble_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]¶
Return file-scope stubs for a call expression.
Under
json_type=CJSONthe universal value type iscJSON *(zero valueNULL) rather than the taggedCValunion, so the stub prototypes and bodies use it.
- property format_call_ref_identifier: Callable[[str, Value | None], str]¶
Rewrite a
{"$ref": "name"}identifier into the language’s call expression syntax.
- property format_call_statement: Callable[[str], str]¶
Return call-statement formatting for this language.
- property format_call_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]¶
Return stub declarations for a call expression.
- property format_call_target: Callable[[Sequence[str]], str]¶
Rewrite a dotted call target into the language’s call syntax.
- property format_call_variable_assignment: Callable[[str, str, Value], str]¶
Callable that formats an assignment binding a call result.
The call-expression counterpart of
format_variable_assignment; the compound-literal wrapping is dropped since the call already yields aCVal.
- property format_call_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]¶
Callable that formats a declaration binding a call result.
A literal binding wraps the right-hand side in a designated- initializer compound literal that encodes the value’s runtime type; a call’s return type is opaque to the renderer and is always the universal
CValunion (the type every generated call stub returns), so the call result is bound directly with a plainCValdeclaration and no compound-literal wrapping.
- static format_constructor_target(class_name: str, /) str¶
Return class_name as a zero-argument constructor call target.
- property format_date: Callable[[date], str]¶
Callable that formats a date as a string literal.
- property format_datetime: Callable[[datetime], str]¶
Callable that formats a datetime as a string literal.
- property format_float: Callable[[float], str]¶
Callable that formats a float value as a literal.
- property format_integer: Callable[[int], str]¶
Callable that formats an int value as a literal.
- property format_integer_widened: None¶
Default
format_integer_widened– no mixed-magnitude integer widening, so the renderer keeps the normal integer formatter.
- property format_ordered_map_entry: Callable[[str, Value, str], str]¶
Callable that formats one ordered-map entry.
- property format_sequence_entry: Callable[[Value, str], str]¶
Callable that formats one sequence entry.
- property format_set_entry: Callable[[Value, str], str]¶
Callable that formats one set entry.
- property format_string: Callable[[str], str]¶
Format a string value as a quoted literal.
- property format_time: Callable[[time], str]¶
Callable that formats a time as a string literal.
- property format_variable_assignment: Callable[[str, str, Value], str]¶
Callable that formats an assignment to an existing variable.
The combined declaration+assignment form is only exercised for a top-level record-shaped dict, so a
RECORDreassignment is a plainmy_data = (struct Record0){...};struct copy.Under
json_type=CJSONthe value is rebuilt as a freshcJSONnode tree and the existing binding is reassigned to its root. A distinct_mnode prefix (the declaration build uses_n) keeps the combined declaration+assignment form free of duplicatecJSON *definitions in one scope.
- property format_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]¶
Callable that formats a new variable declaration.
Under
RECORDa record-shaped root is declared with its generatedstructtype (struct Record0 my_data = (struct Record0){...};) and an all-record-list root as an array (struct Record0 my_data[] = {...};); every other value keeps theCVal-wrapped form.Under
json_type=CJSONthe renderedCValvalue is discarded: the data is built as acJSON_Create*(...)node tree (one statement per node) and the binding declares the rootcJSON *my_data = _n0;.
- has_free_function_calls = True¶
- property heterogeneous_behavior: HeterogeneousBehavior¶
Return the heterogeneous-behavior config.
RECORDresolves to the shared record behavior (its value needs the per-instance renderer, so it cannot be stored on the enum member);ERRORkeeps theCVal-union default.
- heterogeneous_strategies¶
alias of
HeterogeneousStrategies
- heterogeneous_strategy: HeterogeneousStrategies = 1¶
- identifier_cases: ClassVar[tuple[IdentifierCase, ...]] = (IdentifierCase.SNAKE, IdentifierCase.UPPER_SNAKE, IdentifierCase.PASCAL)¶
- indent: str = ' '¶
- indent_closing_delimiter: ClassVar[bool] = False¶
- int_field: str = 'i'¶
- integer_format: IntegerFormats = <class 'str'>¶
- integer_formats¶
alias of
IntegerFormats
- integer_width_strategies¶
alias of
BareIntegerWidthStrategies
- integer_width_strategy: BareIntegerWidthStrategies = 1¶
- key_field: str = 'k'¶
- language_version: VersionFormats = 1¶
- property leading_preamble: LeadingPreamble¶
Default
leading_preamble– no preamble lines that must precedeLanguage.static_preamble.
- map_field: str = 'm'¶
- max_call_parameters = 9223372036854775807¶
- modifier_combinations: ClassVar[tuple[ModifierCombination, ...]] = ()¶
- module_name: str = 'Module'¶
- module_name_case: ClassVar[IdentifierCase] = 'snake'¶
- property null_literal: str¶
Literal representing
None.Bare
NULLunderRECORD(a cleanconst void *record field);_format_entryre-wraps it forCValcontexts.
- numeric_literal_suffix: NumericLiteralSuffixes = 1¶
- numeric_literal_suffixes¶
alias of
NumericLiteralSuffixes
- numeric_separator: NumericSeparators = 1¶
- numeric_separators¶
alias of
NumericSeparators
- numeric_style: NumericStyles = 1¶
- numeric_styles¶
alias of
NumericStyles
- property ordered_map_format_config: OrderedMapFormatConfig¶
Configuration for ordered-map formatting.
- pygments_name = 'c'¶
- reserved_identifiers: ClassVar[frozenset[str]] = frozenset({})¶
- property scalar_body_preamble: dict[type, tuple[str, ...]]¶
Per-instance scalar body preamble (C needs none).
- property scalar_preamble: dict[type, tuple[str, ...]]¶
Per-instance scalar preamble (C needs none).
- sequence_binding_declarations(declarations: tuple[str, ...]) str¶
Default
sequence_binding_declarations– join the per-binding snippets with newlines.
- sequence_format: SequenceFormats = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close='}})', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)¶
- property sequence_format_config: SequenceFormatConfig¶
Configuration for the chosen sequence format.
Under
RECORDthe asymmetric((CVal){.a = (CVal[]){…}})wrapper is dropped: every list is a(CVal[]){...}/{...}initializer closing with a single}(a record field or astructarray, never a free-standingCVal), so the close pairs with_record_sequence_open.
- sequence_formats¶
alias of
SequenceFormats
- property sequence_open: Callable[[list[Value]], str]¶
Callable that returns the opening delimiter for a sequence.
- set_format: SetFormats = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close='}})', empty_set=None, preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)¶
- property set_format_config: SetFormatConfig¶
Configuration for the chosen set format.
- set_formats¶
alias of
SetFormats
- skip_null_dict_values: ClassVar[bool] = False¶
- special_float_preamble: ClassVar[tuple[str, ...]] = ('#include <math.h>',)¶
- statement_terminator: ClassVar[str] = ';'¶
- statement_terminator_style: StatementTerminatorStyles = 1¶
- statement_terminator_styles¶
alias of
StatementTerminatorStyles
- static_body_preamble: ClassVar[Sequence[str]] = ()¶
- property static_preamble: Sequence[str]¶
Static preamble lines emitted once per file.
Under
json_type=CJSONthecJSONheader replaces the defaultCVal/CKVtype declarations: every value is acJSON *node built with the library’s own constructors.
- string_field: str = 's'¶
- string_format: StringFormats = 1¶
- string_formats¶
alias of
StringFormats
- supported_ref_cases: ClassVar[frozenset[IdentifierCase]] = frozenset({IdentifierCase.CAMEL, IdentifierCase.PASCAL, IdentifierCase.SNAKE, IdentifierCase.UPPER_SNAKE})¶
- supports_call_style = True¶
- supports_collection_comments: ClassVar[bool] = True¶
- supports_default_dict_key_type = False¶
- supports_default_dict_value_type = False¶
- supports_default_ordered_map_value_type = False¶
- supports_default_sequence_element_type = False¶
- supports_default_set_element_type = False¶
- supports_dict_literal_as_free_expression = True¶
- supports_dotted_call_stub = True¶
- supports_dotted_calls = True¶
- supports_empty_dict_key = False¶
- supports_inline_multiline_dict_args = True¶
- supports_module_name = True¶
- supports_multi_param_call_wrapper_stub = True¶
- supports_no_variable_wrap_in_file = False¶
- supports_non_string_dict_keys = False¶
- supports_record_shape_names = False¶
- supports_record_struct_name_prefix = False¶
- supports_scalar_before_comments: ClassVar[bool] = True¶
- supports_scalar_inline_comments: ClassVar[bool] = False¶
- supports_special_floats = True¶
- supports_standalone_comments_in_wrapped_calls = True¶
- supports_variable_names = True¶
- supports_zero_parameter_calls = True¶
- trailing_comma: TrailingCommas = TrailingCommaConfig(multiline_trailing_comma=True)¶
- property trailing_comma_config: TrailingCommaConfig¶
Configuration for trailing-comma behavior.
- trailing_commas¶
alias of
TrailingCommas
- property true_literal: str¶
Literal representing
True.Bare
trueunderRECORD(a cleanboolrecord field);_format_entryre-wraps it forCValcontexts.
- property type_hint_collection_preamble_lines: Callable[[frozenset[type]], tuple[str, ...]]¶
Return preamble lines for empty-collection type hints.
- uint_field: str = 'u'¶
- property validate_call_arg: Callable[[Value], None]¶
Return call-argument validation for this language.
- validate_spec_for_data(data: Value) None¶
Raise if the spec cannot produce valid C for data.
Under
json_type=CJSONa dict becomes acJSON_CreateObjectwhose members are keyed by JSON object strings, so non-string dict keys are rejected.Under the
RECORDstrategy a record-shaped dict renders as a(struct RecordN){...}literal (and a list whose elements are all record-shaped dicts as astruct RecordN[]array); astructis not aCValunion member, so a record reachable only through a non-record container would have to occupy aCValslot and cannot compile. The same walk rejects two same-shape records whose shared all-record-list field has differing lengths (the field’s fixed-sizestructarray is sized from the first-seen instance). Rejecting here keeps the boundary explicit rather than emitting C that fails to build (cf. the set / non-record-dict field boundary tracked in #2317). The default (ERROR) strategy is unconstrained.
- value_field: str = 'v'¶
- variable_type_hints: VariableTypeHints = 1¶
- variable_type_hints_formats¶
alias of
VariableTypeHints
- version_formats¶
alias of
VersionFormats
- wrap_calls_with_declarations(declarations: tuple[str, ...], calls: str, body_preamble: tuple[str, ...]) str¶
Default
wrap_calls_with_declarations— concatenate the declarations and calls and route throughwrap_in_file()in call mode.
- wrap_combined_in_file(declaration: str, assignment: str, variable_name: str, body_preamble: tuple[str, ...]) str¶
Wrap C declaration + assignment in a function.
Reads
variable_namebetween the declaration and the assignment so the initial value is not a dead store flagged by clang-tidy’sclang-analyzer-deadcode.DeadStorescheck.
- wrap_in_file(content: str, variable_name: str, body_preamble: tuple[str, ...]) str¶
Wrap a C declaration in a main function.
- class literalizer.languages.CSharp(*args: object, **kwargs: object)¶
C# language specification.
- Parameters:
date_format –
How to format
datetime.datevalues.date_formats.CSHARP—new DateOnly(...)call, e.g.new DateOnly(2024, 1, 15).date_formats.ISO— ISO 8601 quoted string, e.g."2024-01-15".
datetime_format –
How to format
datetime.datetimevalues.datetime_formats.CSHARP—new DateTime(...)call, e.g.new DateTime(2024, 1, 15, 12, 30, 0).datetime_formats.ISO— ISO 8601 quoted string, e.g."2024-01-15T12:30:00".
json_type – When set to
json_types.SYSTEM_TEXT_JSON_NODE, render values throughSystem.Text.Json.Nodes.JsonNode(JsonObject/JsonArray/ typed scalars) instead of C#’s narrow collection types. Dates / datetimes / times switch to ISO 8601 strings (unlessdatetime_formatisEPOCH) and theconstmodifier is rejected because the JSON constructors are not constant expressions.
- class BoolFormats(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
Empty: this language has no alternative boolean formats.
- class BytesFormats(*values)¶
Bytes formatting options.
- BASE64 = <function format_bytes_base64>¶
- HEX = <function format_bytes_hex>¶
- class CallStyles(*values)¶
CSharp call style options.
- NAMED = KeywordCallStyle(separator=': ')¶
- POSITIONAL = PositionalCallStyle(arg_separator=', ', parenthesize_each_arg=False)¶
- class CommentFormats(*values)¶
Comment style options.
- BLOCK = CommentConfig(prefix='/*', suffix=' */')¶
- DOUBLE_SLASH = CommentConfig(prefix='//', suffix='')¶
- class DateFormats(*values)¶
Date format options for C#.
- CSHARP = DateFormatConfig(formatter=<function date_ymd_formatter.<locals>._format>, preamble_lines=('using System;',), type_produced=<class 'datetime.date'>)¶
- ISO = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- class DatetimeFormats(*values)¶
Datetime format options for C#.
- CSHARP = DatetimeFormatConfig(formatter=<function datetime_ymdhms_formatter.<locals>._format>, preamble_lines=('using System;',), type_produced=<class 'datetime.datetime'>)¶
- EPOCH = DatetimeFormatConfig(formatter=<function format_datetime_epoch>, preamble_lines=(), type_produced=<class 'int'>)¶
- ISO = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- class DeclarationStyles(*values)¶
Declaration style options.
- VAR = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=True)¶
- class DictFormats(*values)¶
Dict/map format options.
- DICTIONARY = _CSharpDictSpec(opener_template='new Dictionary<{key_type}, {type_name}> {{')¶
- SORTED_DICTIONARY = _CSharpDictSpec(opener_template='new SortedDictionary<{key_type}, {type_name}> {{')¶
- class FloatFormats(*values)¶
Float format options.
- FIXED = <function format_float_fixed>¶
- REPR = <function format_float_repr>¶
- SCIENTIFIC = <function format_float_scientific>¶
- class HeterogeneousStrategies(*values)¶
Heterogeneous-scalar strategy options.
ERRORraises on any value that cannot be represented.RECORDrenders each record-shaped dict (non-empty, string-keyed) as a generated positionalrecorddeclared in the preamble plus a matching positional literal, rather than a homogeneousDictionary.- ERROR = 1¶
- RECORD = 2¶
- class IntegerFormats(*values)¶
Integer format options.
- BINARY = mappingproxy({'NONE': <function format_integer_binary>, 'UNDERSCORE': <function format_integer_binary>})¶
- DECIMAL = mappingproxy({'NONE': <class 'str'>, 'UNDERSCORE': <function format_integer_underscore>})¶
- HEX = mappingproxy({'NONE': <function format_integer_hex>, 'UNDERSCORE': <function format_integer_hex>})¶
- get_formatter(numeric_separator: Enum) Callable[[int], str]¶
Return the integer formatter for the given separator.
- class JsonTypes(*values)¶
JSON value type options for C#.
- SYSTEM_TEXT_JSON_NODE = 'JsonNode'¶
System.Text.Json.Nodes.JsonNode, the built-in .NET JSON document object model.
- Modifiers¶
alias of
_CSharpModifiers
- class SequenceFormats(*values)¶
Sequence type options for C#.
- ARRAY = <function sequence_format_factory.<locals>._build>¶
- TUPLE = <function sequence_format_factory.<locals>._build>¶
- class SetFormats(*values)¶
Set type options for C#.
- HASH_SET = <function set_format_factory.<locals>._build>¶
- SORTED_SET = <function set_format_factory.<locals>._build>¶
- class StringFormats(*values)¶
String format options.
- DOUBLE = <function _build_backslash_formatter.<locals>._format>¶
- VERBATIM = <function format_string_verbatim_csharp>¶
- class TrailingCommas(*values)¶
Trailing comma options.
- NO = TrailingCommaConfig(multiline_trailing_comma=False)¶
- YES = TrailingCommaConfig(multiline_trailing_comma=True)¶
- allows_empty_call_parens = True¶
- bool_formats¶
alias of
BoolFormats
- bytes_format: BytesFormats = <function format_bytes_hex>¶
- bytes_formats¶
alias of
BytesFormats
- property call_data_dependent_preamble: Callable[[Value], tuple[str, ...]]¶
Return data-dependent preamble lines for call rendering.
- call_returns_expression = True¶
- call_style: CallStyles = PositionalCallStyle(arg_separator=', ', parenthesize_each_arg=False)¶
- property call_style_config: PositionalCallStyle | KeywordCallStyle | ObjectCallStyle | PostfixCallStyle | PrefixCallStyle | CommandCallStyle¶
Configuration for the chosen call style.
- call_styles¶
alias of
CallStyles
- property comment_config: CommentConfig¶
Configuration for the language’s comment syntax.
- comment_format: CommentFormats = CommentConfig(prefix='//', suffix='')¶
- comment_formats¶
alias of
CommentFormats
- property compute_body_preamble: Callable[[frozenset[type], Value], tuple[str, ...]]¶
Compute body-preamble lines from the scalar map.
- property consumable_ref_value_inhibits_consuming_form: Callable[[Value], bool]¶
Predicate deciding whether a ref’s underlying value type inhibits the consume form.
Delegates to
never_inhibits_consuming_form. Languages whose consume operator rejects certain value types (notably the Mojo^on register-trivial scalars) override this.
- property data_dependent_preamble: Callable[[Value], tuple[str, ...]]¶
Return data-dependent preamble lines.
Under
json_typeevery rendered file pulls inSystem.Text.Json.Nodesunconditionally; the per-collection format configurations leave theirpreamble_linesempty so theusingline is emitted here exactly once regardless of which container shapes appear in the data.Under
HeterogeneousStrategies.RECORDthis emits one positionalrecorddeclaration per record shape present in the data; otherwise C# needs no data-dependent preamble.
- date_format: DateFormats = DateFormatConfig(formatter=<function date_ymd_formatter.<locals>._format>, preamble_lines=('using System;',), type_produced=<class 'datetime.date'>)¶
- date_formats¶
alias of
DateFormats
- datetime_format: DatetimeFormats = DatetimeFormatConfig(formatter=<function datetime_ymdhms_formatter.<locals>._format>, preamble_lines=('using System;',), type_produced=<class 'datetime.datetime'>)¶
- datetime_formats¶
alias of
DatetimeFormats
- declaration_style: DeclarationStyles = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=True)¶
- declaration_styles¶
alias of
DeclarationStyles
- default_dict_key_type: str = 'string'¶
- default_dict_value_type: str = 'object'¶
- default_sequence_element_type: str = 'object'¶
- default_set_element_type: str = 'object'¶
- dict_entry_style: DictEntryStyles = 1¶
- dict_entry_styles¶
alias of
DictEntryStyles
- dict_format: DictFormats = _CSharpDictSpec(opener_template='new Dictionary<{key_type}, {type_name}> {{')¶
- property dict_format_config: DictFormatConfig¶
Configuration for dict formatting.
Under
json_typeevery dict literal is wrapped innew JsonObject { ["key"] = value, ... }so it renders as a JSON object, and an empty dict widens tonew JsonObject(). Theusing System.Text.Json.Nodes;line that powersJsonObjectis contributed bydata_dependent_preamblerather than from this config, so a json-mode fixture imports it exactly once regardless of how many dict literals appear.
- dict_formats¶
alias of
DictFormats
- dict_supports_heterogeneous_values = True¶
- element_separator: ClassVar[str] = ', '¶
- empty_dict_keys¶
alias of
EmptyDictKey
- extension = '.cs'¶
- false_literal: ClassVar[str] = 'false'¶
- float_format: FloatFormats = <function format_float_repr>¶
- float_formats¶
alias of
FloatFormats
- property format_bytes: Callable[[bytes], str]¶
Callable that formats a bytes value as a string literal.
- property format_call_arg: Callable[[Value, str], str]¶
Callable that rewrites a formatted direct call argument.
Under
json_typeevery call argument is cast toJsonNode?so the underlying stub receives a JSON value; under any other mode call arguments pass through unchanged.
- property format_call_arg_ref_identifier: Callable[[str, Value | None], str]¶
Rewrite a
{"$ref": "name"}identifier in a call-argument context.Delegates to
format_call_ref_identifier. Override this to allow call-argument$refvalues that would otherwise be rejected.
- property format_call_arg_ref_identifier_consumable: Callable[[str, Value | None], str]¶
Format a
$refthe caller authorized as consumable.Delegates to
format_call_arg_ref_identifier. Override this to opt into a consuming form (e.g. C++std::move).
- format_call_binding_body_preamble() tuple[str, ...]¶
Default
format_call_binding_body_preamble– no extra body preamble lines for an inference-bound call result.
- format_call_binding_file_pragmas() tuple[str, ...]¶
Default
format_call_binding_file_pragmas– no file-level compiler-pragma line for an inference-bound call result.
- property format_call_preamble_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]¶
Return file-scope stubs for a call expression.
- property format_call_ref_identifier: Callable[[str, Value | None], str]¶
Rewrite a
{"$ref": "name"}identifier into the language’s call expression syntax.
- property format_call_statement: Callable[[str], str]¶
Return call-statement formatting for this language.
- property format_call_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]¶
Return stub declarations for a call expression.
- property format_call_target: Callable[[Sequence[str]], str]¶
Rewrite a dotted call target into the language’s call syntax.
- property format_call_variable_assignment: Callable[[str, str, Value], str]¶
Default
format_call_variable_assignment– reuse the literal-binding assignment formatter unchanged.
- property format_call_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]¶
Default
format_call_variable_declaration– reuse the literal-binding declaration formatter unchanged.
- static format_constructor_target(class_name: str, /) str¶
Return a
new ClassNameconstructor call target.
- property format_date: Callable[[date], str]¶
Callable that formats a date as a string literal.
json_typeoverrides the configureddate_formatwith the ISO 8601 string form because the C# nativeDateOnlyliteral would not round-trip through JSON.
- property format_datetime: Callable[[datetime], str]¶
Callable that formats a datetime as a string literal.
json_typeoverrides the configureddatetime_formatwith the ISO 8601 string form unless the user has explicitly chosen theEPOCHinteger form, which remains a valid JSON number.
- property format_float: Callable[[float], str]¶
Callable that formats a float value as a literal.
- property format_integer: Callable[[int], str]¶
Callable that formats an int value as a literal.
Positive values above
long.MaxValueare accepted as bare literals because C# infersulongfor literals without a type suffix up toulong.MaxValue. Values belowlong.MinValuehave no clean literal form (unary minus cannot apply toulong), so they raiseUnrepresentableIntegerError.
- property format_integer_widened: None¶
Default
format_integer_widened– no mixed-magnitude integer widening, so the renderer keeps the normal integer formatter.
- property format_ordered_map_entry: Callable[[str, Value, str], str]¶
Format one ordered-map entry.
Under
json_typean ordered map renders as aJsonObject, whose collection initializer takesKeyValuePairentries via the indexer["key"] = valueform (matching the dict renderer).
- property format_sequence_entry: Callable[[Value, str], str]¶
Format a sequence entry.
- property format_set_entry: Callable[[Value, str], str]¶
Format a set entry.
- property format_string: Callable[[str], str]¶
Callable that formats a string value as a quoted literal.
- property format_time: Callable[[time], str]¶
Callable that formats a time as a string literal.
json_typeoverrides the nativeTimeOnlyliteral with the ISO 8601 string form because there is no implicit conversion fromTimeOnlytoJsonNodeand JSON has no native time type.
- property format_variable_assignment: Callable[[str, str, Value], str]¶
Format an assignment to an existing variable.
Under
json_typethe assigned expression is cast toJsonNode?through the same helper as the declaration form so the two halves of a combined declaration / assignment stay consistent.
- property format_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]¶
Callable that formats a new variable declaration.
Under
json_typethe declaration carries an explicitJsonNode?type annotation (nevervar) and the right-hand side is wrapped in a(JsonNode?)cast unless the value is already aJsonObject/JsonArrayliteral. The per-declaration formatter rejects theconstmodifier because every json-mode initializer (the cast or the constructor) is a runtime expression.
- has_free_function_calls = True¶
- property heterogeneous_behavior: HeterogeneousBehavior¶
Return the heterogeneous-behavior config.
json_typerelaxes scalar-type checks unconditionally, becauseJsonObject/JsonArrayaccept heterogeneousJsonNodechildren by construction.RECORDresolves to the shared record behavior (its value needs the per-instance renderer, so it cannot be stored on the enum member);ERRORuses the static raising behavior.
- heterogeneous_strategies¶
alias of
HeterogeneousStrategies
- heterogeneous_strategy: HeterogeneousStrategies = 1¶
- identifier_cases: ClassVar[tuple[IdentifierCase, ...]] = (IdentifierCase.PASCAL, IdentifierCase.CAMEL, IdentifierCase.UPPER_SNAKE)¶
- indent: str = ' '¶
- indent_closing_delimiter: ClassVar[bool] = False¶
- integer_format: IntegerFormats = mappingproxy({'NONE': <class 'str'>, 'UNDERSCORE': <function format_integer_underscore>})¶
- integer_formats¶
alias of
IntegerFormats
- integer_width_strategies¶
alias of
BareIntegerWidthStrategies
- integer_width_strategy: BareIntegerWidthStrategies = 1¶
- language_version: VersionFormats = 1¶
- property leading_preamble: LeadingPreamble¶
Default
leading_preamble– no preamble lines that must precedeLanguage.static_preamble.
- max_call_parameters = 9223372036854775807¶
- modifier_combinations: ClassVar[tuple[ModifierCombination, ...]] = (ModifierCombination(name='public_static_readonly', modifiers=frozenset({<_CSharpModifiers.PUBLIC: 'public'>, <_CSharpModifiers.READONLY: 'readonly'>, <_CSharpModifiers.STATIC: 'static'>})),)¶
- modifiers¶
alias of
_CSharpModifiers
- property null_literal: str¶
Null literal for the active C# representation.
Under
json_typean explicitly-typed(JsonNode?)nullkeeps a top-levelnullfrom ambiguously binding to a method overload (System.Text.Json.Nodesexposes implicit operators from many primitive types that a barenullliteral would also match).
- numeric_literal_suffix: NumericLiteralSuffixes = 1¶
- numeric_literal_suffixes¶
alias of
NumericLiteralSuffixes
- numeric_separator: NumericSeparators = 1¶
- numeric_separators¶
alias of
NumericSeparators
- numeric_style: NumericStyles = 1¶
- numeric_styles¶
alias of
NumericStyles
- property ordered_map_format_config: OrderedMapFormatConfig¶
Configuration for ordered-map formatting.
Under
json_typean ordered map renders as aJsonObject; theSystem.Text.Json.Nodeslibrary preserves the indexer insertion order in the rendered output, so the JSON object opener is interchangeable with the dict opener here.
- pygments_name = 'csharp'¶
- reserved_identifiers: ClassVar[frozenset[str]] = frozenset({})¶
- property scalar_body_preamble: dict[type, tuple[str, ...]]¶
Per-instance scalar body preamble (C# needs none).
- property scalar_preamble: dict[type, tuple[str, ...]]¶
Per-instance scalar preamble computed from date/datetime format.
Under
json_typetheusing System.Text.Json.Nodes;line is contributed bydata_dependent_preambleinstead, so this method returns an empty per-scalar map to avoid duplicating it; dates / datetimes / times all render as ISO 8601 strings (or an epoch integer for the explicitEPOCHdatetime format) and need no per-scalar import of their own.
- sequence_binding_declarations(declarations: tuple[str, ...]) str¶
Default
sequence_binding_declarations– join the per-binding snippets with newlines.
- sequence_format: SequenceFormats = <function sequence_format_factory.<locals>._build>¶
- property sequence_format_config: SequenceFormatConfig¶
Configuration for the chosen sequence format.
Under
json_typeevery sequence is rendered asnew JsonArray { ... }(andnew JsonArray()for the empty case), which accepts heterogeneousJsonNodechildren via the implicit conversion operators onSystem.Text.Json.Nodes. Theusingdirective is contributed bydata_dependent_preamble, so this config leaves itspreamble_linesempty.()parses as an invalid expression in C#; the language’sValueTuple.Create()(or a typed empty array literalnew T[] {}for the array format) is the syntactically valid empty form, so prefer it whenever an empty inner list sits beside non-empty siblings. The array empty form is a plain language-level array literal, neverArray.Empty<T>(), so the array path needs nousing System;.
- sequence_formats¶
alias of
SequenceFormats
- property sequence_open: Callable[[list[Value]], str]¶
Callable that returns the opening delimiter for a sequence.
Under the
RECORDstrategy a list whose every element is a record-shaped dict renders each element as a generatedRecordNliteral; the typed opener would type such a listDictionary<string, object>[](the homogeneous-map element type) which the record literals cannot initialize. Such a list is instead opened with an implicitly-typed arraynew[] {so C# infersRecordN[]from the literals. Every other list keeps the typed array opener.json_typetakes precedence over theRECORDstrategy: record-shaped dicts under json mode render asnew JsonObject { ... }(not asRecordNliterals), so their parent list must keep the jsonnew JsonArray {opener rather than the implicitly-typednew[] {form, which would otherwise infer aJsonObject[]array that is not what json mode promises.
- set_format: SetFormats = <function set_format_factory.<locals>._build>¶
- property set_format_config: SetFormatConfig¶
Configuration for the chosen set format (with typed opener).
Under
json_typea set renders as anew JsonArray { ... }because JSON has no native set type; the empty form widens tonew JsonArray()for the same reason an empty sequence does.
- set_formats¶
alias of
SetFormats
- skip_null_dict_values: ClassVar[bool] = False¶
- special_float_preamble: ClassVar[tuple[str, ...]] = ()¶
- statement_terminator: ClassVar[str] = ';'¶
- statement_terminator_style: StatementTerminatorStyles = 1¶
- statement_terminator_styles¶
alias of
StatementTerminatorStyles
- static_body_preamble: ClassVar[Sequence[str]] = ()¶
- static_preamble: ClassVar[Sequence[str]] = ()¶
- string_format: StringFormats = <function _build_backslash_formatter.<locals>._format>¶
- string_formats¶
alias of
StringFormats
- supported_ref_cases: ClassVar[frozenset[IdentifierCase]] = frozenset({IdentifierCase.CAMEL, IdentifierCase.PASCAL, IdentifierCase.SNAKE, IdentifierCase.UPPER_SNAKE})¶
- supports_call_style = True¶
- supports_collection_comments: ClassVar[bool] = True¶
- supports_default_dict_key_type = True¶
- supports_default_dict_value_type = True¶
- supports_default_ordered_map_value_type = False¶
- supports_default_sequence_element_type = True¶
- supports_default_set_element_type = True¶
- supports_dict_literal_as_free_expression = True¶
- supports_dotted_call_stub = True¶
- supports_dotted_calls = True¶
- supports_empty_dict_key = False¶
- supports_inline_multiline_dict_args = True¶
- supports_module_name = False¶
- supports_multi_param_call_wrapper_stub = True¶
- supports_no_variable_wrap_in_file = False¶
- supports_non_string_dict_keys = False¶
- supports_record_shape_names = False¶
- supports_record_struct_name_prefix = False¶
- supports_scalar_before_comments: ClassVar[bool] = True¶
- supports_scalar_inline_comments: ClassVar[bool] = False¶
- supports_special_floats = True¶
- supports_standalone_comments_in_wrapped_calls = True¶
- supports_variable_names = True¶
- supports_zero_parameter_calls = True¶
- trailing_comma: TrailingCommas = TrailingCommaConfig(multiline_trailing_comma=False)¶
- property trailing_comma_config: TrailingCommaConfig¶
Configuration for trailing-comma behavior.
- trailing_commas¶
alias of
TrailingCommas
- true_literal: ClassVar[str] = 'true'¶
- property type_hint_collection_preamble_lines: Callable[[frozenset[type]], tuple[str, ...]]¶
Return preamble lines for empty-collection type hints.
- property validate_call_arg: Callable[[Value], None]¶
Return call-argument validation for this language.
- validate_spec_for_data(data: Value) None¶
Validate C#-specific data / format combinations.
Under
json_typeonly dict keys that are strings can be represented as JSON object keys, so a non-string dict key is rejected up-front rather than emitted as a[<non-string>] = ...initializer that the C# compiler would reject.
- variable_type_hints: VariableTypeHints = 1¶
- variable_type_hints_formats¶
alias of
VariableTypeHints
- version_formats¶
alias of
VersionFormats
- wrap_calls_with_declarations(declarations: tuple[str, ...], calls: str, body_preamble: tuple[str, ...]) str¶
Default
wrap_calls_with_declarations— concatenate the declarations and calls and route throughwrap_in_file()in call mode.
- wrap_combined_in_file(declaration: str, assignment: str, variable_name: str, body_preamble: tuple[str, ...]) str¶
Wrap declaration and assignment in a valid file.
Under the
RECORDstrategy the declaration and assignment are top-level statements that must follow the file-scoperecorddeclarations, so they are wrapped as aMainmethod body viawrap_in_file(); otherwise this is a no-op.
- wrap_in_file(content: str, variable_name: str, body_preamble: tuple[str, ...]) str¶
Wrap code in a valid file.
When content starts with a class-field modifier keyword (one of the visibility or storage keywords that C# only accepts on class members) the declaration is placed inside a
class Checkbody with aMainentry point.When body_preamble carries call-stub declarations (
class Foo_ { ... }andstatic Foo_ foo = new Foo_();) the whole file is wrapped inclass Check { ...stubs... static void Main() { ...content... } }. C# requires type declarations to follow top-level statements, so stubs cannot sit before top-level calls — wrapping them as class members sidesteps that ordering rule.Under the
RECORDstrategy a record literal’svardeclaration would otherwise be a bare top-level statement, but the generatedrecorddeclarations are emitted at file scope (by the data-dependent preamble) ahead of this output and C# forbids a top-level statement after a type declaration; such content is therefore wrapped as aMainmethod body insideclass Checkrather than left as a top-level statement (call stubs and class-field declarations keep their own wrapping).Otherwise the content is emitted as a top-level statement, which is the only context where
vardeclarations are valid.
- class literalizer.languages.Clojure(*args: object, **kwargs: object)¶
Clojure language specification.
- class BoolFormats(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
Empty: this language has no alternative boolean formats.
- class BytesFormats(*values)¶
Bytes formatting options.
- BASE64 = <function format_bytes_base64>¶
- HEX = <function format_bytes_hex>¶
- class CallStyles(*values)¶
Clojure call style options.
- PREFIX_KEYWORD = PrefixCallStyle(arg_separator=' ', keyword_prefix=':')¶
- class CommentFormats(*values)¶
Comment style options.
- SEMICOLON = CommentConfig(prefix=';', suffix='')¶
- class DateFormats(*values)¶
Date format options for Clojure.
- ISO = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- class DatetimeFormats(*values)¶
Datetime format options for Clojure.
- EPOCH = DatetimeFormatConfig(formatter=<function format_datetime_epoch>, preamble_lines=(), type_produced=<class 'int'>)¶
- ISO = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- class DeclarationStyles(*values)¶
Declaration style options.
- DEF = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=True)¶
- class FloatFormats(*values)¶
Float format options.
- FIXED = <function format_float_fixed>¶
- REPR = <function format_float_repr>¶
- SCIENTIFIC = <function format_float_scientific>¶
- class HeterogeneousStrategies(*values)¶
Heterogeneous-scalar strategy options — this language only supports raising.
- ERROR = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)¶
- class JsonTypes(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
Empty: this language has no JSON value-type variants.
- class Modifiers(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
C++/Java/C#-style declaration modifiers: this language has none.
- class SequenceFormats(*values)¶
Sequence type options for Clojure.
- VECTOR = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=']', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)¶
- class SetFormats(*values)¶
Set type options for Clojure.
- SET = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close='}', empty_set=None, preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)¶
- class TrailingCommas(*values)¶
Trailing comma options.
- NO = TrailingCommaConfig(multiline_trailing_comma=False)¶
- allows_empty_call_parens = True¶
- bool_formats¶
alias of
BoolFormats
- bytes_format: BytesFormats = <function format_bytes_hex>¶
- bytes_formats¶
alias of
BytesFormats
- property call_data_dependent_preamble: Callable[[Value], tuple[str, ...]]¶
Return data-dependent preamble lines for call rendering.
- call_returns_expression = True¶
- call_style: CallStyles = PrefixCallStyle(arg_separator=' ', keyword_prefix=':')¶
- property call_style_config: PositionalCallStyle | KeywordCallStyle | ObjectCallStyle | PostfixCallStyle | PrefixCallStyle | CommandCallStyle¶
Configuration for Clojure’s call style.
- call_styles¶
alias of
CallStyles
- property comment_config: CommentConfig¶
Configuration for the language’s comment syntax.
- comment_format: CommentFormats = CommentConfig(prefix=';', suffix='')¶
- comment_formats¶
alias of
CommentFormats
- property compute_body_preamble: Callable[[frozenset[type], Value], tuple[str, ...]]¶
Compute body-preamble lines from the scalar map.
- property consumable_ref_value_inhibits_consuming_form: Callable[[Value], bool]¶
Predicate deciding whether a ref’s underlying value type inhibits the consume form.
Delegates to
never_inhibits_consuming_form. Languages whose consume operator rejects certain value types (notably the Mojo^on register-trivial scalars) override this.
- property data_dependent_preamble: Callable[[Value], tuple[str, ...]]¶
Return data-dependent preamble lines.
- date_format: DateFormats = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- date_formats¶
alias of
DateFormats
- datetime_format: DatetimeFormats = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- datetime_formats¶
alias of
DatetimeFormats
- declaration_style: DeclarationStyles = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=True)¶
- declaration_styles¶
alias of
DeclarationStyles
- dict_entry_style: DictEntryStyles = 1¶
- dict_entry_styles¶
alias of
DictEntryStyles
- dict_format: DictFormats = 1¶
- property dict_format_config: DictFormatConfig¶
Configuration for dict formatting.
- dict_formats¶
alias of
DictFormats
- dict_supports_heterogeneous_values = True¶
- element_separator: ClassVar[str] = ' '¶
- empty_dict_keys¶
alias of
EmptyDictKey
- extension = '.clj'¶
- false_literal: ClassVar[str] = 'false'¶
- float_format: FloatFormats = <function format_float_repr>¶
- float_formats¶
alias of
FloatFormats
- property format_bytes: Callable[[bytes], str]¶
Callable that formats a bytes value as a string literal.
- static format_call_arg(_value: Value, formatted: str, /) str¶
Callable that rewrites a formatted direct call argument.
- property format_call_arg_ref_identifier: Callable[[str, Value | None], str]¶
Rewrite a
{"$ref": "name"}identifier in a call-argument context.Delegates to
format_call_ref_identifier. Override this to allow call-argument$refvalues that would otherwise be rejected.
- property format_call_arg_ref_identifier_consumable: Callable[[str, Value | None], str]¶
Format a
$refthe caller authorized as consumable.Delegates to
format_call_arg_ref_identifier. Override this to opt into a consuming form (e.g. C++std::move).
- format_call_binding_body_preamble() tuple[str, ...]¶
Default
format_call_binding_body_preamble– no extra body preamble lines for an inference-bound call result.
- format_call_binding_file_pragmas() tuple[str, ...]¶
Default
format_call_binding_file_pragmas– no file-level compiler-pragma line for an inference-bound call result.
- property format_call_preamble_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]¶
Return file-scope stubs for a call expression.
- property format_call_ref_identifier: Callable[[str, Value | None], str]¶
Raise for any
{"$ref": "name"}identifier.Clojure output is not wrapped in a function body, so symbol references require a surrounding
defthat cannot be injected.
- property format_call_statement: Callable[[str], str]¶
Return call-statement formatting for this language.
- property format_call_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]¶
Return stub declarations for a call expression.
- property format_call_target: Callable[[Sequence[str]], str]¶
Rewrite a dotted call target into the language’s call syntax.
- property format_call_variable_assignment: Callable[[str, str, Value], str]¶
Default
format_call_variable_assignment– reuse the literal-binding assignment formatter unchanged.
- property format_call_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]¶
Default
format_call_variable_declaration– reuse the literal-binding declaration formatter unchanged.
- static format_constructor_target(class_name: str, /) str¶
Return class_name as a zero-argument constructor call target.
- property format_date: Callable[[date], str]¶
Callable that formats a date as a string literal.
- property format_datetime: Callable[[datetime], str]¶
Callable that formats a datetime as a string literal.
- property format_float: Callable[[float], str]¶
Callable that formats a float value as a literal.
- property format_integer: Callable[[int], str]¶
Format an int value as a literal.
- property format_integer_widened: None¶
Default
format_integer_widened– no mixed-magnitude integer widening, so the renderer keeps the normal integer formatter.
- property format_ordered_map_entry: Callable[[str, Value, str], str]¶
Callable that formats one ordered-map entry.
- property format_sequence_entry: Callable[[Value, str], str]¶
Format a sequence entry.
- property format_set_entry: Callable[[Value, str], str]¶
Format a set entry.
- property format_string: Callable[[str], str]¶
Format a string value as a quoted literal.
- property format_time: Callable[[time], str]¶
Callable that formats a time as a string literal.
- property format_variable_assignment: Callable[[str, str, Value], str]¶
Callable that formats an assignment to an existing variable.
- property format_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]¶
Callable that formats a new variable declaration.
- has_free_function_calls = True¶
- property heterogeneous_behavior: HeterogeneousBehavior¶
Return the heterogeneous-behavior config.
- heterogeneous_strategies¶
alias of
HeterogeneousStrategies
- heterogeneous_strategy: HeterogeneousStrategies = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)¶
- identifier_cases: ClassVar[tuple[IdentifierCase, ...]] = (IdentifierCase.KEBAB,)¶
- indent: str = ' '¶
- indent_closing_delimiter: ClassVar[bool] = False¶
- integer_format: IntegerFormats = 1¶
- integer_formats¶
alias of
IntegerFormats
- integer_width_strategies¶
alias of
BareIntegerWidthStrategies
- integer_width_strategy: BareIntegerWidthStrategies = 1¶
- language_version: VersionFormats = 1¶
- property leading_preamble: LeadingPreamble¶
Default
leading_preamble– no preamble lines that must precedeLanguage.static_preamble.
- max_call_parameters = 9223372036854775807¶
- modifier_combinations: ClassVar[tuple[ModifierCombination, ...]] = ()¶
- null_literal: ClassVar[str] = 'nil'¶
- numeric_literal_suffix: NumericLiteralSuffixes = 1¶
- numeric_literal_suffixes¶
alias of
NumericLiteralSuffixes
- numeric_separator: NumericSeparators = 1¶
- numeric_separators¶
alias of
NumericSeparators
- numeric_style: NumericStyles = 1¶
- numeric_styles¶
alias of
NumericStyles
- property ordered_map_format_config: OrderedMapFormatConfig¶
Configuration for ordered-map formatting.
- pygments_name = 'clojure'¶
- reserved_identifiers: ClassVar[frozenset[str]] = frozenset({})¶
- property scalar_body_preamble: dict[type, tuple[str, ...]]¶
Per-instance scalar body preamble (Clojure needs none).
- property scalar_preamble: dict[type, tuple[str, ...]]¶
Per-instance scalar preamble (Clojure needs none).
- sequence_binding_declarations(declarations: tuple[str, ...]) str¶
Default
sequence_binding_declarations– join the per-binding snippets with newlines.
- sequence_format: SequenceFormats = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=']', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)¶
- property sequence_format_config: SequenceFormatConfig¶
Configuration for the chosen sequence format.
- sequence_formats¶
alias of
SequenceFormats
- property sequence_open: Callable[[list[Value]], str]¶
Callable that returns the opening delimiter for a sequence.
- set_format: SetFormats = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close='}', empty_set=None, preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)¶
- property set_format_config: SetFormatConfig¶
Configuration for the chosen set format.
- set_formats¶
alias of
SetFormats
- skip_null_dict_values: ClassVar[bool] = False¶
- special_float_preamble: ClassVar[tuple[str, ...]] = ()¶
- statement_terminator: ClassVar[str] = ''¶
- statement_terminator_style: StatementTerminatorStyles = 1¶
- statement_terminator_styles¶
alias of
StatementTerminatorStyles
- static_body_preamble: ClassVar[Sequence[str]] = ()¶
- static_preamble: ClassVar[Sequence[str]] = ()¶
- string_format: StringFormats = 1¶
- string_formats¶
alias of
StringFormats
- supported_ref_cases: ClassVar[frozenset[IdentifierCase]] = frozenset({IdentifierCase.CAMEL, IdentifierCase.KEBAB, IdentifierCase.PASCAL, IdentifierCase.SNAKE, IdentifierCase.UPPER_SNAKE})¶
- supports_call_style = True¶
- supports_collection_comments: ClassVar[bool] = True¶
- supports_default_dict_key_type = False¶
- supports_default_dict_value_type = False¶
- supports_default_ordered_map_value_type = False¶
- supports_default_sequence_element_type = False¶
- supports_default_set_element_type = False¶
- supports_dict_literal_as_free_expression = True¶
- supports_dotted_call_stub = True¶
- supports_dotted_calls = True¶
- supports_empty_dict_key = False¶
- supports_inline_multiline_dict_args = True¶
- supports_module_name = False¶
- supports_multi_param_call_wrapper_stub = True¶
- supports_no_variable_wrap_in_file = True¶
- supports_non_string_dict_keys = True¶
- supports_record_shape_names = False¶
- supports_record_struct_name_prefix = False¶
- supports_scalar_before_comments: ClassVar[bool] = True¶
- supports_scalar_inline_comments: ClassVar[bool] = False¶
- supports_special_floats = True¶
- supports_standalone_comments_in_wrapped_calls = True¶
- supports_variable_names = True¶
- supports_zero_parameter_calls = True¶
- trailing_comma: TrailingCommas = TrailingCommaConfig(multiline_trailing_comma=False)¶
- property trailing_comma_config: TrailingCommaConfig¶
Configuration for trailing-comma behavior.
- trailing_commas¶
alias of
TrailingCommas
- true_literal: ClassVar[str] = 'true'¶
- property type_hint_collection_preamble_lines: Callable[[frozenset[type]], tuple[str, ...]]¶
Return preamble lines for empty-collection type hints.
- property validate_call_arg: Callable[[Value], None]¶
Return call-argument validation for this language.
- validate_spec_for_data(data: Value) None¶
Default
validate_spec_for_data— no spec/data constraints.
- variable_type_hints: VariableTypeHints = 1¶
- variable_type_hints_formats¶
alias of
VariableTypeHints
- version_formats¶
alias of
VersionFormats
- wrap_calls_with_declarations(declarations: tuple[str, ...], calls: str, body_preamble: tuple[str, ...]) str¶
Default
wrap_calls_with_declarations— concatenate the declarations and calls and route throughwrap_in_file()in call mode.
- static wrap_combined_in_file(declaration: str, assignment: str, variable_name: str, body_preamble: tuple[str, ...]) str¶
Wrap declaration and assignment in a valid file (no-op).
- static wrap_in_file(content: str, variable_name: str, body_preamble: tuple[str, ...]) str¶
Wrap code in a valid file (no-op).
- class literalizer.languages.Cobol(*args: object, **kwargs: object)¶
GnuCOBOL free-format language specification.
Data is represented as COBOL WORKING-STORAGE SECTION level items: scalars become elementary data items with VALUE clauses, and sequences / dicts become group items with 05-level sub-items.
- class BoolFormats(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
Empty: this language has no alternative boolean formats.
- class BytesFormats(*values)¶
Bytes formatting options.
- BASE64 = <function format_bytes_base64>¶
- HEX = <function format_bytes_hex>¶
- CJSON_PROCEDURE_SECTION: ClassVar[str] = 'PROCEDURE'¶
nameof the statements region ajson_type=CJSONwrap_in_file=Falseresult exposes; its content belongs in a program’s PROCEDURE DIVISION.
- CJSON_WORKING_STORAGE_SECTION: ClassVar[str] = 'WORKING-STORAGE'¶
nameof the declarations region ajson_type=CJSONwrap_in_file=Falseresult exposes throughsections; its content belongs in a program’s WORKING-STORAGE SECTION.
- class CallStyles(*values)¶
Cobol call style options.
- POSITIONAL = CommandCallStyle(arg_separator=' ')¶
- class CommentFormats(*values)¶
Comment style options.
- STAR_ANGLE = CommentConfig(prefix='*>', suffix='')¶
- class DateFormats(*values)¶
Date format options for Cobol.
- ISO = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- class DatetimeFormats(*values)¶
Datetime format options for Cobol.
- EPOCH = DatetimeFormatConfig(formatter=<function format_datetime_epoch>, preamble_lines=(), type_produced=<class 'int'>)¶
- ISO = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- class DeclarationStyles(*values)¶
Declaration style options.
- TYPED = DeclarationStyleConfig(formatter=<function _format_variable_declaration>, supports_redefinition=True)¶
- class FloatFormats(*values)¶
Float format options.
- FIXED = <function format_float_fixed>¶
- REPR = <function format_float_repr>¶
- SCIENTIFIC = <function format_float_scientific>¶
- class HeterogeneousStrategies(*values)¶
Heterogeneous-scalar strategy options — this language only supports raising.
- ERROR = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)¶
- class JsonTypes(*values)¶
JSON value type options for COBOL.
- CJSON = 'cJSON'¶
The
cJSONlibrary’scJSON *dynamic JSON value, built through GnuCOBOL’s CCALLinterface.The document is rendered as a tree of
cJSON_Create*CALLs composed withcJSON_AddItemTo*rather than a WORKING-STORAGE record, so arbitrary string keys, JSON booleans, real numbers, heterogeneous arrays, and the empty string are all faithful.
- class Modifiers(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
C++/Java/C#-style declaration modifiers: this language has none.
- class SequenceFormats(*values)¶
Sequence type options for COBOL.
- SEQUENCE = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close='', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence='05 FILLER PIC X(1) VALUE SPACES.', preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)¶
- class SetFormats(*values)¶
Set type options for COBOL.
- SET = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close='', empty_set='05 FILLER PIC X(1) VALUE SPACES.', preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)¶
- class TrailingCommas(*values)¶
Trailing comma options.
- NO = TrailingCommaConfig(multiline_trailing_comma=False)¶
- allows_empty_call_parens = True¶
- bool_formats¶
alias of
BoolFormats
- bytes_format: BytesFormats = <function format_bytes_hex>¶
- bytes_formats¶
alias of
BytesFormats
- property call_data_dependent_preamble: Callable[[Value], tuple[str, ...]]¶
Return data-dependent preamble lines for call rendering.
- call_returns_expression = False¶
- call_style: CallStyles = CommandCallStyle(arg_separator=' ')¶
- property call_style_config: PositionalCallStyle | KeywordCallStyle | ObjectCallStyle | PostfixCallStyle | PrefixCallStyle | CommandCallStyle¶
Configuration for the chosen call style.
- call_styles¶
alias of
CallStyles
- property comment_config: CommentConfig¶
Configuration for the language’s comment syntax.
- comment_format: CommentFormats = CommentConfig(prefix='*>', suffix='')¶
- comment_formats¶
alias of
CommentFormats
- property compute_body_preamble: Callable[[frozenset[type], Value], tuple[str, ...]]¶
Compute body-preamble lines from the scalar map.
- property consumable_ref_value_inhibits_consuming_form: Callable[[Value], bool]¶
Predicate deciding whether a ref’s underlying value type inhibits the consume form.
Delegates to
never_inhibits_consuming_form. Languages whose consume operator rejects certain value types (notably the Mojo^on register-trivial scalars) override this.
- property data_dependent_preamble: Callable[[Value], tuple[str, ...]]¶
Return data-dependent preamble lines.
- date_format: DateFormats = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- date_formats¶
alias of
DateFormats
- datetime_format: DatetimeFormats = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- datetime_formats¶
alias of
DatetimeFormats
- declaration_style: DeclarationStyles = DeclarationStyleConfig(formatter=<function _format_variable_declaration>, supports_redefinition=True)¶
- declaration_styles¶
alias of
DeclarationStyles
- dict_entry_style: DictEntryStyles = 1¶
- dict_entry_styles¶
alias of
DictEntryStyles
- dict_format: DictFormats = 1¶
- property dict_format_config: DictFormatConfig¶
Configuration for dict formatting.
- dict_formats¶
alias of
DictFormats
- dict_supports_heterogeneous_values = True¶
- element_separator: ClassVar[str] = '\n'¶
- empty_dict_keys¶
alias of
EmptyDictKey
- extension = '.cob'¶
- false_literal: ClassVar[str] = '"FALSE"'¶
- float_format: FloatFormats = <function format_float_repr>¶
- float_formats¶
alias of
FloatFormats
- property format_bytes: Callable[[bytes], str]¶
Callable that formats a bytes value as a string literal.
- property format_call_arg: Callable[[Value, str], str]¶
Prepend
BY CONTENTto each COBOL CALL argument.Under
json_type=CJSONa value is a multi-statementcJSONnode tree, and COBOL has no inline call-expression form to pass one as a CALL argument, so call binding is rejected (the case is skipped, no golden emitted).
- property format_call_arg_ref_identifier: Callable[[str, Value | None], str]¶
Rewrite a
{"$ref": "name"}identifier in a call-argument context.Delegates to
format_call_ref_identifier. Override this to allow call-argument$refvalues that would otherwise be rejected.
- property format_call_arg_ref_identifier_consumable: Callable[[str, Value | None], str]¶
Format a
$refthe caller authorized as consumable.Delegates to
format_call_arg_ref_identifier. Override this to opt into a consuming form (e.g. C++std::move).
- format_call_binding_body_preamble() tuple[str, ...]¶
Default
format_call_binding_body_preamble– no extra body preamble lines for an inference-bound call result.
- format_call_binding_file_pragmas() tuple[str, ...]¶
Default
format_call_binding_file_pragmas– no file-level compiler-pragma line for an inference-bound call result.
- property format_call_preamble_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]¶
Return file-scope stubs for a call expression.
- property format_call_ref_identifier: Callable[[str, Value | None], str]¶
Raise for any
{"$ref": "name"}identifier.COBOL DATA DIVISION VALUE clauses only accept literals, not identifier references, so refs are not supported.
- property format_call_statement: Callable[[str], str]¶
Wrap a call expression as a complete COBOL CALL statement.
- property format_call_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]¶
Return nested-program stub declarations for a call expression.
- property format_call_target: Callable[[Sequence[str]], str]¶
Return the quoted COBOL program name and USING keyword.
- property format_call_variable_assignment: Callable[[str, str, Value], str]¶
Default
format_call_variable_assignment– reuse the literal-binding assignment formatter unchanged.
- property format_call_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]¶
Default
format_call_variable_declaration– reuse the literal-binding declaration formatter unchanged.
- static format_constructor_target(class_name: str, /) str¶
Return class_name as a zero-argument constructor call target.
- property format_date: Callable[[date], str]¶
Callable that formats a date as a string literal.
- property format_datetime: Callable[[datetime], str]¶
Callable that formats a datetime as a string literal.
- property format_float: Callable[[float], str]¶
Callable that formats a float value as a literal.
- property format_integer: Callable[[int], str]¶
Format an int value as a literal.
- property format_integer_widened: None¶
Default
format_integer_widened– no mixed-magnitude integer widening, so the renderer keeps the normal integer formatter.
- property format_ordered_map_entry: Callable[[str, Value, str], str]¶
Format one ordered-map entry.
- property format_sequence_entry: Callable[[Value, str], str]¶
Format a sequence entry.
- property format_set_entry: Callable[[Value, str], str]¶
Format a set entry.
- property format_string: Callable[[str], str]¶
Format a string value as a quoted literal.
- property format_time: Callable[[time], str]¶
Callable that formats a time as a string literal.
- property format_variable_assignment: Callable[[str, str, Value], str]¶
Format an assignment to an existing variable.
Under
json_type=CJSONthe value is rebuilt as a freshcJSONnode tree (a distinctMnode prefix keeps the combined declaration+assignment form from defining a data name twice) and the existing pointer is reset to its root.
- property format_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]¶
Callable that formats a new variable declaration.
Under
json_type=CJSONthe rendered record value is discarded: the data is built as acJSONnode tree (WORKING-STORAGE pointer items plus PROCEDURE DIVISIONCALLstatements, joined as encoded file-section regions) and the binding pointer is set to its root.
- has_free_function_calls = True¶
- property heterogeneous_behavior: HeterogeneousBehavior¶
Return the heterogeneous-behavior config.
- heterogeneous_strategies¶
alias of
HeterogeneousStrategies
- heterogeneous_strategy: HeterogeneousStrategies = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)¶
- identifier_cases: ClassVar[tuple[IdentifierCase, ...]] = (IdentifierCase.UPPER_SNAKE,)¶
- indent: str = ' '¶
- indent_closing_delimiter: ClassVar[bool] = False¶
- integer_format: IntegerFormats = 1¶
- integer_formats¶
alias of
IntegerFormats
- integer_width_strategies¶
alias of
BareIntegerWidthStrategies
- integer_width_strategy: BareIntegerWidthStrategies = 1¶
- language_version: VersionFormats = 1¶
- property leading_preamble: LeadingPreamble¶
Default
leading_preamble– no preamble lines that must precedeLanguage.static_preamble.
- max_call_parameters = 9223372036854775807¶
- modifier_combinations: ClassVar[tuple[ModifierCombination, ...]] = ()¶
- null_literal: ClassVar[str] = 'SPACES'¶
- numeric_literal_suffix: NumericLiteralSuffixes = 1¶
- numeric_literal_suffixes¶
alias of
NumericLiteralSuffixes
- numeric_separator: NumericSeparators = 1¶
- numeric_separators¶
alias of
NumericSeparators
- numeric_style: NumericStyles = 1¶
- numeric_styles¶
alias of
NumericStyles
- property ordered_map_format_config: OrderedMapFormatConfig¶
Configuration for ordered-map formatting.
- pygments_name = 'cobol'¶
- reserved_identifiers: ClassVar[frozenset[str]] = frozenset({})¶
- property scalar_body_preamble: dict[type, tuple[str, ...]]¶
Per-instance scalar body preamble (COBOL needs none).
- property scalar_preamble: dict[type, tuple[str, ...]]¶
Per-instance scalar preamble (COBOL needs none).
- sequence_binding_declarations(declarations: tuple[str, ...]) str¶
Default
sequence_binding_declarations– join the per-binding snippets with newlines.
- sequence_format: SequenceFormats = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close='', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence='05 FILLER PIC X(1) VALUE SPACES.', preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)¶
- property sequence_format_config: SequenceFormatConfig¶
Configuration for the chosen sequence format.
- sequence_formats¶
alias of
SequenceFormats
- property sequence_open: Callable[[list[Value]], str]¶
Callable that returns the opening delimiter for a sequence.
- set_format: SetFormats = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close='', empty_set='05 FILLER PIC X(1) VALUE SPACES.', preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)¶
- property set_format_config: SetFormatConfig¶
Configuration for the chosen set format.
- set_formats¶
alias of
SetFormats
- skip_null_dict_values: ClassVar[bool] = False¶
- special_float_preamble: ClassVar[tuple[str, ...]] = ()¶
- statement_terminator: ClassVar[str] = ''¶
- statement_terminator_style: StatementTerminatorStyles = 1¶
- statement_terminator_styles¶
alias of
StatementTerminatorStyles
- static_body_preamble: ClassVar[Sequence[str]] = ()¶
- static_preamble: ClassVar[Sequence[str]] = ()¶
- string_format: StringFormats = 1¶
- string_formats¶
alias of
StringFormats
- supported_ref_cases: ClassVar[frozenset[IdentifierCase]] = frozenset({IdentifierCase.CAMEL, IdentifierCase.KEBAB, IdentifierCase.PASCAL, IdentifierCase.SNAKE, IdentifierCase.UPPER_SNAKE})¶
- supports_call_style = True¶
- supports_collection_comments: ClassVar[bool] = True¶
- supports_default_dict_key_type = False¶
- supports_default_dict_value_type = False¶
- supports_default_ordered_map_value_type = False¶
- supports_default_sequence_element_type = False¶
- supports_default_set_element_type = False¶
- supports_dict_literal_as_free_expression = True¶
- supports_dotted_call_stub = False¶
- supports_dotted_calls = True¶
- supports_empty_dict_key = False¶
- supports_inline_multiline_dict_args = False¶
- supports_module_name = False¶
- supports_multi_param_call_wrapper_stub = True¶
- supports_no_variable_wrap_in_file = False¶
- supports_non_string_dict_keys = False¶
- supports_record_shape_names = False¶
- supports_record_struct_name_prefix = False¶
- supports_scalar_before_comments: ClassVar[bool] = False¶
- supports_scalar_inline_comments: ClassVar[bool] = False¶
- supports_special_floats = True¶
- supports_standalone_comments_in_wrapped_calls = True¶
- supports_variable_names = True¶
- supports_zero_parameter_calls = False¶
- trailing_comma: TrailingCommas = TrailingCommaConfig(multiline_trailing_comma=False)¶
- property trailing_comma_config: TrailingCommaConfig¶
Configuration for trailing-comma behavior.
- trailing_commas¶
alias of
TrailingCommas
- true_literal: ClassVar[str] = '"TRUE"'¶
- property type_hint_collection_preamble_lines: Callable[[frozenset[type]], tuple[str, ...]]¶
Return preamble lines for empty-collection type hints.
- property validate_call_arg: Callable[[Value], None]¶
Return call-argument validation for this language.
- validate_spec_for_data(data: Value) None¶
Default
validate_spec_for_data— no spec/data constraints.
- variable_type_hints: VariableTypeHints = 1¶
- variable_type_hints_formats¶
alias of
VariableTypeHints
- version_formats¶
alias of
VersionFormats
- wrap_calls_with_declarations(declarations: tuple[str, ...], calls: str, body_preamble: tuple[str, ...]) str¶
Default
wrap_calls_with_declarations— concatenate the declarations and calls and route throughwrap_in_file()in call mode.
- static wrap_combined_in_file(declaration: str, assignment: str, variable_name: str, body_preamble: tuple[str, ...]) str¶
Wrap COBOL declaration and assignment in a complete program.
Under
json_type=CJSONboth declaration and assignment are two-region payloads: their WORKING-STORAGE halves merge into one DATA DIVISION (the declaration already declares the binding pointer; the assignment build only adds itsMnodes) and their PROCEDURE halves run one after the other. The file-section markers in declaration are the reliable discriminator, so this stays astaticmethod().
- wrap_in_file(content: str, variable_name: str, body_preamble: tuple[str, ...]) str¶
Wrap a COBOL variable declaration or call block in a program.
In variable-declaration mode (variable_name is non-empty), content goes in the DATA DIVISION and body_preamble is prepended before it. In call mode (variable_name is empty), content holds PROCEDURE DIVISION statements and body_preamble holds nested-program stubs that follow
STOP RUN..Under
json_type=CJSONcontent is a two-region payload (see_render_cjson_payload()): its WORKING-STORAGE half supplies the node pointers and literal items and its PROCEDURE half theCALLstatements that build the tree.
- class literalizer.languages.CommonLisp(*args: object, **kwargs: object)¶
Common Lisp language specification.
- class BoolFormats(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
Empty: this language has no alternative boolean formats.
- class BytesFormats(*values)¶
Bytes formatting options.
- BASE64 = <function format_bytes_base64>¶
- HEX = <function format_bytes_hex>¶
- class CallStyles(*values)¶
CommonLisp call style options.
- PREFIX_KEYWORD = PrefixCallStyle(arg_separator=' ', keyword_prefix=':')¶
- class CommentFormats(*values)¶
Comment style options.
- BLOCK = CommentConfig(prefix='#|', suffix=' |#')¶
- SEMICOLON = CommentConfig(prefix=';', suffix='')¶
- class DateFormats(*values)¶
Date format options for CommonLisp.
- ISO = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- class DatetimeFormats(*values)¶
Datetime format options for CommonLisp.
- EPOCH = DatetimeFormatConfig(formatter=<function format_datetime_epoch>, preamble_lines=(), type_produced=<class 'int'>)¶
- ISO = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- class DeclarationStyles(*values)¶
Declaration style options.
- DEFPARAMETER = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=True)¶
- class FloatFormats(*values)¶
Float format options.
- FIXED = <function format_float_fixed>¶
- REPR = <function format_float_repr>¶
- SCIENTIFIC = <function format_float_scientific>¶
- class HeterogeneousStrategies(*values)¶
Heterogeneous-scalar strategy options — this language only supports raising.
- ERROR = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)¶
- class JsonTypes(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
Empty: this language has no JSON value-type variants.
- class Modifiers(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
C++/Java/C#-style declaration modifiers: this language has none.
- class SequenceFormats(*values)¶
Sequence type options for Common Lisp.
- LIST = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=')', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=False, empty_sequence='nil', preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)¶
- class SetFormats(*values)¶
Set type options for Common Lisp.
- SET = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close=')', empty_set='nil', preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)¶
- class TrailingCommas(*values)¶
Trailing comma options.
- NO = TrailingCommaConfig(multiline_trailing_comma=False)¶
- allows_empty_call_parens = True¶
- bool_formats¶
alias of
BoolFormats
- bytes_format: BytesFormats = <function format_bytes_hex>¶
- bytes_formats¶
alias of
BytesFormats
- property call_data_dependent_preamble: Callable[[Value], tuple[str, ...]]¶
Return data-dependent preamble lines for call rendering.
- call_returns_expression = True¶
- call_style: CallStyles = PrefixCallStyle(arg_separator=' ', keyword_prefix=':')¶
- property call_style_config: PositionalCallStyle | KeywordCallStyle | ObjectCallStyle | PostfixCallStyle | PrefixCallStyle | CommandCallStyle¶
Configuration for Common Lisp’s call style.
- call_styles¶
alias of
CallStyles
- property comment_config: CommentConfig¶
Configuration for the language’s comment syntax.
- comment_format: CommentFormats = CommentConfig(prefix=';', suffix='')¶
- comment_formats¶
alias of
CommentFormats
- property compute_body_preamble: Callable[[frozenset[type], Value], tuple[str, ...]]¶
Compute body-preamble lines from the scalar map.
- property consumable_ref_value_inhibits_consuming_form: Callable[[Value], bool]¶
Predicate deciding whether a ref’s underlying value type inhibits the consume form.
Delegates to
never_inhibits_consuming_form. Languages whose consume operator rejects certain value types (notably the Mojo^on register-trivial scalars) override this.
- property data_dependent_preamble: Callable[[Value], tuple[str, ...]]¶
Return data-dependent preamble lines.
- date_format: DateFormats = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- date_formats¶
alias of
DateFormats
- datetime_format: DatetimeFormats = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- datetime_formats¶
alias of
DatetimeFormats
- declaration_style: DeclarationStyles = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=True)¶
- declaration_styles¶
alias of
DeclarationStyles
- dict_entry_style: DictEntryStyles = 1¶
- dict_entry_styles¶
alias of
DictEntryStyles
- dict_format: DictFormats = 1¶
- property dict_format_config: DictFormatConfig¶
Configuration for dict formatting.
- dict_formats¶
alias of
DictFormats
- dict_supports_heterogeneous_values = True¶
- element_separator: ClassVar[str] = ' '¶
- empty_dict_keys¶
alias of
EmptyDictKey
- extension = '.lisp'¶
- false_literal: ClassVar[str] = 'nil'¶
- float_format: FloatFormats = <function format_float_repr>¶
- float_formats¶
alias of
FloatFormats
- property format_bytes: Callable[[bytes], str]¶
Callable that formats a bytes value as a string literal.
- static format_call_arg(_value: Value, formatted: str, /) str¶
Callable that rewrites a formatted direct call argument.
- property format_call_arg_ref_identifier: Callable[[str, Value | None], str]¶
Rewrite a
{"$ref": "name"}identifier in a call-argument context.Delegates to
format_call_ref_identifier. Override this to allow call-argument$refvalues that would otherwise be rejected.
- property format_call_arg_ref_identifier_consumable: Callable[[str, Value | None], str]¶
Format a
$refthe caller authorized as consumable.Delegates to
format_call_arg_ref_identifier. Override this to opt into a consuming form (e.g. C++std::move).
- format_call_binding_body_preamble() tuple[str, ...]¶
Default
format_call_binding_body_preamble– no extra body preamble lines for an inference-bound call result.
- format_call_binding_file_pragmas() tuple[str, ...]¶
Default
format_call_binding_file_pragmas– no file-level compiler-pragma line for an inference-bound call result.
- property format_call_preamble_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]¶
Return file-scope stubs for a call expression.
- property format_call_ref_identifier: Callable[[str, Value | None], str]¶
Raise for any
{"$ref": "name"}identifier.Common Lisp output is not wrapped in a function body, so
*name*global-variable references require a surroundingDEFPARAMETERthat cannot be injected.
- property format_call_statement: Callable[[str], str]¶
Return call-statement formatting for this language.
- property format_call_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]¶
Return stub declarations for a call expression.
- property format_call_target: Callable[[Sequence[str]], str]¶
Rewrite a dotted call target into the language’s call syntax.
- property format_call_variable_assignment: Callable[[str, str, Value], str]¶
Default
format_call_variable_assignment– reuse the literal-binding assignment formatter unchanged.
- property format_call_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]¶
Default
format_call_variable_declaration– reuse the literal-binding declaration formatter unchanged.
- static format_constructor_target(class_name: str, /) str¶
Return class_name as a zero-argument constructor call target.
- property format_date: Callable[[date], str]¶
Callable that formats a date as a string literal.
- property format_datetime: Callable[[datetime], str]¶
Callable that formats a datetime as a string literal.
- property format_float: Callable[[float], str]¶
Callable that formats a float value as a literal.
- property format_integer: Callable[[int], str]¶
Format an int value as a literal.
- property format_integer_widened: None¶
Default
format_integer_widened– no mixed-magnitude integer widening, so the renderer keeps the normal integer formatter.
- property format_ordered_map_entry: Callable[[str, Value, str], str]¶
Format one ordered-map entry.
- property format_sequence_entry: Callable[[Value, str], str]¶
Format a sequence entry.
- property format_set_entry: Callable[[Value, str], str]¶
Format a set entry.
- property format_string: Callable[[str], str]¶
Format a string value as a quoted literal.
- property format_time: Callable[[time], str]¶
Callable that formats a time as a string literal.
- property format_variable_assignment: Callable[[str, str, Value], str]¶
Callable that formats an assignment to an existing variable.
- property format_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]¶
Callable that formats a new variable declaration.
- has_free_function_calls = True¶
- property heterogeneous_behavior: HeterogeneousBehavior¶
Return the heterogeneous-behavior config.
- heterogeneous_strategies¶
alias of
HeterogeneousStrategies
- heterogeneous_strategy: HeterogeneousStrategies = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)¶
- identifier_cases: ClassVar[tuple[IdentifierCase, ...]] = (IdentifierCase.KEBAB,)¶
- indent: str = ' '¶
- indent_closing_delimiter: ClassVar[bool] = False¶
- integer_format: IntegerFormats = 1¶
- integer_formats¶
alias of
IntegerFormats
- integer_width_strategies¶
alias of
BareIntegerWidthStrategies
- integer_width_strategy: BareIntegerWidthStrategies = 1¶
- language_version: VersionFormats = 1¶
- property leading_preamble: LeadingPreamble¶
Default
leading_preamble– no preamble lines that must precedeLanguage.static_preamble.
- max_call_parameters = 9223372036854775807¶
- modifier_combinations: ClassVar[tuple[ModifierCombination, ...]] = ()¶
- null_literal: ClassVar[str] = 'nil'¶
- numeric_literal_suffix: NumericLiteralSuffixes = 1¶
- numeric_literal_suffixes¶
alias of
NumericLiteralSuffixes
- numeric_separator: NumericSeparators = 1¶
- numeric_separators¶
alias of
NumericSeparators
- numeric_style: NumericStyles = 1¶
- numeric_styles¶
alias of
NumericStyles
- property ordered_map_format_config: OrderedMapFormatConfig¶
Configuration for ordered-map formatting.
- pygments_name = 'common-lisp'¶
- reserved_identifiers: ClassVar[frozenset[str]] = frozenset({})¶
- property scalar_body_preamble: dict[type, tuple[str, ...]]¶
Per-instance scalar body preamble (Common Lisp needs none).
- property scalar_preamble: dict[type, tuple[str, ...]]¶
Per-instance scalar preamble (Common Lisp needs none).
- sequence_binding_declarations(declarations: tuple[str, ...]) str¶
Default
sequence_binding_declarations– join the per-binding snippets with newlines.
- sequence_format: SequenceFormats = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=')', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=False, empty_sequence='nil', preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)¶
- property sequence_format_config: SequenceFormatConfig¶
Configuration for the chosen sequence format.
- sequence_formats¶
alias of
SequenceFormats
- property sequence_open: Callable[[list[Value]], str]¶
Callable that returns the opening delimiter for a sequence.
- set_format: SetFormats = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close=')', empty_set='nil', preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)¶
- property set_format_config: SetFormatConfig¶
Configuration for the chosen set format.
- set_formats¶
alias of
SetFormats
- skip_null_dict_values: ClassVar[bool] = False¶
- special_float_preamble: ClassVar[tuple[str, ...]] = ()¶
- statement_terminator: ClassVar[str] = ''¶
- statement_terminator_style: StatementTerminatorStyles = 1¶
- statement_terminator_styles¶
alias of
StatementTerminatorStyles
- static_body_preamble: ClassVar[Sequence[str]] = ()¶
- static_preamble: ClassVar[Sequence[str]] = ()¶
- string_format: StringFormats = 1¶
- string_formats¶
alias of
StringFormats
- supported_ref_cases: ClassVar[frozenset[IdentifierCase]] = frozenset({IdentifierCase.CAMEL, IdentifierCase.KEBAB, IdentifierCase.PASCAL, IdentifierCase.SNAKE, IdentifierCase.UPPER_SNAKE})¶
- supports_call_style = True¶
- supports_collection_comments: ClassVar[bool] = True¶
- supports_default_dict_key_type = False¶
- supports_default_dict_value_type = False¶
- supports_default_ordered_map_value_type = False¶
- supports_default_sequence_element_type = False¶
- supports_default_set_element_type = False¶
- supports_dict_literal_as_free_expression = True¶
- supports_dotted_call_stub = True¶
- supports_dotted_calls = True¶
- supports_empty_dict_key = False¶
- supports_inline_multiline_dict_args = True¶
- supports_module_name = False¶
- supports_multi_param_call_wrapper_stub = True¶
- supports_no_variable_wrap_in_file = True¶
- supports_non_string_dict_keys = True¶
- supports_record_shape_names = False¶
- supports_record_struct_name_prefix = False¶
- supports_scalar_before_comments: ClassVar[bool] = True¶
- supports_scalar_inline_comments: ClassVar[bool] = False¶
- supports_special_floats = True¶
- supports_standalone_comments_in_wrapped_calls = True¶
- supports_variable_names = True¶
- supports_zero_parameter_calls = True¶
- trailing_comma: TrailingCommas = TrailingCommaConfig(multiline_trailing_comma=False)¶
- property trailing_comma_config: TrailingCommaConfig¶
Configuration for trailing-comma behavior.
- trailing_commas¶
alias of
TrailingCommas
- true_literal: ClassVar[str] = 't'¶
- property type_hint_collection_preamble_lines: Callable[[frozenset[type]], tuple[str, ...]]¶
Return preamble lines for empty-collection type hints.
- property validate_call_arg: Callable[[Value], None]¶
Return call-argument validation for this language.
- validate_spec_for_data(data: Value) None¶
Default
validate_spec_for_data— no spec/data constraints.
- variable_type_hints: VariableTypeHints = 1¶
- variable_type_hints_formats¶
alias of
VariableTypeHints
- version_formats¶
alias of
VersionFormats
- wrap_calls_with_declarations(declarations: tuple[str, ...], calls: str, body_preamble: tuple[str, ...]) str¶
Default
wrap_calls_with_declarations— concatenate the declarations and calls and route throughwrap_in_file()in call mode.
- static wrap_combined_in_file(declaration: str, assignment: str, variable_name: str, body_preamble: tuple[str, ...]) str¶
Wrap declaration and assignment in a valid file (no-op).
- static wrap_in_file(content: str, variable_name: str, body_preamble: tuple[str, ...]) str¶
Wrap code in a valid file (no-op).
- class literalizer.languages.Cpp(*args: object, **kwargs: object)¶
C++ language specification.
- Parameters:
date_format –
How to format
datetime.datevalues.date_formats.CPP—std::chrono::year_month_dayliteral, e.g.std::chrono::year_month_day{std::chrono::year{2024}, std::chrono::month{1}, std::chrono::day{15}}.date_formats.ISO— ISO 8601 quoted string, e.g."2024-01-15".
datetime_format –
How to format
datetime.datetimevalues.datetime_formats.CPP—std::chrono::sys_dayswith time-of-day durations, e.g.std::chrono::sys_days{...} + std::chrono::hours{12} + std::chrono::minutes{30}.datetime_formats.ISO— ISO 8601 quoted string, e.g."2024-01-15T12:30:00".
json_type – When set to
json_types.NLOHMANN_JSON, render values throughnlohmann::json::parseover an inline JSON document instead of C++’s narrowstd::vector/std::map/std::unordered_mapcollection types. Dict keys must be strings so they remain valid JSON object keys.
- class BoolFormats(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
Empty: this language has no alternative boolean formats.
- class BytesFormats(*values)¶
Bytes formatting options.
- BASE64 = <function format_bytes_base64>¶
- HEX = <function format_bytes_hex>¶
- class CallStyles(*values)¶
Cpp call style options.
- POSITIONAL = PositionalCallStyle(arg_separator=', ', parenthesize_each_arg=False)¶
- class CommentFormats(*values)¶
Comment style options.
- BLOCK = CommentConfig(prefix='/*', suffix=' */')¶
- DOUBLE_SLASH = CommentConfig(prefix='//', suffix='')¶
- class DateFormats(*values)¶
Date format options for C++.
- CPP = DateFormatConfig(formatter=<function _format_date_cpp>, preamble_lines=('#include <chrono>',), type_produced=<class 'datetime.date'>)¶
- ISO = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=('#include <string>',), type_produced=<class 'str'>)¶
- property cpp_type: str¶
Return the C++ type name for this date format.
- class DatetimeFormats(*values)¶
Datetime format options for C++.
- CPP = DatetimeFormatConfig(formatter=<function _format_datetime_cpp>, preamble_lines=('#include <chrono>',), type_produced=<class 'datetime.datetime'>)¶
- EPOCH = DatetimeFormatConfig(formatter=<function format_datetime_epoch>, preamble_lines=(), type_produced=<class 'int'>)¶
- ISO = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=('#include <string>',), type_produced=<class 'str'>)¶
- property cpp_type: str¶
Return the C++ type name for this datetime format.
- class DeclarationStyles(*values)¶
Declaration style options.
- AUTO = _CppDeclarationStyleConfig(supports_redefinition=True)¶
- class DictFormats(*values)¶
Dict/map format options.
- MAP = _DictFormatOption(config=DictFormatConfig(dict_open=<function Cpp.DictFormats.<lambda>>, close='}', format_entry=<function braced_dict_entry.<locals>._format>, empty_dict=None, preamble_lines=('#include <map>',), narrowed_open=None, supports_trailing_comma=True), opener_template='std::map<std::string, {type_name}>{{')¶
- UNORDERED_MAP = _DictFormatOption(config=DictFormatConfig(dict_open=<function Cpp.DictFormats.<lambda>>, close='}', format_entry=<function braced_dict_entry.<locals>._format>, empty_dict=None, preamble_lines=('#include <unordered_map>',), narrowed_open=None, supports_trailing_comma=True), opener_template='std::unordered_map<std::string, {type_name}>{{')¶
- get_config(*, type_ctx: _CppTypeCtx) DictFormatConfig¶
Return the dict format config with variant opener.
- class FloatFormats(*values)¶
Float format options.
- FIXED = <function format_float_fixed>¶
- REPR = <function format_float_repr>¶
- SCIENTIFIC = <function format_float_scientific>¶
- class HeterogeneousStrategies(*values)¶
Heterogeneous-scalar strategy options.
C++ represents heterogeneous scalar collections with
std::variantby default (ERROR);TUPLEadditionally renders a fixed-length heterogeneous scalar array (a dict value or the document root, all elements scalar, spanning at least two scalar buckets) asstd::make_tuple(...)typedstd::tuple<...>.RECORDinstead renders each record-shaped dict (non-empty, string-keyed) as a generated aggregatestructdeclared in the preamble plus a matchingRecord0{.field = value, ...}designated-initializer literal, so fields may mix scalars and containers that the homogeneousstd::mapcannot.- ERROR = 1¶
- RECORD = 3¶
- TUPLE = 2¶
- class IntegerFormats(*values)¶
Integer format options.
- BINARY = mappingproxy({'NONE': <function format_integer_binary>, 'UNDERSCORE': <function format_integer_binary>})¶
- DECIMAL = mappingproxy({'NONE': <class 'str'>, 'UNDERSCORE': <function format_integer_tick>})¶
- HEX = mappingproxy({'NONE': <function format_integer_hex>, 'UNDERSCORE': <function format_integer_hex>})¶
- OCTAL = mappingproxy({'NONE': <function format_integer_octal_c_style>, 'UNDERSCORE': <function format_integer_octal_c_style>})¶
- get_formatter(numeric_separator: Enum) Callable[[int], str]¶
Return the integer formatter for the given separator.
- class JsonTypes(*values)¶
JSON value type options for C++.
- NLOHMANN_JSON = 'nlohmann::json'¶
The
nlohmann::jsondynamic JSON value type from thenlohmann/json.hpplibrary.
- Modifiers¶
alias of
_CppModifiers
- class NumericLiteralSuffixes(*values)¶
Numeric literal suffix options.
- AUTO = _NumericLiteralSuffixConfig(int_resolver=<function _static_int_resolver.<locals>._resolve>, formatter_wrapper=<function make_long_suffix_formatter>)¶
- NONE = _NumericLiteralSuffixConfig(int_resolver=<function _narrowest_cpp_int_type>, formatter_wrapper=<function _identity_wrapper>)¶
- property int_resolver: Callable[[list[int]], str]¶
Return the value-driven int type resolver.
- wrap_integer_formatter(base: Callable[[int], str]) Callable[[int], str]¶
Wrap the base integer formatter.
- class SequenceFormats(*values)¶
Sequence type options for C++.
- ARRAY = <function _make_array_config>¶
- INITIALIZER_LIST = <function _make_initializer_list_config>¶
- get_config(*, type_ctx: _CppTypeCtx) SequenceFormatConfig¶
Return the sequence format config for the given context.
- class SetFormats(*values)¶
Set type options for C++.
- SET = SetFormatConfig(set_open=<function Cpp.SetFormats.<lambda>>, close='}', empty_set=None, preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)¶
- get_config(*, type_ctx: _CppTypeCtx) SetFormatConfig¶
Return the set format config with variant opener.
- class TrailingCommas(*values)¶
Trailing comma options.
- NO = TrailingCommaConfig(multiline_trailing_comma=False)¶
- YES = TrailingCommaConfig(multiline_trailing_comma=True)¶
- allows_empty_call_parens = True¶
- bool_formats¶
alias of
BoolFormats
- bytes_format: BytesFormats = <function format_bytes_hex>¶
- bytes_formats¶
alias of
BytesFormats
- property call_data_dependent_preamble: Callable[[Value], tuple[str, ...]]¶
Return data-dependent preamble lines for call rendering.
- call_returns_expression = True¶
- call_style: CallStyles = PositionalCallStyle(arg_separator=', ', parenthesize_each_arg=False)¶
- property call_style_config: PositionalCallStyle | KeywordCallStyle | ObjectCallStyle | PostfixCallStyle | PrefixCallStyle | CommandCallStyle¶
Configuration for the chosen call style.
- call_styles¶
alias of
CallStyles
- property comment_config: CommentConfig¶
Configuration for the language’s comment syntax.
- comment_format: CommentFormats = CommentConfig(prefix='//', suffix='')¶
- comment_formats¶
alias of
CommentFormats
- property compute_body_preamble: Callable[[frozenset[type], Value], tuple[str, ...]]¶
Compute body-preamble lines from the scalar map.
- property consumable_ref_value_inhibits_consuming_form: Callable[[Value], bool]¶
Return
Truefor ref values whose C++ type is register- trivial.clang-tidy’sperformance-move-const-argrule (and the equivalenthicpp-move-const-arg) reportsstd::moveon a register-trivial value as an error: the move has no effect and the wrapping is wasteful. The call site routes these refs through the non-consuming formatter so the emitted C++ compiles cleanly under--warnings-as-errors.
- property data_dependent_preamble: Callable[[Value], tuple[str, ...]]¶
Build data-dependent preamble lines (variant and
nullptrheaders, plus<tuple>under theTUPLEstrategy or the generatedstructdeclarations underRECORD).
- date_format: DateFormats = DateFormatConfig(formatter=<function _format_date_cpp>, preamble_lines=('#include <chrono>',), type_produced=<class 'datetime.date'>)¶
- date_formats¶
alias of
DateFormats
- datetime_format: DatetimeFormats = DatetimeFormatConfig(formatter=<function _format_datetime_cpp>, preamble_lines=('#include <chrono>',), type_produced=<class 'datetime.datetime'>)¶
- datetime_formats¶
alias of
DatetimeFormats
- declaration_style: DeclarationStyles = _CppDeclarationStyleConfig(supports_redefinition=True)¶
- declaration_styles¶
alias of
DeclarationStyles
- dict_entry_style: DictEntryStyles = 1¶
- dict_entry_styles¶
alias of
DictEntryStyles
- dict_format: DictFormats = _DictFormatOption(config=DictFormatConfig(dict_open=<function Cpp.DictFormats.<lambda>>, close='}', format_entry=<function braced_dict_entry.<locals>._format>, empty_dict=None, preamble_lines=('#include <map>',), narrowed_open=None, supports_trailing_comma=True), opener_template='std::map<std::string, {type_name}>{{')¶
- property dict_format_config: DictFormatConfig¶
Configuration for dict formatting.
- dict_formats¶
alias of
DictFormats
- dict_supports_heterogeneous_values = True¶
- element_separator: ClassVar[str] = ', '¶
- empty_dict_keys¶
alias of
EmptyDictKey
- extension = '.cpp'¶
- false_literal: ClassVar[str] = 'false'¶
- float_format: FloatFormats = <function format_float_repr>¶
- float_formats¶
alias of
FloatFormats
- property format_bytes: Callable[[bytes], str]¶
Callable that formats a bytes value as a string literal.
- property format_call_arg: Callable[[Value, str], str]¶
Callable that rewrites a formatted direct call argument.
- property format_call_arg_ref_identifier: Callable[[str, Value | None], str]¶
Emit a call-argument
$refas the bare identifier.std::movewould consume the variable, which is unsafe when the caller may use it again in a later call (or after theliteralize_callblock). Callers opt in to consuming a specific ref by listing it inliteralize_call’sconsumable_refsset; in that caseformat_call_arg_ref_identifier_consumableis used instead and emitsstd::move(name).
- property format_call_arg_ref_identifier_consumable: Callable[[str, Value | None], str]¶
Wrap a consumable call-argument
$refinstd::move().Used only for refs the caller declared as consumable on
literalize_call()and that appear in just one call argument, so the move cannot strand a later use.
- format_call_binding_body_preamble() tuple[str, ...]¶
Default
format_call_binding_body_preamble– no extra body preamble lines for an inference-bound call result.
- format_call_binding_file_pragmas() tuple[str, ...]¶
Default
format_call_binding_file_pragmas– no file-level compiler-pragma line for an inference-bound call result.
- property format_call_preamble_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]¶
Return file-scope stubs for a call expression.
- property format_call_ref_identifier: Callable[[str, Value | None], str]¶
Wrap a
{"$ref": "name"}identifier instd::move(), except fortrivially-copyablescalars.A direct copy assignment (
auto my_data = my_var) triggers clang-tidyperformance-unnecessary-copy-initializationwhen the variable is never modified, sostd::moveis used for container-typed refs to satisfy the linter. Applyingstd::moveto atrivially-copyablescalar (int,bool,float) is itself a clang-tidyhicpp-move-const-arg/performance-move-const-argwarning (“has no effect; remove std::move()”), so we drop the wrapper when the caller’sref_valuesidentifies the ref as one of those types. When the value is unknown we keep the historicalstd::moveform.
- property format_call_statement: Callable[[str], str]¶
Return call-statement formatting for this language.
- property format_call_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]¶
Return stub declarations for a call expression.
- property format_call_target: Callable[[Sequence[str]], str]¶
Rewrite a dotted call target into the language’s call syntax.
- property format_call_variable_assignment: Callable[[str, str, Value], str]¶
Default
format_call_variable_assignment– reuse the literal-binding assignment formatter unchanged.
- property format_call_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]¶
Default
format_call_variable_declaration– reuse the literal-binding declaration formatter unchanged.
- static format_constructor_target(class_name: str, /) str¶
Return class_name as a zero-argument constructor call target.
- property format_date: Callable[[date], str]¶
Callable that formats a date as a string literal.
- property format_datetime: Callable[[datetime], str]¶
Callable that formats a datetime as a string literal.
- property format_float: Callable[[float], str]¶
Callable that formats a float value as a literal.
- property format_integer: Callable[[int], str]¶
Callable that formats an int value as a literal.
- property format_integer_widened: None¶
Default
format_integer_widened– no mixed-magnitude integer widening, so the renderer keeps the normal integer formatter.
- property format_ordered_map_entry: Callable[[str, Value, str], str]¶
Callable that formats one ordered-map entry.
- property format_sequence_entry: Callable[[Value, str], str]¶
Format a sequence entry.
- property format_set_entry: Callable[[Value, str], str]¶
Format a set entry.
- property format_string: Callable[[str], str]¶
Format a string value as a quoted literal.
- property format_time: Callable[[time], str]¶
Callable that formats a time as a string literal.
- property format_variable_assignment: Callable[[str, str, Value], str]¶
Format an assignment to an existing variable.
- property format_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]¶
Callable that formats a new variable declaration.
Closes over the chosen date/datetime
type_producedso theconst auto*vsautodecision can be driven by the parsedValuerather than the rendered text.
- has_free_function_calls = True¶
- property heterogeneous_behavior: HeterogeneousBehavior¶
Return the heterogeneous-behavior config.
RECORDresolves to the shared record behavior (its value needs the per-instance renderer, so it cannot be stored on the enum member);TUPLEandERRORuse their static behaviors.
- heterogeneous_strategies¶
alias of
HeterogeneousStrategies
- heterogeneous_strategy: HeterogeneousStrategies = 1¶
- identifier_cases: ClassVar[tuple[IdentifierCase, ...]] = (IdentifierCase.SNAKE, IdentifierCase.UPPER_SNAKE, IdentifierCase.PASCAL, IdentifierCase.CAMEL)¶
- indent: str = ' '¶
- indent_closing_delimiter: ClassVar[bool] = False¶
- integer_format: IntegerFormats = mappingproxy({'NONE': <class 'str'>, 'UNDERSCORE': <function format_integer_tick>})¶
- integer_formats¶
alias of
IntegerFormats
- integer_width_strategies¶
alias of
BareIntegerWidthStrategies
- integer_width_strategy: BareIntegerWidthStrategies = 1¶
- language_version: VersionFormats = 1¶
- property leading_preamble: LeadingPreamble¶
Default
leading_preamble– no preamble lines that must precedeLanguage.static_preamble.
- max_call_parameters = 9223372036854775807¶
- modifier_combinations: ClassVar[tuple[ModifierCombination, ...]] = (ModifierCombination(name='static_const', modifiers=frozenset({<_CppModifiers.CONST: 'const'>, <_CppModifiers.STATIC: 'static'>})),)¶
- modifiers¶
alias of
_CppModifiers
- module_name: str = 'Module'¶
- module_name_case: ClassVar[IdentifierCase] = 'snake'¶
- property null_literal: str¶
Null literal for the active C++ representation.
- numeric_literal_suffix: NumericLiteralSuffixes = _NumericLiteralSuffixConfig(int_resolver=<function _narrowest_cpp_int_type>, formatter_wrapper=<function _identity_wrapper>)¶
- numeric_literal_suffixes¶
alias of
NumericLiteralSuffixes
- numeric_separator: NumericSeparators = 1¶
- numeric_separators¶
alias of
NumericSeparators
- numeric_style: NumericStyles = 1¶
- numeric_styles¶
alias of
NumericStyles
- property ordered_map_format_config: OrderedMapFormatConfig¶
Configuration for ordered-map formatting.
- pygments_name = 'cpp'¶
- record_struct_name_prefix: str = 'Record'¶
- reserved_identifiers: ClassVar[frozenset[str]] = frozenset({})¶
- property scalar_body_preamble: dict[type, tuple[str, ...]]¶
Per-instance scalar body preamble (C++ needs none).
- property scalar_preamble: dict[type, tuple[str, ...]]¶
Per-instance scalar preamble computed from date/datetime format.
- sequence_binding_declarations(declarations: tuple[str, ...]) str¶
Default
sequence_binding_declarations– join the per-binding snippets with newlines.
- sequence_format: SequenceFormats = <function _make_initializer_list_config>¶
- property sequence_format_config: SequenceFormatConfig¶
Configuration for the chosen sequence format.
- sequence_formats¶
alias of
SequenceFormats
- property sequence_open: Callable[[list[Value]], str]¶
Callable that returns the opening delimiter for a sequence.
Under the
RECORDstrategy a list whose every element is a record-shaped dict renders each element as a generatedRecordNliteral; the variant opener would type such a liststd::vector<std::map<...>>(the homogeneous-map element type) which the struct literals cannot initialize. Such a list is instead opened with a barestd::vector{so class-template argument deduction infersstd::vector<RecordN>from the literals. Every other list keeps the typed variant opener.
- set_format: SetFormats = SetFormatConfig(set_open=<function Cpp.SetFormats.<lambda>>, close='}', empty_set=None, preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)¶
- property set_format_config: SetFormatConfig¶
Configuration for the chosen set format.
- set_formats¶
alias of
SetFormats
- skip_null_dict_values: ClassVar[bool] = False¶
- special_float_preamble: ClassVar[tuple[str, ...]] = ('#include <cmath>',)¶
- statement_terminator: ClassVar[str] = ';'¶
- statement_terminator_style: StatementTerminatorStyles = 1¶
- statement_terminator_styles¶
alias of
StatementTerminatorStyles
- static_body_preamble: ClassVar[Sequence[str]] = ()¶
- property static_preamble: Sequence[str]¶
Static preamble lines emitted once per file.
Under
json_typethenlohmann/json.hppheader replaces the default<initializer_list>include because every emitted expression goes throughnlohmann::json::parse().
- string_format: StringFormats = 1¶
- string_formats¶
alias of
StringFormats
- supported_ref_cases: ClassVar[frozenset[IdentifierCase]] = frozenset({IdentifierCase.CAMEL, IdentifierCase.PASCAL, IdentifierCase.SNAKE, IdentifierCase.UPPER_SNAKE})¶
- supports_call_style = True¶
- supports_collection_comments: ClassVar[bool] = True¶
- supports_default_dict_key_type = False¶
- supports_default_dict_value_type = False¶
- supports_default_ordered_map_value_type = False¶
- supports_default_sequence_element_type = False¶
- supports_default_set_element_type = False¶
- supports_dict_literal_as_free_expression = True¶
- supports_dotted_call_stub = True¶
- supports_dotted_calls = True¶
- supports_empty_dict_key = False¶
- supports_inline_multiline_dict_args = True¶
- supports_module_name = True¶
- supports_multi_param_call_wrapper_stub = True¶
- supports_no_variable_wrap_in_file = False¶
- supports_non_string_dict_keys = False¶
- supports_record_shape_names = False¶
- supports_record_struct_name_prefix = True¶
- supports_scalar_before_comments: ClassVar[bool] = True¶
- supports_scalar_inline_comments: ClassVar[bool] = False¶
- supports_special_floats = True¶
- supports_standalone_comments_in_wrapped_calls = True¶
- supports_variable_names = True¶
- supports_zero_parameter_calls = True¶
- trailing_comma: TrailingCommas = TrailingCommaConfig(multiline_trailing_comma=True)¶
- property trailing_comma_config: TrailingCommaConfig¶
Configuration for trailing-comma behavior.
- trailing_commas¶
alias of
TrailingCommas
- true_literal: ClassVar[str] = 'true'¶
- property type_hint_collection_preamble_lines: Callable[[frozenset[type]], tuple[str, ...]]¶
Return preamble lines for empty-collection type hints.
- property validate_call_arg: Callable[[Value], None]¶
Return call-argument validation for this language.
- validate_spec_for_data(data: Value) None¶
Validate C++-specific data/format combinations.
- variable_type_hints: VariableTypeHints = 1¶
- variable_type_hints_formats¶
alias of
VariableTypeHints
- version_formats¶
alias of
VersionFormats
- wrap_calls_with_declarations(declarations: tuple[str, ...], calls: str, body_preamble: tuple[str, ...]) str¶
Default
wrap_calls_with_declarations— concatenate the declarations and calls and route throughwrap_in_file()in call mode.
- wrap_combined_in_file(declaration: str, assignment: str, variable_name: str, body_preamble: tuple[str, ...]) str¶
Wrap C++ declaration + assignment in a function body.
Reads
variable_namebetween the declaration and the assignment so the initial value is not a dead store flagged by clang-tidy’sclang-analyzer-deadcode.DeadStorescheck.
- wrap_in_file(content: str, variable_name: str, body_preamble: tuple[str, ...]) str¶
Wrap a C++ declaration in a main function.
Under
json_typethe body is additionally wrapped intry { ... } catch (...) { return 1; }so the potentially-throwingnlohmann::json::parsecall cannot makemainitself throwing — clang-tidy’sbugprone-exception-escapecheck rejects an implicitlynoexceptmainthat calls a function whose signature permits exceptions, even when the runtime flagallow_exceptions=falsehas been passed to suppress them.
- class literalizer.languages.Crystal(*args: object, **kwargs: object)¶
Crystal language specification.
- Parameters:
sequence_format –
Which Crystal sequence type to use.
sequence_formats.ARRAY— array literal, e.g.[1, 2, 3].sequence_formats.TUPLE— tuple literal, e.g.{1, 2, 3}.
- class BoolFormats(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
Empty: this language has no alternative boolean formats.
- class BytesFormats(*values)¶
Bytes formatting options.
- BASE64 = <function format_bytes_base64>¶
- HEX = <function format_bytes_hex>¶
- class CallStyles(*values)¶
Crystal call style options.
- KEYWORD = KeywordCallStyle(separator=': ')¶
- POSITIONAL = PositionalCallStyle(arg_separator=', ', parenthesize_each_arg=False)¶
- class DateFormats(*values)¶
Date format options for Crystal.
- ISO = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- class DatetimeFormats(*values)¶
Datetime format options for Crystal.
- EPOCH = DatetimeFormatConfig(formatter=<function format_datetime_epoch>, preamble_lines=(), type_produced=<class 'int'>)¶
- ISO = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- class DeclarationStyles(*values)¶
Declaration style options.
- ASSIGN = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=True)¶
- class DictFormats(*values)¶
Dict/map format options.
- DEFAULT = <function dict_format_factory.<locals>._build>¶
- class FloatFormats(*values)¶
Float format options.
- FIXED = <function format_float_fixed>¶
- REPR = <function format_float_repr>¶
- SCIENTIFIC = <function format_float_scientific>¶
- class HeterogeneousStrategies(*values)¶
Heterogeneous-scalar strategy options.
ERRORraises for any record-shaped dict that mixes scalars with a container (Hashrequires a homogeneous value type).RECORDinstead renders each record-shaped dict (non-empty, string-keyed) as a generatedrecordstruct declared in the per-fixture module body plus a matching positionalRecord0.new(value, ...)literal, so such fields are representable.- ERROR = 1¶
- RECORD = 2¶
- class IntegerFormats(*values)¶
Integer format options.
- DECIMAL = mappingproxy({'NONE': <function Crystal.IntegerFormats.<lambda>>, 'UNDERSCORE': <function format_integer_underscore>})¶
- get_formatter(numeric_separator: Enum) Callable[[int], str]¶
Return the integer formatter for the given separator.
- class JsonTypes(*values)¶
JSON value type options for Crystal.
- JSON_ANY = 'JSON::Any'¶
Standard-library
JSON::AnyviaJSON.parse(%(...)).
- class Modifiers(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
C++/Java/C#-style declaration modifiers: this language has none.
- class SequenceFormats(*values)¶
Sequence type options for Crystal.
- ARRAY = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=']', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence='[] of Nil', preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)¶
- TUPLE = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close='}', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence='Tuple.new', preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)¶
- class SetFormats(*values)¶
Set type options for Crystal.
- SET = <function set_format_factory.<locals>._build>¶
- class TrailingCommas(*values)¶
Trailing comma options.
- NO = TrailingCommaConfig(multiline_trailing_comma=False)¶
- YES = TrailingCommaConfig(multiline_trailing_comma=True)¶
- allows_empty_call_parens = True¶
- bool_formats¶
alias of
BoolFormats
- bytes_format: BytesFormats = <function format_bytes_hex>¶
- bytes_formats¶
alias of
BytesFormats
- property call_data_dependent_preamble: Callable[[Value], tuple[str, ...]]¶
Return data-dependent preamble lines for call rendering.
- call_returns_expression = True¶
- call_style: CallStyles = KeywordCallStyle(separator=': ')¶
- property call_style_config: PositionalCallStyle | KeywordCallStyle | ObjectCallStyle | PostfixCallStyle | PrefixCallStyle | CommandCallStyle¶
Configuration for the chosen call style.
- call_styles¶
alias of
CallStyles
- property comment_config: CommentConfig¶
Configuration for the language’s comment syntax.
- comment_format: CommentFormats = CommentConfig(prefix='#', suffix='')¶
- comment_formats¶
alias of
CommentFormats
- property compute_body_preamble: Callable[[frozenset[type], Value], tuple[str, ...]]¶
Compute body-preamble lines from the scalar map, prefixed with the
RECORDstrategy’s generatedrecorddeclarations.Crystal compiles every fixture in one
crystal runinvocation, so a file-scoperecord Record0would collide across cases. Emitting the declarations into the body preamble (whichwrap_in_file()places inside the per-fixture module, ahead of the value) scopes eachRecordNto its own fixture; the declarations precede the scalar body lines so a record type is in scope before its literal.
- property consumable_ref_value_inhibits_consuming_form: Callable[[Value], bool]¶
Predicate deciding whether a ref’s underlying value type inhibits the consume form.
Delegates to
never_inhibits_consuming_form. Languages whose consume operator rejects certain value types (notably the Mojo^on register-trivial scalars) override this.
- property data_dependent_preamble: Callable[[Value], tuple[str, ...]]¶
Return data-dependent preamble lines.
The
RECORDstrategy’s generatedrecorddeclarations are not emitted here (file scope): Crystal compiles every fixture in onecrystal runinvocation, so a file-scoperecord Record0would collide across cases. They are emitted into the per-fixture module body instead; seecompute_body_preamble.Under
json_typethe rendered output always passes throughJSON.parse, sorequire "json"is contributed unconditionally.
- date_format: DateFormats = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- date_formats¶
alias of
DateFormats
- datetime_format: DatetimeFormats = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- datetime_formats¶
alias of
DatetimeFormats
- declaration_style: DeclarationStyles = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=True)¶
- declaration_styles¶
alias of
DeclarationStyles
- default_dict_key_type: str = 'String'¶
- default_dict_value_type: str = 'String'¶
- default_set_element_type: str = 'String'¶
- dict_entry_style: DictEntryStyles = 1¶
- dict_entry_styles¶
alias of
DictEntryStyles
- dict_format: DictFormats = <function dict_format_factory.<locals>._build>¶
- property dict_format_config: DictFormatConfig¶
Configuration for dict formatting.
json_typerenders a dict as a JSON object with": "as the entry separator and no trailing comma; the empty form widens to{}.
- dict_formats¶
alias of
DictFormats
- dict_supports_heterogeneous_values = True¶
- element_separator: ClassVar[str] = ', '¶
- empty_dict_keys¶
alias of
EmptyDictKey
- extension = '.cr'¶
- false_literal: ClassVar[str] = 'false'¶
- float_format: FloatFormats = <function format_float_repr>¶
- float_formats¶
alias of
FloatFormats
- property format_bytes: Callable[[bytes], str]¶
Callable that formats a bytes value as a string literal.
- property format_call_arg: Callable[[Value, str], str]¶
Callable that rewrites a formatted direct call argument.
Under
json_typeevery call argument is wrapped inJSON.parse(%(...))so the receiving proc gets aJSON::Anyregardless of the underlying scalar or container shape; otherwise the rendered literal passes through unchanged.
- property format_call_arg_ref_identifier: Callable[[str, Value | None], str]¶
Rewrite a
{"$ref": "name"}identifier in a call-argument context.Delegates to
format_call_ref_identifier. Override this to allow call-argument$refvalues that would otherwise be rejected.
- property format_call_arg_ref_identifier_consumable: Callable[[str, Value | None], str]¶
Format a
$refthe caller authorized as consumable.Delegates to
format_call_arg_ref_identifier. Override this to opt into a consuming form (e.g. C++std::move).
- format_call_binding_body_preamble() tuple[str, ...]¶
Default
format_call_binding_body_preamble– no extra body preamble lines for an inference-bound call result.
- format_call_binding_file_pragmas() tuple[str, ...]¶
Default
format_call_binding_file_pragmas– no file-level compiler-pragma line for an inference-bound call result.
- property format_call_preamble_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]¶
Return file-scope stubs for a call expression.
- property format_call_ref_identifier: Callable[[str, Value | None], str]¶
Rewrite a
{"$ref": "name"}identifier into the language’s call expression syntax.
- property format_call_statement: Callable[[str], str]¶
Return call-statement formatting for this language.
- property format_call_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]¶
Return stub declarations for a call expression.
- property format_call_target: Callable[[Sequence[str]], str]¶
Rewrite a dotted call target into the language’s call syntax.
- property format_call_variable_assignment: Callable[[str, str, Value], str]¶
Default
format_call_variable_assignment– reuse the literal-binding assignment formatter unchanged.
- property format_call_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]¶
Default
format_call_variable_declaration– reuse the literal-binding declaration formatter unchanged.
- static format_constructor_target(class_name: str, /) str¶
Return a Crystal
ClassName.newconstructor call target.
- property format_date: Callable[[date], str]¶
Callable that formats a date as a string literal.
json_typealways emits ISO 8601 dates so the result is a JSON string regardless of the configureddate_format.
- property format_datetime: Callable[[datetime], str]¶
Callable that formats a datetime as a string literal.
json_typealways emits ISO 8601 datetimes (JSON strings) unless the user has explicitly chosen theEPOCHform, which remains a valid JSON number.
- property format_float: Callable[[float], str]¶
Callable that formats a float value as a literal.
- property format_integer: Callable[[int], str]¶
Callable that formats an int value as a literal.
json_typeskips the_i128overflow fallback because the JSON spec has no integer-width annotation; out-of-range values are rejected byvalidate_spec_for_data()with a clear error before they reach the formatter.
- property format_integer_widened: None¶
Default
format_integer_widened– no mixed-magnitude integer widening, so the renderer keeps the normal integer formatter.
- property format_ordered_map_entry: Callable[[str, Value, str], str]¶
Callable that formats one ordered-map entry.
json_typeuses the JSON": "separator; the native Crystal form uses" => ".
- property format_sequence_entry: Callable[[Value, str], str]¶
Format a sequence entry.
- property format_set_entry: Callable[[Value, str], str]¶
Format a set entry.
- property format_string: Callable[[str], str]¶
Format a string value as a quoted literal.
- property format_time: Callable[[time], str]¶
Callable that formats a time as a string literal.
- property format_variable_assignment: Callable[[str, str, Value], str]¶
Format an assignment to an existing variable.
- property format_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]¶
Callable that formats a new variable declaration.
Under
json_typethe rendered literal is wrapped inJSON.parse(%(...)); Crystal’s only declaration style isASSIGN, so the formatter does not branch on the keyword.
- has_free_function_calls = True¶
- property heterogeneous_behavior: HeterogeneousBehavior¶
Return the heterogeneous-behavior config.
json_typeoverrides the configured strategy: JSON arrays and objects accept any mix of value types, so scalar-type checks are skipped unconditionally.RECORDresolves to the shared record behavior (its value needs the per-instance renderer, so it cannot be stored on the enum member);ERRORraises.
- heterogeneous_strategies¶
alias of
HeterogeneousStrategies
- heterogeneous_strategy: HeterogeneousStrategies = 1¶
- identifier_cases: ClassVar[tuple[IdentifierCase, ...]] = (IdentifierCase.SNAKE, IdentifierCase.UPPER_SNAKE, IdentifierCase.PASCAL)¶
- indent: str = ' '¶
- indent_closing_delimiter: ClassVar[bool] = False¶
- integer_format: IntegerFormats = mappingproxy({'NONE': <function Crystal.IntegerFormats.<lambda>>, 'UNDERSCORE': <function format_integer_underscore>})¶
- integer_formats¶
alias of
IntegerFormats
- integer_width_strategies¶
alias of
BareIntegerWidthStrategies
- integer_width_strategy: BareIntegerWidthStrategies = 1¶
- language_version: VersionFormats = 1¶
- property leading_preamble: LeadingPreamble¶
Default
leading_preamble– no preamble lines that must precedeLanguage.static_preamble.
- max_call_parameters = 9223372036854775807¶
- modifier_combinations: ClassVar[tuple[ModifierCombination, ...]] = ()¶
- module_name: str = 'Check'¶
- module_name_case: ClassVar[IdentifierCase] = 'pascal'¶
- property null_literal: str¶
Null literal for the active Crystal representation.
JSON::Anymode produces JSON documents inside aJSON.parse(%(...))wrapper, so the JSONnullkeyword replaces Crystal’snil.
- numeric_literal_suffix: NumericLiteralSuffixes = 1¶
- numeric_literal_suffixes¶
alias of
NumericLiteralSuffixes
- numeric_separator: NumericSeparators = 1¶
- numeric_separators¶
alias of
NumericSeparators
- numeric_style: NumericStyles = 1¶
- numeric_styles¶
alias of
NumericStyles
- property ordered_map_format_config: OrderedMapFormatConfig¶
Configuration for ordered-map formatting.
json_typereuses the JSON object form for ordered maps (JSON objects preserve insertion order in the rendered text).
- pygments_name = 'crystal'¶
- record_struct_name_prefix: str = 'Record'¶
- reserved_identifiers: ClassVar[frozenset[str]] = frozenset({})¶
- property scalar_body_preamble: dict[type, tuple[str, ...]]¶
Per-instance scalar body preamble (Crystal needs none).
- property scalar_preamble: dict[type, tuple[str, ...]]¶
Per-instance scalar preamble (Crystal needs none).
- sequence_binding_declarations(declarations: tuple[str, ...]) str¶
Default
sequence_binding_declarations– join the per-binding snippets with newlines.
- sequence_format: SequenceFormats = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=']', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence='[] of Nil', preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)¶
- property sequence_format_config: SequenceFormatConfig¶
Configuration for the chosen sequence format.
json_typerenders sequences as JSON arrays ([ ... ]) inside the outerJSON.parse(%(...))wrapper, with no Crystal-side typing or trailing comma (the JSON spec rejects trailing commas in arrays).
- sequence_formats¶
alias of
SequenceFormats
- property sequence_open: Callable[[list[Value]], str]¶
Callable that returns the opening delimiter for a sequence.
- set_format: SetFormats = <function set_format_factory.<locals>._build>¶
- property set_format_config: SetFormatConfig¶
Configuration for the chosen set format.
json_typerenders a set as a JSON array because JSON has no native set type; the empty form widens to[]for the same reason.
- set_formats¶
alias of
SetFormats
- skip_null_dict_values: ClassVar[bool] = False¶
- special_float_preamble: ClassVar[tuple[str, ...]] = ()¶
- statement_terminator: ClassVar[str] = ';'¶
- statement_terminator_style: StatementTerminatorStyles = 1¶
- statement_terminator_styles¶
alias of
StatementTerminatorStyles
- static_body_preamble: ClassVar[Sequence[str]] = ()¶
- static_preamble: ClassVar[Sequence[str]] = ()¶
- string_format: StringFormats = 1¶
- string_formats¶
alias of
StringFormats
- supported_ref_cases: ClassVar[frozenset[IdentifierCase]] = frozenset({IdentifierCase.CAMEL, IdentifierCase.PASCAL, IdentifierCase.SNAKE, IdentifierCase.UPPER_SNAKE})¶
- supports_call_style = True¶
- supports_collection_comments: ClassVar[bool] = True¶
- supports_default_dict_key_type = True¶
- supports_default_dict_value_type = True¶
- supports_default_ordered_map_value_type = False¶
- supports_default_sequence_element_type = False¶
- supports_default_set_element_type = True¶
- supports_dict_literal_as_free_expression = True¶
- supports_dotted_call_stub = True¶
- supports_dotted_calls = True¶
- supports_empty_dict_key = False¶
- supports_inline_multiline_dict_args = True¶
- supports_module_name = True¶
- supports_multi_param_call_wrapper_stub = True¶
- supports_no_variable_wrap_in_file = True¶
- supports_non_string_dict_keys = True¶
- supports_record_shape_names = False¶
- supports_record_struct_name_prefix = True¶
- supports_scalar_before_comments: ClassVar[bool] = True¶
- supports_scalar_inline_comments: ClassVar[bool] = True¶
- supports_special_floats = True¶
- supports_standalone_comments_in_wrapped_calls = True¶
- supports_variable_names = True¶
- supports_zero_parameter_calls = True¶
- trailing_comma: TrailingCommas = TrailingCommaConfig(multiline_trailing_comma=True)¶
- property trailing_comma_config: TrailingCommaConfig¶
Configuration for trailing-comma behavior.
json_typealways disables trailing commas because the JSON content embedded inJSON.parse(%(...))is parsed against the JSON spec, which rejects trailing commas in arrays and objects.
- trailing_commas¶
alias of
TrailingCommas
- true_literal: ClassVar[str] = 'true'¶
- property type_hint_collection_preamble_lines: Callable[[frozenset[type]], tuple[str, ...]]¶
Return preamble lines for empty-collection type hints.
- property validate_call_arg: Callable[[Value], None]¶
Return call-argument validation for this language.
- validate_spec_for_data(data: Value) None¶
Validate Crystal-specific data/format combinations.
Under
json_typeevery dict key must be a string (a JSON object only admits string keys) and every integer must fit theInt64range that Crystal’sJSON.parseexposes throughJSON::Any#as_i. Strings embedded in the rendered JSON document cannot contain characters the%(...)percent literal interprets specially:\\,",(,), or#{; we reject those upfront with a clear error rather than letting the Crystal compiler or JSON parser fail at runtime.
- variable_type_hints: VariableTypeHints = 1¶
- variable_type_hints_formats¶
alias of
VariableTypeHints
- version_formats¶
alias of
VersionFormats
- wrap_calls_with_declarations(declarations: tuple[str, ...], calls: str, body_preamble: tuple[str, ...]) str¶
Default
wrap_calls_with_declarations— concatenate the declarations and calls and route throughwrap_in_file()in call mode.
- wrap_combined_in_file(declaration: str, assignment: str, variable_name: str, body_preamble: tuple[str, ...]) str¶
Wrap Crystal declaration + assignment in a module.
- wrap_in_file(content: str, variable_name: str, body_preamble: tuple[str, ...]) str¶
Wrap a Crystal declaration in a module.
- class literalizer.languages.D(*args: object, **kwargs: object)¶
D language specification.
- class BoolFormats(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
Empty: this language has no alternative boolean formats.
- class BytesFormats(*values)¶
Bytes formatting options.
- BASE64 = <function format_bytes_base64>¶
- HEX = <function format_bytes_hex>¶
- class CallStyles(*values)¶
D call style options.
- POSITIONAL = PositionalCallStyle(arg_separator=', ', parenthesize_each_arg=False)¶
- class CommentFormats(*values)¶
Comment style options.
- BLOCK = CommentConfig(prefix='/*', suffix=' */')¶
- DOUBLE_SLASH = CommentConfig(prefix='//', suffix='')¶
- class DateFormats(*values)¶
Date format options for D.
- ISO = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- class DatetimeFormats(*values)¶
Datetime format options for D.
- EPOCH = DatetimeFormatConfig(formatter=<function format_datetime_epoch>, preamble_lines=(), type_produced=<class 'int'>)¶
- ISO = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- class DeclarationStyles(*values)¶
Declaration style options.
- AUTO = DeclarationStyleConfig(formatter=<function _format_variable_declaration>, supports_redefinition=True)¶
- class FloatFormats(*values)¶
Float format options.
- FIXED = <function format_float_fixed>¶
- REPR = <function format_float_repr>¶
- SCIENTIFIC = <function format_float_scientific>¶
- class HeterogeneousStrategies(*values)¶
Heterogeneous-scalar strategy options.
ERRORkeeps the defaultstd.json.JSONValuemodel (a record-shaped dict that mixes scalars with a container is rendered as a homogeneousJSONValuemap).RECORDinstead renders each record-shaped dict (non-empty, string-keyed) as a generatedstruct RecordN { ... }declared in the preamble plus a matching positionalRecord0(value, ...)constructor literal whose fields are raw D values, so a field may mix scalars and containers that the homogeneousJSONValuemap cannot. Without theJSONValuewrapper the whole value is raw; a heterogeneous scalar list, a set, an ordered map or a non-record dict has no raw D representation and raisesUnrepresentableInputError(D has noJSONValue-free heterogeneous container; the cross-language decision for these is tracked in #2317).- ERROR = 1¶
- RECORD = 2¶
- class IntegerFormats(*values)¶
Integer format options.
- BINARY = mappingproxy({'NONE': <function format_integer_binary>, 'UNDERSCORE': <function format_integer_binary>})¶
- DECIMAL = mappingproxy({'NONE': <class 'str'>, 'UNDERSCORE': <function format_integer_underscore>})¶
- HEX = mappingproxy({'NONE': <function format_integer_hex>, 'UNDERSCORE': <function format_integer_hex>})¶
- get_formatter(numeric_separator: Enum) Callable[[int], str]¶
Return the integer formatter for the given separator.
- class JsonTypes(*values)¶
JSON value type options for D.
D’s default rendering already wraps every value in
std.json.JSONValue; this enum exposes that mode explicitly so the field has a named value paired with the opt-outjson_type=None, which selects narrow-typed rendering (raw scalars,T[]arrays,V[K]associative arrays) and rejects inputs that cannot be expressed without theJSONValuewrapper.- STD_JSON_VALUE = 'JSONValue'¶
The standard-library
std.json.JSONValuemodel (D’s default).
- class Modifiers(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
C++/Java/C#-style declaration modifiers: this language has none.
- class SequenceFormats(*values)¶
Sequence type options for D.
- ARRAY = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close='])', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence='parseJSON("[]")', preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)¶
- class SetFormats(*values)¶
Set type options for D.
- SET = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close='])', empty_set='parseJSON("[]")', preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)¶
- class TrailingCommas(*values)¶
Trailing comma options.
- NO = TrailingCommaConfig(multiline_trailing_comma=False)¶
- YES = TrailingCommaConfig(multiline_trailing_comma=True)¶
- allows_empty_call_parens = True¶
- bool_formats¶
alias of
BoolFormats
- bytes_format: BytesFormats = <function format_bytes_hex>¶
- bytes_formats¶
alias of
BytesFormats
- property call_data_dependent_preamble: Callable[[Value], tuple[str, ...]]¶
Return data-dependent preamble lines for call rendering.
- call_returns_expression = True¶
- call_style: CallStyles = PositionalCallStyle(arg_separator=', ', parenthesize_each_arg=False)¶
- property call_style_config: PositionalCallStyle | KeywordCallStyle | ObjectCallStyle | PostfixCallStyle | PrefixCallStyle | CommandCallStyle¶
Configuration for the chosen call style.
- call_styles¶
alias of
CallStyles
- property comment_config: CommentConfig¶
Configuration for the language’s comment syntax.
- comment_format: CommentFormats = CommentConfig(prefix='//', suffix='')¶
- comment_formats¶
alias of
CommentFormats
- property compute_body_preamble: Callable[[frozenset[type], Value], tuple[str, ...]]¶
Compute body-preamble lines from the scalar map.
- property consumable_ref_value_inhibits_consuming_form: Callable[[Value], bool]¶
Predicate deciding whether a ref’s underlying value type inhibits the consume form.
Delegates to
never_inhibits_consuming_form. Languages whose consume operator rejects certain value types (notably the Mojo^on register-trivial scalars) override this.
- property data_dependent_preamble: Callable[[Value], tuple[str, ...]]¶
Return data-dependent preamble lines.
Under
RECORDthis is the generatedstruct RecordN { ... }block, emitted in dependency order so a nested record is declared before its parent.
- date_format: DateFormats = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- date_formats¶
alias of
DateFormats
- datetime_format: DatetimeFormats = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- datetime_formats¶
alias of
DatetimeFormats
- declaration_style: DeclarationStyles = DeclarationStyleConfig(formatter=<function _format_variable_declaration>, supports_redefinition=True)¶
- declaration_styles¶
alias of
DeclarationStyles
- dict_entry_style: DictEntryStyles = 1¶
- dict_entry_styles¶
alias of
DictEntryStyles
- dict_format: DictFormats = 1¶
- property dict_format_config: DictFormatConfig¶
Configuration for dict formatting.
Under
RECORDevery record-shaped dict is intercepted by the shared record behavior, so any dict reaching this formatter is a non-record (empty or non-string-keyed) dict with no raw D representation; its opener rejects the input.
- dict_formats¶
alias of
DictFormats
- dict_supports_heterogeneous_values = True¶
- element_separator: ClassVar[str] = ', '¶
- empty_dict_keys¶
alias of
EmptyDictKey
- extension = '.d'¶
- false_literal: ClassVar[str] = 'false'¶
- float_format: FloatFormats = <function format_float_repr>¶
- float_formats¶
alias of
FloatFormats
- property format_bytes: Callable[[bytes], str]¶
Callable that formats a bytes value as a string literal.
- static format_call_arg(_value: Value, formatted: str, /) str¶
Callable that rewrites a formatted direct call argument.
- property format_call_arg_ref_identifier: Callable[[str, Value | None], str]¶
Rewrite a
{"$ref": "name"}identifier in a call-argument context.Delegates to
format_call_ref_identifier. Override this to allow call-argument$refvalues that would otherwise be rejected.
- property format_call_arg_ref_identifier_consumable: Callable[[str, Value | None], str]¶
Format a
$refthe caller authorized as consumable.Delegates to
format_call_arg_ref_identifier. Override this to opt into a consuming form (e.g. C++std::move).
- format_call_binding_body_preamble() tuple[str, ...]¶
Default
format_call_binding_body_preamble– no extra body preamble lines for an inference-bound call result.
- format_call_binding_file_pragmas() tuple[str, ...]¶
Default
format_call_binding_file_pragmas– no file-level compiler-pragma line for an inference-bound call result.
- property format_call_preamble_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]¶
Return file-scope stubs for a call expression.
- property format_call_ref_identifier: Callable[[str, Value | None], str]¶
Rewrite a
{"$ref": "name"}identifier into the language’s call expression syntax.
- property format_call_statement: Callable[[str], str]¶
Return call-statement formatting for this language.
- property format_call_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]¶
Return stub declarations for a call expression.
- property format_call_target: Callable[[Sequence[str]], str]¶
Rewrite a dotted call target into the language’s call syntax.
- property format_call_variable_assignment: Callable[[str, str, Value], str]¶
Callable that formats an assignment binding a call result.
The call-expression counterpart of
format_variable_assignment; theJSONValue/ struct-constructor wrapping is dropped since the variable is already declared.
- property format_call_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]¶
Callable that formats a declaration binding a call result.
A literal binding wraps the right-hand side to encode the parsed value’s runtime type (a
JSONValue(...)projection, or a positionalRecord0(...)struct-constructor literal underRECORD); a call’s return type is opaque to the renderer, so the call result is bound directly with a plain inferredautodeclaration and no value-wrapping.
- static format_constructor_target(class_name: str, /) str¶
Return class_name as a zero-argument constructor call target.
- property format_date: Callable[[date], str]¶
Callable that formats a date as a string literal.
- property format_datetime: Callable[[datetime], str]¶
Callable that formats a datetime as a string literal.
- property format_float: Callable[[float], str]¶
Callable that formats a float value as a literal.
- property format_integer: Callable[[int], str]¶
Callable that formats an int value as a literal.
D’s widest built-in integer types are
long(signed 64-bit) andulong(unsigned 64-bit). Positive values abovelong.maxemit aUL-suffixedulongliteral; values belowlong.minor aboveulong.maxraiseUnrepresentableIntegerErrorrather than emit a decimal literal the compiler rejects.
- property format_integer_widened: None¶
Default
format_integer_widened– no mixed-magnitude integer widening, so the renderer keeps the normal integer formatter.
- property format_ordered_map_entry: Callable[[str, Value, str], str]¶
Format one ordered-map entry.
Under
RECORDan ordered map has no raw D representation;ordered_map_format_configrejects it before an entry is formatted, so thisJSONValuetemplate is only ever used by the default model.
- property format_sequence_entry: Callable[[Value, str], str]¶
Format a sequence entry.
Under
RECORDor narrow-typed mode every element is a raw D literal (noJSONValuewrapper), so the entry formatter is the identity.
- property format_set_entry: Callable[[Value, str], str]¶
Format a set entry.
Under
RECORDa set has no raw D representation andset_format_configrejects it at its opener before any entry is formatted, so this formatter is only ever reached by the defaultJSONValuemodel.
- property format_string: Callable[[str], str]¶
Format a string value as a quoted literal.
- property format_time: Callable[[time], str]¶
Callable that formats a time as a string literal.
- property format_variable_assignment: Callable[[str, str, Value], str]¶
Format an assignment to an existing variable.
The default model wraps the value in
JSONValue; underRECORDor narrow-typed mode the value is a raw D literal (aRecord0(...)struct, AA literal, array or scalar) assigned directly.
- property format_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]¶
Callable that formats a new variable declaration.
The default model wraps the value in
JSONValue; underRECORDor narrow-typed mode the value is a raw D literal whose type is inferred, so a plainautobinding is emitted.
- has_free_function_calls = True¶
- property heterogeneous_behavior: HeterogeneousBehavior¶
Return the heterogeneous-behavior config.
RECORDresolves to the shared record behavior (its value needs the per-instance renderer, so it cannot be stored on the enum member);ERRORkeeps the defaultJSONValuemodel.
- heterogeneous_strategies¶
alias of
HeterogeneousStrategies
- heterogeneous_strategy: HeterogeneousStrategies = 1¶
- identifier_cases: ClassVar[tuple[IdentifierCase, ...]] = (IdentifierCase.SNAKE, IdentifierCase.PASCAL, IdentifierCase.CAMEL)¶
- indent: str = ' '¶
- indent_closing_delimiter: ClassVar[bool] = False¶
- integer_format: IntegerFormats = mappingproxy({'NONE': <class 'str'>, 'UNDERSCORE': <function format_integer_underscore>})¶
- integer_formats¶
alias of
IntegerFormats
- integer_width_strategies¶
alias of
BareIntegerWidthStrategies
- integer_width_strategy: BareIntegerWidthStrategies = 1¶
- language_version: VersionFormats = 1¶
- property leading_preamble: LeadingPreamble¶
Default
leading_preamble– no preamble lines that must precedeLanguage.static_preamble.
- max_call_parameters = 9223372036854775807¶
- modifier_combinations: ClassVar[tuple[ModifierCombination, ...]] = ()¶
- module_name: str = 'Module'¶
- module_name_case: ClassVar[IdentifierCase] = 'snake'¶
- null_literal: ClassVar[str] = 'null'¶
- numeric_literal_suffix: NumericLiteralSuffixes = 1¶
- numeric_literal_suffixes¶
alias of
NumericLiteralSuffixes
- numeric_separator: NumericSeparators = 1¶
- numeric_separators¶
alias of
NumericSeparators
- numeric_style: NumericStyles = 1¶
- numeric_styles¶
alias of
NumericStyles
- property ordered_map_format_config: OrderedMapFormatConfig¶
Configuration for ordered-map formatting.
An ordered map is never record-eligible and has no raw D representation, so under
RECORDits opener rejects the input.
- pygments_name = 'd'¶
- record_struct_name_prefix: str = 'Record'¶
- reserved_identifiers: ClassVar[frozenset[str]] = frozenset({})¶
- property scalar_body_preamble: dict[type, tuple[str, ...]]¶
Per-instance scalar body preamble (D needs none).
- property scalar_preamble: dict[type, tuple[str, ...]]¶
Per-instance scalar preamble (D needs none).
- sequence_binding_declarations(declarations: tuple[str, ...]) str¶
Default
sequence_binding_declarations– join the per-binding snippets with newlines.
- sequence_format: SequenceFormats = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close='])', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence='parseJSON("[]")', preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)¶
- property sequence_format_config: SequenceFormatConfig¶
Configuration for the chosen sequence format.
Under
RECORDa list is a raw D array[ ... ](noJSONValuewrapper): the opener is[for a homogeneous or empty list and rejects a heterogeneous scalar list, the closer is], the empty literal is[](it coerces to any declared element type) and there is noparseJSONnarrowed empty form.Under narrow-typed mode (
json_type=None) the literal is also raw[ ... ], but D’sautocannot infer an element type for an empty literal, so an empty list is rejected at the opener alongside the heterogeneous case.
- sequence_formats¶
alias of
SequenceFormats
- property sequence_open: Callable[[list[Value]], str]¶
Callable that returns the opening delimiter for a sequence.
- set_format: SetFormats = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close='])', empty_set='parseJSON("[]")', preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)¶
- property set_format_config: SetFormatConfig¶
Configuration for the chosen set format.
A set has no raw D representation, so under
RECORDor narrow-typed mode its opener rejects the input.
- set_formats¶
alias of
SetFormats
- skip_null_dict_values: ClassVar[bool] = False¶
- special_float_preamble: ClassVar[tuple[str, ...]] = ()¶
- statement_terminator: ClassVar[str] = ';'¶
- statement_terminator_style: StatementTerminatorStyles = 1¶
- statement_terminator_styles¶
alias of
StatementTerminatorStyles
- static_body_preamble: ClassVar[Sequence[str]] = ()¶
- property static_preamble: Sequence[str]¶
File-scope preamble.
The default
ERRORJSONValuemodel needsimport std.json;; theRECORDstrategy and narrow-typed (json_type=None) mode both emit raw D values with noJSONValuereference, so neither needs the import.
- string_format: StringFormats = 1¶
- string_formats¶
alias of
StringFormats
- supported_ref_cases: ClassVar[frozenset[IdentifierCase]] = frozenset({IdentifierCase.CAMEL, IdentifierCase.PASCAL, IdentifierCase.SNAKE, IdentifierCase.UPPER_SNAKE})¶
- supports_call_style = True¶
- supports_collection_comments: ClassVar[bool] = True¶
- supports_default_dict_key_type = False¶
- supports_default_dict_value_type = False¶
- supports_default_ordered_map_value_type = False¶
- supports_default_sequence_element_type = False¶
- supports_default_set_element_type = False¶
- supports_dict_literal_as_free_expression = True¶
- supports_dotted_call_stub = True¶
- supports_dotted_calls = True¶
- supports_empty_dict_key = False¶
- supports_inline_multiline_dict_args = True¶
- supports_module_name = True¶
- supports_multi_param_call_wrapper_stub = True¶
- supports_no_variable_wrap_in_file = False¶
- supports_non_string_dict_keys = False¶
- supports_record_shape_names = False¶
- supports_record_struct_name_prefix = True¶
- supports_scalar_before_comments: ClassVar[bool] = True¶
- supports_scalar_inline_comments: ClassVar[bool] = False¶
- supports_special_floats = True¶
- supports_standalone_comments_in_wrapped_calls = True¶
- supports_variable_names = True¶
- supports_zero_parameter_calls = True¶
- trailing_comma: TrailingCommas = TrailingCommaConfig(multiline_trailing_comma=True)¶
- property trailing_comma_config: TrailingCommaConfig¶
Configuration for trailing-comma behavior.
- trailing_commas¶
alias of
TrailingCommas
- true_literal: ClassVar[str] = 'true'¶
- property type_hint_collection_preamble_lines: Callable[[frozenset[type]], tuple[str, ...]]¶
Return preamble lines for empty-collection type hints.
- property validate_call_arg: Callable[[Value], None]¶
Return call-argument validation for this language.
- validate_spec_for_data(data: Value) None¶
Validate D-specific data/format combinations.
Narrow-typed mode (
json_type=None) rejects empty containers up front so D’sautois never asked to infer a type from an empty literal; the defaultJSONValuemodel rendersparseJSON("[]")/parseJSON("{}")for these and needs no validation.
- variable_type_hints: VariableTypeHints = 1¶
- variable_type_hints_formats¶
alias of
VariableTypeHints
- version_formats¶
alias of
VersionFormats
- wrap_calls_with_declarations(declarations: tuple[str, ...], calls: str, body_preamble: tuple[str, ...]) str¶
Default
wrap_calls_with_declarations— concatenate the declarations and calls and route throughwrap_in_file()in call mode.
- wrap_combined_in_file(declaration: str, assignment: str, variable_name: str, body_preamble: tuple[str, ...]) str¶
Wrap D declaration + assignment in a function.
- wrap_in_file(content: str, variable_name: str, body_preamble: tuple[str, ...]) str¶
Wrap a D declaration in a main function.
- class literalizer.languages.Dart(*args: object, **kwargs: object)¶
Dart language specification.
- Parameters:
date_format –
How to format
datetime.datevalues.date_formats.DART—DateTime.parse(...)call, e.g.DateTime.parse("2024-01-15").date_formats.ISO— ISO 8601 quoted string, e.g."2024-01-15".
datetime_format –
How to format
datetime.datetimevalues.datetime_formats.DART—DateTime.parse(...)call, e.g.DateTime.parse("2024-01-15T12:30:00").datetime_formats.ISO— ISO 8601 quoted string, e.g."2024-01-15T12:30:00".
- class BoolFormats(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
Empty: this language has no alternative boolean formats.
- class BytesFormats(*values)¶
Bytes formatting options.
- BASE64 = <function format_bytes_base64>¶
- HEX = <function format_bytes_hex>¶
- class CommentFormats(*values)¶
Comment style options.
- BLOCK = CommentConfig(prefix='/*', suffix=' */')¶
- DOUBLE_SLASH = CommentConfig(prefix='//', suffix='')¶
- class DateFormats(*values)¶
Date formatting options for Dart.
- DART = DateFormatConfig(formatter=<function date_iso_formatter.<locals>._format>, preamble_lines=(), type_produced=<class 'datetime.date'>)¶
- ISO = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- class DatetimeFormats(*values)¶
Datetime formatting options for Dart.
- DART = DatetimeFormatConfig(formatter=<function datetime_iso_formatter.<locals>._format>, preamble_lines=(), type_produced=<class 'datetime.datetime'>)¶
- EPOCH = DatetimeFormatConfig(formatter=<function format_datetime_epoch>, preamble_lines=(), type_produced=<class 'int'>)¶
- ISO = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- class DeclarationStyles(*values)¶
Declaration style options.
- CONST = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=False)¶
- FINAL = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=False)¶
- VAR = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=False)¶
- class FloatFormats(*values)¶
Float format options.
- FIXED = <function format_float_fixed>¶
- REPR = <function format_float_repr>¶
- SCIENTIFIC = <function format_float_scientific>¶
- class HeterogeneousStrategies(*values)¶
Heterogeneous-scalar strategy options — this language only supports raising.
- ERROR = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)¶
- class IntegerFormats(*values)¶
Integer format options.
- DECIMAL = <class 'str'>¶
- HEX = <function format_integer_hex>¶
- class JsonTypes(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
Empty: this language has no JSON value-type variants.
- class Modifiers(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
C++/Java/C#-style declaration modifiers: this language has none.
- class SequenceFormats(*values)¶
Sequence type options for Dart.
- LIST = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=']', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback='[', uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)¶
- TUPLE = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=')', supports_heterogeneity=True, single_element_trailing_comma=True, supports_trailing_comma=True, empty_sequence='()', preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)¶
- class SetFormats(*values)¶
Set type options for Dart.
- SET = <function set_format_factory.<locals>._build>¶
- class StringFormats(*values)¶
String format options.
- DOUBLE = <function _build_backslash_formatter.<locals>._format>¶
- SINGLE = <function _build_backslash_formatter.<locals>._format>¶
- class TrailingCommas(*values)¶
Trailing comma options.
- NO = TrailingCommaConfig(multiline_trailing_comma=False)¶
- YES = TrailingCommaConfig(multiline_trailing_comma=True)¶
- class VariableTypeHints(*values)¶
Variable type hint options.
- ALWAYS = 2¶
- NEVER = 1¶
- SAFE = 3¶
- formatter(*, auto_formatter: Callable[[str, str, Value, frozenset[Enum]], str], keyword: str, date_hint: str, datetime_hint: str, default_set_element_type: str, default_dict_key_type: str, default_dict_value_type: str, sequence_is_tuple: bool) Callable[[str, str, Value, frozenset[Enum]], str]¶
Return the variable declaration formatter.
- allows_empty_call_parens = True¶
- bool_formats¶
alias of
BoolFormats
- bytes_format: BytesFormats = <function format_bytes_hex>¶
- bytes_formats¶
alias of
BytesFormats
- property call_data_dependent_preamble: Callable[[Value], tuple[str, ...]]¶
Return data-dependent preamble lines for call rendering.
- call_returns_expression = True¶
- call_style: CallStyles = KeywordCallStyle(separator=': ')¶
- property call_style_config: PositionalCallStyle | KeywordCallStyle | ObjectCallStyle | PostfixCallStyle | PrefixCallStyle | CommandCallStyle¶
Configuration for the chosen call style.
- call_styles¶
alias of
CallStyles
- property comment_config: CommentConfig¶
Configuration for the language’s comment syntax.
- comment_format: CommentFormats = CommentConfig(prefix='//', suffix='')¶
- comment_formats¶
alias of
CommentFormats
- property compute_body_preamble: Callable[[frozenset[type], Value], tuple[str, ...]]¶
Compute body-preamble lines from the scalar map.
- property consumable_ref_value_inhibits_consuming_form: Callable[[Value], bool]¶
Predicate deciding whether a ref’s underlying value type inhibits the consume form.
Delegates to
never_inhibits_consuming_form. Languages whose consume operator rejects certain value types (notably the Mojo^on register-trivial scalars) override this.
- property data_dependent_preamble: Callable[[Value], tuple[str, ...]]¶
Return data-dependent preamble lines.
- date_format: DateFormats = DateFormatConfig(formatter=<function date_iso_formatter.<locals>._format>, preamble_lines=(), type_produced=<class 'datetime.date'>)¶
- date_formats¶
alias of
DateFormats
- datetime_format: DatetimeFormats = DatetimeFormatConfig(formatter=<function datetime_iso_formatter.<locals>._format>, preamble_lines=(), type_produced=<class 'datetime.datetime'>)¶
- datetime_formats¶
alias of
DatetimeFormats
- declaration_style: DeclarationStyles = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=False)¶
- declaration_styles¶
alias of
DeclarationStyles
- default_dict_key_type: str = 'String'¶
- default_dict_value_type: str = 'dynamic'¶
- default_set_element_type: str = 'dynamic'¶
- dict_entry_style: DictEntryStyles = 1¶
- dict_entry_styles¶
alias of
DictEntryStyles
- dict_format: DictFormats = 1¶
- property dict_format_config: DictFormatConfig¶
Configuration for dict formatting.
- dict_formats¶
alias of
DictFormats
- dict_supports_heterogeneous_values = True¶
- element_separator: ClassVar[str] = ', '¶
- empty_dict_keys¶
alias of
EmptyDictKey
- extension = '.dart'¶
- false_literal: ClassVar[str] = 'false'¶
- float_format: FloatFormats = <function format_float_repr>¶
- float_formats¶
alias of
FloatFormats
- property format_bytes: Callable[[bytes], str]¶
Callable that formats a bytes value as a string literal.
- static format_call_arg(_value: Value, formatted: str, /) str¶
Callable that rewrites a formatted direct call argument.
- property format_call_arg_ref_identifier: Callable[[str, Value | None], str]¶
Rewrite a
{"$ref": "name"}identifier in a call-argument context.Delegates to
format_call_ref_identifier. Override this to allow call-argument$refvalues that would otherwise be rejected.
- property format_call_arg_ref_identifier_consumable: Callable[[str, Value | None], str]¶
Format a
$refthe caller authorized as consumable.Delegates to
format_call_arg_ref_identifier. Override this to opt into a consuming form (e.g. C++std::move).
- format_call_binding_body_preamble() tuple[str, ...]¶
Default
format_call_binding_body_preamble– no extra body preamble lines for an inference-bound call result.
- format_call_binding_file_pragmas() tuple[str, ...]¶
Default
format_call_binding_file_pragmas– no file-level compiler-pragma line for an inference-bound call result.
- property format_call_preamble_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]¶
Return file-scope stubs for a call expression.
- property format_call_ref_identifier: Callable[[str, Value | None], str]¶
Rewrite a
{"$ref": "name"}identifier into the language’s call expression syntax.
- property format_call_statement: Callable[[str], str]¶
Return call-statement formatting for this language.
- property format_call_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]¶
Return stub declarations for a call expression.
- property format_call_target: Callable[[Sequence[str]], str]¶
Rewrite a dotted call target into the language’s call syntax.
- property format_call_variable_assignment: Callable[[str, str, Value], str]¶
Default
format_call_variable_assignment– reuse the literal-binding assignment formatter unchanged.
- property format_call_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]¶
Default
format_call_variable_declaration– reuse the literal-binding declaration formatter unchanged.
- static format_constructor_target(class_name: str, /) str¶
Return class_name as a zero-argument constructor call target.
- property format_date: Callable[[date], str]¶
Callable that formats a date as a string literal.
- property format_datetime: Callable[[datetime], str]¶
Callable that formats a datetime as a string literal.
- property format_float: Callable[[float], str]¶
Callable that formats a float value as a literal.
- property format_integer: Callable[[int], str]¶
Callable that formats an int value as a literal.
- property format_integer_widened: None¶
Default
format_integer_widened– no mixed-magnitude integer widening, so the renderer keeps the normal integer formatter.
- property format_ordered_map_entry: Callable[[str, Value, str], str]¶
Format one ordered-map entry.
- property format_sequence_entry: Callable[[Value, str], str]¶
Format a sequence entry.
- property format_set_entry: Callable[[Value, str], str]¶
Format a set entry.
- property format_string: Callable[[str], str]¶
Callable that formats a string value as a quoted literal.
- property format_time: Callable[[time], str]¶
Callable that formats a time as a string literal.
- property format_variable_assignment: Callable[[str, str, Value], str]¶
Format an assignment to an existing variable.
- property format_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]¶
Callable that formats a new variable declaration.
- has_free_function_calls = True¶
- property heterogeneous_behavior: HeterogeneousBehavior¶
Return the heterogeneous-behavior config.
- heterogeneous_strategies¶
alias of
HeterogeneousStrategies
- heterogeneous_strategy: HeterogeneousStrategies = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)¶
- identifier_cases: ClassVar[tuple[IdentifierCase, ...]] = (IdentifierCase.CAMEL, IdentifierCase.PASCAL, IdentifierCase.UPPER_SNAKE)¶
- indent: str = ' '¶
- indent_closing_delimiter: ClassVar[bool] = False¶
- integer_format: IntegerFormats = <class 'str'>¶
- integer_formats¶
alias of
IntegerFormats
- integer_width_strategies¶
alias of
BareIntegerWidthStrategies
- integer_width_strategy: BareIntegerWidthStrategies = 1¶
- language_version: VersionFormats = 1¶
- property leading_preamble: LeadingPreamble¶
Default
leading_preamble– no preamble lines that must precedeLanguage.static_preamble.
- max_call_parameters = 9223372036854775807¶
- modifier_combinations: ClassVar[tuple[ModifierCombination, ...]] = ()¶
- null_literal: ClassVar[str] = 'null'¶
- numeric_literal_suffix: NumericLiteralSuffixes = 1¶
- numeric_literal_suffixes¶
alias of
NumericLiteralSuffixes
- numeric_separator: NumericSeparators = 1¶
- numeric_separators¶
alias of
NumericSeparators
- numeric_style: NumericStyles = 1¶
- numeric_styles¶
alias of
NumericStyles
- property ordered_map_format_config: OrderedMapFormatConfig¶
Configuration for ordered-map formatting.
- pygments_name = 'dart'¶
- reserved_identifiers: ClassVar[frozenset[str]] = frozenset({})¶
- property scalar_body_preamble: dict[type, tuple[str, ...]]¶
Per-instance scalar body preamble (Dart needs none).
- property scalar_preamble: dict[type, tuple[str, ...]]¶
Per-instance scalar preamble (Dart needs none).
- sequence_binding_declarations(declarations: tuple[str, ...]) str¶
Default
sequence_binding_declarations– join the per-binding snippets with newlines.
- sequence_format: SequenceFormats = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=']', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback='[', uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)¶
- property sequence_format_config: SequenceFormatConfig¶
Configuration for the chosen sequence format.
- sequence_formats¶
alias of
SequenceFormats
- property sequence_open: Callable[[list[Value]], str]¶
Callable that returns the opening delimiter for a sequence.
- set_format: SetFormats = <function set_format_factory.<locals>._build>¶
- property set_format_config: SetFormatConfig¶
Configuration for the chosen set format.
- set_formats¶
alias of
SetFormats
- skip_null_dict_values: ClassVar[bool] = False¶
- special_float_preamble: ClassVar[tuple[str, ...]] = ()¶
- statement_terminator: ClassVar[str] = ';'¶
- statement_terminator_style: StatementTerminatorStyles = 1¶
- statement_terminator_styles¶
alias of
StatementTerminatorStyles
- static_body_preamble: ClassVar[Sequence[str]] = ()¶
- static_preamble: ClassVar[Sequence[str]] = ()¶
- string_format: StringFormats = <function _build_backslash_formatter.<locals>._format>¶
- string_formats¶
alias of
StringFormats
- supported_ref_cases: ClassVar[frozenset[IdentifierCase]] = frozenset({IdentifierCase.CAMEL, IdentifierCase.PASCAL, IdentifierCase.SNAKE, IdentifierCase.UPPER_SNAKE})¶
- supports_call_style = True¶
- supports_collection_comments: ClassVar[bool] = True¶
- supports_default_dict_key_type = True¶
- supports_default_dict_value_type = True¶
- supports_default_ordered_map_value_type = False¶
- supports_default_sequence_element_type = False¶
- supports_default_set_element_type = True¶
- supports_dict_literal_as_free_expression = True¶
- supports_dotted_call_stub = True¶
- supports_dotted_calls = True¶
- supports_empty_dict_key = False¶
- supports_inline_multiline_dict_args = True¶
- supports_module_name = False¶
- supports_multi_param_call_wrapper_stub = True¶
- supports_no_variable_wrap_in_file = False¶
- supports_non_string_dict_keys = False¶
- supports_record_shape_names = False¶
- supports_record_struct_name_prefix = False¶
- supports_scalar_before_comments: ClassVar[bool] = True¶
- supports_scalar_inline_comments: ClassVar[bool] = False¶
- supports_special_floats = True¶
- supports_standalone_comments_in_wrapped_calls = True¶
- supports_variable_names = True¶
- supports_zero_parameter_calls = True¶
- trailing_comma: TrailingCommas = TrailingCommaConfig(multiline_trailing_comma=True)¶
- property trailing_comma_config: TrailingCommaConfig¶
Configuration for trailing-comma behavior.
- trailing_commas¶
alias of
TrailingCommas
- true_literal: ClassVar[str] = 'true'¶
- property type_hint_collection_preamble_lines: Callable[[frozenset[type]], tuple[str, ...]]¶
Return preamble lines for empty-collection type hints.
- property validate_call_arg: Callable[[Value], None]¶
Return call-argument validation for this language.
- validate_spec_for_data(data: Value) None¶
Raise if the spec cannot produce valid code for data.
Dart’s
DARTdate / datetime formats render asDateTime.parse(...), which is a runtime call and not a constant expression, so they are incompatible withCONST.
- variable_type_hints: VariableTypeHints = 1¶
- variable_type_hints_formats¶
alias of
VariableTypeHints
- version_formats¶
alias of
VersionFormats
- wrap_calls_with_declarations(declarations: tuple[str, ...], calls: str, body_preamble: tuple[str, ...]) str¶
Default
wrap_calls_with_declarations— concatenate the declarations and calls and route throughwrap_in_file()in call mode.
- static wrap_combined_in_file(declaration: str, assignment: str, variable_name: str, body_preamble: tuple[str, ...]) str¶
Unsupported: literalize() rejects BothVariableForms upstream.
- wrap_in_file(content: str, variable_name: str, body_preamble: tuple[str, ...]) str¶
Wrap code in a valid file.
- class literalizer.languages.Dhall(*args: object, **kwargs: object)¶
Dhall language specification.
Produces Dhall values — records for mappings, and lists for sequences and sets — following Dhall syntax.
Dhall is a programmable configuration language that is not Turing-complete. It supports records (
{ key = value }), lists ([1, 2, 3]),Text,Natural,Double, andBooltypes.Dhall has no
nulltype;nullvalues are rendered as the empty string"".Dates and datetimes are rendered as quoted ISO 8601 strings because Dhall has no native date type.
Dict keys that cannot be represented as Dhall backtick-quoted labels raise
InvalidDictKeyError. This includes empty keys and keys containing control characters or backticks, since Dhall labels only allow printable ASCII.- class BoolFormats(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
Empty: this language has no alternative boolean formats.
- class BytesFormats(*values)¶
Bytes formatting options.
- BASE64 = <function format_bytes_base64>¶
- HEX = <function format_bytes_hex>¶
- class CallStyles(*values)¶
Dhall call style options.
- POSITIONAL = PositionalCallStyle(arg_separator=' ', parenthesize_each_arg=True)¶
- class DateFormats(*values)¶
Date format options for Dhall.
- ISO = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- class DatetimeFormats(*values)¶
Datetime format options for Dhall.
- EPOCH = DatetimeFormatConfig(formatter=<function datetime_epoch_formatter.<locals>._format>, preamble_lines=(), type_produced=<class 'int'>)¶
- ISO = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- class DeclarationStyles(*values)¶
Declaration style options.
- LET = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=False)¶
- class EmptyDictKey(*values)¶
Empty dict key options.
Dhall backtick-quoted labels must be non-empty and contain only printable ASCII, so unsupported dict keys always raise
InvalidDictKeyError.- ERROR = 1¶
- class FloatFormats(*values)¶
Float format options.
- FIXED = <function format_float_fixed>¶
- REPR = <function format_float_repr>¶
- SCIENTIFIC = <function format_float_scientific>¶
- class HeterogeneousStrategies(*values)¶
Strategy for representing dicts or lists whose scalar values span more than one Dhall type.
- ERROR = _HeterogeneousStrategyConfig(build_behavior=<function _build_error_behavior>, build_preamble=<function _build_error_preamble>)¶
Raise
HeterogeneousScalarCollectionError(orHeterogeneousSiblingListsError) when scalar values of mixed types appear in a container that cannot represent them. This is the default, matching Dhall’s strict-typing convention.
- UNION_TYPE = _HeterogeneousStrategyConfig(build_behavior=<function _build_union_type_behavior>, build_preamble=<function _build_union_type_preamble>)¶
Auto-generate a Dhall union type in the preamble containing only the variants actually present in the data, and wrap each heterogeneous scalar value as
{UnionName}.{Variant} payload.The union name is configurable via
Dhall.heterogeneous_value_union_name(default"Value").
- class JsonTypes(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
Empty: this language has no JSON value-type variants.
- class Modifiers(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
C++/Java/C#-style declaration modifiers: this language has none.
- class SequenceFormats(*values)¶
Sequence type options for Dhall.
- LIST = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=']', supports_heterogeneity=False, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence='[] : List {}', preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=True, declared_type=None, narrowed_empty_form=None)¶
- class SetFormats(*values)¶
Set type options for Dhall.
- SET = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close=']', empty_set='[] : List {}', preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)¶
- class TrailingCommas(*values)¶
Trailing comma options.
- NO = TrailingCommaConfig(multiline_trailing_comma=False)¶
- YES = TrailingCommaConfig(multiline_trailing_comma=True)¶
- allows_empty_call_parens = True¶
- bool_formats¶
alias of
BoolFormats
- bytes_format: BytesFormats = <function format_bytes_hex>¶
- bytes_formats¶
alias of
BytesFormats
- property call_data_dependent_preamble: Callable[[Value], tuple[str, ...]]¶
Return data-dependent preamble lines for call rendering.
- call_returns_expression = True¶
- call_style: CallStyles = PositionalCallStyle(arg_separator=' ', parenthesize_each_arg=True)¶
- property call_style_config: PositionalCallStyle | KeywordCallStyle | ObjectCallStyle | PostfixCallStyle | PrefixCallStyle | CommandCallStyle¶
Configuration for the chosen call style.
- call_styles¶
alias of
CallStyles
- property comment_config: CommentConfig¶
Configuration for the language’s comment syntax.
- comment_format: CommentFormats = CommentConfig(prefix='--', suffix='')¶
- comment_formats¶
alias of
CommentFormats
- property compute_body_preamble: Callable[[frozenset[type], Value], tuple[str, ...]]¶
Compute body-preamble lines from the scalar map.
- property consumable_ref_value_inhibits_consuming_form: Callable[[Value], bool]¶
Predicate deciding whether a ref’s underlying value type inhibits the consume form.
Delegates to
never_inhibits_consuming_form. Languages whose consume operator rejects certain value types (notably the Mojo^on register-trivial scalars) override this.
- property data_dependent_preamble: Callable[[Value], tuple[str, ...]]¶
Return data-dependent preamble lines.
For
HeterogeneousStrategies.UNION_TYPEemits aletbinding declaring a union type containing only the variants actually used in heterogeneous positions in the data. Other strategies produce no preamble.
- date_format: DateFormats = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- date_formats¶
alias of
DateFormats
- datetime_format: DatetimeFormats = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- datetime_formats¶
alias of
DatetimeFormats
- declaration_style: DeclarationStyles = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=False)¶
- declaration_styles¶
alias of
DeclarationStyles
- dict_entry_style: DictEntryStyles = 1¶
- dict_entry_styles¶
alias of
DictEntryStyles
- dict_format: DictFormats = 1¶
- property dict_format_config: DictFormatConfig¶
Configuration for dict formatting.
- dict_formats¶
alias of
DictFormats
- dict_supports_heterogeneous_values = False¶
- element_separator: ClassVar[str] = ', '¶
- empty_dict_keys¶
alias of
EmptyDictKey
- extension = '.dhall'¶
- false_literal: ClassVar[str] = 'False'¶
- float_format: FloatFormats = <function format_float_repr>¶
- float_formats¶
alias of
FloatFormats
- property format_bytes: Callable[[bytes], str]¶
Callable that formats a bytes value as a string literal.
- property format_call_arg: Callable[[Value, str], str]¶
Wrap each scalar call argument in the
DValunion tag.
- property format_call_arg_ref_identifier: Callable[[str, Value | None], str]¶
Rewrite a
{"$ref": "name"}identifier in a call-argument context.Delegates to
format_call_ref_identifier. Override this to allow call-argument$refvalues that would otherwise be rejected.
- property format_call_arg_ref_identifier_consumable: Callable[[str, Value | None], str]¶
Format a
$refthe caller authorized as consumable.Delegates to
format_call_arg_ref_identifier. Override this to opt into a consuming form (e.g. C++std::move).
- format_call_binding_body_preamble() tuple[str, ...]¶
Default
format_call_binding_body_preamble– no extra body preamble lines for an inference-bound call result.
- format_call_binding_file_pragmas() tuple[str, ...]¶
Default
format_call_binding_file_pragmas– no file-level compiler-pragma line for an inference-bound call result.
- property format_call_preamble_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]¶
Return the
DValunion-type preamble for a call expression.
- property format_call_ref_identifier: Callable[[str, Value | None], str]¶
Raise for any
$refargument.Dhall’s stub parameter type is
DVal; a ref variable holds a concrete type that Dhall’s type-checker cannot unify with it.
- property format_call_statement: Callable[[str], str]¶
Validate and wrap a call expression as a
let _ =binding.Raises
CallArgNotSupportedErrorif the rendered call contains a function application without the required whitespace, or more than one positional argument.
- property format_call_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]¶
Return stub declarations for a call expression.
- property format_call_target: Callable[[Sequence[str]], str]¶
Rewrite a dotted call target into the language’s call syntax.
- property format_call_variable_assignment¶
- property format_call_variable_declaration¶
- static format_constructor_target(class_name: str, /) str¶
Return class_name as a zero-argument constructor call target.
- property format_date: Callable[[date], str]¶
Callable that formats a date as a string literal.
- property format_datetime: Callable[[datetime], str]¶
Callable that formats a datetime as a string literal.
- property format_float: Callable[[float], str]¶
Callable that formats a float value as a literal.
- property format_integer: Callable[[int], str]¶
Format an int value as a literal.
- property format_integer_widened: None¶
Default
format_integer_widened– no mixed-magnitude integer widening, so the renderer keeps the normal integer formatter.
- property format_ordered_map_entry: Callable[[str, Value, str], str]¶
Format one ordered-map entry.
- property format_sequence_entry: Callable[[Value, str], str]¶
Format a sequence entry.
- property format_set_entry: Callable[[Value, str], str]¶
Format a set entry.
- property format_string: Callable[[str], str]¶
Format a string value as a quoted literal.
- property format_time: Callable[[time], str]¶
Callable that formats a time as a string literal.
- property format_variable_assignment: Callable[[str, str, Value], str]¶
Format an assignment to an existing variable.
- property format_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]¶
Callable that formats a new variable declaration.
- has_free_function_calls = True¶
- property heterogeneous_behavior: HeterogeneousBehavior¶
Return the behavior for the chosen heterogeneous strategy.
- heterogeneous_strategies¶
alias of
HeterogeneousStrategies
- heterogeneous_strategy: HeterogeneousStrategies = _HeterogeneousStrategyConfig(build_behavior=<function _build_error_behavior>, build_preamble=<function _build_error_preamble>)¶
- heterogeneous_value_union_name: str = 'Value'¶
- identifier_cases: ClassVar[tuple[IdentifierCase, ...]] = (IdentifierCase.SNAKE, IdentifierCase.CAMEL)¶
- indent: str = ' '¶
- indent_closing_delimiter: ClassVar[bool] = False¶
- integer_format: IntegerFormats = 1¶
- integer_formats¶
alias of
IntegerFormats
- integer_width_strategies¶
alias of
BareIntegerWidthStrategies
- integer_width_strategy: BareIntegerWidthStrategies = 1¶
- language_version: VersionFormats = 1¶
- property leading_preamble: LeadingPreamble¶
Default
leading_preamble– no preamble lines that must precedeLanguage.static_preamble.
- max_call_parameters = 9223372036854775807¶
- modifier_combinations: ClassVar[tuple[ModifierCombination, ...]] = ()¶
- null_literal: ClassVar[str] = '""'¶
- numeric_literal_suffix: NumericLiteralSuffixes = 1¶
- numeric_literal_suffixes¶
alias of
NumericLiteralSuffixes
- numeric_separator: NumericSeparators = 1¶
- numeric_separators¶
alias of
NumericSeparators
- numeric_style: NumericStyles = 1¶
- numeric_styles¶
alias of
NumericStyles
- property ordered_map_format_config: OrderedMapFormatConfig¶
Configuration for ordered-map formatting.
- pygments_name: ClassVar[str | None] = None¶
- reserved_identifiers: ClassVar[frozenset[str]] = frozenset({})¶
- property scalar_body_preamble: dict[type, tuple[str, ...]]¶
Per-instance scalar body preamble (Dhall needs none).
- property scalar_preamble: dict[type, tuple[str, ...]]¶
Per-instance scalar preamble (Dhall needs none).
- sequence_binding_declarations(declarations: tuple[str, ...]) str¶
Default
sequence_binding_declarations– join the per-binding snippets with newlines.
- sequence_format: SequenceFormats = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=']', supports_heterogeneity=False, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence='[] : List {}', preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=True, declared_type=None, narrowed_empty_form=None)¶
- property sequence_format_config: SequenceFormatConfig¶
Configuration for the chosen sequence format.
- sequence_formats¶
alias of
SequenceFormats
- property sequence_open: Callable[[list[Value]], str]¶
Callable that returns the opening delimiter for a sequence.
- set_format: SetFormats = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close=']', empty_set='[] : List {}', preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)¶
- property set_format_config: SetFormatConfig¶
Configuration for the chosen set format.
- set_formats¶
alias of
SetFormats
- skip_null_dict_values: ClassVar[bool] = False¶
- special_float_preamble: ClassVar[tuple[str, ...]] = ()¶
- statement_terminator: ClassVar[str] = ''¶
- statement_terminator_style: StatementTerminatorStyles = 1¶
- statement_terminator_styles¶
alias of
StatementTerminatorStyles
- static_body_preamble: ClassVar[Sequence[str]] = ()¶
- static_preamble: ClassVar[Sequence[str]] = ()¶
- string_format: StringFormats = 1¶
- string_formats¶
alias of
StringFormats
- supported_ref_cases: ClassVar[frozenset[IdentifierCase]] = frozenset({IdentifierCase.CAMEL, IdentifierCase.PASCAL, IdentifierCase.SNAKE, IdentifierCase.UPPER_SNAKE})¶
- supports_call_style = True¶
- supports_collection_comments: ClassVar[bool] = True¶
- supports_default_dict_key_type = False¶
- supports_default_dict_value_type = False¶
- supports_default_ordered_map_value_type = False¶
- supports_default_sequence_element_type = False¶
- supports_default_set_element_type = False¶
- supports_dict_literal_as_free_expression = True¶
- supports_dotted_call_stub = True¶
- supports_dotted_calls = True¶
- supports_empty_dict_key = False¶
- supports_inline_multiline_dict_args = True¶
- supports_module_name = False¶
- supports_multi_param_call_wrapper_stub = True¶
- supports_no_variable_wrap_in_file = False¶
- supports_non_string_dict_keys = False¶
- supports_record_shape_names = False¶
- supports_record_struct_name_prefix = False¶
- supports_scalar_before_comments: ClassVar[bool] = True¶
- supports_scalar_inline_comments: ClassVar[bool] = False¶
- supports_special_floats = True¶
- supports_standalone_comments_in_wrapped_calls = True¶
- supports_variable_names = True¶
- supports_zero_parameter_calls = False¶
- trailing_comma: TrailingCommas = TrailingCommaConfig(multiline_trailing_comma=True)¶
- property trailing_comma_config: TrailingCommaConfig¶
Configuration for trailing-comma behavior.
- trailing_commas¶
alias of
TrailingCommas
- true_literal: ClassVar[str] = 'True'¶
- property type_hint_collection_preamble_lines: Callable[[frozenset[type]], tuple[str, ...]]¶
Return preamble lines for empty-collection type hints.
- property validate_call_arg: Callable[[Value], None]¶
Return call-argument validation for this language.
- validate_spec_for_data(data: Value) None¶
Default
validate_spec_for_data— no spec/data constraints.
- variable_type_hints: VariableTypeHints = 1¶
- variable_type_hints_formats¶
alias of
VariableTypeHints
- version_formats¶
alias of
VersionFormats
- wrap_calls_with_declarations(declarations: tuple[str, ...], calls: str, body_preamble: tuple[str, ...]) str¶
Join declarations and calls into a Dhall let-chain.
Delegates to
wrap_in_file()with an empty variable name, which appends thein {=}terminator needed by both this path and thewrap_in_file=Truecall path.
- static wrap_combined_in_file(declaration: str, assignment: str, variable_name: str, body_preamble: tuple[str, ...]) str¶
Unsupported: literalize() rejects BothVariableForms upstream.
- static wrap_in_file(content: str, variable_name: str, body_preamble: tuple[str, ...]) str¶
Wrap code in a valid Dhall file.
When variable_name is empty the call is from a call context (either
wrap_calls_with_declarations()orliteralize_call()withwrap_in_file=True); both need a closingin {=}to complete thelet-chain into a valid Dhall expression. When variable_name is set the call is from a regularliteralize()path whose content already ends with thein <varname>clause produced by the variable form.
- class literalizer.languages.Elixir(*args: object, **kwargs: object)¶
Elixir language specification.
- Parameters:
date_format –
Which date format to use.
date_formats.ISO— ISO 8601 string literal, e.g."2024-01-15".date_formats.ELIXIR— Elixir~Dsigil, e.g.~D[2024-01-15].
datetime_format –
Which datetime format to use.
datetime_formats.ISO— ISO 8601 string literal, e.g."2024-01-15T12:30:00+00:00".datetime_formats.ELIXIR— Elixir~Usigil for timezone-aware datetimes (e.g.~U[2024-01-15 12:30:00+00:00]) or~Nsigil for naive datetimes (e.g.~N[2024-01-15 12:30:00]).
sequence_format –
Which Elixir sequence type to use.
sequence_formats.LIST— list literal, e.g.[1, 2, 3].sequence_formats.TUPLE— tuple literal, e.g.{1, 2, 3}.
- class BoolFormats(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
Empty: this language has no alternative boolean formats.
- class BytesFormats(*values)¶
Bytes formatting options.
- BASE64 = <function format_bytes_base64>¶
- HEX = <function format_bytes_hex>¶
- class CallStyles(*values)¶
Elixir call style options.
- POSITIONAL = PositionalCallStyle(arg_separator=', ', parenthesize_each_arg=False)¶
- class DateFormats(*values)¶
Date format options for Elixir.
- ELIXIR = DateFormatConfig(formatter=<function date_iso_formatter.<locals>._format>, preamble_lines=(), type_produced=<class 'datetime.date'>)¶
- ISO = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- class DatetimeFormats(*values)¶
Datetime format options for Elixir.
- ELIXIR = DatetimeFormatConfig(formatter=<function _format_datetime_elixir>, preamble_lines=(), type_produced=<class 'datetime.datetime'>)¶
- EPOCH = DatetimeFormatConfig(formatter=<function format_datetime_epoch>, preamble_lines=(), type_produced=<class 'int'>)¶
- ISO = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- class DeclarationStyles(*values)¶
Declaration style options.
- ASSIGN = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=False)¶
- class FloatFormats(*values)¶
Float format options.
- FIXED = <function format_float_fixed>¶
- REPR = <function format_float_repr>¶
- SCIENTIFIC = <function format_float_scientific>¶
- class HeterogeneousStrategies(*values)¶
Heterogeneous-scalar strategy options — this language only supports raising.
- ERROR = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)¶
- class IntegerFormats(*values)¶
Integer format options.
- BINARY = mappingproxy({'NONE': <function format_integer_binary>, 'UNDERSCORE': <function format_integer_binary>})¶
- DECIMAL = mappingproxy({'NONE': <class 'str'>, 'UNDERSCORE': <function format_integer_underscore>})¶
- HEX = mappingproxy({'NONE': <function format_integer_hex>, 'UNDERSCORE': <function format_integer_hex>})¶
- OCTAL = mappingproxy({'NONE': <function format_integer_octal>, 'UNDERSCORE': <function format_integer_octal>})¶
- get_formatter(numeric_separator: Enum) Callable[[int], str]¶
Return the integer formatter for the given separator.
- class JsonTypes(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
Empty: this language has no JSON value-type variants.
- class Modifiers(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
C++/Java/C#-style declaration modifiers: this language has none.
- class SequenceFormats(*values)¶
Sequence type options for Elixir.
- LIST = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=']', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)¶
- TUPLE = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close='}', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)¶
- class SetFormats(*values)¶
Set type options for Elixir.
- MAP_SET = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close='])', empty_set='MapSet.new()', preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)¶
- class TrailingCommas(*values)¶
Trailing comma options.
- NO = TrailingCommaConfig(multiline_trailing_comma=False)¶
- YES = TrailingCommaConfig(multiline_trailing_comma=True)¶
- allows_empty_call_parens = True¶
- bool_formats¶
alias of
BoolFormats
- bytes_format: BytesFormats = <function format_bytes_hex>¶
- bytes_formats¶
alias of
BytesFormats
- property call_data_dependent_preamble: Callable[[Value], tuple[str, ...]]¶
Return data-dependent preamble lines for call rendering.
- call_returns_expression = True¶
- call_style: CallStyles = PositionalCallStyle(arg_separator=', ', parenthesize_each_arg=False)¶
- property call_style_config: PositionalCallStyle | KeywordCallStyle | ObjectCallStyle | PostfixCallStyle | PrefixCallStyle | CommandCallStyle¶
Return the call style configuration.
- call_styles¶
alias of
CallStyles
- property comment_config: CommentConfig¶
Configuration for the language’s comment syntax.
- comment_format: CommentFormats = CommentConfig(prefix='#', suffix='')¶
- comment_formats¶
alias of
CommentFormats
- property compute_body_preamble: Callable[[frozenset[type], Value], tuple[str, ...]]¶
Compute body-preamble lines from the scalar map.
- property consumable_ref_value_inhibits_consuming_form: Callable[[Value], bool]¶
Predicate deciding whether a ref’s underlying value type inhibits the consume form.
Delegates to
never_inhibits_consuming_form. Languages whose consume operator rejects certain value types (notably the Mojo^on register-trivial scalars) override this.
- property data_dependent_preamble: Callable[[Value], tuple[str, ...]]¶
Return data-dependent preamble lines.
- date_format: DateFormats = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- date_formats¶
alias of
DateFormats
- datetime_format: DatetimeFormats = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- datetime_formats¶
alias of
DatetimeFormats
- declaration_style: DeclarationStyles = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=False)¶
- declaration_styles¶
alias of
DeclarationStyles
- dict_entry_style: DictEntryStyles = 1¶
- dict_entry_styles¶
alias of
DictEntryStyles
- dict_format: DictFormats = 1¶
- property dict_format_config: DictFormatConfig¶
Configuration for dict formatting.
- dict_formats¶
alias of
DictFormats
- dict_supports_heterogeneous_values = True¶
- element_separator: ClassVar[str] = ', '¶
- empty_dict_keys¶
alias of
EmptyDictKey
- extension = '.ex'¶
- false_literal: ClassVar[str] = 'false'¶
- float_format: FloatFormats = <function format_float_repr>¶
- float_formats¶
alias of
FloatFormats
- property format_bytes: Callable[[bytes], str]¶
Callable that formats a bytes value as a string literal.
- static format_call_arg(_value: Value, formatted: str, /) str¶
Callable that rewrites a formatted direct call argument.
- property format_call_arg_ref_identifier: Callable[[str, Value | None], str]¶
Rewrite a
{"$ref": "name"}identifier in a call-argument context.Delegates to
format_call_ref_identifier. Override this to allow call-argument$refvalues that would otherwise be rejected.
- property format_call_arg_ref_identifier_consumable: Callable[[str, Value | None], str]¶
Format a
$refthe caller authorized as consumable.Delegates to
format_call_arg_ref_identifier. Override this to opt into a consuming form (e.g. C++std::move).
- format_call_binding_body_preamble() tuple[str, ...]¶
Default
format_call_binding_body_preamble– no extra body preamble lines for an inference-bound call result.
- format_call_binding_file_pragmas() tuple[str, ...]¶
Default
format_call_binding_file_pragmas– no file-level compiler-pragma line for an inference-bound call result.
- property format_call_preamble_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]¶
Return file-scope stubs for a call expression.
- property format_call_ref_identifier: Callable[[str, Value | None], str]¶
Rewrite a
{"$ref": "name"}identifier into the language’s call expression syntax.
- property format_call_statement: Callable[[str], str]¶
Return call-statement formatting for this language.
- property format_call_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]¶
Return stub declarations for a call expression.
- property format_call_target: Callable[[Sequence[str]], str]¶
Rewrite a dotted call target into the language’s call syntax.
- property format_call_variable_assignment: Callable[[str, str, Value], str]¶
Default
format_call_variable_assignment– reuse the literal-binding assignment formatter unchanged.
- property format_call_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]¶
Default
format_call_variable_declaration– reuse the literal-binding declaration formatter unchanged.
- static format_constructor_target(class_name: str, /) str¶
Return class_name as a zero-argument constructor call target.
- property format_date: Callable[[date], str]¶
Callable that formats a date as a string literal.
- property format_datetime: Callable[[datetime], str]¶
Callable that formats a datetime as a string literal.
- property format_float: Callable[[float], str]¶
Callable that formats a float value as a literal.
- property format_integer: Callable[[int], str]¶
Callable that formats an int value as a literal.
- property format_integer_widened: None¶
Default
format_integer_widened– no mixed-magnitude integer widening, so the renderer keeps the normal integer formatter.
- property format_ordered_map_entry: Callable[[str, Value, str], str]¶
Callable that formats one ordered-map entry.
- property format_sequence_entry: Callable[[Value, str], str]¶
Format a sequence entry.
- property format_set_entry: Callable[[Value, str], str]¶
Format a set entry.
- property format_string: Callable[[str], str]¶
Format a string value as a quoted literal.
- property format_time: Callable[[time], str]¶
Callable that formats a time as a string literal.
- property format_variable_assignment: Callable[[str, str, Value], str]¶
Callable that formats an assignment to an existing variable.
- property format_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]¶
Callable that formats a new variable declaration.
- has_free_function_calls = True¶
- property heterogeneous_behavior: HeterogeneousBehavior¶
Return the heterogeneous-behavior config.
- heterogeneous_strategies¶
alias of
HeterogeneousStrategies
- heterogeneous_strategy: HeterogeneousStrategies = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)¶
- identifier_cases: ClassVar[tuple[IdentifierCase, ...]] = (IdentifierCase.SNAKE, IdentifierCase.UPPER_SNAKE, IdentifierCase.PASCAL)¶
- indent: str = ' '¶
- indent_closing_delimiter: ClassVar[bool] = False¶
- integer_format: IntegerFormats = mappingproxy({'NONE': <class 'str'>, 'UNDERSCORE': <function format_integer_underscore>})¶
- integer_formats¶
alias of
IntegerFormats
- integer_width_strategies¶
alias of
BareIntegerWidthStrategies
- integer_width_strategy: BareIntegerWidthStrategies = 1¶
- language_version: VersionFormats = 1¶
- property leading_preamble: LeadingPreamble¶
Default
leading_preamble– no preamble lines that must precedeLanguage.static_preamble.
- max_call_parameters = 9223372036854775807¶
- modifier_combinations: ClassVar[tuple[ModifierCombination, ...]] = ()¶
- null_literal: ClassVar[str] = 'nil'¶
- numeric_literal_suffix: NumericLiteralSuffixes = 1¶
- numeric_literal_suffixes¶
alias of
NumericLiteralSuffixes
- numeric_separator: NumericSeparators = 1¶
- numeric_separators¶
alias of
NumericSeparators
- numeric_style: NumericStyles = 1¶
- numeric_styles¶
alias of
NumericStyles
- property ordered_map_format_config: OrderedMapFormatConfig¶
Configuration for ordered-map formatting.
- pygments_name = 'elixir'¶
- reserved_identifiers: ClassVar[frozenset[str]] = frozenset({})¶
- property scalar_body_preamble: dict[type, tuple[str, ...]]¶
Per-instance scalar body preamble (Elixir needs none).
- property scalar_preamble: dict[type, tuple[str, ...]]¶
Per-instance scalar preamble (Elixir needs none).
- sequence_binding_declarations(declarations: tuple[str, ...]) str¶
Default
sequence_binding_declarations– join the per-binding snippets with newlines.
- sequence_format: SequenceFormats = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=']', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)¶
- property sequence_format_config: SequenceFormatConfig¶
Configuration for the chosen sequence format.
- sequence_formats¶
alias of
SequenceFormats
- property sequence_open: Callable[[list[Value]], str]¶
Callable that returns the opening delimiter for a sequence.
- set_format: SetFormats = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close='])', empty_set='MapSet.new()', preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)¶
- property set_format_config: SetFormatConfig¶
Configuration for the chosen set format.
- set_formats¶
alias of
SetFormats
- skip_null_dict_values: ClassVar[bool] = False¶
- special_float_preamble: ClassVar[tuple[str, ...]] = ()¶
- statement_terminator: ClassVar[str] = ''¶
- statement_terminator_style: StatementTerminatorStyles = 1¶
- statement_terminator_styles¶
alias of
StatementTerminatorStyles
- static_body_preamble: ClassVar[Sequence[str]] = ()¶
- static_preamble: ClassVar[Sequence[str]] = ()¶
- string_format: StringFormats = 1¶
- string_formats¶
alias of
StringFormats
- supported_ref_cases: ClassVar[frozenset[IdentifierCase]] = frozenset({IdentifierCase.CAMEL, IdentifierCase.PASCAL, IdentifierCase.SNAKE, IdentifierCase.UPPER_SNAKE})¶
- supports_call_style = True¶
- supports_collection_comments: ClassVar[bool] = True¶
- supports_default_dict_key_type = False¶
- supports_default_dict_value_type = False¶
- supports_default_ordered_map_value_type = False¶
- supports_default_sequence_element_type = False¶
- supports_default_set_element_type = False¶
- supports_dict_literal_as_free_expression = True¶
- supports_dotted_call_stub = True¶
- supports_dotted_calls = True¶
- supports_empty_dict_key = False¶
- supports_inline_multiline_dict_args = True¶
- supports_module_name = False¶
- supports_multi_param_call_wrapper_stub = True¶
- supports_no_variable_wrap_in_file = True¶
- supports_non_string_dict_keys = True¶
- supports_record_shape_names = False¶
- supports_record_struct_name_prefix = False¶
- supports_scalar_before_comments: ClassVar[bool] = True¶
- supports_scalar_inline_comments: ClassVar[bool] = True¶
- supports_special_floats = True¶
- supports_standalone_comments_in_wrapped_calls = True¶
- supports_variable_names = True¶
- supports_zero_parameter_calls = True¶
- trailing_comma: TrailingCommas = TrailingCommaConfig(multiline_trailing_comma=True)¶
- property trailing_comma_config: TrailingCommaConfig¶
Configuration for trailing-comma behavior.
- trailing_commas¶
alias of
TrailingCommas
- true_literal: ClassVar[str] = 'true'¶
- property type_hint_collection_preamble_lines: Callable[[frozenset[type]], tuple[str, ...]]¶
Return preamble lines for empty-collection type hints.
- property validate_call_arg: Callable[[Value], None]¶
Return call-argument validation for this language.
- validate_spec_for_data(data: Value) None¶
Default
validate_spec_for_data— no spec/data constraints.
- variable_type_hints: VariableTypeHints = 1¶
- variable_type_hints_formats¶
alias of
VariableTypeHints
- version_formats¶
alias of
VersionFormats
- wrap_call_variable_in_file(content: str, variable_name: str, body_preamble: tuple[str, ...]) str¶
Wrap a call-result variable binding in an Elixir module.
wrap_in_file()’s variable branch places body_preamble insidedef x do, but for a call binding those lines are the module-level stub function definitions emitted by_elixir_call_stub(); nesting adefinsidedef x dois a syntax error. This hook hoists thedef ``-prefixed preamble lines to module scope (matching the call-without-binding branch of :meth:`wrap_in_file`) while keeping the ``my_data = make_widget(...)binding, any non-stub preamble lines (e.g. the dotted-callroot = RootType_alias), and the trailing_ = my_datause insidedef x do.
- wrap_calls_with_declarations(declarations: tuple[str, ...], calls: str, body_preamble: tuple[str, ...]) str¶
Default
wrap_calls_with_declarations— concatenate the declarations and calls and route throughwrap_in_file()in call mode.
- static wrap_combined_in_file(declaration: str, assignment: str, variable_name: str, body_preamble: tuple[str, ...]) str¶
Unsupported: literalize() rejects BothVariableForms upstream.
- wrap_in_file(content: str, variable_name: str, body_preamble: tuple[str, ...]) str¶
Wrap an Elixir variable assignment in a module function.
For variable cases, body_preamble lines are prepended inside
def x do. For call cases (empty variable_name), lines starting withdef `` are lifted to module level inside ``defmodule Check dobut beforedef x do, while other preamble lines stay insidedef x do.
- class literalizer.languages.Elm(*args: object, **kwargs: object)¶
Elm language specification.
The generated output uses custom constructors (
ENull,EBool,EList,EDict,ESet) that are not built-in Elm types. To compile the generated code, define aValcustom type in the consuming module:type Val = ENull | EBool Bool | EInt Int | EFloat Float | EStr String | EList (List Val) | EDict (List ( String, Val )) | ESet (List Val)
The body preamble automatically emits only the constructors that are actually used by the data.
- Parameters:
date_format –
How to format
datetime.datevalues.date_formats.ISO— ISO 8601 string, e.g.EStr "2024-01-15".
datetime_format –
How to format
datetime.datetimevalues.datetime_formats.ISO— ISO 8601 string, e.g.EStr "2024-01-15T12:30:00".
type_name – Name of the generated custom type. Defaults to
"Val".constructor_prefix – Prefix for generated constructor names. Defaults to
"E", producing constructors likeENull,EBool,EInt, etc.
- class BoolFormats(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
Empty: this language has no alternative boolean formats.
- class BytesFormats(*values)¶
Bytes formatting options.
- BASE64 = <function _build_elm_bytes_base64.<locals>._format>¶
- HEX = <function _build_elm_bytes_hex.<locals>._format>¶
- class CommentFormats(*values)¶
Comment style options.
- BLOCK = CommentConfig(prefix='{-', suffix=' -}')¶
- DOUBLE_DASH = CommentConfig(prefix='--', suffix='')¶
- class DateFormats(*values)¶
Date format options for Elm.
- ISO = DateFormatConfig(formatter=<function _build_elm_date_iso.<locals>._format>, preamble_lines=(), type_produced=<class 'str'>)¶
- class DatetimeFormats(*values)¶
Datetime format options for Elm.
- EPOCH = DatetimeFormatConfig(formatter=<function datetime_epoch_formatter.<locals>._format>, preamble_lines=(), type_produced=<class 'int'>)¶
- ISO = DatetimeFormatConfig(formatter=<function _build_elm_datetime_iso.<locals>._format>, preamble_lines=(), type_produced=<class 'str'>)¶
- class DeclarationStyles(*values)¶
Declaration style options.
- ASSIGN = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=False)¶
- class FloatFormats(*values)¶
Float format options.
- FIXED = <function _build_elm_float_wrapper.<locals>._format>¶
- REPR = <function _build_elm_float_wrapper.<locals>._format>¶
- SCIENTIFIC = <function _build_elm_float_wrapper.<locals>._format>¶
- class HeterogeneousStrategies(*values)¶
Heterogeneous-scalar strategy options — this language only supports raising.
- ERROR = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)¶
- class IntegerFormats(*values)¶
Integer format options.
- DECIMAL = <function _build_elm_integer_formatter.<locals>._format>¶
- HEX = <function _build_elm_integer_formatter.<locals>._format>¶
- class JsonTypes(*values)¶
JSON value type options for Elm.
- JSON_ENCODE_VALUE = 1¶
Render values directly as
elm/jsonJson.Encode.*calls producingJson.Encode.Value.With this mode the generated module contains no
ValADT and no walker: every literal is an idiomaticJson.Encode.bool,Json.Encode.int,Json.Encode.string,Json.Encode.list identity [ ... ],Json.Encode.object [ ( "k", ... ) ]etc., and feeds straight intoJson.Encode.encode 0for serialization.
- class Modifiers(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
C++/Java/C#-style declaration modifiers: this language has none.
- class SequenceFormats(*values)¶
Sequence type options for Elm.
- LIST = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=']', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type='Val', narrowed_empty_form=None)¶
- class SetFormats(*values)¶
Set type options for Elm.
- SET = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close=']', empty_set=None, preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)¶
- class TrailingCommas(*values)¶
Trailing comma options.
- NO = TrailingCommaConfig(multiline_trailing_comma=False)¶
- allows_empty_call_parens = True¶
- bool_formats¶
alias of
BoolFormats
- bytes_format: BytesFormats = <function _build_elm_bytes_hex.<locals>._format>¶
- bytes_formats¶
alias of
BytesFormats
- property call_data_dependent_preamble: Callable[[Value], tuple[str, ...]]¶
Return data-dependent preamble lines for call rendering.
- call_returns_expression = True¶
- call_style: CallStyles = CommandCallStyle(arg_separator=' ')¶
- property call_style_config: PositionalCallStyle | KeywordCallStyle | ObjectCallStyle | PostfixCallStyle | PrefixCallStyle | CommandCallStyle¶
Configuration for Elm’s call style.
- call_styles¶
alias of
CallStyles
- property comment_config: CommentConfig¶
Configuration for the language’s comment syntax.
- comment_format: CommentFormats = CommentConfig(prefix='--', suffix='')¶
- comment_formats¶
alias of
CommentFormats
- property compute_body_preamble: Callable[[frozenset[type], Value], tuple[str, ...]]¶
Compute body-preamble lines.
Under
json_typethe preamble is a singleimport Json.Encodeline; otherwise the per-fixtureValADT declaration is emitted with only the constructors actually referenced by the data.
- constructor_prefix: str = 'E'¶
- property consumable_ref_value_inhibits_consuming_form: Callable[[Value], bool]¶
Predicate deciding whether a ref’s underlying value type inhibits the consume form.
Delegates to
never_inhibits_consuming_form. Languages whose consume operator rejects certain value types (notably the Mojo^on register-trivial scalars) override this.
- property data_dependent_preamble: Callable[[Value], tuple[str, ...]]¶
Return data-dependent preamble lines.
- date_format: DateFormats = DateFormatConfig(formatter=<function _build_elm_date_iso.<locals>._format>, preamble_lines=(), type_produced=<class 'str'>)¶
- date_formats¶
alias of
DateFormats
- datetime_format: DatetimeFormats = DatetimeFormatConfig(formatter=<function _build_elm_datetime_iso.<locals>._format>, preamble_lines=(), type_produced=<class 'str'>)¶
- datetime_formats¶
alias of
DatetimeFormats
- declaration_style: DeclarationStyles = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=False)¶
- declaration_styles¶
alias of
DeclarationStyles
- dict_entry_style: DictEntryStyles = 1¶
- dict_entry_styles¶
alias of
DictEntryStyles
- dict_format: DictFormats = 1¶
- property dict_format_config: DictFormatConfig¶
Configuration for dict formatting.
Under
json_typedicts render asJson.Encode.object [ ( "k", v ) ]rather than the ADT{prefix}Dict [ ( "k", v ) ]form.
- dict_formats¶
alias of
DictFormats
- dict_supports_heterogeneous_values = True¶
- element_separator: ClassVar[str] = ', '¶
- empty_dict_keys¶
alias of
EmptyDictKey
- extension = '.elm'¶
- property false_literal: str¶
Literal representing
False.
- float_format: FloatFormats = <function _build_elm_float_wrapper.<locals>._format>¶
- float_formats¶
alias of
FloatFormats
- property format_bytes: Callable[[bytes], str]¶
Callable that formats a bytes value as a string literal.
- property format_call_arg: Callable[[Value, str], str]¶
Wrap each formatted call argument in parentheses.
- property format_call_arg_ref_identifier: Callable[[str, Value | None], str]¶
Rewrite a
{"$ref": "name"}identifier in a call-argument context.Delegates to
format_call_ref_identifier. Override this to allow call-argument$refvalues that would otherwise be rejected.
- property format_call_arg_ref_identifier_consumable: Callable[[str, Value | None], str]¶
Format a
$refthe caller authorized as consumable.Delegates to
format_call_arg_ref_identifier. Override this to opt into a consuming form (e.g. C++std::move).
- format_call_binding_body_preamble() tuple[str, ...]¶
Default
format_call_binding_body_preamble– no extra body preamble lines for an inference-bound call result.
- format_call_binding_file_pragmas() tuple[str, ...]¶
Default
format_call_binding_file_pragmas– no file-level compiler-pragma line for an inference-bound call result.
- property format_call_preamble_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]¶
Return file-scope stubs for a call expression.
- property format_call_ref_identifier: Callable[[str, Value | None], str]¶
Rewrite a
{"$ref": "name"}identifier into the language’s call expression syntax.
- property format_call_statement: Callable[[str], str]¶
Return call-statement formatting for this language.
- property format_call_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]¶
Return stub declarations for a call expression.
Under
json_typethe stub returnsJson.Encode.Value(and defaults toJson.Encode.null) so the bound call type-checks against theJson.Encode.Valueannotation on the enclosing declaration.
- property format_call_target: Callable[[Sequence[str]], str]¶
Rewrite call target parts into an Elm identifier.
The first character of each part after the first is upper-cased and the parts are concatenated (e.g.
["app", "client", "fetch"]becomesappClientFetch).
- property format_call_variable_assignment: Callable[[str, str, Value], str]¶
Default
format_call_variable_assignment– reuse the literal-binding assignment formatter unchanged.
- property format_call_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]¶
Callable that formats a declaration binding a call expression.
The literal-binding declaration is prepended with a
name : Valannotation derived from the bound value’s runtime tagged-enum type; a call expression has no such tag, so the annotation is omitted and Elm infers the call’s return type instead.
- static format_constructor_target(class_name: str, /) str¶
Return class_name as a zero-argument constructor call target.
- property format_date: Callable[[date], str]¶
Callable that formats a date as a string literal.
- property format_datetime: Callable[[datetime], str]¶
Callable that formats a datetime as a string literal.
- property format_float: Callable[[float], str]¶
Callable that formats a float value as a literal.
- property format_integer: Callable[[int], str]¶
Callable that formats an int value as a literal.
- property format_integer_widened: None¶
Default
format_integer_widened– no mixed-magnitude integer widening, so the renderer keeps the normal integer formatter.
- property format_ordered_map_entry: Callable[[str, Value, str], str]¶
Callable that formats one ordered-map entry.
- property format_sequence_entry: Callable[[Value, str], str]¶
Format a sequence entry.
- property format_set_entry: Callable[[Value, str], str]¶
Format a set entry.
- property format_string: Callable[[str], str]¶
Callable that formats a string value as a quoted literal.
- property format_time: Callable[[time], str]¶
Callable that formats a time as a string literal.
- property format_variable_assignment: Callable[[str, str, Value], str]¶
Callable that formats an assignment to an existing variable.
- property format_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]¶
Callable that formats a new variable declaration.
Under
json_typethe annotation is the flatJson.Encode.Valueregardless of whether the top-level shape is a list, dict, set, or scalar; every literal flows through the sameJson.Encode.*constructor pipeline.
- has_free_function_calls = True¶
- property heterogeneous_behavior: HeterogeneousBehavior¶
Return the heterogeneous-behavior config.
- heterogeneous_strategies¶
alias of
HeterogeneousStrategies
- heterogeneous_strategy: HeterogeneousStrategies = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)¶
- identifier_cases: ClassVar[tuple[IdentifierCase, ...]] = (IdentifierCase.CAMEL, IdentifierCase.PASCAL)¶
- indent: str = ' '¶
- indent_closing_delimiter: ClassVar[bool] = True¶
- integer_format: IntegerFormats = <function _build_elm_integer_formatter.<locals>._format>¶
- integer_formats¶
alias of
IntegerFormats
- integer_width_strategies¶
alias of
BareIntegerWidthStrategies
- integer_width_strategy: BareIntegerWidthStrategies = 1¶
- language_version: VersionFormats = 1¶
- property leading_preamble: LeadingPreamble¶
Default
leading_preamble– no preamble lines that must precedeLanguage.static_preamble.
- max_call_parameters = 9223372036854775807¶
- modifier_combinations: ClassVar[tuple[ModifierCombination, ...]] = ()¶
- property null_literal: str¶
Literal representing
None.
- numeric_literal_suffix: NumericLiteralSuffixes = 1¶
- numeric_literal_suffixes¶
alias of
NumericLiteralSuffixes
- numeric_separator: NumericSeparators = 1¶
- numeric_separators¶
alias of
NumericSeparators
- numeric_style: NumericStyles = 1¶
- numeric_styles¶
alias of
NumericStyles
- property ordered_map_format_config: OrderedMapFormatConfig¶
Configuration for ordered-map formatting.
- pygments_name = 'elm'¶
- reserved_identifiers: ClassVar[frozenset[str]] = frozenset({})¶
- property scalar_body_preamble: dict[type, tuple[str, ...]]¶
Per-instance scalar body preamble (Elm needs none).
- property scalar_preamble: dict[type, tuple[str, ...]]¶
Per-instance scalar preamble (Elm needs none).
- sequence_binding_declarations(declarations: tuple[str, ...]) str¶
Default
sequence_binding_declarations– join the per-binding snippets with newlines.
- sequence_format: SequenceFormats = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=']', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type='Val', narrowed_empty_form=None)¶
- property sequence_format_config: SequenceFormatConfig¶
Configuration for the chosen sequence format.
- sequence_formats¶
alias of
SequenceFormats
- property sequence_open: Callable[[list[Value]], str]¶
Callable that returns the opening delimiter for a sequence.
- set_format: SetFormats = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close=']', empty_set=None, preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)¶
- property set_format_config: SetFormatConfig¶
Configuration for the chosen set format.
Under
json_typesets render as a JSON array (Json.Encode.list identity [...]) because JSON has no set type; otherwise the configured ADT{prefix}Set [...]form applies.
- set_formats¶
alias of
SetFormats
- skip_null_dict_values: ClassVar[bool] = False¶
- special_float_preamble: ClassVar[tuple[str, ...]] = ()¶
- statement_terminator: ClassVar[str] = ''¶
- statement_terminator_style: StatementTerminatorStyles = 1¶
- statement_terminator_styles¶
alias of
StatementTerminatorStyles
- static_body_preamble: ClassVar[Sequence[str]] = ()¶
- static_preamble: ClassVar[Sequence[str]] = ()¶
- string_format: StringFormats = 1¶
- string_formats¶
alias of
StringFormats
- supported_ref_cases: ClassVar[frozenset[IdentifierCase]] = frozenset({IdentifierCase.CAMEL, IdentifierCase.PASCAL, IdentifierCase.SNAKE, IdentifierCase.UPPER_SNAKE})¶
- supports_call_style = True¶
- supports_collection_comments: ClassVar[bool] = True¶
- supports_default_dict_key_type = False¶
- supports_default_dict_value_type = False¶
- supports_default_ordered_map_value_type = False¶
- supports_default_sequence_element_type = False¶
- supports_default_set_element_type = False¶
- supports_dict_literal_as_free_expression = True¶
- supports_dotted_call_stub = False¶
- supports_dotted_calls = True¶
- supports_empty_dict_key = False¶
- supports_inline_multiline_dict_args = True¶
- supports_module_name = False¶
- supports_multi_param_call_wrapper_stub = True¶
- supports_no_variable_wrap_in_file = False¶
- supports_non_string_dict_keys = False¶
- supports_record_shape_names = False¶
- supports_record_struct_name_prefix = False¶
- supports_scalar_before_comments: ClassVar[bool] = False¶
- supports_scalar_inline_comments: ClassVar[bool] = True¶
- supports_special_floats = True¶
- supports_standalone_comments_in_wrapped_calls = False¶
- supports_variable_names = True¶
- supports_zero_parameter_calls = False¶
- trailing_comma: TrailingCommas = TrailingCommaConfig(multiline_trailing_comma=False)¶
- property trailing_comma_config: TrailingCommaConfig¶
Configuration for trailing-comma behavior.
- trailing_commas¶
alias of
TrailingCommas
- property true_literal: str¶
Literal representing
True.
- property type_hint_collection_preamble_lines: Callable[[frozenset[type]], tuple[str, ...]]¶
Return preamble lines for empty-collection type hints.
- type_name: str = 'Val'¶
- property validate_call_arg: Callable[[Value], None]¶
Return call-argument validation for this language.
- validate_spec_for_data(data: Value) None¶
Validate Elm-specific data/format combinations.
Under
json_typeevery dict key must be a string becauseJson.Encode.objectonly admits string keys.
- variable_type_hints: VariableTypeHints = 1¶
- variable_type_hints_formats¶
alias of
VariableTypeHints
- version_formats¶
alias of
VersionFormats
- wrap_call_variable_in_file(content: str, variable_name: str, body_preamble: tuple[str, ...]) str¶
Wrap a call-result variable binding in an Elm module.
The literal-binding scaffold emits a top-level
name : Val/name = …pair that the test driver forces externally via aCheck.my_datareference. A call-mode fixture is instead driven throughCheck.main, so the binding is placed inside themainletblock; evaluating the block forces the call. content is the single-linename = call …binding produced byformat_call_variable_declaration.
- wrap_calls_with_declarations(declarations: tuple[str, ...], calls: str, body_preamble: tuple[str, ...]) str¶
Wrap Elm declarations and call expressions in a module.
Both variable declarations and call statements are placed inside a
letblock so the generated file is a valid Elm module. Declarations are indented without a_ =prefix; call statements are bound via_ = …to satisfy Elm’s requirement that everyletbinding produces a value. calls is one single-line call expression per line: this is the only shapeliteralize_callproduces for Elm, which usesCollectionLayout.COMPACTfor wrapped calls and rejects standalone comments in that path.
- static wrap_combined_in_file(declaration: str, assignment: str, variable_name: str, body_preamble: tuple[str, ...]) str¶
Unsupported: literalize() rejects BothVariableForms upstream.
- wrap_in_file(content: str, variable_name: str, body_preamble: tuple[str, ...]) str¶
Wrap an Elm value declaration in a module.
When variable_name is empty (call mode), each call expression in content is bound via
_ = …inside aletblock so the generated file is syntactically valid Elm. content is one single-line call expression per line: this is the only shapeliteralize_callproduces for Elm, which usesCollectionLayout.COMPACTfor wrapped calls and rejects standalone comments in that path.
- class literalizer.languages.Erlang(*args: object, **kwargs: object)¶
Erlang language specification.
- Parameters:
date_format –
Which date format to use.
date_formats.ISO— ISO 8601 string literal, e.g."2024-01-15".date_formats.ERLANG— Erlang date tuple, e.g.{2024, 1, 15}.
datetime_format –
Which datetime format to use.
datetime_formats.ISO— ISO 8601 string literal, e.g."2024-01-15T12:30:00+00:00".datetime_formats.ERLANG— Erlang datetime tuple, e.g.{{2024, 1, 15}, {12, 30, 0}}.
sequence_format –
Which Erlang sequence type to use.
sequence_formats.LIST— list literal, e.g.[1, 2, 3].sequence_formats.TUPLE— tuple literal, e.g.{1, 2, 3}.
- class BoolFormats(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
Empty: this language has no alternative boolean formats.
- class BytesFormats(*values)¶
Bytes formatting options.
- BASE64 = <function format_bytes_base64>¶
- BINARY = <function _format_bytes>¶
- class CallStyles(*values)¶
Erlang call style options.
- POSITIONAL = PositionalCallStyle(arg_separator=', ', parenthesize_each_arg=False)¶
- class CommentFormats(*values)¶
Comment style options.
- PERCENT = CommentConfig(prefix='%', suffix='')¶
- class DateFormats(*values)¶
Date format options for Erlang.
- ERLANG = DateFormatConfig(formatter=<function _format_date_erlang>, preamble_lines=(), type_produced=<class 'datetime.date'>)¶
- ISO = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- class DatetimeFormats(*values)¶
Datetime format options for Erlang.
- EPOCH = DatetimeFormatConfig(formatter=<function format_datetime_epoch>, preamble_lines=(), type_produced=<class 'int'>)¶
- ERLANG = DatetimeFormatConfig(formatter=<function _format_datetime_erlang>, preamble_lines=(), type_produced=<class 'datetime.datetime'>)¶
- ISO = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- class DeclarationStyles(*values)¶
Declaration style options.
- ASSIGN = DeclarationStyleConfig(formatter=<function _format_variable_declaration>, supports_redefinition=False)¶
- class FloatFormats(*values)¶
Float format options.
- FIXED = <function format_float_fixed>¶
- REPR = <function format_float_repr>¶
- SCIENTIFIC = <function format_float_scientific>¶
- class HeterogeneousStrategies(*values)¶
Heterogeneous-scalar strategy options — this language only supports raising.
- ERROR = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)¶
- class IntegerFormats(*values)¶
Integer format options.
- BINARY = <function format_integer_binary_erlang>¶
- DECIMAL = <class 'str'>¶
- HEX = <function format_integer_hex_erlang>¶
- class JsonTypes(*values)¶
JSON value type options for Erlang.
- OTP_JSON = 1¶
Erlang’s built-in
jsonmodule (OTP_27and later).Renders strings, ISO dates / datetimes / times, and bytes (base64-encoded) as UTF-8 binary literals so
json:encode/1accepts the value directly. Null is emitted as the bare atomnull; sets render as JSON arrays. Dict keys must be strings (validated upfront).
- class Modifiers(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
C++/Java/C#-style declaration modifiers: this language has none.
- class SequenceFormats(*values)¶
Sequence type options for Erlang.
- LIST = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=']', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=False, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)¶
- TUPLE = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close='}', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=False, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)¶
- class SetFormats(*values)¶
Set type options for Erlang.
- SET = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close='])', empty_set='sets:from_list([])', preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)¶
- class TrailingCommas(*values)¶
Trailing comma options.
- NO = TrailingCommaConfig(multiline_trailing_comma=False)¶
- allows_empty_call_parens = True¶
- bool_formats¶
alias of
BoolFormats
- bytes_format: BytesFormats = <function _format_bytes>¶
- bytes_formats¶
alias of
BytesFormats
- property call_data_dependent_preamble: Callable[[Value], tuple[str, ...]]¶
Return data-dependent preamble lines for call rendering.
- call_returns_expression = True¶
- call_style: CallStyles = PositionalCallStyle(arg_separator=', ', parenthesize_each_arg=False)¶
- property call_style_config: PositionalCallStyle | KeywordCallStyle | ObjectCallStyle | PostfixCallStyle | PrefixCallStyle | CommandCallStyle¶
Configuration for Erlang’s call style.
- call_styles¶
alias of
CallStyles
- property comment_config: CommentConfig¶
Configuration for the language’s comment syntax.
- comment_format: CommentFormats = CommentConfig(prefix='%', suffix='')¶
- comment_formats¶
alias of
CommentFormats
- property compute_body_preamble: Callable[[frozenset[type], Value], tuple[str, ...]]¶
Compute body-preamble lines from the scalar map.
- property consumable_ref_value_inhibits_consuming_form: Callable[[Value], bool]¶
Predicate deciding whether a ref’s underlying value type inhibits the consume form.
Delegates to
never_inhibits_consuming_form. Languages whose consume operator rejects certain value types (notably the Mojo^on register-trivial scalars) override this.
- property data_dependent_preamble: Callable[[Value], tuple[str, ...]]¶
Return data-dependent preamble lines.
- date_format: DateFormats = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- date_formats¶
alias of
DateFormats
- datetime_format: DatetimeFormats = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- datetime_formats¶
alias of
DatetimeFormats
- declaration_style: DeclarationStyles = DeclarationStyleConfig(formatter=<function _format_variable_declaration>, supports_redefinition=False)¶
- declaration_styles¶
alias of
DeclarationStyles
- dict_entry_style: DictEntryStyles = 1¶
- dict_entry_styles¶
alias of
DictEntryStyles
- dict_format: DictFormats = 1¶
- property dict_format_config: DictFormatConfig¶
Configuration for dict formatting.
- dict_formats¶
alias of
DictFormats
- dict_supports_heterogeneous_values = True¶
- element_separator: ClassVar[str] = ', '¶
- empty_dict_keys¶
alias of
EmptyDictKey
- extension = '.erl'¶
- false_literal: ClassVar[str] = 'false'¶
- float_format: FloatFormats = <function format_float_repr>¶
- float_formats¶
alias of
FloatFormats
- property format_bytes: Callable[[bytes], str]¶
Callable that formats a bytes value as a string literal.
- static format_call_arg(_value: Value, formatted: str, /) str¶
Callable that rewrites a formatted direct call argument.
- property format_call_arg_ref_identifier: Callable[[str, Value | None], str]¶
Rewrite a
{"$ref": "name"}identifier in a call-argument context.Delegates to
format_call_ref_identifier. Override this to allow call-argument$refvalues that would otherwise be rejected.
- property format_call_arg_ref_identifier_consumable: Callable[[str, Value | None], str]¶
Format a
$refthe caller authorized as consumable.Delegates to
format_call_arg_ref_identifier. Override this to opt into a consuming form (e.g. C++std::move).
- format_call_binding_body_preamble() tuple[str, ...]¶
Default
format_call_binding_body_preamble– no extra body preamble lines for an inference-bound call result.
- format_call_binding_file_pragmas() tuple[str, ...]¶
Default
format_call_binding_file_pragmas– no file-level compiler-pragma line for an inference-bound call result.
- property format_call_preamble_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]¶
Return file-scope stubs for a call expression.
- property format_call_ref_identifier: Callable[[str, Value | None], str]¶
Capitalize a
{"$ref": "name"}identifier so the call site references the declared Erlang variable.
- property format_call_statement: Callable[[str], str]¶
Return call-statement formatting for this language.
- property format_call_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]¶
Return stub declarations for a call expression.
- property format_call_target: Callable[[Sequence[str]], str]¶
Rewrite a dotted call target into the language’s call syntax.
- property format_call_variable_assignment: Callable[[str, str, Value], str]¶
Default
format_call_variable_assignment– reuse the literal-binding assignment formatter unchanged.
- property format_call_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]¶
Default
format_call_variable_declaration– reuse the literal-binding declaration formatter unchanged.
- static format_constructor_target(class_name: str, /) str¶
Return class_name as a zero-argument constructor call target.
- property format_date: Callable[[date], str]¶
Callable that formats a date as a string literal.
- property format_datetime: Callable[[datetime], str]¶
Callable that formats a datetime as a string literal.
- property format_float: Callable[[float], str]¶
Callable that formats a float value as a literal.
- property format_integer: Callable[[int], str]¶
Callable that formats an int value as a literal.
- property format_integer_widened: None¶
Default
format_integer_widened– no mixed-magnitude integer widening, so the renderer keeps the normal integer formatter.
- property format_ordered_map_entry: Callable[[str, Value, str], str]¶
Callable that formats one ordered-map entry.
- property format_sequence_entry: Callable[[Value, str], str]¶
Format a sequence entry.
- property format_set_entry: Callable[[Value, str], str]¶
Format a set entry.
- property format_string: Callable[[str], str]¶
Format a string value as a quoted literal.
- property format_time: Callable[[time], str]¶
Callable that formats a time as a string literal.
- property format_variable_assignment: Callable[[str, str, Value], str]¶
Format an assignment to an existing variable.
- property format_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]¶
Callable that formats a new variable declaration.
- has_free_function_calls = True¶
- property heterogeneous_behavior: HeterogeneousBehavior¶
Return the heterogeneous-behavior config.
- heterogeneous_strategies¶
alias of
HeterogeneousStrategies
- heterogeneous_strategy: HeterogeneousStrategies = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)¶
- identifier_cases: ClassVar[tuple[IdentifierCase, ...]] = (IdentifierCase.SNAKE,)¶
- indent: str = ' '¶
- indent_closing_delimiter: ClassVar[bool] = False¶
- integer_format: IntegerFormats = <class 'str'>¶
- integer_formats¶
alias of
IntegerFormats
- integer_width_strategies¶
alias of
BareIntegerWidthStrategies
- integer_width_strategy: BareIntegerWidthStrategies = 1¶
- language_version: VersionFormats = 1¶
- property leading_preamble: LeadingPreamble¶
Default
leading_preamble– no preamble lines that must precedeLanguage.static_preamble.
- max_call_parameters = 9223372036854775807¶
- modifier_combinations: ClassVar[tuple[ModifierCombination, ...]] = ()¶
- module_name: str = 'Module'¶
- module_name_case: ClassVar[IdentifierCase] = 'snake'¶
- property null_literal: str¶
nullunderOTP_JSON,undefinedotherwise.Erlang’s
json:encode/1rejects the bare atomundefined(it is not in the documented set of accepted scalars) but encodesnullas JSONnull.- Type:
Null literal
- numeric_literal_suffix: NumericLiteralSuffixes = 1¶
- numeric_literal_suffixes¶
alias of
NumericLiteralSuffixes
- numeric_separator: NumericSeparators = 1¶
- numeric_separators¶
alias of
NumericSeparators
- numeric_style: NumericStyles = 1¶
- numeric_styles¶
alias of
NumericStyles
- property ordered_map_format_config: OrderedMapFormatConfig¶
Configuration for ordered-map formatting.
- pygments_name = 'erlang'¶
- reserved_identifiers: ClassVar[frozenset[str]] = frozenset({})¶
- property scalar_body_preamble: dict[type, tuple[str, ...]]¶
Per-instance scalar body preamble (Erlang needs none).
- property scalar_preamble: dict[type, tuple[str, ...]]¶
Per-instance scalar preamble (Erlang needs none).
- sequence_binding_declarations(declarations: tuple[str, ...]) str¶
Default
sequence_binding_declarations– join the per-binding snippets with newlines.
- sequence_format: SequenceFormats = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=']', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=False, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)¶
- property sequence_format_config: SequenceFormatConfig¶
Configuration for the chosen sequence format.
- sequence_formats¶
alias of
SequenceFormats
- property sequence_open: Callable[[list[Value]], str]¶
Callable that returns the opening delimiter for a sequence.
- set_format: SetFormats = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close='])', empty_set='sets:from_list([])', preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)¶
- property set_format_config: SetFormatConfig¶
Configuration for the chosen set format.
- set_formats¶
alias of
SetFormats
- skip_null_dict_values: ClassVar[bool] = False¶
- special_float_preamble: ClassVar[tuple[str, ...]] = ()¶
- statement_terminator: ClassVar[str] = ','¶
- statement_terminator_style: StatementTerminatorStyles = 1¶
- statement_terminator_styles¶
alias of
StatementTerminatorStyles
- static_body_preamble: ClassVar[Sequence[str]] = ()¶
- static_preamble: ClassVar[Sequence[str]] = ()¶
- string_format: StringFormats = 1¶
- string_formats¶
alias of
StringFormats
- supported_ref_cases: ClassVar[frozenset[IdentifierCase]] = frozenset({IdentifierCase.CAMEL, IdentifierCase.PASCAL, IdentifierCase.SNAKE, IdentifierCase.UPPER_SNAKE})¶
- supports_call_style = True¶
- supports_collection_comments: ClassVar[bool] = True¶
- supports_default_dict_key_type = False¶
- supports_default_dict_value_type = False¶
- supports_default_ordered_map_value_type = False¶
- supports_default_sequence_element_type = False¶
- supports_default_set_element_type = False¶
- supports_dict_literal_as_free_expression = True¶
- supports_dotted_call_stub = False¶
- supports_dotted_calls = True¶
- supports_empty_dict_key = False¶
- supports_inline_multiline_dict_args = True¶
- supports_module_name = True¶
- supports_multi_param_call_wrapper_stub = True¶
- supports_no_variable_wrap_in_file = False¶
- supports_non_string_dict_keys = True¶
- supports_record_shape_names = False¶
- supports_record_struct_name_prefix = False¶
- supports_scalar_before_comments: ClassVar[bool] = False¶
- supports_scalar_inline_comments: ClassVar[bool] = False¶
- supports_special_floats = True¶
- supports_standalone_comments_in_wrapped_calls = False¶
- supports_variable_names = True¶
- supports_zero_parameter_calls = True¶
- trailing_comma: TrailingCommas = TrailingCommaConfig(multiline_trailing_comma=False)¶
- property trailing_comma_config: TrailingCommaConfig¶
Configuration for trailing-comma behavior.
- trailing_commas¶
alias of
TrailingCommas
- true_literal: ClassVar[str] = 'true'¶
- property type_hint_collection_preamble_lines: Callable[[frozenset[type]], tuple[str, ...]]¶
Return preamble lines for empty-collection type hints.
- property validate_call_arg: Callable[[Value], None]¶
Return call-argument validation for this language.
- validate_spec_for_data(data: Value) None¶
Validate Erlang-specific data/format combinations.
Under
json_typeevery dict key must be a string so the rendered map keys (UTF-8 binaries) match what Erlang’sjson:encode/1expects.
- variable_type_hints: VariableTypeHints = 1¶
- variable_type_hints_formats¶
alias of
VariableTypeHints
- version_formats¶
alias of
VersionFormats
- wrap_call_variable_in_file(content: str, variable_name: str, body_preamble: tuple[str, ...]) str¶
Wrap a call-result variable binding in an Erlang module.
wrap_in_file()’s variable branch places body_preamble insidex(), but for a call binding those lines are the module-level stub function definitions emitted by_erlang_call_stub(); nesting a function definition inside thex/0clause is a syntax error. This hook hoists body_preamble to module scope between-exportandx()(matching the call-without-binding branch ofwrap_in_file()) while keeping theMy_data = make_widget(...)binding and the trailingMy_data.return insidex().
- wrap_calls_with_declarations(declarations: tuple[str, ...], calls: str, body_preamble: tuple[str, ...]) str¶
Default
wrap_calls_with_declarations— concatenate the declarations and calls and route throughwrap_in_file()in call mode.
- static wrap_combined_in_file(declaration: str, assignment: str, variable_name: str, body_preamble: tuple[str, ...]) str¶
Unsupported: literalize() rejects BothVariableForms upstream.
- wrap_in_file(content: str, variable_name: str, body_preamble: tuple[str, ...]) str¶
Wrap an Erlang snippet in a module function.
For the variable form, body_preamble lines are prepended inside
x()and the function returns the bound variable. For the call form (empty variable_name), body_preamble lines are treated as module-level function definitions placed between-exportandx(); the call statements in content are terminated with,viastatement_terminatorand the trailing,is rewritten to.sox()ends on a valid clause.
- class literalizer.languages.FSharp(*args: object, **kwargs: object)¶
F# language specification.
- Parameters:
date_format –
How to format
datetime.datevalues.date_formats.FSHARP—System.DateOnly(...)call, e.g.System.DateOnly(2024, 1, 15).
datetime_format –
How to format
datetime.datetimevalues.datetime_formats.FSHARP—System.DateTime(...)call, e.g.System.DateTime(2024, 1, 15, 12, 30, 0).
type_name – Name of the generated custom type. Defaults to
"Val".constructor_prefix – Prefix for generated constructor names. Defaults to
"F", producing constructors likeFNull,FBool,FInt, etc.json_type – When set to
json_types.SYSTEM_TEXT_JSON_NODE, render values throughSystem.Text.Json.Nodes.JsonNode(JsonObject/JsonArray/JsonValue.Create) instead of the generated taggedValdiscriminated union. Dates / datetimes / times switch to ISO 8601 strings (unlessdatetime_formatisEPOCH), heterogeneous collections are accepted, and non-string dict keys are rejected because JSON object keys must be strings.
Notes
The default tagged
Valdiscriminated union does not round-trip throughSystem.Text.Json.JsonSerializer.Serialize(with or withoutFSharp.SystemTextJson) without a customJsonConverter<Val>. Two pitfalls:The map case is emitted as
FMap of (string * Val) list, a tuple list rather than aMap<,>, so that insertion order survives (F#’s built-inMap<,>is sorted by key). A generic JSON encoder emits it as[[k, v], ...]instead of{"k": v}.FSharp.SystemTextJson’sUntaggedencoding ignoresUnwrapSingleFieldCases, soFInt 42Lround-trips as{"Item": 42}rather than42(upstream behavior reproduced on 1.3.13 and 1.4.36).
Users serializing
Valto JSON must walk the constructors explicitly; selectingjson_type=SYSTEM_TEXT_JSON_NODEavoids theValunion entirely so a single.ToJsonString()call round-trips the rendered value.- class BoolFormats(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
Empty: this language has no alternative boolean formats.
- class BytesFormats(*values)¶
Bytes formatting options.
- BASE64 = <function format_bytes_base64>¶
- HEX = <function format_bytes_hex>¶
- class CallStyles(*values)¶
FSharp call style options.
- CURRIED = CommandCallStyle(arg_separator=' ')¶
- POSITIONAL = PositionalCallStyle(arg_separator=', ', parenthesize_each_arg=False)¶
- class CommentFormats(*values)¶
Comment style options.
- BLOCK = CommentConfig(prefix='(*', suffix=' *)')¶
- DOUBLE_SLASH = CommentConfig(prefix='//', suffix='')¶
- class DateFormats(*values)¶
Date format options for FSharp.
- FSHARP = DateFormatConfig(formatter=<function date_ymd_formatter.<locals>._format>, preamble_lines=(), type_produced=<class 'datetime.date'>)¶
- ISO = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- class DatetimeFormats(*values)¶
Datetime format options for FSharp.
- EPOCH = DatetimeFormatConfig(formatter=<function _build_fsharp_datetime_epoch.<locals>._format>, preamble_lines=(), type_produced=<class 'int'>)¶
- FSHARP = DatetimeFormatConfig(formatter=<function datetime_ymdhms_formatter.<locals>._format>, preamble_lines=(), type_produced=<class 'datetime.datetime'>)¶
- ISO = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- class DeclarationStyles(*values)¶
Declaration style options.
- LET = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=False)¶
- LET_MUTABLE = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=True)¶
- class FloatFormats(*values)¶
Float format options.
- FIXED = <function format_float_fixed>¶
- REPR = <function format_float_repr>¶
- SCIENTIFIC = <function format_float_scientific>¶
- class HeterogeneousStrategies(*values)¶
Heterogeneous-scalar strategy options — this language only supports raising.
- ERROR = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)¶
- class IntegerFormats(*values)¶
Integer format options.
- BINARY = <function format_integer_binary>¶
- DECIMAL = <class 'str'>¶
- HEX = <function format_integer_hex>¶
- OCTAL = <function format_integer_octal>¶
- class JsonTypes(*values)¶
JSON value type options for F#.
- SYSTEM_TEXT_JSON_NODE = 'JsonNode'¶
System.Text.Json.Nodes.JsonNode, the built-in .NET JSON document object model.
- class Modifiers(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
C++/Java/C#-style declaration modifiers: this language has none.
- class SequenceFormats(*values)¶
Sequence type options for F#.
- ARRAY = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close='|]', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=False, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type='Val array', narrowed_empty_form=None)¶
- LIST = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=']', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=False, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type='Val', narrowed_empty_form=None)¶
- class SetFormats(*values)¶
Set type options for F#.
- SET = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close=']', empty_set=None, preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)¶
- class TrailingCommas(*values)¶
Trailing comma options.
- NO = TrailingCommaConfig(multiline_trailing_comma=False)¶
- allows_empty_call_parens = True¶
- bool_formats¶
alias of
BoolFormats
- bytes_format: BytesFormats = <function format_bytes_hex>¶
- bytes_formats¶
alias of
BytesFormats
- property call_data_dependent_preamble: Callable[[Value], tuple[str, ...]]¶
Return data-dependent preamble lines for call rendering.
- call_returns_expression = True¶
- call_style: CallStyles = PositionalCallStyle(arg_separator=', ', parenthesize_each_arg=False)¶
- property call_style_config: PositionalCallStyle | KeywordCallStyle | ObjectCallStyle | PostfixCallStyle | PrefixCallStyle | CommandCallStyle¶
Configuration for the chosen call style.
- call_styles¶
alias of
CallStyles
- property comment_config: CommentConfig¶
Configuration for the language’s comment syntax.
- comment_format: CommentFormats = CommentConfig(prefix='//', suffix='')¶
- comment_formats¶
alias of
CommentFormats
- property compute_body_preamble: Callable[[frozenset[type], Value], tuple[str, ...]]¶
Compute body-preamble lines from the scalar map.
Under
json_typethe file alwaysopen``s the ``System.Text.Json.Nodestypes inside the module body so theJsonObject/JsonArray/JsonValueconstructors resolve; the F#moduledeclaration must be the first non-blank line, which rules out the file-level preamble that other languages use for an equivalent import.Swaps
int64tobigintin theFIntvariant when the data contains an integer outside signed 64-bit range.
- constructor_prefix: str = 'F'¶
- property consumable_ref_value_inhibits_consuming_form: Callable[[Value], bool]¶
Predicate deciding whether a ref’s underlying value type inhibits the consume form.
Delegates to
never_inhibits_consuming_form. Languages whose consume operator rejects certain value types (notably the Mojo^on register-trivial scalars) override this.
- property data_dependent_preamble: Callable[[Value], tuple[str, ...]]¶
Return data-dependent preamble lines.
- date_format: DateFormats = DateFormatConfig(formatter=<function date_ymd_formatter.<locals>._format>, preamble_lines=(), type_produced=<class 'datetime.date'>)¶
- date_formats¶
alias of
DateFormats
- datetime_format: DatetimeFormats = DatetimeFormatConfig(formatter=<function datetime_ymdhms_formatter.<locals>._format>, preamble_lines=(), type_produced=<class 'datetime.datetime'>)¶
- datetime_formats¶
alias of
DatetimeFormats
- declaration_style: DeclarationStyles = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=False)¶
- declaration_styles¶
alias of
DeclarationStyles
- dict_entry_style: DictEntryStyles = 1¶
- dict_entry_styles¶
alias of
DictEntryStyles
- dict_format: DictFormats = 1¶
- property dict_format_config: DictFormatConfig¶
Configuration for dict formatting.
- dict_formats¶
alias of
DictFormats
- dict_supports_heterogeneous_values = True¶
- element_separator: ClassVar[str] = '; '¶
- empty_dict_keys¶
alias of
EmptyDictKey
- extension = '.fs'¶
- property false_literal: str¶
Literal representing
False.
- float_format: FloatFormats = <function format_float_repr>¶
- float_formats¶
alias of
FloatFormats
- property format_bytes: Callable[[bytes], str]¶
Callable that formats a bytes value as a string literal.
- property format_call_arg: Callable[[Value, str], str]¶
Callable that rewrites a formatted direct call argument.
Curried calls parenthesize each argument so that constructor applications are not parsed as additional arguments to the outer call. Under
json_typeevery argument is wrapped as aJsonNode(viaJsonValue.Createand an explicit:> JsonNodewidening cast) so the underlying stub receives a JSON value.
- property format_call_arg_ref_identifier: Callable[[str, Value | None], str]¶
Rewrite a
{"$ref": "name"}identifier in a call-argument context.Delegates to
format_call_ref_identifier. Override this to allow call-argument$refvalues that would otherwise be rejected.
- property format_call_arg_ref_identifier_consumable: Callable[[str, Value | None], str]¶
Format a
$refthe caller authorized as consumable.Delegates to
format_call_arg_ref_identifier. Override this to opt into a consuming form (e.g. C++std::move).
- format_call_binding_body_preamble() tuple[str, ...]¶
Default
format_call_binding_body_preamble– no extra body preamble lines for an inference-bound call result.
- format_call_binding_file_pragmas() tuple[str, ...]¶
Default
format_call_binding_file_pragmas– no file-level compiler-pragma line for an inference-bound call result.
- property format_call_preamble_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]¶
Return file-scope stubs for a call expression.
- property format_call_ref_identifier: Callable[[str, Value | None], str]¶
Rewrite a
{"$ref": "name"}identifier into the language’s call expression syntax.
- property format_call_statement: Callable[[str], str]¶
Return call-statement formatting for this language.
- property format_call_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]¶
Return stub declarations for a call expression.
- property format_call_target: Callable[[Sequence[str]], str]¶
Rewrite a dotted call target into the language’s call syntax.
- property format_call_variable_assignment: Callable[[str, str, Value], str]¶
Callable that formats an assignment binding a call expression.
The literal-binding assignment injects a
: Valannotation and a tagged-enum constructor derived from the bound value’s runtime type; a call expression has no such tag, so both are omitted and F# infers the return type. Mirrorsformat_variable_assignment, which always emits a plainlet(neverlet mutable) regardless ofdeclaration_style: an F# rebinding shadows withlet, so themutablekeyword would be spurious here.
- property format_call_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]¶
Callable that formats a declaration binding a call expression.
The literal-binding declaration adds a leading
name: Valtype annotation and wraps the value in a tagged-enum constructor (FInt,FStr, …) derived from the bound value’s runtime type; a call expression has no such tag, so both the annotation and the constructor wrapper are omitted and F# infers the call’s return type instead.
- static format_constructor_target(class_name: str, /) str¶
Return class_name as a zero-argument constructor call target.
- property format_date: Callable[[date], str]¶
Callable that formats a date as a string literal.
- property format_datetime: Callable[[datetime], str]¶
Callable that formats a datetime as a string literal.
Under
json_typethe EPOCH branch emits a bareint64literal (e.g.1705320600L) rather than the taggedFInt ...constructor used outside json mode: theValdiscriminated union does not exist underjson_type, and the entry / top-level formatter is responsible for wrapping the literal withJsonValue.Createso it becomes aJsonNode.
- property format_float: Callable[[float], str]¶
Callable that formats a float value as a literal.
- property format_integer: Callable[[int], str]¶
Callable that formats an int value as a literal.
Under
json_typeintegers carry an explicit F# suffix (Lfor signed-64-bit,ULfor values one beyondInt64.MaxValueup throughUInt64.MaxValue) so theJsonValue.Createoverload set can resolve unambiguously tolong/ulong. Negative values belowInt64.MinValueand positive values aboveUInt64.MaxValuehave noJsonValue.Createoverload and are rejected up-front rather than emitted as a literal F# would refuse to compile.
- property format_integer_widened: None¶
Default
format_integer_widened– no mixed-magnitude integer widening, so the renderer keeps the normal integer formatter.
- property format_ordered_map_entry: Callable[[str, Value, str], str]¶
Callable that formats one ordered-map entry.
- property format_sequence_entry: Callable[[Value, str], str]¶
Callable that formats one sequence entry.
- property format_set_entry: Callable[[Value, str], str]¶
Callable that formats one set entry.
- property format_string: Callable[[str], str]¶
Format a string value as a quoted literal.
- property format_time: Callable[[time], str]¶
Callable that formats a time as a string literal.
- property format_variable_assignment: Callable[[str, str, Value], str]¶
Callable that formats an assignment to an existing variable.
- property format_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]¶
Callable that formats a new variable declaration.
- has_free_function_calls = True¶
- property heterogeneous_behavior: HeterogeneousBehavior¶
Return the heterogeneous-behavior config.
json_typerelaxes scalar-type checks unconditionally becauseJsonObject/JsonArrayaccept heterogeneousJsonNodechildren by construction.
- heterogeneous_strategies¶
alias of
HeterogeneousStrategies
- heterogeneous_strategy: HeterogeneousStrategies = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)¶
- identifier_cases: ClassVar[tuple[IdentifierCase, ...]] = (IdentifierCase.CAMEL, IdentifierCase.PASCAL)¶
- indent: str = ' '¶
- indent_closing_delimiter: ClassVar[bool] = False¶
- integer_format: IntegerFormats = <class 'str'>¶
- integer_formats¶
alias of
IntegerFormats
- integer_width_strategies¶
alias of
BareIntegerWidthStrategies
- integer_width_strategy: BareIntegerWidthStrategies = 1¶
- language_version: VersionFormats = 1¶
- property leading_preamble: LeadingPreamble¶
Default
leading_preamble– no preamble lines that must precedeLanguage.static_preamble.
- max_call_parameters = 9223372036854775807¶
- modifier_combinations: ClassVar[tuple[ModifierCombination, ...]] = ()¶
- module_name: str = 'Module'¶
- module_name_case: ClassVar[IdentifierCase] = 'pascal'¶
- property null_literal: str¶
Literal representing
None.
- numeric_literal_suffix: NumericLiteralSuffixes = 1¶
- numeric_literal_suffixes¶
alias of
NumericLiteralSuffixes
- numeric_separator: NumericSeparators = 1¶
- numeric_separators¶
alias of
NumericSeparators
- numeric_style: NumericStyles = 1¶
- numeric_styles¶
alias of
NumericStyles
- property ordered_map_format_config: OrderedMapFormatConfig¶
Configuration for ordered-map formatting.
- pygments_name = 'fsharp'¶
- reserved_identifiers: ClassVar[frozenset[str]] = frozenset({})¶
- property scalar_body_preamble: dict[type, tuple[str, ...]]¶
Per-instance scalar body preamble with type declarations.
- property scalar_preamble: dict[type, tuple[str, ...]]¶
Per-instance scalar preamble.
- sequence_binding_declarations(declarations: tuple[str, ...]) str¶
Default
sequence_binding_declarations– join the per-binding snippets with newlines.
- sequence_format: SequenceFormats = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=']', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=False, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type='Val', narrowed_empty_form=None)¶
- property sequence_format_config: SequenceFormatConfig¶
Configuration for the chosen sequence format.
- sequence_formats¶
alias of
SequenceFormats
- property sequence_open: Callable[[list[Value]], str]¶
Callable that returns the opening delimiter for a sequence.
- set_format: SetFormats = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close=']', empty_set=None, preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)¶
- property set_format_config: SetFormatConfig¶
Configuration for the chosen set format.
- set_formats¶
alias of
SetFormats
- skip_null_dict_values: ClassVar[bool] = False¶
- special_float_preamble: ClassVar[tuple[str, ...]] = ()¶
- statement_terminator: ClassVar[str] = ''¶
- statement_terminator_style: StatementTerminatorStyles = 1¶
- statement_terminator_styles¶
alias of
StatementTerminatorStyles
- static_body_preamble: ClassVar[Sequence[str]] = ()¶
- static_preamble: ClassVar[Sequence[str]] = ()¶
- string_format: StringFormats = 1¶
- string_formats¶
alias of
StringFormats
- supported_ref_cases: ClassVar[frozenset[IdentifierCase]] = frozenset({IdentifierCase.CAMEL, IdentifierCase.PASCAL, IdentifierCase.SNAKE, IdentifierCase.UPPER_SNAKE})¶
- supports_call_style = True¶
- supports_collection_comments: ClassVar[bool] = True¶
- supports_default_dict_key_type = False¶
- supports_default_dict_value_type = False¶
- supports_default_ordered_map_value_type = False¶
- supports_default_sequence_element_type = False¶
- supports_default_set_element_type = False¶
- supports_dict_literal_as_free_expression = True¶
- supports_dotted_call_stub = True¶
- supports_dotted_calls = True¶
- supports_empty_dict_key = False¶
- supports_inline_multiline_dict_args = True¶
- supports_module_name = True¶
- supports_multi_param_call_wrapper_stub = True¶
- supports_no_variable_wrap_in_file = False¶
- supports_non_string_dict_keys = False¶
- supports_record_shape_names = False¶
- supports_record_struct_name_prefix = False¶
- supports_scalar_before_comments: ClassVar[bool] = False¶
- supports_scalar_inline_comments: ClassVar[bool] = False¶
- supports_special_floats = True¶
- supports_standalone_comments_in_wrapped_calls = True¶
- supports_variable_names = True¶
- supports_zero_parameter_calls = True¶
- trailing_comma: TrailingCommas = TrailingCommaConfig(multiline_trailing_comma=False)¶
- property trailing_comma_config: TrailingCommaConfig¶
Configuration for trailing-comma behavior.
- trailing_commas¶
alias of
TrailingCommas
- property true_literal: str¶
Literal representing
True.
- property type_hint_collection_preamble_lines: Callable[[frozenset[type]], tuple[str, ...]]¶
Return preamble lines for empty-collection type hints.
- type_name: str = 'Val'¶
- property validate_call_arg: Callable[[Value], None]¶
Return call-argument validation for this language.
- validate_spec_for_data(data: Value) None¶
Validate F#-specific data / format combinations.
Under
json_typeonly dict keys that are strings can be represented as JSON object keys, so a non-string dict key is rejected up-front.
- variable_type_hints: VariableTypeHints = 1¶
- variable_type_hints_formats¶
alias of
VariableTypeHints
- version_formats¶
alias of
VersionFormats
- wrap_calls_with_declarations(declarations: tuple[str, ...], calls: str, body_preamble: tuple[str, ...]) str¶
Default
wrap_calls_with_declarations— concatenate the declarations and calls and route throughwrap_in_file()in call mode.
- wrap_combined_in_file(declaration: str, assignment: str, variable_name: str, body_preamble: tuple[str, ...]) str¶
Wrap F# declaration + assignment in separate private functions.
- wrap_in_file(content: str, variable_name: str, body_preamble: tuple[str, ...]) str¶
Wrap an F# let declaration in a module.
- class literalizer.languages.Forth(*args: object, **kwargs: object)¶
Forth language specification.
- class BoolFormats(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
Empty: this language has no alternative boolean formats.
- class BytesFormats(*values)¶
Bytes formatting options.
- BASE64 = <function _format_bytes_base64_forth>¶
- HEX = <function _format_bytes_hex_forth>¶
- class CommentFormats(*values)¶
Comment style options.
- BACKSLASH = CommentConfig(prefix='\\', suffix='')¶
- PAREN = CommentConfig(prefix='(', suffix=' )')¶
- class DateFormats(*values)¶
Date format options.
- ISO = DateFormatConfig(formatter=<function _format_date_forth>, preamble_lines=(), type_produced=<class 'str'>)¶
- class DatetimeFormats(*values)¶
Datetime format options.
- EPOCH = DatetimeFormatConfig(formatter=<function format_datetime_epoch>, preamble_lines=(), type_produced=<class 'int'>)¶
- ISO = DatetimeFormatConfig(formatter=<function _format_datetime_forth>, preamble_lines=(), type_produced=<class 'str'>)¶
- class DeclarationStyles(*values)¶
Declaration style options.
- COLON = DeclarationStyleConfig(formatter=<function _format_forth_declaration>, supports_redefinition=True)¶
- class HeterogeneousStrategies(*values)¶
Heterogeneous-scalar strategy options — this language only supports raising.
- ERROR = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)¶
- class JsonTypes(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
Empty: this language has no JSON value-type variants.
- class Modifiers(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
C++/Java/C#-style declaration modifiers: this language has none.
- class SequenceFormats(*values)¶
Sequence type options.
- LIST = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=' -arr', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=False, empty_sequence='+arr -arr', preamble_lines=(), format_entry=<function _forth_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)¶
- class SetFormats(*values)¶
Set type options.
- SET = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close=' -arr', empty_set='+arr -arr', preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)¶
- class TrailingCommas(*values)¶
Trailing comma options.
- NO = TrailingCommaConfig(multiline_trailing_comma=False)¶
- allows_empty_call_parens = True¶
- bool_formats¶
alias of
BoolFormats
- bytes_format: BytesFormats = <function _format_bytes_hex_forth>¶
- bytes_formats¶
alias of
BytesFormats
- property call_data_dependent_preamble: Callable[[Value], tuple[str, ...]]¶
Return data-dependent preamble lines for call rendering.
- call_returns_expression = True¶
- call_style_config: ClassVar[PositionalCallStyle | KeywordCallStyle | ObjectCallStyle | PostfixCallStyle | PrefixCallStyle | CommandCallStyle | CallSupport] = PostfixCallStyle(arg_separator=' ')¶
- call_styles¶
alias of
CallStyles
- property comment_config: CommentConfig¶
Configuration for the language’s comment syntax.
- comment_format: CommentFormats = CommentConfig(prefix='\\', suffix='')¶
- comment_formats¶
alias of
CommentFormats
- property compute_body_preamble: Callable[[frozenset[type], Value], tuple[str, ...]]¶
Compute body-preamble lines from the scalar map.
- property consumable_ref_value_inhibits_consuming_form: Callable[[Value], bool]¶
Predicate deciding whether a ref’s underlying value type inhibits the consume form.
Delegates to
never_inhibits_consuming_form. Languages whose consume operator rejects certain value types (notably the Mojo^on register-trivial scalars) override this.
- property data_dependent_preamble: Callable[[Value], tuple[str, ...]]¶
Return data-dependent preamble lines.
- date_format: DateFormats = DateFormatConfig(formatter=<function _format_date_forth>, preamble_lines=(), type_produced=<class 'str'>)¶
- date_formats¶
alias of
DateFormats
- datetime_format: DatetimeFormats = DatetimeFormatConfig(formatter=<function _format_datetime_forth>, preamble_lines=(), type_produced=<class 'str'>)¶
- datetime_formats¶
alias of
DatetimeFormats
- declaration_style: DeclarationStyles = DeclarationStyleConfig(formatter=<function _format_forth_declaration>, supports_redefinition=True)¶
- declaration_styles¶
alias of
DeclarationStyles
- dict_entry_style: DictEntryStyles = 1¶
- dict_entry_styles¶
alias of
DictEntryStyles
- dict_format: DictFormats = 1¶
- property dict_format_config: DictFormatConfig¶
Configuration for dict formatting.
- dict_formats¶
alias of
DictFormats
- dict_supports_heterogeneous_values = True¶
- element_separator: ClassVar[str] = ' '¶
- empty_dict_keys¶
alias of
EmptyDictKey
- extension = '.fth'¶
- false_literal: ClassVar[str] = 'false'¶
- float_format: FloatFormats = <function _format_float_forth>¶
- float_formats¶
alias of
FloatFormats
- property format_bytes: Callable[[bytes], str]¶
Callable that formats a bytes value as a string literal.
- static format_call_arg(_value: Value, formatted: str, /) str¶
Callable that rewrites a formatted direct call argument.
- property format_call_arg_ref_identifier: Callable[[str, Value | None], str]¶
Rewrite a
{"$ref": "name"}identifier in a call-argument context.Delegates to
format_call_ref_identifier. Override this to allow call-argument$refvalues that would otherwise be rejected.
- property format_call_arg_ref_identifier_consumable: Callable[[str, Value | None], str]¶
Format a
$refthe caller authorized as consumable.Delegates to
format_call_arg_ref_identifier. Override this to opt into a consuming form (e.g. C++std::move).
- format_call_binding_body_preamble() tuple[str, ...]¶
Default
format_call_binding_body_preamble– no extra body preamble lines for an inference-bound call result.
- format_call_binding_file_pragmas() tuple[str, ...]¶
Default
format_call_binding_file_pragmas– no file-level compiler-pragma line for an inference-bound call result.
- property format_call_preamble_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]¶
Return file-scope stubs for a call expression.
- property format_call_ref_identifier: Callable[[str, Value | None], str]¶
Rewrite a
{"$ref": "name"}identifier into the language’s call expression syntax.
- property format_call_statement: Callable[[str], str]¶
Return call-statement formatting for this language.
- property format_call_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]¶
Return stub declarations for a call expression.
- property format_call_target: Callable[[Sequence[str]], str]¶
Rewrite a dotted call target into the language’s call syntax.
- property format_call_variable_assignment: Callable[[str, str, Value], str]¶
Default
format_call_variable_assignment– reuse the literal-binding assignment formatter unchanged.
- property format_call_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]¶
Default
format_call_variable_declaration– reuse the literal-binding declaration formatter unchanged.
- static format_constructor_target(class_name: str, /) str¶
Return class_name as a zero-argument constructor call target.
- property format_date: Callable[[date], str]¶
Callable that formats a date as a string literal.
- property format_datetime: Callable[[datetime], str]¶
Callable that formats a datetime as a string literal.
- property format_float: Callable[[float], str]¶
Callable that formats a float value as a literal.
- property format_integer: Callable[[int], str]¶
Format an int value as a literal.
- property format_integer_widened: None¶
Default
format_integer_widened– no mixed-magnitude integer widening, so the renderer keeps the normal integer formatter.
- property format_ordered_map_entry: Callable[[str, Value, str], str]¶
Format one ordered-map entry.
- property format_sequence_entry: Callable[[Value, str], str]¶
Format a sequence entry.
- property format_set_entry: Callable[[Value, str], str]¶
Format a set entry.
- property format_string: Callable[[str], str]¶
Callable that formats a string value as a quoted literal.
- property format_time: Callable[[time], str]¶
Callable that formats a time as a string literal.
- property format_variable_assignment: Callable[[str, str, Value], str]¶
Callable that formats an assignment to an existing variable.
- property format_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]¶
Callable that formats a new variable declaration.
- has_free_function_calls = True¶
- property heterogeneous_behavior: HeterogeneousBehavior¶
Return the heterogeneous-behavior config.
- heterogeneous_strategies¶
alias of
HeterogeneousStrategies
- heterogeneous_strategy: HeterogeneousStrategies = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)¶
- identifier_cases: ClassVar[tuple[IdentifierCase, ...]] = (IdentifierCase.UPPER_SNAKE, IdentifierCase.SNAKE)¶
- indent: str = ' '¶
- indent_closing_delimiter: ClassVar[bool] = False¶
- integer_format: IntegerFormats = 1¶
- integer_formats¶
alias of
IntegerFormats
- integer_width_strategies¶
alias of
BareIntegerWidthStrategies
- integer_width_strategy: BareIntegerWidthStrategies = 1¶
- language_version: VersionFormats = 1¶
- property leading_preamble: LeadingPreamble¶
Default
leading_preamble– no preamble lines that must precedeLanguage.static_preamble.
- max_call_parameters = 9223372036854775807¶
- modifier_combinations: ClassVar[tuple[ModifierCombination, ...]] = ()¶
- null_literal: ClassVar[str] = '0'¶
- numeric_literal_suffix: NumericLiteralSuffixes = 1¶
- numeric_literal_suffixes¶
alias of
NumericLiteralSuffixes
- numeric_separator: NumericSeparators = 1¶
- numeric_separators¶
alias of
NumericSeparators
- numeric_style: NumericStyles = 1¶
- numeric_styles¶
alias of
NumericStyles
- property ordered_map_format_config: OrderedMapFormatConfig¶
Configuration for ordered-map formatting.
- pygments_name = 'forth'¶
- reserved_identifiers: ClassVar[frozenset[str]] = frozenset({})¶
- property scalar_body_preamble: dict[type, tuple[str, ...]]¶
Per-instance scalar body preamble (Forth needs none).
- property scalar_preamble: dict[type, tuple[str, ...]]¶
Per-instance scalar preamble (Forth needs none).
- sequence_binding_declarations(declarations: tuple[str, ...]) str¶
Default
sequence_binding_declarations– join the per-binding snippets with newlines.
- sequence_format: SequenceFormats = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=' -arr', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=False, empty_sequence='+arr -arr', preamble_lines=(), format_entry=<function _forth_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)¶
- property sequence_format_config: SequenceFormatConfig¶
Configuration for the chosen sequence format.
- sequence_formats¶
alias of
SequenceFormats
- property sequence_open: Callable[[list[Value]], str]¶
Callable that returns the opening delimiter for a sequence.
- set_format: SetFormats = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close=' -arr', empty_set='+arr -arr', preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)¶
- property set_format_config: SetFormatConfig¶
Configuration for the chosen set format.
- set_formats¶
alias of
SetFormats
- skip_null_dict_values: ClassVar[bool] = False¶
- special_float_preamble: ClassVar[tuple[str, ...]] = ()¶
- statement_terminator: ClassVar[str] = ''¶
- statement_terminator_style: StatementTerminatorStyles = 1¶
- statement_terminator_styles¶
alias of
StatementTerminatorStyles
- static_body_preamble: ClassVar[Sequence[str]] = ()¶
- static_preamble: ClassVar[Sequence[str]] = ()¶
- string_format: StringFormats = <function _format_string_forth>¶
- string_formats¶
alias of
StringFormats
- supported_ref_cases: ClassVar[frozenset[IdentifierCase]] = frozenset({IdentifierCase.CAMEL, IdentifierCase.PASCAL, IdentifierCase.SNAKE, IdentifierCase.UPPER_SNAKE})¶
- supports_call_style = False¶
- supports_collection_comments: ClassVar[bool] = False¶
- supports_default_dict_key_type = False¶
- supports_default_dict_value_type = False¶
- supports_default_ordered_map_value_type = False¶
- supports_default_sequence_element_type = False¶
- supports_default_set_element_type = False¶
- supports_dict_literal_as_free_expression = True¶
- supports_dotted_call_stub = True¶
- supports_dotted_calls = True¶
- supports_empty_dict_key = False¶
- supports_inline_multiline_dict_args = True¶
- supports_module_name = False¶
- supports_multi_param_call_wrapper_stub = True¶
- supports_no_variable_wrap_in_file = True¶
- supports_non_string_dict_keys = False¶
- supports_record_shape_names = False¶
- supports_record_struct_name_prefix = False¶
- supports_scalar_before_comments: ClassVar[bool] = False¶
- supports_scalar_inline_comments: ClassVar[bool] = False¶
- supports_special_floats = True¶
- supports_standalone_comments_in_wrapped_calls = True¶
- supports_variable_names = True¶
- supports_zero_parameter_calls = True¶
- trailing_comma: TrailingCommas = TrailingCommaConfig(multiline_trailing_comma=False)¶
- property trailing_comma_config: TrailingCommaConfig¶
Configuration for trailing-comma behavior.
- trailing_commas¶
alias of
TrailingCommas
- true_literal: ClassVar[str] = 'true'¶
- property type_hint_collection_preamble_lines: Callable[[frozenset[type]], tuple[str, ...]]¶
Return preamble lines for empty-collection type hints.
- property validate_call_arg: Callable[[Value], None]¶
Return call-argument validation for this language.
- validate_spec_for_data(data: Value) None¶
Default
validate_spec_for_data— no spec/data constraints.
- variable_type_hints: VariableTypeHints = 1¶
- variable_type_hints_formats¶
alias of
VariableTypeHints
- version_formats¶
alias of
VersionFormats
- wrap_calls_with_declarations(declarations: tuple[str, ...], calls: str, body_preamble: tuple[str, ...]) str¶
Default
wrap_calls_with_declarations— concatenate the declarations and calls and route throughwrap_in_file()in call mode.
- static wrap_combined_in_file(declaration: str, assignment: str, variable_name: str, body_preamble: tuple[str, ...]) str¶
Wrap declaration and assignment in a valid file (no-op).
- static wrap_in_file(content: str, variable_name: str, body_preamble: tuple[str, ...]) str¶
Wrap code in a valid file (no-op).
- class literalizer.languages.Fortran(*args: object, **kwargs: object)¶
Fortran language specification.
- class BoolFormats(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
Empty: this language has no alternative boolean formats.
- class BytesFormats(*values)¶
Bytes formatting options.
- BASE64 = <function format_bytes_base64>¶
- HEX = <function format_bytes_hex>¶
- class CallStyles(*values)¶
Fortran call style options.
- POSITIONAL = PositionalCallStyle(arg_separator=', ', parenthesize_each_arg=False)¶
- class CommentFormats(*values)¶
Comment style options.
- EXCLAMATION = CommentConfig(prefix='!', suffix='')¶
- class DateFormats(*values)¶
Date format options for Fortran.
- ISO = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- class DatetimeFormats(*values)¶
Datetime format options for Fortran.
- EPOCH = DatetimeFormatConfig(formatter=<function _format_fortran_datetime_epoch>, preamble_lines=(), type_produced=<class 'int'>)¶
- ISO = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- class DeclarationStyles(*values)¶
Declaration style options.
- TYPED = DeclarationStyleConfig(formatter=<function _build_format_variable_declaration.<locals>._format_variable_declaration>, supports_redefinition=True)¶
- class FloatFormats(*values)¶
Float format options.
Every finite literal is emitted with the
_real64kind suffix so that values like1.7976931348623157e+308(which exceed the default single-precision real range) parse correctly and so that3.14is not silently rounded to single precision before being passed to thefreal(real(real64))constructor declared instatic_body_preamble.- FIXED = <function _suffix_real64.<locals>._suffixed>¶
- REPR = <function _suffix_real64.<locals>._suffixed>¶
- SCIENTIFIC = <function _suffix_real64.<locals>._suffixed>¶
- class HeterogeneousStrategies(*values)¶
Heterogeneous-scalar strategy options — this language only supports raising.
- ERROR = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)¶
- class JsonTypes(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
Empty: this language has no JSON value-type variants.
- class Modifiers(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
C++/Java/C#-style declaration modifiers: this language has none.
- class SequenceFormats(*values)¶
Sequence type options for Fortran.
- LIST = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close='])', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=False, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)¶
- class SetFormats(*values)¶
Set type options for Fortran.
- SET = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close='])', empty_set=None, preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)¶
- class TrailingCommas(*values)¶
Trailing comma options.
- NO = TrailingCommaConfig(multiline_trailing_comma=False)¶
- class VersionFormats(*values)¶
Version options for Fortran.
VersionFormats.V2003— target Fortran 2003; theint64andreal64kinds are defined locally viaselected_int_kind/selected_real_kindbecause Fortran 2003’siso_fortran_envhas no such named constants.VersionFormats.V2008— target Fortran 2008; theint64andreal64kinds are imported from the intrinsiciso_fortran_envmodule.
- V2003 = 1¶
- V2008 = 2¶
- allows_empty_call_parens = True¶
- bool_formats¶
alias of
BoolFormats
- bool_name: str = 'fbool'¶
- bytes_format: BytesFormats = <function format_bytes_hex>¶
- bytes_formats¶
alias of
BytesFormats
- property call_data_dependent_preamble: Callable[[Value], tuple[str, ...]]¶
Return data-dependent preamble lines for call rendering.
- call_returns_expression = True¶
- call_style: CallStyles = PositionalCallStyle(arg_separator=', ', parenthesize_each_arg=False)¶
- property call_style_config: PositionalCallStyle | KeywordCallStyle | ObjectCallStyle | PostfixCallStyle | PrefixCallStyle | CommandCallStyle¶
Configuration for the chosen call style.
- call_styles¶
alias of
CallStyles
- property comment_config: CommentConfig¶
Configuration for the language’s comment syntax.
- comment_format: CommentFormats = CommentConfig(prefix='!', suffix='')¶
- comment_formats¶
alias of
CommentFormats
- property compute_body_preamble: Callable[[frozenset[type], Value], tuple[str, ...]]¶
Compute body-preamble lines from the scalar map.
- property consumable_ref_value_inhibits_consuming_form: Callable[[Value], bool]¶
Predicate deciding whether a ref’s underlying value type inhibits the consume form.
Delegates to
never_inhibits_consuming_form. Languages whose consume operator rejects certain value types (notably the Mojo^on register-trivial scalars) override this.
- property data_dependent_preamble: Callable[[Value], tuple[str, ...]]¶
Return data-dependent preamble lines.
- date_format: DateFormats = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- date_formats¶
alias of
DateFormats
- datetime_format: DatetimeFormats = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- datetime_formats¶
alias of
DatetimeFormats
- declaration_style: DeclarationStyles = DeclarationStyleConfig(formatter=<function _build_format_variable_declaration.<locals>._format_variable_declaration>, supports_redefinition=True)¶
- declaration_styles¶
alias of
DeclarationStyles
- dict_entry_style: DictEntryStyles = 1¶
- dict_entry_styles¶
alias of
DictEntryStyles
- dict_format: DictFormats = 1¶
- property dict_format_config: DictFormatConfig¶
Configuration for dict formatting.
- dict_formats¶
alias of
DictFormats
- dict_supports_heterogeneous_values = True¶
- element_separator: ClassVar[str] = ', '¶
- empty_dict_keys¶
alias of
EmptyDictKey
- entry_name: str = 'fentry'¶
- extension = '.f90'¶
- property false_literal: str¶
Literal representing
False.
- float_format: FloatFormats = <function _suffix_real64.<locals>._suffixed>¶
- float_formats¶
alias of
FloatFormats
- property format_bytes: Callable[[bytes], str]¶
Callable that formats a bytes value as a string literal.
- property format_call_arg: Callable[[Value, str], str]¶
Wrap a call argument in the appropriate
fval_tconstructor.
- property format_call_arg_ref_identifier: Callable[[str, Value | None], str]¶
Rewrite a
{"$ref": "name"}identifier in a call-argument context.Delegates to
format_call_ref_identifier. Override this to allow call-argument$refvalues that would otherwise be rejected.
- property format_call_arg_ref_identifier_consumable: Callable[[str, Value | None], str]¶
Format a
$refthe caller authorized as consumable.Delegates to
format_call_arg_ref_identifier. Override this to opt into a consuming form (e.g. C++std::move).
- format_call_binding_body_preamble() tuple[str, ...]¶
Default
format_call_binding_body_preamble– no extra body preamble lines for an inference-bound call result.
- format_call_binding_file_pragmas() tuple[str, ...]¶
Default
format_call_binding_file_pragmas– no file-level compiler-pragma line for an inference-bound call result.
- property format_call_preamble_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]¶
Return file-scope stubs for a call expression.
- property format_call_ref_identifier: Callable[[str, Value | None], str]¶
Rewrite a
{"$ref": "name"}identifier into the language’s call expression syntax.
- property format_call_statement: Callable[[str], str]¶
Prepend the Fortran
callkeyword to each call statement.
- property format_call_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]¶
Return stub declarations for a call expression.
- property format_call_target: Callable[[Sequence[str]], str]¶
Rewrite a dotted call target into the language’s call syntax.
- property format_call_variable_assignment: Callable[[str, str, Value], str]¶
Callable that formats an assignment binding a call result.
The call-expression counterpart of
format_variable_assignment; thefval_t-constructor wrapping is dropped since the call already yields atype(fval_t).
- property format_call_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]¶
Callable that formats a declaration binding a call result.
A literal binding wraps the right-hand side in a
fval_tconstructor chosen from the parsed literal’s type; a call’s return type is opaque to the renderer and is alwaystype(fval_t)(the type every generated call stub returns), so the call result is bound directly to a plaintype(fval_t)declaration with no constructor wrapping.
- static format_constructor_target(class_name: str, /) str¶
Return class_name as a zero-argument constructor call target.
- property format_date: Callable[[date], str]¶
Callable that formats a date as a string literal.
- property format_datetime: Callable[[datetime], str]¶
Callable that formats a datetime as a string literal.
- property format_float: Callable[[float], str]¶
Callable that formats a float value as a literal.
- property format_integer: Callable[[int], str]¶
Format an int value as an int64 Fortran literal.
- property format_integer_widened: None¶
Default
format_integer_widened– no mixed-magnitude integer widening, so the renderer keeps the normal integer formatter.
- property format_ordered_map_entry: Callable[[str, Value, str], str]¶
Callable that formats one ordered-map entry.
- property format_sequence_entry: Callable[[Value, str], str]¶
Callable that formats one sequence entry.
- property format_set_entry: Callable[[Value, str], str]¶
Callable that formats one set entry.
- property format_string: Callable[[str], str]¶
Callable that formats a string value as a quoted literal.
- property format_time: Callable[[time], str]¶
Callable that formats a time as a string literal.
- property format_variable_assignment: Callable[[str, str, Value], str]¶
Callable that formats an assignment to an existing variable.
- property format_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]¶
Callable that formats a new variable declaration.
- has_free_function_calls = True¶
- property heterogeneous_behavior: HeterogeneousBehavior¶
Return the heterogeneous-behavior config.
- heterogeneous_strategies¶
alias of
HeterogeneousStrategies
- heterogeneous_strategy: HeterogeneousStrategies = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)¶
- identifier_cases: ClassVar[tuple[IdentifierCase, ...]] = (IdentifierCase.SNAKE, IdentifierCase.UPPER_SNAKE)¶
- indent: str = ' '¶
- indent_closing_delimiter: ClassVar[bool] = False¶
- int_name: str = 'fint'¶
- integer_format: IntegerFormats = 1¶
- integer_formats¶
alias of
IntegerFormats
- integer_width_strategies¶
alias of
BareIntegerWidthStrategies
- integer_width_strategy: BareIntegerWidthStrategies = 1¶
- language_version: VersionFormats = 2¶
- property leading_preamble: LeadingPreamble¶
Default
leading_preamble– no preamble lines that must precedeLanguage.static_preamble.
- list_name: str = 'flist'¶
- map_name: str = 'fmap'¶
- max_call_parameters = 9223372036854775807¶
- modifier_combinations: ClassVar[tuple[ModifierCombination, ...]] = ()¶
- module_name: str = 'Module'¶
- module_name_case: ClassVar[IdentifierCase] = 'snake'¶
- property null_literal: str¶
Literal representing
None.
- null_name: str = 'fnull'¶
- numeric_literal_suffix: NumericLiteralSuffixes = 1¶
- numeric_literal_suffixes¶
alias of
NumericLiteralSuffixes
- numeric_separator: NumericSeparators = 1¶
- numeric_separators¶
alias of
NumericSeparators
- numeric_style: NumericStyles = 1¶
- numeric_styles¶
alias of
NumericStyles
- property ordered_map_format_config: OrderedMapFormatConfig¶
Configuration for ordered-map formatting.
- pygments_name = 'fortran'¶
- real_name: str = 'freal'¶
- reserved_identifiers: ClassVar[frozenset[str]] = frozenset({})¶
- property scalar_body_preamble: dict[type, tuple[str, ...]]¶
Per-instance scalar body preamble (Fortran needs none).
- property scalar_preamble: dict[type, tuple[str, ...]]¶
Per-instance scalar preamble (Fortran needs none).
- static sequence_binding_declarations(declarations: tuple[str, ...]) str¶
Order Fortran binding declarations for variable-mode wrapping.
Each binding’s
bare_codeis atype(fval_t) :: namespecification line followed by an assignment. Fortran requires every specification statement to precede every executable statement, so the type-declaration lines are gathered first and the assignment lines follow, across all bindings including the final result binding.
- sequence_format: SequenceFormats = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close='])', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=False, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)¶
- property sequence_format_config: SequenceFormatConfig¶
Configuration for the chosen sequence format.
- sequence_formats¶
alias of
SequenceFormats
- property sequence_open: Callable[[list[Value]], str]¶
Callable that returns the opening delimiter for a sequence.
- set_format: SetFormats = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close='])', empty_set=None, preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)¶
- property set_format_config: SetFormatConfig¶
Configuration for the chosen set format.
- set_formats¶
alias of
SetFormats
- set_name: str = 'fset'¶
- skip_null_dict_values: ClassVar[bool] = False¶
- special_float_preamble: ClassVar[tuple[str, ...]] = (' use, intrinsic :: ieee_arithmetic',)¶
- statement_terminator: ClassVar[str] = ''¶
- statement_terminator_style: StatementTerminatorStyles = 1¶
- statement_terminator_styles¶
alias of
StatementTerminatorStyles
- property static_body_preamble: Sequence[str]¶
Static body-preamble lines emitted once per file.
Fortran 2008 imports the
int64andreal64kinds from the intrinsiciso_fortran_envmodule. Those named constants did not exist in Fortran 2003’siso_fortran_env, so the 2003 target instead defines equivalent kind parameters withselected_int_kind(18)(18 decimal digits selects the same 8-byte integer kindint64denotes) andselected_real_kind(15, 307)(15 decimal digits + a 10**307 range selects the IEEE 754 binary64 kindreal64denotes). Fortran requiresimplicit nonebefore any data declaration, so the 2003 parameters follow it whereas the 2008useprecedes it. Either way the rest of the module, including the_int64and_real64literal suffixes, refers to the kinds by name, so nothing else varies by version.
- property static_preamble: Sequence[str]¶
Static preamble lines emitted once per file.
- str_name: str = 'fstr'¶
- string_format: StringFormats = 1¶
- string_formats¶
alias of
StringFormats
- supported_ref_cases: ClassVar[frozenset[IdentifierCase]] = frozenset({IdentifierCase.CAMEL, IdentifierCase.PASCAL, IdentifierCase.SNAKE, IdentifierCase.UPPER_SNAKE})¶
- supports_call_style = True¶
- supports_collection_comments: ClassVar[bool] = True¶
- supports_default_dict_key_type = False¶
- supports_default_dict_value_type = False¶
- supports_default_ordered_map_value_type = False¶
- supports_default_sequence_element_type = False¶
- supports_default_set_element_type = False¶
- supports_dict_literal_as_free_expression = True¶
- supports_dotted_call_stub = False¶
- supports_dotted_calls = True¶
- supports_empty_dict_key = False¶
- supports_inline_multiline_dict_args = True¶
- supports_module_name = True¶
- supports_multi_param_call_wrapper_stub = True¶
- supports_no_variable_wrap_in_file = False¶
- supports_non_string_dict_keys = False¶
- supports_record_shape_names = False¶
- supports_record_struct_name_prefix = False¶
- supports_scalar_before_comments: ClassVar[bool] = False¶
- supports_scalar_inline_comments: ClassVar[bool] = False¶
- supports_special_floats = True¶
- supports_standalone_comments_in_wrapped_calls = True¶
- supports_variable_names = True¶
- supports_zero_parameter_calls = True¶
- trailing_comma: TrailingCommas = TrailingCommaConfig(multiline_trailing_comma=False)¶
- property trailing_comma_config: TrailingCommaConfig¶
Configuration for trailing-comma behavior.
- trailing_commas¶
alias of
TrailingCommas
- property true_literal: str¶
Literal representing
True.
- property type_hint_collection_preamble_lines: Callable[[frozenset[type]], tuple[str, ...]]¶
Return preamble lines for empty-collection type hints.
- property validate_call_arg: Callable[[Value], None]¶
Return call-argument validation for this language.
- validate_spec_for_data(data: Value) None¶
Default
validate_spec_for_data— no spec/data constraints.
- variable_type_hints: VariableTypeHints = 1¶
- variable_type_hints_formats¶
alias of
VariableTypeHints
- version_formats¶
alias of
VersionFormats
- wrap_call_variable_in_file(content: str, variable_name: str, body_preamble: tuple[str, ...]) str¶
Wrap a call-result variable binding in a Fortran program.
The literal-binding
wrap_in_file()variable branch places body_preamble directly in the program body, but a call stub (an internalfunction/subroutine) cannot be a plain executable statement: it must live in thecontainssection after the executable statements. content already carries thetype(fval_t) :: namespecification line followed by the binding assignment in the order Fortran requires, so this delegates to the empty-variable_name(call-mode) branch ofwrap_in_file(), which places content in the program body and the stubs incontains.
- wrap_calls_with_declarations(declarations: tuple[str, ...], calls: str, body_preamble: tuple[str, ...]) str¶
Wrap Fortran call stubs and variable declarations alongside calls.
Fortran requires all specification statements (type declarations) to precede executable statements (assignments and calls). Each declaration bare_code from
literalize()is a two-part string: atype(fval_t) :: namedeclaration on the first line and an assignment on the remaining lines. This method splits them so that all type-declaration lines appear before any assignment or call lines, producing a valid program.Call stubs are placed in the
containssection viawrap_in_file().
- wrap_combined_in_file(declaration: str, assignment: str, variable_name: str, body_preamble: tuple[str, ...]) str¶
Wrap Fortran declaration + assignment in separate subroutines.
- wrap_in_file(content: str, variable_name: str, body_preamble: tuple[str, ...]) str¶
Wrap a Fortran variable declaration or call block in a program.
When variable_name is non-empty (variable declaration mode), body_preamble is prepended before content in the program body. When variable_name is empty (call mode), body_preamble holds internal-procedure stubs that go in the
containssection after the executable statements in content.
- class literalizer.languages.Gleam(*args: object, **kwargs: object)¶
Gleam language specification.
The generated output uses custom constructors (
GNull,GBool,GList,GDict,GSet) that are not built-in Gleam types. To compile the generated code, aGValcustom type is emitted in the body preamble, containing only the constructors actually used by the data. For example, data consisting solely of an integer yields:pub type GVal { GInt(Int) }
- Parameters:
date_format –
How to format
datetime.datevalues.date_formats.ISO— ISO 8601 string, e.g.GStr("2024-01-15").
datetime_format –
How to format
datetime.datetimevalues.datetime_formats.ISO— ISO 8601 string, e.g.GStr("2024-01-15T12:30:00").
sequence_format –
Which Gleam sequence type to use.
sequence_formats.LIST— list literal, e.g.GList([GInt(1), GInt(2), GInt(3)]).sequence_formats.TUPLE— tuple literal, e.g.#(GInt(1), GInt(2), GInt(3)).
type_name – Name of the generated custom type. Defaults to
"GVal".constructor_prefix – Prefix for generated constructor names. Defaults to
"G", producing constructors likeGNull,GBool,GInt, etc.
- class BoolFormats(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
Empty: this language has no alternative boolean formats.
- class BytesFormats(*values)¶
Bytes formatting options.
- BASE64 = <function _build_gleam_bytes_base64.<locals>._format>¶
- HEX = <function _build_gleam_bytes_hex.<locals>._format>¶
- class CallStyles(*values)¶
Gleam call style options.
- POSITIONAL = PositionalCallStyle(arg_separator=', ', parenthesize_each_arg=False)¶
- class CommentFormats(*values)¶
Comment style options.
- DOUBLE_SLASH = CommentConfig(prefix='//', suffix='')¶
- class DateFormats(*values)¶
Date format options for Gleam.
- ISO = DateFormatConfig(formatter=<function _build_gleam_date_iso.<locals>._format>, preamble_lines=(), type_produced=<class 'str'>)¶
- class DatetimeFormats(*values)¶
Datetime format options for Gleam.
- EPOCH = DatetimeFormatConfig(formatter=<function datetime_epoch_formatter.<locals>._format>, preamble_lines=(), type_produced=<class 'int'>)¶
- ISO = DatetimeFormatConfig(formatter=<function _build_gleam_datetime_iso.<locals>._format>, preamble_lines=(), type_produced=<class 'str'>)¶
- class DeclarationStyles(*values)¶
Declaration style options.
- LET = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=True)¶
- class FloatFormats(*values)¶
Float format options.
- FIXED = <function _build_gleam_float_wrapper.<locals>._format>¶
- REPR = <function _build_gleam_float_wrapper.<locals>._format>¶
- SCIENTIFIC = <function _build_gleam_float_wrapper.<locals>._format>¶
- class HeterogeneousStrategies(*values)¶
Heterogeneous-scalar strategy options — this language only supports raising.
- ERROR = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)¶
- class IntegerFormats(*values)¶
Integer format options.
- BINARY = mappingproxy({'NONE': <function _build_gleam_integer_wrapper.<locals>._format>, 'UNDERSCORE': <function _build_gleam_integer_wrapper.<locals>._format>})¶
- DECIMAL = mappingproxy({'NONE': <function _build_gleam_integer_wrapper.<locals>._format>, 'UNDERSCORE': <function _build_gleam_integer_wrapper.<locals>._format>})¶
- HEX = mappingproxy({'NONE': <function _build_gleam_integer_wrapper.<locals>._format>, 'UNDERSCORE': <function _build_gleam_integer_wrapper.<locals>._format>})¶
- OCTAL = mappingproxy({'NONE': <function _build_gleam_integer_wrapper.<locals>._format>, 'UNDERSCORE': <function _build_gleam_integer_wrapper.<locals>._format>})¶
- get_formatter(numeric_separator: Enum) Callable[[int], str]¶
Return the integer formatter for the given separator.
- class JsonTypes(*values)¶
JSON value type options for Gleam.
- GLEAM_JSON_JSON = 'gleam/json.Json'¶
The
gleam_jsonpackage’sJsonbuilder type.
- class Modifiers(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
C++/Java/C#-style declaration modifiers: this language has none.
- class SequenceFormats(*values)¶
Sequence type options for Gleam.
- LIST = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close='])', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)¶
- TUPLE = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=')', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence='#()', preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)¶
- class SetFormats(*values)¶
Set type options for Gleam.
- SET = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close='])', empty_set=None, preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)¶
- class TrailingCommas(*values)¶
Trailing comma options.
- NO = TrailingCommaConfig(multiline_trailing_comma=False)¶
- YES = TrailingCommaConfig(multiline_trailing_comma=True)¶
- allows_empty_call_parens = True¶
- bool_formats¶
alias of
BoolFormats
- bytes_format: BytesFormats = <function _build_gleam_bytes_hex.<locals>._format>¶
- bytes_formats¶
alias of
BytesFormats
- property call_data_dependent_preamble: Callable[[Value], tuple[str, ...]]¶
Return data-dependent preamble lines for call rendering.
- call_returns_expression = True¶
- call_style: CallStyles = PositionalCallStyle(arg_separator=', ', parenthesize_each_arg=False)¶
- property call_style_config: PositionalCallStyle | KeywordCallStyle | ObjectCallStyle | PostfixCallStyle | PrefixCallStyle | CommandCallStyle¶
Configuration for Gleam’s call style.
- call_styles¶
alias of
CallStyles
- property comment_config: CommentConfig¶
Configuration for the language’s comment syntax.
- comment_format: CommentFormats = CommentConfig(prefix='//', suffix='')¶
- comment_formats¶
alias of
CommentFormats
- property compute_body_preamble: Callable[[frozenset[type], Value], tuple[str, ...]]¶
Compute body-preamble lines from the scalar map.
- constructor_prefix: str = 'G'¶
- property consumable_ref_value_inhibits_consuming_form: Callable[[Value], bool]¶
Predicate deciding whether a ref’s underlying value type inhibits the consume form.
Delegates to
never_inhibits_consuming_form. Languages whose consume operator rejects certain value types (notably the Mojo^on register-trivial scalars) override this.
- property data_dependent_preamble: Callable[[Value], tuple[str, ...]]¶
Return the
pub typedeclaration tailored to data.Under
json_typethe rendered values flow through thegleam_jsonbuilder API and noGValADT is needed, so the preamble is empty.
- date_format: DateFormats = DateFormatConfig(formatter=<function _build_gleam_date_iso.<locals>._format>, preamble_lines=(), type_produced=<class 'str'>)¶
- date_formats¶
alias of
DateFormats
- datetime_format: DatetimeFormats = DatetimeFormatConfig(formatter=<function _build_gleam_datetime_iso.<locals>._format>, preamble_lines=(), type_produced=<class 'str'>)¶
- datetime_formats¶
alias of
DatetimeFormats
- declaration_style: DeclarationStyles = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=True)¶
- declaration_styles¶
alias of
DeclarationStyles
- dict_entry_style: DictEntryStyles = 1¶
- dict_entry_styles¶
alias of
DictEntryStyles
- dict_format: DictFormats = 1¶
- property dict_format_config: DictFormatConfig¶
Configuration for dict formatting.
Under
json_typedicts are rendered asjson.object([#("k", v), ...])builder calls; the entry formatter strips thejson.string(...)wrapping the key formatter applied so each pair’s key is a bare string literal.
- dict_formats¶
alias of
DictFormats
- dict_supports_heterogeneous_values = True¶
- element_separator: ClassVar[str] = ', '¶
- empty_dict_keys¶
alias of
EmptyDictKey
- extension = '.gleam'¶
- property false_literal: str¶
Literal representing
False.
- float_format: FloatFormats = <function _build_gleam_float_wrapper.<locals>._format>¶
- float_formats¶
alias of
FloatFormats
- property format_bytes: Callable[[bytes], str]¶
Callable that formats a bytes value as a string literal.
- static format_call_arg(_value: Value, formatted: str, /) str¶
Callable that rewrites a formatted direct call argument.
- property format_call_arg_ref_identifier: Callable[[str, Value | None], str]¶
Rewrite a
{"$ref": "name"}identifier in a call-argument context.Delegates to
format_call_ref_identifier. Override this to allow call-argument$refvalues that would otherwise be rejected.
- property format_call_arg_ref_identifier_consumable: Callable[[str, Value | None], str]¶
Format a
$refthe caller authorized as consumable.Delegates to
format_call_arg_ref_identifier. Override this to opt into a consuming form (e.g. C++std::move).
- format_call_binding_body_preamble() tuple[str, ...]¶
Default
format_call_binding_body_preamble– no extra body preamble lines for an inference-bound call result.
- format_call_binding_file_pragmas() tuple[str, ...]¶
Default
format_call_binding_file_pragmas– no file-level compiler-pragma line for an inference-bound call result.
- property format_call_preamble_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]¶
Return file-scope stubs for a call expression.
- property format_call_ref_identifier: Callable[[str, Value | None], str]¶
Rewrite a
{"$ref": "name"}identifier into the language’s call expression syntax.
- property format_call_statement: Callable[[str], str]¶
Return call-statement formatting for this language.
- property format_call_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]¶
Return stub declarations for a call expression.
- property format_call_target: Callable[[Sequence[str]], str]¶
Rewrite a dotted call target into the language’s call syntax.
- property format_call_variable_assignment: Callable[[str, str, Value], str]¶
Default
format_call_variable_assignment– reuse the literal-binding assignment formatter unchanged.
- property format_call_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]¶
Default
format_call_variable_declaration– reuse the literal-binding declaration formatter unchanged.
- static format_constructor_target(class_name: str, /) str¶
Return class_name as a zero-argument constructor call target.
- property format_date: Callable[[date], str]¶
Callable that formats a date as a string literal.
- property format_datetime: Callable[[datetime], str]¶
Callable that formats a datetime as a string literal.
- property format_float: Callable[[float], str]¶
Callable that formats a float value as a literal.
Non-finite values raise
UnrepresentableSpecialFloatErrorbecause Gleam’s Erlang target has no expression that evaluates to a non-finite float.The redundant
+Python’srepremits on positive exponents (1.0e+16) is stripped because Gleam’s parser rejects it withThis float is missing an exponent.
- property format_integer: Callable[[int], str]¶
Callable that formats an int value as a literal.
- property format_integer_widened: None¶
Default
format_integer_widened– no mixed-magnitude integer widening, so the renderer keeps the normal integer formatter.
- property format_ordered_map_entry: Callable[[str, Value, str], str]¶
Callable that formats one ordered-map entry.
- property format_sequence_entry: Callable[[Value, str], str]¶
Format a sequence entry.
- property format_set_entry: Callable[[Value, str], str]¶
Format a set entry.
- property format_string: Callable[[str], str]¶
Callable that formats a string value as a quoted literal.
- property format_time: Callable[[time], str]¶
Callable that formats a time as a string literal.
- property format_variable_assignment: Callable[[str, str, Value], str]¶
Callable that formats an assignment to an existing variable.
Under
json_typethe assignment also carries the: json.Jsonannotation so a shadowed binding keeps the builder static type explicit.
- property format_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]¶
Callable that formats a new variable declaration.
Under
json_typethe binding carries an explicit: json.Jsonannotation so the static type matches thegleam_jsonbuilder’s return type and downstream encoders likejson.to_stringresolve without inference.
- has_free_function_calls = True¶
- property heterogeneous_behavior: HeterogeneousBehavior¶
Return the heterogeneous-behavior config.
Under
json_typeevery value is wrapped in ajson.Jsonbuilder call so scalar uniformity is irrelevant across container elements.
- heterogeneous_strategies¶
alias of
HeterogeneousStrategies
- heterogeneous_strategy: HeterogeneousStrategies = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)¶
- identifier_cases: ClassVar[tuple[IdentifierCase, ...]] = (IdentifierCase.SNAKE,)¶
- indent: str = ' '¶
- indent_closing_delimiter: ClassVar[bool] = False¶
- integer_format: IntegerFormats = mappingproxy({'NONE': <function _build_gleam_integer_wrapper.<locals>._format>, 'UNDERSCORE': <function _build_gleam_integer_wrapper.<locals>._format>})¶
- integer_formats¶
alias of
IntegerFormats
- integer_width_strategies¶
alias of
BareIntegerWidthStrategies
- integer_width_strategy: BareIntegerWidthStrategies = 1¶
- language_version: VersionFormats = 1¶
- property leading_preamble: LeadingPreamble¶
Default
leading_preamble– no preamble lines that must precedeLanguage.static_preamble.
- max_call_parameters = 9223372036854775807¶
- modifier_combinations: ClassVar[tuple[ModifierCombination, ...]] = ()¶
- property null_literal: str¶
Literal representing
None.
- numeric_literal_suffix: NumericLiteralSuffixes = 1¶
- numeric_literal_suffixes¶
alias of
NumericLiteralSuffixes
- numeric_separator: NumericSeparators = 1¶
- numeric_separators¶
alias of
NumericSeparators
- numeric_style: NumericStyles = 1¶
- numeric_styles¶
alias of
NumericStyles
- property ordered_map_format_config: OrderedMapFormatConfig¶
Configuration for ordered-map formatting.
- pygments_name = 'gleam'¶
- reserved_identifiers: ClassVar[frozenset[str]] = frozenset({})¶
- property scalar_body_preamble: dict[type, tuple[str, ...]]¶
Per-instance scalar body preamble (Gleam needs none).
- property scalar_preamble: dict[type, tuple[str, ...]]¶
Per-instance scalar preamble (Gleam needs none).
- sequence_binding_declarations(declarations: tuple[str, ...]) str¶
Default
sequence_binding_declarations– join the per-binding snippets with newlines.
- sequence_format: SequenceFormats = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close='])', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)¶
- property sequence_format_config: SequenceFormatConfig¶
Configuration for the chosen sequence format.
Under
json_typesequences are rendered asjson.preprocessed_array([...])builder calls since each element is already ajson.Jsonvalue; the typedjson.array(of:)overload would require a uniform element encoder which the heterogeneous-input case cannot supply.
- sequence_formats¶
alias of
SequenceFormats
- property sequence_open: Callable[[list[Value]], str]¶
Callable that returns the opening delimiter for a sequence.
- set_format: SetFormats = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close='])', empty_set=None, preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)¶
- property set_format_config: SetFormatConfig¶
Configuration for the chosen set format.
Under
json_typesets becomejson.preprocessed_array([...])builder calls; JSON has no set type so the closest builder is the heterogeneous array constructor.
- set_formats¶
alias of
SetFormats
- skip_null_dict_values: ClassVar[bool] = False¶
- special_float_preamble: ClassVar[tuple[str, ...]] = ()¶
- statement_terminator: ClassVar[str] = ''¶
- statement_terminator_style: StatementTerminatorStyles = 1¶
- statement_terminator_styles¶
alias of
StatementTerminatorStyles
- static_body_preamble: ClassVar[Sequence[str]] = ()¶
- property static_preamble: Sequence[str]¶
File-scope preamble.
Under
json_typeanimport gleam/jsonline is added so the rendered builder calls resolve. The defaultGValADT mode needs no static preamble; its tagged ADT declaration is emitted bydata_dependent_preambleinstead.
- string_format: StringFormats = 1¶
- string_formats¶
alias of
StringFormats
- supported_ref_cases: ClassVar[frozenset[IdentifierCase]] = frozenset({IdentifierCase.SNAKE})¶
- supports_call_style = True¶
- supports_collection_comments: ClassVar[bool] = True¶
- supports_default_dict_key_type = False¶
- supports_default_dict_value_type = False¶
- supports_default_ordered_map_value_type = False¶
- supports_default_sequence_element_type = False¶
- supports_default_set_element_type = False¶
- supports_dict_literal_as_free_expression = True¶
- supports_dotted_call_stub = False¶
- supports_dotted_calls = True¶
- supports_empty_dict_key = False¶
- supports_inline_multiline_dict_args = True¶
- supports_module_name = False¶
- supports_multi_param_call_wrapper_stub = True¶
- supports_no_variable_wrap_in_file = False¶
- supports_non_string_dict_keys = False¶
- supports_record_shape_names = False¶
- supports_record_struct_name_prefix = False¶
- supports_scalar_before_comments: ClassVar[bool] = True¶
- supports_scalar_inline_comments: ClassVar[bool] = True¶
- supports_special_floats = False¶
- supports_standalone_comments_in_wrapped_calls = True¶
- supports_variable_names = True¶
- supports_zero_parameter_calls = True¶
- trailing_comma: TrailingCommas = TrailingCommaConfig(multiline_trailing_comma=True)¶
- property trailing_comma_config: TrailingCommaConfig¶
Configuration for trailing-comma behavior.
- trailing_commas¶
alias of
TrailingCommas
- property true_literal: str¶
Literal representing
True.
- property type_hint_collection_preamble_lines: Callable[[frozenset[type]], tuple[str, ...]]¶
Return preamble lines for empty-collection type hints.
- type_name: str = 'GVal'¶
- property validate_call_arg: Callable[[Value], None]¶
Return call-argument validation for this language.
- validate_spec_for_data(data: Value) None¶
Default
validate_spec_for_data— no spec/data constraints.
- variable_type_hints: VariableTypeHints = 1¶
- variable_type_hints_formats¶
alias of
VariableTypeHints
- version_formats¶
alias of
VersionFormats
- wrap_calls_with_declarations(declarations: tuple[str, ...], calls: str, body_preamble: tuple[str, ...]) str¶
Default
wrap_calls_with_declarations— concatenate the declarations and calls and route throughwrap_in_file()in call mode.
- wrap_combined_in_file(declaration: str, assignment: str, variable_name: str, body_preamble: tuple[str, ...]) str¶
Wrap Gleam declaration + assignment in a main function.
- wrap_in_file(content: str, variable_name: str, body_preamble: tuple[str, ...]) str¶
Wrap a Gleam let binding in a main function.
- class literalizer.languages.Go(*args: object, **kwargs: object)¶
Go language specification.
- Parameters:
date_format –
How to format
datetime.datevalues.date_formats.GO—time.Datecall, e.g.time.Date(2024, time.January, 15, 0, 0, 0, 0, time.UTC).date_formats.ISO— ISO 8601 quoted string, e.g."2024-01-15".
datetime_format –
How to format
datetime.datetimevalues.datetime_formats.GO—time.Datecall, e.g.time.Date(2024, time.January, 15, 12, 30, 0, 0, time.UTC).datetime_formats.ISO— ISO 8601 quoted string, e.g."2024-01-15T12:30:00".
- class BoolFormats(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
Empty: this language has no alternative boolean formats.
- class BytesFormats(*values)¶
Bytes formatting options.
- BASE64 = <function format_bytes_base64>¶
- HEX = <function format_bytes_hex>¶
- class CallStyles(*values)¶
Go call style options.
- POSITIONAL = PositionalCallStyle(arg_separator=', ', parenthesize_each_arg=False)¶
- class CommentFormats(*values)¶
Comment style options.
- BLOCK = CommentConfig(prefix='/*', suffix=' */')¶
- DOUBLE_SLASH = CommentConfig(prefix='//', suffix='')¶
- class DateFormats(*values)¶
Date format options for Go.
- GO = DateFormatConfig(formatter=<function _format_date_go>, preamble_lines=('import "time"',), type_produced=<class 'datetime.date'>)¶
- ISO = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- class DatetimeFormats(*values)¶
Datetime format options for Go.
- EPOCH = DatetimeFormatConfig(formatter=<function format_datetime_epoch>, preamble_lines=(), type_produced=<class 'int'>)¶
- GO = DatetimeFormatConfig(formatter=<function _format_datetime_go>, preamble_lines=('import "time"',), type_produced=<class 'datetime.datetime'>)¶
- ISO = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- class DeclarationStyles(*values)¶
Declaration style options.
- SHORT = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=True)¶
- VAR = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=True)¶
- class FloatFormats(*values)¶
Float format options.
- FIXED = <function format_float_fixed>¶
- REPR = <function format_float_repr>¶
- SCIENTIFIC = <function format_float_scientific>¶
- class HeterogeneousStrategies(*values)¶
Strategy for dicts whose values span more than one Go type.
ERRORkeeps Go’s strict-typing behavior (mixed-value dicts that cannot be represented raise).RECORDrenders each record-shaped dict (non-empty, string-keyed) as a generatedstructdeclared in the preamble plus a matching struct literal, so fields may legitimately mix scalars and containers.- ERROR = 1¶
- RECORD = 2¶
- class IntegerFormats(*values)¶
Integer format options.
- BINARY = mappingproxy({'NONE': <function format_integer_binary>, 'UNDERSCORE': <function format_integer_binary>})¶
- DECIMAL = mappingproxy({'NONE': <class 'str'>, 'UNDERSCORE': <function format_integer_underscore>})¶
- HEX = mappingproxy({'NONE': <function format_integer_hex>, 'UNDERSCORE': <function format_integer_hex>})¶
- OCTAL = mappingproxy({'NONE': <function format_integer_octal>, 'UNDERSCORE': <function format_integer_octal>})¶
- get_formatter(numeric_separator: Enum) Callable[[int], str]¶
Return the integer formatter for the given separator.
- class JsonTypes(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
Empty: this language has no JSON value-type variants.
- class Modifiers(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
C++/Java/C#-style declaration modifiers: this language has none.
- class SequenceFormats(*values)¶
Sequence type options for Go.
- SLICE = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close='}', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)¶
- class SetFormats(*values)¶
Set type options for Go.
- SET = <function set_format_factory.<locals>._build>¶
- class StatementTerminatorStyles(*values)¶
Statement terminator options.
- NONE = ''¶
- property statement_terminator: str¶
Terminator appended to complete call statements.
- class TrailingCommas(*values)¶
Trailing comma options.
- YES = TrailingCommaConfig(multiline_trailing_comma=True)¶
- allows_empty_call_parens = True¶
- bool_formats¶
alias of
BoolFormats
- bytes_format: BytesFormats = <function format_bytes_hex>¶
- bytes_formats¶
alias of
BytesFormats
- property call_data_dependent_preamble: Callable[[Value], tuple[str, ...]]¶
Return data-dependent preamble lines for call rendering.
- call_returns_expression = True¶
- call_style: CallStyles = PositionalCallStyle(arg_separator=', ', parenthesize_each_arg=False)¶
- property call_style_config: PositionalCallStyle | KeywordCallStyle | ObjectCallStyle | PostfixCallStyle | PrefixCallStyle | CommandCallStyle¶
Configuration for the chosen call style.
- call_styles¶
alias of
CallStyles
- property comment_config: CommentConfig¶
Configuration for the language’s comment syntax.
- comment_format: CommentFormats = CommentConfig(prefix='//', suffix='')¶
- comment_formats¶
alias of
CommentFormats
- property compute_body_preamble: Callable[[frozenset[type], Value], tuple[str, ...]]¶
Compute body-preamble lines from the scalar map.
- property consumable_ref_value_inhibits_consuming_form: Callable[[Value], bool]¶
Predicate deciding whether a ref’s underlying value type inhibits the consume form.
Delegates to
never_inhibits_consuming_form. Languages whose consume operator rejects certain value types (notably the Mojo^on register-trivial scalars) override this.
- property data_dependent_preamble: Callable[[Value], tuple[str, ...]]¶
Return data-dependent preamble lines.
For
HeterogeneousStrategies.RECORDemits onestructdeclaration per record shape present in the data; otherwise produces no preamble.
- date_format: DateFormats = DateFormatConfig(formatter=<function _format_date_go>, preamble_lines=('import "time"',), type_produced=<class 'datetime.date'>)¶
- date_formats¶
alias of
DateFormats
- datetime_format: DatetimeFormats = DatetimeFormatConfig(formatter=<function _format_datetime_go>, preamble_lines=('import "time"',), type_produced=<class 'datetime.datetime'>)¶
- datetime_formats¶
alias of
DatetimeFormats
- declaration_style: DeclarationStyles = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=True)¶
- declaration_styles¶
alias of
DeclarationStyles
- default_dict_key_type: str = 'string'¶
- default_dict_value_type: str = 'any'¶
- default_ordered_map_value_type: str = 'any'¶
- default_sequence_element_type: str = 'any'¶
- default_set_element_type: str = 'any'¶
- dict_entry_style: DictEntryStyles = 1¶
- dict_entry_styles¶
alias of
DictEntryStyles
- dict_format: DictFormats = 1¶
- property dict_format_config: DictFormatConfig¶
Configuration for dict formatting.
- dict_formats¶
alias of
DictFormats
- dict_supports_heterogeneous_values = True¶
- element_separator: ClassVar[str] = ', '¶
- empty_dict_keys¶
alias of
EmptyDictKey
- extension = '.go'¶
- false_literal: ClassVar[str] = 'false'¶
- float_format: FloatFormats = <function format_float_repr>¶
- float_formats¶
alias of
FloatFormats
- property format_bytes: Callable[[bytes], str]¶
Callable that formats a bytes value as a string literal.
- static format_call_arg(_value: Value, formatted: str, /) str¶
Callable that rewrites a formatted direct call argument.
- property format_call_arg_ref_identifier: Callable[[str, Value | None], str]¶
Rewrite a
{"$ref": "name"}identifier in a call-argument context.Delegates to
format_call_ref_identifier. Override this to allow call-argument$refvalues that would otherwise be rejected.
- property format_call_arg_ref_identifier_consumable: Callable[[str, Value | None], str]¶
Format a
$refthe caller authorized as consumable.Delegates to
format_call_arg_ref_identifier. Override this to opt into a consuming form (e.g. C++std::move).
- format_call_binding_body_preamble() tuple[str, ...]¶
Default
format_call_binding_body_preamble– no extra body preamble lines for an inference-bound call result.
- format_call_binding_file_pragmas() tuple[str, ...]¶
Default
format_call_binding_file_pragmas– no file-level compiler-pragma line for an inference-bound call result.
- property format_call_preamble_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]¶
Return file-scope stubs for a call expression.
- property format_call_ref_identifier: Callable[[str, Value | None], str]¶
Rewrite a
{"$ref": "name"}identifier into the language’s call expression syntax.
- property format_call_statement: Callable[[str], str]¶
Return call-statement formatting for this language.
- property format_call_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]¶
Return stub declarations for a call expression.
- property format_call_target: Callable[[Sequence[str]], str]¶
Rewrite a dotted call target into the language’s call syntax.
- property format_call_variable_assignment: Callable[[str, str, Value], str]¶
Default
format_call_variable_assignment– reuse the literal-binding assignment formatter unchanged.
- property format_call_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]¶
Default
format_call_variable_declaration– reuse the literal-binding declaration formatter unchanged.
- static format_constructor_target(class_name: str, /) str¶
Return a Go
NewClassNameconstructor call target.
- property format_date: Callable[[date], str]¶
Callable that formats a date as a string literal.
- property format_datetime: Callable[[datetime], str]¶
Callable that formats a datetime as a string literal.
- property format_float: Callable[[float], str]¶
Callable that formats a float value as a literal.
- property format_integer: Callable[[int], str]¶
Callable that formats an int value as a literal.
- property format_integer_widened: None¶
Default
format_integer_widened– no mixed-magnitude integer widening, so the renderer keeps the normal integer formatter.
- property format_ordered_map_entry: Callable[[str, Value, str], str]¶
Callable that formats one ordered-map entry.
- property format_sequence_entry: Callable[[Value, str], str]¶
Format a sequence entry.
- property format_set_entry: Callable[[Value, str], str]¶
Format a set entry.
- property format_string: Callable[[str], str]¶
Format a string value as a quoted literal.
- property format_time: Callable[[time], str]¶
Callable that formats a time as a string literal.
- property format_variable_assignment: Callable[[str, str, Value], str]¶
Callable that formats an assignment to an existing variable.
- property format_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]¶
Callable that formats a new variable declaration.
- has_free_function_calls = True¶
- property heterogeneous_behavior: HeterogeneousBehavior¶
Return the behavior for the chosen heterogeneous strategy.
- heterogeneous_strategies¶
alias of
HeterogeneousStrategies
- heterogeneous_strategy: HeterogeneousStrategies = 1¶
- identifier_cases: ClassVar[tuple[IdentifierCase, ...]] = (IdentifierCase.PASCAL, IdentifierCase.CAMEL)¶
- indent: str = '\t'¶
- indent_closing_delimiter: ClassVar[bool] = False¶
- integer_format: IntegerFormats = mappingproxy({'NONE': <class 'str'>, 'UNDERSCORE': <function format_integer_underscore>})¶
- integer_formats¶
alias of
IntegerFormats
- integer_width_strategies¶
alias of
BareIntegerWidthStrategies
- integer_width_strategy: BareIntegerWidthStrategies = 1¶
- language_version: VersionFormats = 1¶
- property leading_preamble: LeadingPreamble¶
Default
leading_preamble– no preamble lines that must precedeLanguage.static_preamble.
- max_call_parameters = 9223372036854775807¶
- modifier_combinations: ClassVar[tuple[ModifierCombination, ...]] = ()¶
- null_literal: ClassVar[str] = 'nil'¶
- numeric_literal_suffix: NumericLiteralSuffixes = 1¶
- numeric_literal_suffixes¶
alias of
NumericLiteralSuffixes
- numeric_separator: NumericSeparators = 1¶
- numeric_separators¶
alias of
NumericSeparators
- numeric_style: NumericStyles = 1¶
- numeric_styles¶
alias of
NumericStyles
- property ordered_map_format_config: OrderedMapFormatConfig¶
Configuration for ordered-map formatting.
- pygments_name = 'go'¶
- record_shape_names: Mapping[frozenset[str], str]¶
- record_struct_name_prefix: str = 'Record'¶
- reserved_identifiers: ClassVar[frozenset[str]] = frozenset({})¶
- property scalar_body_preamble: dict[type, tuple[str, ...]]¶
Per-instance scalar body preamble (Go needs none).
- property scalar_preamble: dict[type, tuple[str, ...]]¶
Per-instance scalar preamble computed from date/datetime format.
- sequence_binding_declarations(declarations: tuple[str, ...]) str¶
Default
sequence_binding_declarations– join the per-binding snippets with newlines.
- sequence_format: SequenceFormats = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close='}', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)¶
- property sequence_format_config: SequenceFormatConfig¶
Configuration for the chosen sequence format.
- sequence_formats¶
alias of
SequenceFormats
- property sequence_open: Callable[[list[Value]], str]¶
Callable that returns the opening delimiter for a sequence.
Under the
RECORDstrategy a list whose elements are record-shaped dicts is rendered as[]any{ RecordN{...}, ... }(the elements format as struct literals, not as themap[string]...the typed opener would otherwise infer).
- set_format: SetFormats = <function set_format_factory.<locals>._build>¶
- property set_format_config: SetFormatConfig¶
Configuration for the chosen set format.
- set_formats¶
alias of
SetFormats
- skip_null_dict_values: ClassVar[bool] = False¶
- special_float_preamble: ClassVar[tuple[str, ...]] = ('import "math"',)¶
- property statement_terminator: str¶
String appended to each call expression.
- statement_terminator_style: StatementTerminatorStyles = ''¶
- statement_terminator_styles¶
alias of
StatementTerminatorStyles
- static_body_preamble: ClassVar[Sequence[str]] = ()¶
- static_preamble: ClassVar[Sequence[str]] = ('package main',)¶
- string_format: StringFormats = 1¶
- string_formats¶
alias of
StringFormats
- supported_ref_cases: ClassVar[frozenset[IdentifierCase]] = frozenset({IdentifierCase.CAMEL, IdentifierCase.PASCAL, IdentifierCase.SNAKE, IdentifierCase.UPPER_SNAKE})¶
- supports_call_style = True¶
- supports_collection_comments: ClassVar[bool] = True¶
- supports_default_dict_key_type = True¶
- supports_default_dict_value_type = True¶
- supports_default_ordered_map_value_type = True¶
- supports_default_sequence_element_type = True¶
- supports_default_set_element_type = True¶
- supports_dict_literal_as_free_expression = True¶
- supports_dotted_call_stub = True¶
- supports_dotted_calls = True¶
- supports_empty_dict_key = False¶
- supports_inline_multiline_dict_args = True¶
- supports_module_name = False¶
- supports_multi_param_call_wrapper_stub = True¶
- supports_no_variable_wrap_in_file = False¶
- supports_non_string_dict_keys = False¶
- supports_record_shape_names = True¶
- supports_record_struct_name_prefix = True¶
- supports_scalar_before_comments: ClassVar[bool] = False¶
- supports_scalar_inline_comments: ClassVar[bool] = True¶
- supports_special_floats = True¶
- supports_standalone_comments_in_wrapped_calls = True¶
- supports_variable_names = True¶
- supports_zero_parameter_calls = True¶
- trailing_comma: TrailingCommas = TrailingCommaConfig(multiline_trailing_comma=True)¶
- property trailing_comma_config: TrailingCommaConfig¶
Configuration for trailing-comma behavior.
- trailing_commas¶
alias of
TrailingCommas
- true_literal: ClassVar[str] = 'true'¶
- property type_hint_collection_preamble_lines: Callable[[frozenset[type]], tuple[str, ...]]¶
Return preamble lines for empty-collection type hints.
- property validate_call_arg: Callable[[Value], None]¶
Return call-argument validation for this language.
- validate_spec_for_data(data: Value) None¶
Default
validate_spec_for_data— no spec/data constraints.
- variable_type_hints: VariableTypeHints = 1¶
- variable_type_hints_formats¶
alias of
VariableTypeHints
- version_formats¶
alias of
VersionFormats
- wrap_calls_with_declarations(declarations: tuple[str, ...], calls: str, body_preamble: tuple[str, ...]) str¶
Default
wrap_calls_with_declarations— concatenate the declarations and calls and route throughwrap_in_file()in call mode.
- static wrap_combined_in_file(declaration: str, assignment: str, variable_name: str, body_preamble: tuple[str, ...]) str¶
Wrap Go declaration + assignment in
func main().
- static wrap_in_file(content: str, variable_name: str, body_preamble: tuple[str, ...]) str¶
Wrap a Go declaration in
func main().
- class literalizer.languages.Groovy(*args: object, **kwargs: object)¶
Groovy language specification.
- class BoolFormats(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
Empty: this language has no alternative boolean formats.
- class BytesFormats(*values)¶
Bytes formatting options.
- BASE64 = <function format_bytes_base64>¶
- HEX = <function format_bytes_hex>¶
- class CallStyles(*values)¶
Groovy call style options.
- KEYWORD = KeywordCallStyle(separator=': ')¶
- POSITIONAL = PositionalCallStyle(arg_separator=', ', parenthesize_each_arg=False)¶
- class CommentFormats(*values)¶
Comment style options.
- BLOCK = CommentConfig(prefix='/*', suffix=' */')¶
- DOUBLE_SLASH = CommentConfig(prefix='//', suffix='')¶
- class DateFormats(*values)¶
Date format options for Groovy.
- ISO = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- class DatetimeFormats(*values)¶
Datetime format options for Groovy.
- EPOCH = DatetimeFormatConfig(formatter=<function format_datetime_epoch>, preamble_lines=(), type_produced=<class 'int'>)¶
- ISO = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- class DeclarationStyles(*values)¶
Declaration style options.
- DEF = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=True)¶
- class FloatFormats(*values)¶
Float format options.
- FIXED = <function format_float_fixed>¶
- REPR = <function format_float_repr>¶
- SCIENTIFIC = <function format_float_scientific>¶
- class HeterogeneousStrategies(*values)¶
Heterogeneous-scalar strategy options — this language only supports raising.
- ERROR = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)¶
- class JsonTypes(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
Empty: this language has no JSON value-type variants.
- class Modifiers(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
C++/Java/C#-style declaration modifiers: this language has none.
- class SequenceFormats(*values)¶
Sequence type options for Groovy.
- LIST = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=']', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)¶
- class SetFormats(*values)¶
Set type options for Groovy.
- SET = <function set_format_factory.<locals>._build>¶
- class TrailingCommas(*values)¶
Trailing comma options.
- NO = TrailingCommaConfig(multiline_trailing_comma=False)¶
- YES = TrailingCommaConfig(multiline_trailing_comma=True)¶
- allows_empty_call_parens = True¶
- bool_formats¶
alias of
BoolFormats
- bytes_format: BytesFormats = <function format_bytes_hex>¶
- bytes_formats¶
alias of
BytesFormats
- property call_data_dependent_preamble: Callable[[Value], tuple[str, ...]]¶
Return data-dependent preamble lines for call rendering.
- call_returns_expression = True¶
- call_style: CallStyles = KeywordCallStyle(separator=': ')¶
- property call_style_config: PositionalCallStyle | KeywordCallStyle | ObjectCallStyle | PostfixCallStyle | PrefixCallStyle | CommandCallStyle¶
Configuration for the chosen call style.
- call_styles¶
alias of
CallStyles
- property comment_config: CommentConfig¶
Configuration for the language’s comment syntax.
- comment_format: CommentFormats = CommentConfig(prefix='//', suffix='')¶
- comment_formats¶
alias of
CommentFormats
- property compute_body_preamble: Callable[[frozenset[type], Value], tuple[str, ...]]¶
Compute body-preamble lines from the scalar map.
- property consumable_ref_value_inhibits_consuming_form: Callable[[Value], bool]¶
Predicate deciding whether a ref’s underlying value type inhibits the consume form.
Delegates to
never_inhibits_consuming_form. Languages whose consume operator rejects certain value types (notably the Mojo^on register-trivial scalars) override this.
- property data_dependent_preamble: Callable[[Value], tuple[str, ...]]¶
Return data-dependent preamble lines.
- date_format: DateFormats = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- date_formats¶
alias of
DateFormats
- datetime_format: DatetimeFormats = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- datetime_formats¶
alias of
DatetimeFormats
- declaration_style: DeclarationStyles = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=True)¶
- declaration_styles¶
alias of
DeclarationStyles
- default_set_element_type: str = 'Object'¶
- dict_entry_style: DictEntryStyles = 1¶
- dict_entry_styles¶
alias of
DictEntryStyles
- dict_format: DictFormats = 1¶
- property dict_format_config: DictFormatConfig¶
Configuration for dict formatting.
- dict_formats¶
alias of
DictFormats
- dict_supports_heterogeneous_values = True¶
- element_separator: ClassVar[str] = ', '¶
- empty_dict_keys¶
alias of
EmptyDictKey
- extension = '.groovy'¶
- false_literal: ClassVar[str] = 'false'¶
- float_format: FloatFormats = <function format_float_repr>¶
- float_formats¶
alias of
FloatFormats
- property format_bytes: Callable[[bytes], str]¶
Callable that formats a bytes value as a string literal.
- static format_call_arg(_value: Value, formatted: str, /) str¶
Callable that rewrites a formatted direct call argument.
- property format_call_arg_ref_identifier: Callable[[str, Value | None], str]¶
Rewrite a
{"$ref": "name"}identifier in a call-argument context.Delegates to
format_call_ref_identifier. Override this to allow call-argument$refvalues that would otherwise be rejected.
- property format_call_arg_ref_identifier_consumable: Callable[[str, Value | None], str]¶
Format a
$refthe caller authorized as consumable.Delegates to
format_call_arg_ref_identifier. Override this to opt into a consuming form (e.g. C++std::move).
- format_call_binding_body_preamble() tuple[str, ...]¶
Default
format_call_binding_body_preamble– no extra body preamble lines for an inference-bound call result.
- format_call_binding_file_pragmas() tuple[str, ...]¶
Default
format_call_binding_file_pragmas– no file-level compiler-pragma line for an inference-bound call result.
- property format_call_preamble_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]¶
Return file-scope stubs for a call expression.
- property format_call_ref_identifier: Callable[[str, Value | None], str]¶
Rewrite a
{"$ref": "name"}identifier into the language’s call expression syntax.
- property format_call_statement: Callable[[str], str]¶
Return call-statement formatting for this language.
- property format_call_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]¶
Return stub declarations for a call expression.
- property format_call_target: Callable[[Sequence[str]], str]¶
Rewrite a dotted call target into the language’s call syntax.
- property format_call_variable_assignment: Callable[[str, str, Value], str]¶
Default
format_call_variable_assignment– reuse the literal-binding assignment formatter unchanged.
- property format_call_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]¶
Default
format_call_variable_declaration– reuse the literal-binding declaration formatter unchanged.
- static format_constructor_target(class_name: str, /) str¶
Return a
new ClassNameconstructor call target.
- property format_date: Callable[[date], str]¶
Callable that formats a date as a string literal.
- property format_datetime: Callable[[datetime], str]¶
Callable that formats a datetime as a string literal.
- property format_float: Callable[[float], str]¶
Callable that formats a float value as a literal.
- property format_integer: Callable[[int], str]¶
Format an int value as a literal.
- property format_integer_widened: None¶
Default
format_integer_widened– no mixed-magnitude integer widening, so the renderer keeps the normal integer formatter.
- property format_ordered_map_entry: Callable[[str, Value, str], str]¶
Callable that formats one ordered-map entry.
- property format_sequence_entry: Callable[[Value, str], str]¶
Format a sequence entry.
- property format_set_entry: Callable[[Value, str], str]¶
Format a set entry.
- property format_string: Callable[[str], str]¶
Format a string value as a quoted literal.
- property format_time: Callable[[time], str]¶
Callable that formats a time as a string literal.
- property format_variable_assignment: Callable[[str, str, Value], str]¶
Callable that formats an assignment to an existing variable.
- property format_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]¶
Callable that formats a new variable declaration.
- has_free_function_calls = True¶
- property heterogeneous_behavior: HeterogeneousBehavior¶
Return the heterogeneous-behavior config.
- heterogeneous_strategies¶
alias of
HeterogeneousStrategies
- heterogeneous_strategy: HeterogeneousStrategies = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)¶
- identifier_cases: ClassVar[tuple[IdentifierCase, ...]] = (IdentifierCase.CAMEL, IdentifierCase.PASCAL, IdentifierCase.UPPER_SNAKE)¶
- indent: str = ' '¶
- indent_closing_delimiter: ClassVar[bool] = False¶
- integer_format: IntegerFormats = 1¶
- integer_formats¶
alias of
IntegerFormats
- integer_width_strategies¶
alias of
BareIntegerWidthStrategies
- integer_width_strategy: BareIntegerWidthStrategies = 1¶
- language_version: VersionFormats = 1¶
- property leading_preamble: LeadingPreamble¶
Default
leading_preamble– no preamble lines that must precedeLanguage.static_preamble.
- max_call_parameters = 9223372036854775807¶
- modifier_combinations: ClassVar[tuple[ModifierCombination, ...]] = ()¶
- null_literal: ClassVar[str] = 'null'¶
- numeric_literal_suffix: NumericLiteralSuffixes = 1¶
- numeric_literal_suffixes¶
alias of
NumericLiteralSuffixes
- numeric_separator: NumericSeparators = 1¶
- numeric_separators¶
alias of
NumericSeparators
- numeric_style: NumericStyles = 1¶
- numeric_styles¶
alias of
NumericStyles
- property ordered_map_format_config: OrderedMapFormatConfig¶
Configuration for ordered-map formatting.
- pygments_name = 'groovy'¶
- reserved_identifiers: ClassVar[frozenset[str]] = frozenset({})¶
- property scalar_body_preamble: dict[type, tuple[str, ...]]¶
Per-instance scalar body preamble (Groovy needs none).
- property scalar_preamble: dict[type, tuple[str, ...]]¶
Per-instance scalar preamble.
- sequence_binding_declarations(declarations: tuple[str, ...]) str¶
Default
sequence_binding_declarations– join the per-binding snippets with newlines.
- sequence_format: SequenceFormats = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=']', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)¶
- property sequence_format_config: SequenceFormatConfig¶
Configuration for the chosen sequence format.
- sequence_formats¶
alias of
SequenceFormats
- property sequence_open: Callable[[list[Value]], str]¶
Callable that returns the opening delimiter for a sequence.
- set_format: SetFormats = <function set_format_factory.<locals>._build>¶
- property set_format_config: SetFormatConfig¶
Configuration for the chosen set format.
- set_formats¶
alias of
SetFormats
- skip_null_dict_values: ClassVar[bool] = False¶
- special_float_preamble: ClassVar[tuple[str, ...]] = ()¶
- statement_terminator: ClassVar[str] = ''¶
- statement_terminator_style: StatementTerminatorStyles = 1¶
- statement_terminator_styles¶
alias of
StatementTerminatorStyles
- static_body_preamble: ClassVar[Sequence[str]] = ()¶
- static_preamble: ClassVar[Sequence[str]] = ()¶
- string_format: StringFormats = 1¶
- string_formats¶
alias of
StringFormats
- supported_ref_cases: ClassVar[frozenset[IdentifierCase]] = frozenset({IdentifierCase.CAMEL, IdentifierCase.PASCAL, IdentifierCase.SNAKE, IdentifierCase.UPPER_SNAKE})¶
- supports_call_style = True¶
- supports_collection_comments: ClassVar[bool] = True¶
- supports_default_dict_key_type = False¶
- supports_default_dict_value_type = False¶
- supports_default_ordered_map_value_type = False¶
- supports_default_sequence_element_type = False¶
- supports_default_set_element_type = True¶
- supports_dict_literal_as_free_expression = True¶
- supports_dotted_call_stub = True¶
- supports_dotted_calls = True¶
- supports_empty_dict_key = False¶
- supports_inline_multiline_dict_args = True¶
- supports_module_name = False¶
- supports_multi_param_call_wrapper_stub = False¶
- supports_no_variable_wrap_in_file = True¶
- supports_non_string_dict_keys = True¶
- supports_record_shape_names = False¶
- supports_record_struct_name_prefix = False¶
- supports_scalar_before_comments: ClassVar[bool] = True¶
- supports_scalar_inline_comments: ClassVar[bool] = True¶
- supports_special_floats = True¶
- supports_standalone_comments_in_wrapped_calls = True¶
- supports_variable_names = True¶
- supports_zero_parameter_calls = True¶
- trailing_comma: TrailingCommas = TrailingCommaConfig(multiline_trailing_comma=True)¶
- property trailing_comma_config: TrailingCommaConfig¶
Configuration for trailing-comma behavior.
- trailing_commas¶
alias of
TrailingCommas
- true_literal: ClassVar[str] = 'true'¶
- property type_hint_collection_preamble_lines: Callable[[frozenset[type]], tuple[str, ...]]¶
Return preamble lines for empty-collection type hints.
- property validate_call_arg: Callable[[Value], None]¶
Return call-argument validation for this language.
- validate_spec_for_data(data: Value) None¶
Default
validate_spec_for_data— no spec/data constraints.
- variable_type_hints: VariableTypeHints = 1¶
- variable_type_hints_formats¶
alias of
VariableTypeHints
- version_formats¶
alias of
VersionFormats
- wrap_calls_with_declarations(declarations: tuple[str, ...], calls: str, body_preamble: tuple[str, ...]) str¶
Default
wrap_calls_with_declarations— concatenate the declarations and calls and route throughwrap_in_file()in call mode.
- static wrap_combined_in_file(declaration: str, assignment: str, variable_name: str, body_preamble: tuple[str, ...]) str¶
Wrap declaration and assignment in a valid file (no-op).
- static wrap_in_file(content: str, variable_name: str, body_preamble: tuple[str, ...]) str¶
Wrap code in a valid file (no-op).
- class literalizer.languages.Haskell(*args: object, **kwargs: object)¶
Haskell language specification.
The generated output uses custom constructors (
HNull,HBool,HList,HMap,HSet) that are not built-in Haskell types. To compile the generated code, define aValADT and typeclass instances in the consuming module:data Val = HNull | HBool Bool | HInt Integer | HFloat Double | HStr String | HList [Val] | HMap [(String, Val)] | HSet [Val] instance Num Val where fromInteger = HInt negate (HInt n) = HInt (negate n) negate (HFloat f) = HFloat (negate f) ... instance Fractional Val where fromRational r = HFloat (realToFrac r) ...
The
Num/Fractionalinstances let numeric literals resolve toHInt/HFloat.With the default
EXPLICITstring format, strings are wrapped explicitly (e.g.HStr "hi"). TheDOUBLEformat instead usesOverloadedStringsso bare"hi"literals resolve toHStr "hi"via anIsStringinstance.- Parameters:
date_format –
How to format
datetime.datevalues.date_formats.HASKELL—fromGregoriancall, e.g.fromGregorian 2024 1 15. Requires thetimepackage.date_formats.ISO— ISO 8601 quoted string, e.g."2024-01-15".
datetime_format –
How to format
datetime.datetimevalues.datetime_formats.HASKELL—UTCTimeconstructor, e.g.UTCTime (fromGregorian 2024 1 15) (secondsToDiffTime 45000). Requires thetimepackage.datetime_formats.ISO— ISO 8601 quoted string, e.g."2024-01-15T12:30:00".
type_name – Name of the generated custom type. Defaults to
"Val".constructor_prefix – Prefix for generated constructor names. Defaults to
"H", producing constructors likeHNull,HBool,HInt, etc.numeric_style –
How numeric literals are represented.
numeric_styles.OVERLOADED— emitNumandFractionaltypeclass instances so that bare literals like42and3.14resolve to the custom type.numeric_styles.EXPLICIT— wrap every numeric literal with its constructor (HInt 42,HFloat (3.14)) and omit the typeclass instances.
json_type – When set to
json_types.AESON_VALUE, render values through theaesonQQquasi-quote bracket fromData.Aeson.QQso the output produces aData.Aeson.Valueinstead of Haskell’s narrow customValalgebraic type. Dict keys must be strings so they remain valid JSON object keys.
- class BoolFormats(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
Empty: this language has no alternative boolean formats.
- class BytesFormats(*values)¶
Bytes formatting options.
- BASE64 = <function format_bytes_base64>¶
- HEX = <function format_bytes_hex>¶
- class CallStyles(*values)¶
Haskell call style options.
- CURRIED = CommandCallStyle(arg_separator=' ')¶
- POSITIONAL = PositionalCallStyle(arg_separator=', ', parenthesize_each_arg=False)¶
- class CommentFormats(*values)¶
Comment style options.
- BLOCK = CommentConfig(prefix='{-', suffix=' -}')¶
- DOUBLE_DASH = CommentConfig(prefix='--', suffix='')¶
- class DateFormats(*values)¶
Date format options for Haskell.
- HASKELL = DateFormatConfig(formatter=<function date_ymd_formatter.<locals>._format>, preamble_lines=(), type_produced=<class 'datetime.date'>)¶
- ISO = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=('{-# LANGUAGE OverloadedStrings #-}',), type_produced=<class 'str'>)¶
- class DatetimeFormats(*values)¶
Datetime format options for Haskell.
- EPOCH = DatetimeFormatConfig(formatter=<function format_datetime_epoch>, preamble_lines=(), type_produced=<class 'int'>)¶
- HASKELL = DatetimeFormatConfig(formatter=<function _build_haskell_datetime_formatter.<locals>._format>, preamble_lines=(), type_produced=<class 'datetime.datetime'>)¶
- ISO = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=('{-# LANGUAGE OverloadedStrings #-}',), type_produced=<class 'str'>)¶
- class DeclarationStyles(*values)¶
Declaration style options.
- ASSIGN = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=False)¶
- class FloatFormats(*values)¶
Float format options.
- FIXED = <function format_float_fixed>¶
- REPR = <function format_float_repr>¶
- SCIENTIFIC = <function format_float_scientific>¶
- class HeterogeneousStrategies(*values)¶
Heterogeneous-scalar strategy options — this language only supports raising.
- ERROR = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)¶
- class IntegerFormats(*values)¶
Integer format options.
- BINARY = <function format_integer_binary>¶
- DECIMAL = <class 'str'>¶
- HEX = <function format_integer_hex>¶
- OCTAL = <function format_integer_octal>¶
- class JsonTypes(*values)¶
JSON value type options for Haskell.
- AESON_VALUE = 'Data.Aeson.Value'¶
Data.Aeson.Value— the dynamic JSON value type from theaesonpackage.
- class Modifiers(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
C++/Java/C#-style declaration modifiers: this language has none.
- class NumericStyles(*values)¶
Numeric literal style options.
OVERLOADEDemitsNumandFractionaltypeclass instances so that bare numeric literals (42,3.14) resolve to the custom type viafromInteger/fromRational.EXPLICITwraps every numeric literal with its constructor (HInt 42,HFloat 3.14) and omits the typeclass instances.- EXPLICIT = 2¶
- OVERLOADED = 1¶
- class SequenceFormats(*values)¶
Sequence type options for Haskell.
- LIST = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=']', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type='Val', narrowed_empty_form=None)¶
- TUPLE = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=')', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=False, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)¶
- class SetFormats(*values)¶
Set type options for Haskell.
- SET = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close=']', empty_set=None, preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)¶
- class TrailingCommas(*values)¶
Trailing comma options.
- NO = TrailingCommaConfig(multiline_trailing_comma=False)¶
- allows_empty_call_parens = True¶
- bool_formats¶
alias of
BoolFormats
- bytes_format: BytesFormats = <function format_bytes_hex>¶
- bytes_formats¶
alias of
BytesFormats
- property call_data_dependent_preamble: Callable[[Value], tuple[str, ...]]¶
Return data-dependent preamble lines for call rendering.
- call_returns_expression = True¶
- call_style: CallStyles = CommandCallStyle(arg_separator=' ')¶
- property call_style_config: PositionalCallStyle | KeywordCallStyle | ObjectCallStyle | PostfixCallStyle | PrefixCallStyle | CommandCallStyle¶
Configuration for the chosen call style.
- call_styles¶
alias of
CallStyles
- property comment_config: CommentConfig¶
Configuration for the language’s comment syntax.
- comment_format: CommentFormats = CommentConfig(prefix='--', suffix='')¶
- comment_formats¶
alias of
CommentFormats
- property compute_body_preamble: Callable[[frozenset[type], Value], tuple[str, ...]]¶
Compute body-preamble lines for Haskell data declarations.
Under
json_typethe body preamble is reduced to theData.AesonandData.Aeson.QQimports needed by theaesonQQquasi-quote bracket, so the customValalgebraic type and itsNum/IsStringinstances are not emitted.
- constructor_prefix: str = 'H'¶
- property consumable_ref_value_inhibits_consuming_form: Callable[[Value], bool]¶
Predicate deciding whether a ref’s underlying value type inhibits the consume form.
Delegates to
never_inhibits_consuming_form. Languages whose consume operator rejects certain value types (notably the Mojo^on register-trivial scalars) override this.
- property data_dependent_preamble: Callable[[Value], tuple[str, ...]]¶
Return data-dependent preamble lines.
- date_format: DateFormats = DateFormatConfig(formatter=<function date_ymd_formatter.<locals>._format>, preamble_lines=(), type_produced=<class 'datetime.date'>)¶
- date_formats¶
alias of
DateFormats
- datetime_format: DatetimeFormats = DatetimeFormatConfig(formatter=<function _build_haskell_datetime_formatter.<locals>._format>, preamble_lines=(), type_produced=<class 'datetime.datetime'>)¶
- datetime_formats¶
alias of
DatetimeFormats
- declaration_style: DeclarationStyles = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=False)¶
- declaration_styles¶
alias of
DeclarationStyles
- dict_entry_style: DictEntryStyles = 1¶
- dict_entry_styles¶
alias of
DictEntryStyles
- dict_format: DictFormats = 1¶
- property dict_format_config: DictFormatConfig¶
Configuration for dict formatting.
- dict_formats¶
alias of
DictFormats
- dict_supports_heterogeneous_values = True¶
- element_separator: ClassVar[str] = ', '¶
- empty_dict_keys¶
alias of
EmptyDictKey
- extension = '.hs'¶
- property false_literal: str¶
Literal representing
False.
- float_format: FloatFormats = <function format_float_repr>¶
- float_formats¶
alias of
FloatFormats
- property format_bytes: Callable[[bytes], str]¶
Callable that formats a bytes value as a string literal.
- property format_call_arg: Callable[[Value, str], str]¶
Callable that rewrites a formatted direct call argument.
Curried calls parenthesize each argument so that constructor applications (
HInt 1) are not parsed as additional arguments to the outer call.
- property format_call_arg_ref_identifier: Callable[[str, Value | None], str]¶
Rewrite a
{"$ref": "name"}identifier in a call-argument context.Delegates to
format_call_ref_identifier. Override this to allow call-argument$refvalues that would otherwise be rejected.
- property format_call_arg_ref_identifier_consumable: Callable[[str, Value | None], str]¶
Format a
$refthe caller authorized as consumable.Delegates to
format_call_arg_ref_identifier. Override this to opt into a consuming form (e.g. C++std::move).
- format_call_binding_body_preamble() tuple[str, ...]¶
Default
format_call_binding_body_preamble– no extra body preamble lines for an inference-bound call result.
- static format_call_binding_file_pragmas() tuple[str, ...]¶
File-level pragma emitted alongside a
wrap_in_filescaffold whose top level contains an inference-bound call result.Without an explicit signature the binding trips
-Wmissing-signaturesunder-Wall -Werror; the literalizer cannot synthesize a signature because the call’s return type is not known at render time.
- property format_call_preamble_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]¶
Callable that returns preamble stub declarations.
- property format_call_ref_identifier: Callable[[str, Value | None], str]¶
Rewrite a
{"$ref": "name"}identifier into the language’s call expression syntax.
- property format_call_statement: Callable[[str], str]¶
Return call-statement formatting for this language.
- property format_call_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]¶
Callable that returns Haskell stub declarations for a call.
- property format_call_target: Callable[[Sequence[str]], str]¶
Rewrite a dotted call target into the language’s call syntax.
- property format_call_variable_assignment: Callable[[str, str, Value], str]¶
Default
format_call_variable_assignment– reuse the literal-binding assignment formatter unchanged.
- property format_call_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]¶
Callable that formats a declaration binding a call expression.
The literal-binding declaration is prepended with a
name :: Typeannotation derived from the bound value’s runtime tagged-enum type; a call expression has no such tag, so the annotation is omitted and Haskell infers the call’s return type instead.
- static format_constructor_target(class_name: str, /) str¶
Return class_name as a zero-argument constructor call target.
- property format_date: Callable[[date], str]¶
Callable that formats a date as a string literal.
- property format_datetime: Callable[[datetime], str]¶
Callable that formats a datetime as a string literal.
- property format_float: Callable[[float], str]¶
Callable that formats a float value as a literal.
- property format_integer: Callable[[int], str]¶
Callable that formats an int value as a literal.
- property format_integer_widened: None¶
Default
format_integer_widened– no mixed-magnitude integer widening, so the renderer keeps the normal integer formatter.
- property format_ordered_map_entry: Callable[[str, Value, str], str]¶
Callable that formats one ordered-map entry.
- property format_sequence_entry: Callable[[Value, str], str]¶
Format a sequence entry.
- property format_set_entry: Callable[[Value, str], str]¶
Format a set entry.
- property format_string: Callable[[str], str]¶
Callable that formats a string value as a quoted literal.
- property format_time: Callable[[time], str]¶
Callable that formats a time as a string literal.
- property format_variable_assignment: Callable[[str, str, Value], str]¶
Callable that formats an assignment to an existing variable.
- property format_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]¶
Callable that formats a new variable declaration.
- has_free_function_calls = True¶
- property heterogeneous_behavior: HeterogeneousBehavior¶
Return the heterogeneous-behavior config.
- heterogeneous_strategies¶
alias of
HeterogeneousStrategies
- heterogeneous_strategy: HeterogeneousStrategies = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)¶
- identifier_cases: ClassVar[tuple[IdentifierCase, ...]] = (IdentifierCase.CAMEL, IdentifierCase.PASCAL)¶
- indent: str = ' '¶
- indent_closing_delimiter: ClassVar[bool] = True¶
- integer_format: IntegerFormats = <class 'str'>¶
- integer_formats¶
alias of
IntegerFormats
- integer_width_strategies¶
alias of
BareIntegerWidthStrategies
- integer_width_strategy: BareIntegerWidthStrategies = 1¶
- language_version: VersionFormats = 1¶
- property leading_preamble: LeadingPreamble¶
Default
leading_preamble– no preamble lines that must precedeLanguage.static_preamble.
- max_call_parameters = 9223372036854775807¶
- modifier_combinations: ClassVar[tuple[ModifierCombination, ...]] = ()¶
- module_name: str = 'Check'¶
- module_name_case: ClassVar[IdentifierCase] = 'pascal'¶
- property null_literal: str¶
Literal representing
None.
- numeric_literal_suffix: NumericLiteralSuffixes = 1¶
- numeric_literal_suffixes¶
alias of
NumericLiteralSuffixes
- numeric_separator: NumericSeparators = 1¶
- numeric_separators¶
alias of
NumericSeparators
- numeric_style: NumericStyles = 1¶
- numeric_styles¶
alias of
NumericStyles
- property ordered_map_format_config: OrderedMapFormatConfig¶
Configuration for ordered-map formatting.
- pygments_name = 'haskell'¶
- reserved_identifiers: ClassVar[frozenset[str]] = frozenset({})¶
- property scalar_body_preamble: dict[type, tuple[str, ...]]¶
Per-instance scalar body preamble (Haskell needs none).
- property scalar_preamble: dict[type, tuple[str, ...]]¶
Per-instance scalar preamble for Haskell imports.
Under
json_typeevery temporal value is folded into the JSON text as an ISO-8601 string and every string ships inside that same JSON literal, so the per-scalar Haskell extension directives and imports that the configureddate_format/datetime_formatwould otherwise add do not apply.
- sequence_binding_declarations(declarations: tuple[str, ...]) str¶
Default
sequence_binding_declarations– join the per-binding snippets with newlines.
- sequence_format: SequenceFormats = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=']', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type='Val', narrowed_empty_form=None)¶
- property sequence_format_config: SequenceFormatConfig¶
Configuration for the chosen sequence format.
- sequence_formats¶
alias of
SequenceFormats
- property sequence_open: Callable[[list[Value]], str]¶
Callable that returns the opening delimiter for a sequence.
- set_format: SetFormats = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close=']', empty_set=None, preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)¶
- property set_format_config: SetFormatConfig¶
Configuration for the chosen set format.
- set_formats¶
alias of
SetFormats
- skip_null_dict_values: ClassVar[bool] = False¶
- special_float_preamble: ClassVar[tuple[str, ...]] = ()¶
- statement_terminator: ClassVar[str] = ''¶
- statement_terminator_style: StatementTerminatorStyles = 1¶
- statement_terminator_styles¶
alias of
StatementTerminatorStyles
- static_body_preamble: ClassVar[Sequence[str]] = ()¶
- property static_preamble: Sequence[str]¶
Static preamble lines emitted once per file.
When
json_typeis active theQuasiQuotespragma is emitted here so theaesonQQquasi-quote bracket fromData.Aeson.QQcan parse the inline JSON document into aData.Aeson.Valueat compile time.
- string_format: StringFormats = 2¶
- string_formats¶
alias of
StringFormats
- supported_ref_cases: ClassVar[frozenset[IdentifierCase]] = frozenset({IdentifierCase.CAMEL, IdentifierCase.PASCAL, IdentifierCase.SNAKE, IdentifierCase.UPPER_SNAKE})¶
- supports_call_style = True¶
- supports_collection_comments: ClassVar[bool] = True¶
- supports_default_dict_key_type = False¶
- supports_default_dict_value_type = False¶
- supports_default_ordered_map_value_type = False¶
- supports_default_sequence_element_type = False¶
- supports_default_set_element_type = False¶
- supports_dict_literal_as_free_expression = True¶
- supports_dotted_call_stub = False¶
- supports_dotted_calls = True¶
- supports_empty_dict_key = False¶
- supports_inline_multiline_dict_args = True¶
- supports_module_name = True¶
- supports_multi_param_call_wrapper_stub = True¶
- supports_no_variable_wrap_in_file = False¶
- supports_non_string_dict_keys = False¶
- supports_record_shape_names = False¶
- supports_record_struct_name_prefix = False¶
- supports_scalar_before_comments: ClassVar[bool] = False¶
- supports_scalar_inline_comments: ClassVar[bool] = True¶
- supports_special_floats = True¶
- supports_standalone_comments_in_wrapped_calls = False¶
- supports_variable_names = True¶
- supports_zero_parameter_calls = True¶
- trailing_comma: TrailingCommas = TrailingCommaConfig(multiline_trailing_comma=False)¶
- property trailing_comma_config: TrailingCommaConfig¶
Configuration for trailing-comma behavior.
- trailing_commas¶
alias of
TrailingCommas
- property true_literal: str¶
Literal representing
True.
- property type_hint_collection_preamble_lines: Callable[[frozenset[type]], tuple[str, ...]]¶
Return preamble lines for empty-collection type hints.
- type_name: str = 'Val'¶
- property validate_call_arg: Callable[[Value], None]¶
Return call-argument validation for this language.
- validate_spec_for_data(data: Value) None¶
Default
validate_spec_for_data— no spec/data constraints.
- variable_type_hints: VariableTypeHints = 1¶
- variable_type_hints_formats¶
alias of
VariableTypeHints
- version_formats¶
alias of
VersionFormats
- wrap_calls_with_declarations(declarations: tuple[str, ...], calls: str, body_preamble: tuple[str, ...]) str¶
Wrap a sequence of top-level declarations alongside a block of bare call expressions.
Top-level
name :: Type/name = valuebindings stay at module scope and only the calls go insidemain = do. The integration harness pairs each$refdeclaration’sbare_codewith a downstream call and uses this hook to avoid concatenating both halves into onecontentstring, which would otherwise force the bindings into ado-block where they would needletinjection.
- static wrap_combined_in_file(declaration: str, assignment: str, variable_name: str, body_preamble: tuple[str, ...]) str¶
Unsupported: literalize() rejects BothVariableForms upstream.
- wrap_in_file(content: str, variable_name: str, body_preamble: tuple[str, ...]) str¶
Wrap a Haskell variable binding in a module.
- class literalizer.languages.Haxe(*args: object, **kwargs: object)¶
Haxe language specification.
- Parameters:
date_format –
How to format
datetime.datevalues.date_formats.ISO— ISO 8601 quoted string, e.g."2024-01-15".
datetime_format –
How to format
datetime.datetimevalues.datetime_formats.ISO— ISO 8601 quoted string, e.g."2024-01-15T12:30:00".datetime_formats.EPOCH— Unix timestamp integer.
- class BoolFormats(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
Empty: this language has no alternative boolean formats.
- class BytesFormats(*values)¶
Bytes formatting options.
- BASE64 = <function format_bytes_base64>¶
- HEX = <function format_bytes_hex>¶
- class CallStyles(*values)¶
Haxe call style options.
- POSITIONAL = PositionalCallStyle(arg_separator=', ', parenthesize_each_arg=False)¶
- class CommentFormats(*values)¶
Comment style options.
- BLOCK = CommentConfig(prefix='/*', suffix=' */')¶
- DOUBLE_SLASH = CommentConfig(prefix='//', suffix='')¶
- class DateFormats(*values)¶
Date formatting options for Haxe.
- ISO = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- class DatetimeFormats(*values)¶
Datetime formatting options for Haxe.
- EPOCH = DatetimeFormatConfig(formatter=<function format_datetime_epoch>, preamble_lines=(), type_produced=<class 'int'>)¶
- ISO = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- class DeclarationStyles(*values)¶
Declaration style options.
- FINAL = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=False)¶
- VAR = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=False)¶
- class FloatFormats(*values)¶
Float format options.
- FIXED = <function format_float_fixed>¶
- REPR = <function format_float_repr>¶
- SCIENTIFIC = <function format_float_scientific>¶
- class HeterogeneousStrategies(*values)¶
Heterogeneous-scalar strategy options — this language only supports raising.
- ERROR = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)¶
- class IntegerFormats(*values)¶
Integer format options.
- DECIMAL = <class 'str'>¶
- HEX = <function format_integer_hex>¶
- class JsonTypes(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
Empty: this language has no JSON value-type variants.
- class Modifiers(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
C++/Java/C#-style declaration modifiers: this language has none.
- class SequenceFormats(*values)¶
Sequence type options for Haxe.
- ARRAY = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close='] : Array<Dynamic>)', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)¶
- class SetFormats(*values)¶
Set type options for Haxe.
Haxe has no native set literal, so a set is rendered as a type-annotated
Arrayliteral.- SET = <function set_format_factory.<locals>._build>¶
- class StringFormats(*values)¶
String format options.
Only double-quoted strings are emitted: Haxe performs string interpolation in single-quoted strings, so double quotes give a literal
$with no escaping.- DOUBLE = <function _build_backslash_formatter.<locals>._format>¶
- class TrailingCommas(*values)¶
Trailing comma options.
- NO = TrailingCommaConfig(multiline_trailing_comma=False)¶
- YES = TrailingCommaConfig(multiline_trailing_comma=True)¶
- class VariableTypeHints(*values)¶
Variable type hint options.
- ALWAYS = 2¶
- NEVER = 1¶
- SAFE = 3¶
- formatter(*, auto_formatter: Callable[[str, str, Value, frozenset[Enum]], str], keyword: str) Callable[[str, str, Value, frozenset[Enum]], str]¶
Return the variable declaration formatter.
Collection literals already carry an explicit type cast, so
NEVERandSAFEneed no annotation;ALWAYSadds a redundant-but-valid annotation.
- allows_empty_call_parens = True¶
- bool_formats¶
alias of
BoolFormats
- bytes_format: BytesFormats = <function format_bytes_hex>¶
- bytes_formats¶
alias of
BytesFormats
- property call_data_dependent_preamble: Callable[[Value], tuple[str, ...]]¶
Return data-dependent preamble lines for call rendering.
- call_returns_expression = True¶
- call_style: CallStyles = PositionalCallStyle(arg_separator=', ', parenthesize_each_arg=False)¶
- property call_style_config: PositionalCallStyle | KeywordCallStyle | ObjectCallStyle | PostfixCallStyle | PrefixCallStyle | CommandCallStyle¶
Configuration for the chosen call style.
- call_styles¶
alias of
CallStyles
- property comment_config: CommentConfig¶
Configuration for the language’s comment syntax.
- comment_format: CommentFormats = CommentConfig(prefix='//', suffix='')¶
- comment_formats¶
alias of
CommentFormats
- property compute_body_preamble: Callable[[frozenset[type], Value], tuple[str, ...]]¶
Compute body-preamble lines from the scalar map.
- property consumable_ref_value_inhibits_consuming_form: Callable[[Value], bool]¶
Predicate deciding whether a ref’s underlying value type inhibits the consume form.
- property data_dependent_preamble: Callable[[Value], tuple[str, ...]]¶
Return data-dependent preamble lines.
- date_format: DateFormats = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- date_formats¶
alias of
DateFormats
- datetime_format: DatetimeFormats = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- datetime_formats¶
alias of
DatetimeFormats
- declaration_style: DeclarationStyles = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=False)¶
- declaration_styles¶
alias of
DeclarationStyles
- default_dict_key_type: str = 'String'¶
- default_dict_value_type: str = 'Dynamic'¶
- default_set_element_type: str = 'Dynamic'¶
- dict_entry_style: DictEntryStyles = 1¶
- dict_entry_styles¶
alias of
DictEntryStyles
- dict_format: DictFormats = 1¶
- property dict_format_config: DictFormatConfig¶
Configuration for dict formatting.
- dict_formats¶
alias of
DictFormats
- dict_supports_heterogeneous_values = True¶
- element_separator: ClassVar[str] = ', '¶
- empty_dict_keys¶
alias of
EmptyDictKey
- extension = '.hx'¶
- false_literal: ClassVar[str] = 'false'¶
- float_format: FloatFormats = <function format_float_repr>¶
- float_formats¶
alias of
FloatFormats
- property format_bytes: Callable[[bytes], str]¶
Callable that formats a bytes value as a string literal.
- static format_call_arg(_value: Value, formatted: str, /) str¶
Callable that rewrites a formatted direct call argument.
- property format_call_arg_ref_identifier: Callable[[str, Value | None], str]¶
Rewrite a
{"$ref": "name"}identifier in a call-argument context.
- property format_call_arg_ref_identifier_consumable: Callable[[str, Value | None], str]¶
Format a
$refthe caller authorized as consumable.
- format_call_binding_body_preamble() tuple[str, ...]¶
Default
format_call_binding_body_preamble– no extra body preamble lines for an inference-bound call result.
- format_call_binding_file_pragmas() tuple[str, ...]¶
Default
format_call_binding_file_pragmas– no file-level compiler-pragma line for an inference-bound call result.
- property format_call_preamble_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]¶
Return file-scope stubs for a call expression.
- property format_call_ref_identifier: Callable[[str, Value | None], str]¶
Rewrite a
{"$ref": "name"}identifier into the language’s call expression syntax.
- property format_call_statement: Callable[[str], str]¶
Return call-statement formatting for this language.
- property format_call_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]¶
Return stub declarations for a call expression.
- property format_call_target: Callable[[Sequence[str]], str]¶
Rewrite a dotted call target into the language’s call syntax.
- property format_call_variable_assignment: Callable[[str, str, Value], str]¶
Default
format_call_variable_assignment– reuse the literal-binding assignment formatter unchanged.
- property format_call_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]¶
Default
format_call_variable_declaration– reuse the literal-binding declaration formatter unchanged.
- static format_constructor_target(class_name: str, /) str¶
Return a
new ClassNameconstructor call target.
- property format_date: Callable[[date], str]¶
Callable that formats a date as a string literal.
- property format_datetime: Callable[[datetime], str]¶
Callable that formats a datetime as a string literal.
- property format_float: Callable[[float], str]¶
Callable that formats a float value as a literal.
- property format_integer: Callable[[int], str]¶
Callable that formats an int value as a literal.
- property format_integer_widened: None¶
Default
format_integer_widened– no mixed-magnitude integer widening, so the renderer keeps the normal integer formatter.
- property format_ordered_map_entry: Callable[[str, Value, str], str]¶
Format one ordered-map entry.
- property format_sequence_entry: Callable[[Value, str], str]¶
Format a sequence entry.
- property format_set_entry: Callable[[Value, str], str]¶
Format a set entry.
- property format_string: Callable[[str], str]¶
Callable that formats a string value as a quoted literal.
- property format_time: Callable[[time], str]¶
Callable that formats a time as a string literal.
- property format_variable_assignment: Callable[[str, str, Value], str]¶
Format an assignment to an existing variable.
- property format_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]¶
Callable that formats a new variable declaration.
- has_free_function_calls = True¶
- property heterogeneous_behavior: HeterogeneousBehavior¶
Return the heterogeneous-behavior config.
- heterogeneous_strategies¶
alias of
HeterogeneousStrategies
- heterogeneous_strategy: HeterogeneousStrategies = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)¶
- identifier_cases: ClassVar[tuple[IdentifierCase, ...]] = (IdentifierCase.CAMEL, IdentifierCase.PASCAL, IdentifierCase.UPPER_SNAKE)¶
- indent: str = ' '¶
- indent_closing_delimiter: ClassVar[bool] = False¶
- integer_format: IntegerFormats = <class 'str'>¶
- integer_formats¶
alias of
IntegerFormats
- integer_width_strategies¶
alias of
BareIntegerWidthStrategies
- integer_width_strategy: BareIntegerWidthStrategies = 1¶
- language_version: VersionFormats = 1¶
- property leading_preamble: LeadingPreamble¶
Default
leading_preamble– no preamble lines that must precedeLanguage.static_preamble.
- max_call_parameters = 9223372036854775807¶
- modifier_combinations: ClassVar[tuple[ModifierCombination, ...]] = ()¶
- module_name: str = 'Main'¶
- module_name_case: ClassVar[IdentifierCase] = 'pascal'¶
- null_literal: ClassVar[str] = 'null'¶
- numeric_literal_suffix: NumericLiteralSuffixes = 1¶
- numeric_literal_suffixes¶
alias of
NumericLiteralSuffixes
- numeric_separator: NumericSeparators = 1¶
- numeric_separators¶
alias of
NumericSeparators
- numeric_style: NumericStyles = 1¶
- numeric_styles¶
alias of
NumericStyles
- property ordered_map_format_config: OrderedMapFormatConfig¶
Configuration for ordered-map formatting.
- pygments_name = 'haxe'¶
- reserved_identifiers: ClassVar[frozenset[str]] = frozenset({'abstract', 'break', 'case', 'cast', 'catch', 'class', 'continue', 'default', 'do', 'dynamic', 'else', 'enum', 'extends', 'extern', 'false', 'final', 'for', 'function', 'if', 'implements', 'import', 'in', 'inline', 'interface', 'macro', 'new', 'null', 'operator', 'overload', 'override', 'package', 'private', 'public', 'return', 'static', 'switch', 'this', 'throw', 'true', 'try', 'typedef', 'untyped', 'using', 'var', 'while'})¶
- property scalar_body_preamble: dict[type, tuple[str, ...]]¶
Per-instance scalar body preamble (Haxe needs none).
- property scalar_preamble: dict[type, tuple[str, ...]]¶
Per-instance scalar preamble (Haxe needs none).
- sequence_binding_declarations(declarations: tuple[str, ...]) str¶
Default
sequence_binding_declarations– join the per-binding snippets with newlines.
- sequence_format: SequenceFormats = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close='] : Array<Dynamic>)', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)¶
- property sequence_format_config: SequenceFormatConfig¶
Configuration for the chosen sequence format.
- sequence_formats¶
alias of
SequenceFormats
- property sequence_open: Callable[[list[Value]], str]¶
Callable that returns the opening delimiter for a sequence.
- set_format: SetFormats = <function set_format_factory.<locals>._build>¶
- property set_format_config: SetFormatConfig¶
Configuration for the chosen set format.
- set_formats¶
alias of
SetFormats
- skip_null_dict_values: ClassVar[bool] = False¶
- special_float_preamble: ClassVar[tuple[str, ...]] = ()¶
- statement_terminator: ClassVar[str] = ';'¶
- statement_terminator_style: StatementTerminatorStyles = 1¶
- statement_terminator_styles¶
alias of
StatementTerminatorStyles
- static_body_preamble: ClassVar[Sequence[str]] = ()¶
- static_preamble: ClassVar[Sequence[str]] = ()¶
- string_format: StringFormats = <function _build_backslash_formatter.<locals>._format>¶
- string_formats¶
alias of
StringFormats
- supported_ref_cases: ClassVar[frozenset[IdentifierCase]] = frozenset({IdentifierCase.CAMEL, IdentifierCase.PASCAL, IdentifierCase.SNAKE, IdentifierCase.UPPER_SNAKE})¶
- supports_call_style = True¶
- supports_collection_comments: ClassVar[bool] = True¶
- supports_default_dict_key_type = False¶
- supports_default_dict_value_type = False¶
- supports_default_ordered_map_value_type = False¶
- supports_default_sequence_element_type = False¶
- supports_default_set_element_type = False¶
- supports_dict_literal_as_free_expression = True¶
- supports_dotted_call_stub = True¶
- supports_dotted_calls = True¶
- supports_empty_dict_key = False¶
- supports_inline_multiline_dict_args = True¶
- supports_module_name = True¶
- supports_multi_param_call_wrapper_stub = True¶
- supports_no_variable_wrap_in_file = False¶
- supports_non_string_dict_keys = False¶
- supports_record_shape_names = False¶
- supports_record_struct_name_prefix = False¶
- supports_scalar_before_comments: ClassVar[bool] = True¶
- supports_scalar_inline_comments: ClassVar[bool] = False¶
- supports_special_floats = True¶
- supports_standalone_comments_in_wrapped_calls = True¶
- supports_variable_names = True¶
- supports_zero_parameter_calls = True¶
- trailing_comma: TrailingCommas = TrailingCommaConfig(multiline_trailing_comma=True)¶
- property trailing_comma_config: TrailingCommaConfig¶
Configuration for trailing-comma behavior.
- trailing_commas¶
alias of
TrailingCommas
- true_literal: ClassVar[str] = 'true'¶
- property type_hint_collection_preamble_lines: Callable[[frozenset[type]], tuple[str, ...]]¶
Return preamble lines for empty-collection type hints.
- property validate_call_arg: Callable[[Value], None]¶
Return call-argument validation for this language.
- validate_spec_for_data(data: Value) None¶
Default
validate_spec_for_data— no spec/data constraints.
- variable_type_hints: VariableTypeHints = 1¶
- variable_type_hints_formats¶
alias of
VariableTypeHints
- version_formats¶
alias of
VersionFormats
- wrap_calls_with_declarations(declarations: tuple[str, ...], calls: str, body_preamble: tuple[str, ...]) str¶
Default
wrap_calls_with_declarations— concatenate the declarations and calls and route throughwrap_in_file()in call mode.
- static wrap_combined_in_file(declaration: str, assignment: str, variable_name: str, body_preamble: tuple[str, ...]) str¶
Unsupported: literalize() rejects BothVariableForms upstream.
- wrap_in_file(content: str, variable_name: str, body_preamble: tuple[str, ...]) str¶
Wrap code in a valid Haxe file.
Everything (reference declarations, call stubs and the value itself) goes inside
static function main()of a single class. Haxe permits local functions and anonymous-structure closures inside a function body, so call stubs are emitted as local declarations rather than file-scope types.
- class literalizer.languages.Hcl(*args: object, **kwargs: object)¶
HCL (HashiCorp Configuration Language) language specification.
- class BoolFormats(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
Empty: this language has no alternative boolean formats.
- class BytesFormats(*values)¶
Bytes formatting options.
- BASE64 = <function format_bytes_base64>¶
- HEX = <function format_bytes_hex>¶
- class CallStyles(*values)¶
Hcl call style options.
- POSITIONAL = PositionalCallStyle(arg_separator=', ', parenthesize_each_arg=False)¶
- class CommentFormats(*values)¶
Comment style options.
- BLOCK = CommentConfig(prefix='/*', suffix=' */')¶
- HASH = CommentConfig(prefix='#', suffix='')¶
- class DateFormats(*values)¶
Date format options for Hcl.
- ISO = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- class DatetimeFormats(*values)¶
Datetime format options for Hcl.
- EPOCH = DatetimeFormatConfig(formatter=<function format_datetime_epoch>, preamble_lines=(), type_produced=<class 'int'>)¶
- ISO = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- class DeclarationStyles(*values)¶
Declaration style options.
- ASSIGN = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=False)¶
- class FloatFormats(*values)¶
Float format options.
- FIXED = <function format_float_fixed>¶
- REPR = <function format_float_repr>¶
- SCIENTIFIC = <function format_float_scientific>¶
- class HeterogeneousStrategies(*values)¶
Heterogeneous-scalar strategy options — this language only supports raising.
- ERROR = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)¶
- class JsonTypes(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
Empty: this language has no JSON value-type variants.
- class Modifiers(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
C++/Java/C#-style declaration modifiers: this language has none.
- class SequenceFormats(*values)¶
Sequence type options for HCL.
- LIST = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=']', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)¶
- class SetFormats(*values)¶
Set type options for HCL.
- SET = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close=']', empty_set=None, preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)¶
- class TrailingCommas(*values)¶
Trailing comma options.
- YES = TrailingCommaConfig(multiline_trailing_comma=True)¶
- allows_empty_call_parens = True¶
- bool_formats¶
alias of
BoolFormats
- bytes_format: BytesFormats = <function format_bytes_hex>¶
- bytes_formats¶
alias of
BytesFormats
- property call_data_dependent_preamble: Callable[[Value], tuple[str, ...]]¶
Return data-dependent preamble lines for call rendering.
- call_returns_expression = True¶
- call_style: CallStyles = PositionalCallStyle(arg_separator=', ', parenthesize_each_arg=False)¶
- property call_style_config: PositionalCallStyle | KeywordCallStyle | ObjectCallStyle | PostfixCallStyle | PrefixCallStyle | CommandCallStyle¶
Configuration for the chosen call style.
- call_styles¶
alias of
CallStyles
- property comment_config: CommentConfig¶
Configuration for the language’s comment syntax.
- comment_format: CommentFormats = CommentConfig(prefix='#', suffix='')¶
- comment_formats¶
alias of
CommentFormats
- property compute_body_preamble: Callable[[frozenset[type], Value], tuple[str, ...]]¶
Compute body-preamble lines from the scalar map.
- property consumable_ref_value_inhibits_consuming_form: Callable[[Value], bool]¶
Predicate deciding whether a ref’s underlying value type inhibits the consume form.
Delegates to
never_inhibits_consuming_form. Languages whose consume operator rejects certain value types (notably the Mojo^on register-trivial scalars) override this.
- property data_dependent_preamble: Callable[[Value], tuple[str, ...]]¶
Return data-dependent preamble lines.
- date_format: DateFormats = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- date_formats¶
alias of
DateFormats
- datetime_format: DatetimeFormats = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- datetime_formats¶
alias of
DatetimeFormats
- declaration_style: DeclarationStyles = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=False)¶
- declaration_styles¶
alias of
DeclarationStyles
- dict_entry_style: DictEntryStyles = 1¶
- dict_entry_styles¶
alias of
DictEntryStyles
- dict_format: DictFormats = 1¶
- property dict_format_config: DictFormatConfig¶
Configuration for dict formatting.
- dict_formats¶
alias of
DictFormats
- dict_supports_heterogeneous_values = True¶
- element_separator: ClassVar[str] = ', '¶
- empty_dict_keys¶
alias of
EmptyDictKey
- extension = '.hcl'¶
- false_literal: ClassVar[str] = 'false'¶
- float_format: FloatFormats = <function format_float_repr>¶
- float_formats¶
alias of
FloatFormats
- property format_bytes: Callable[[bytes], str]¶
Callable that formats a bytes value as a string literal.
- static format_call_arg(_value: Value, formatted: str, /) str¶
Callable that rewrites a formatted direct call argument.
- property format_call_arg_ref_identifier: Callable[[str, Value | None], str]¶
Rewrite a
{"$ref": "name"}identifier in a call-argument context.Delegates to
format_call_ref_identifier. Override this to allow call-argument$refvalues that would otherwise be rejected.
- property format_call_arg_ref_identifier_consumable: Callable[[str, Value | None], str]¶
Format a
$refthe caller authorized as consumable.Delegates to
format_call_arg_ref_identifier. Override this to opt into a consuming form (e.g. C++std::move).
- format_call_binding_body_preamble() tuple[str, ...]¶
Default
format_call_binding_body_preamble– no extra body preamble lines for an inference-bound call result.
- format_call_binding_file_pragmas() tuple[str, ...]¶
Default
format_call_binding_file_pragmas– no file-level compiler-pragma line for an inference-bound call result.
- property format_call_preamble_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]¶
Return file-scope stubs for a call expression.
- property format_call_ref_identifier: Callable[[str, Value | None], str]¶
Rewrite a
{"$ref": "name"}identifier into the language’s call expression syntax.
- property format_call_statement: Callable[[str], str]¶
Return call-statement formatting for this language.
- property format_call_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]¶
Return stub declarations for a call expression.
- property format_call_target: Callable[[Sequence[str]], str]¶
Rewrite a dotted call target into the language’s call syntax.
- property format_call_variable_assignment: Callable[[str, str, Value], str]¶
Default
format_call_variable_assignment– reuse the literal-binding assignment formatter unchanged.
- property format_call_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]¶
Default
format_call_variable_declaration– reuse the literal-binding declaration formatter unchanged.
- static format_constructor_target(class_name: str, /) str¶
Return class_name as a zero-argument constructor call target.
- property format_date: Callable[[date], str]¶
Callable that formats a date as a string literal.
- property format_datetime: Callable[[datetime], str]¶
Callable that formats a datetime as a string literal.
- property format_float: Callable[[float], str]¶
Callable that formats a float value as a literal.
- property format_integer: Callable[[int], str]¶
Format an int value as a literal.
- property format_integer_widened: None¶
Default
format_integer_widened– no mixed-magnitude integer widening, so the renderer keeps the normal integer formatter.
- property format_ordered_map_entry: Callable[[str, Value, str], str]¶
Callable that formats one ordered-map entry.
- property format_sequence_entry: Callable[[Value, str], str]¶
Format a sequence entry.
- property format_set_entry: Callable[[Value, str], str]¶
Format a set entry.
- property format_string: Callable[[str], str]¶
Format a string value as a quoted literal.
- property format_time: Callable[[time], str]¶
Callable that formats a time as a string literal.
- property format_variable_assignment: Callable[[str, str, Value], str]¶
Callable that formats an assignment to an existing variable.
- property format_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]¶
Callable that formats a new variable declaration.
- has_free_function_calls = True¶
- property heterogeneous_behavior: HeterogeneousBehavior¶
Return the heterogeneous-behavior config.
- heterogeneous_strategies¶
alias of
HeterogeneousStrategies
- heterogeneous_strategy: HeterogeneousStrategies = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)¶
- identifier_cases: ClassVar[tuple[IdentifierCase, ...]] = (IdentifierCase.SNAKE,)¶
- indent: str = ' '¶
- indent_closing_delimiter: ClassVar[bool] = False¶
- integer_format: IntegerFormats = 1¶
- integer_formats¶
alias of
IntegerFormats
- integer_width_strategies¶
alias of
BareIntegerWidthStrategies
- integer_width_strategy: BareIntegerWidthStrategies = 1¶
- language_version: VersionFormats = 1¶
- property leading_preamble: LeadingPreamble¶
Default
leading_preamble– no preamble lines that must precedeLanguage.static_preamble.
- max_call_parameters = 9223372036854775807¶
- modifier_combinations: ClassVar[tuple[ModifierCombination, ...]] = ()¶
- null_literal: ClassVar[str] = 'null'¶
- numeric_literal_suffix: NumericLiteralSuffixes = 1¶
- numeric_literal_suffixes¶
alias of
NumericLiteralSuffixes
- numeric_separator: NumericSeparators = 1¶
- numeric_separators¶
alias of
NumericSeparators
- numeric_style: NumericStyles = 1¶
- numeric_styles¶
alias of
NumericStyles
- property ordered_map_format_config: OrderedMapFormatConfig¶
Configuration for ordered-map formatting.
- pygments_name = 'hcl'¶
- reserved_identifiers: ClassVar[frozenset[str]] = frozenset({})¶
- property scalar_body_preamble: dict[type, tuple[str, ...]]¶
Per-instance scalar body preamble (HCL needs none).
- property scalar_preamble: dict[type, tuple[str, ...]]¶
Per-instance scalar preamble (HCL needs none).
- sequence_binding_declarations(declarations: tuple[str, ...]) str¶
Default
sequence_binding_declarations– join the per-binding snippets with newlines.
- sequence_format: SequenceFormats = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=']', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)¶
- property sequence_format_config: SequenceFormatConfig¶
Configuration for the chosen sequence format.
- sequence_formats¶
alias of
SequenceFormats
- property sequence_open: Callable[[list[Value]], str]¶
Callable that returns the opening delimiter for a sequence.
- set_format: SetFormats = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close=']', empty_set=None, preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)¶
- property set_format_config: SetFormatConfig¶
Configuration for the chosen set format.
- set_formats¶
alias of
SetFormats
- skip_null_dict_values: ClassVar[bool] = False¶
- special_float_preamble: ClassVar[tuple[str, ...]] = ()¶
- statement_terminator: ClassVar[str] = ''¶
- statement_terminator_style: StatementTerminatorStyles = 1¶
- statement_terminator_styles¶
alias of
StatementTerminatorStyles
- static_body_preamble: ClassVar[Sequence[str]] = ()¶
- static_preamble: ClassVar[Sequence[str]] = ()¶
- string_format: StringFormats = 1¶
- string_formats¶
alias of
StringFormats
- supported_ref_cases: ClassVar[frozenset[IdentifierCase]] = frozenset({IdentifierCase.CAMEL, IdentifierCase.PASCAL, IdentifierCase.SNAKE, IdentifierCase.UPPER_SNAKE})¶
- supports_call_style = True¶
- supports_collection_comments: ClassVar[bool] = True¶
- supports_default_dict_key_type = False¶
- supports_default_dict_value_type = False¶
- supports_default_ordered_map_value_type = False¶
- supports_default_sequence_element_type = False¶
- supports_default_set_element_type = False¶
- supports_dict_literal_as_free_expression = True¶
- supports_dotted_call_stub = False¶
- supports_dotted_calls = False¶
- supports_empty_dict_key = False¶
- supports_inline_multiline_dict_args = True¶
- supports_module_name = False¶
- supports_multi_param_call_wrapper_stub = True¶
- supports_no_variable_wrap_in_file = True¶
- supports_non_string_dict_keys = True¶
- supports_record_shape_names = False¶
- supports_record_struct_name_prefix = False¶
- supports_scalar_before_comments: ClassVar[bool] = False¶
- supports_scalar_inline_comments: ClassVar[bool] = True¶
- supports_special_floats = True¶
- supports_standalone_comments_in_wrapped_calls = True¶
- supports_variable_names = True¶
- supports_zero_parameter_calls = True¶
- trailing_comma: TrailingCommas = TrailingCommaConfig(multiline_trailing_comma=True)¶
- property trailing_comma_config: TrailingCommaConfig¶
Configuration for trailing-comma behavior.
- trailing_commas¶
alias of
TrailingCommas
- true_literal: ClassVar[str] = 'true'¶
- property type_hint_collection_preamble_lines: Callable[[frozenset[type]], tuple[str, ...]]¶
Return preamble lines for empty-collection type hints.
- property validate_call_arg: Callable[[Value], None]¶
Return call-argument validation for this language.
- validate_spec_for_data(data: Value) None¶
Default
validate_spec_for_data— no spec/data constraints.
- variable_type_hints: VariableTypeHints = 1¶
- variable_type_hints_formats¶
alias of
VariableTypeHints
- version_formats¶
alias of
VersionFormats
- wrap_calls_with_declarations(declarations: tuple[str, ...], calls: str, body_preamble: tuple[str, ...]) str¶
Default
wrap_calls_with_declarations— concatenate the declarations and calls and route throughwrap_in_file()in call mode.
- static wrap_combined_in_file(declaration: str, assignment: str, variable_name: str, body_preamble: tuple[str, ...]) str¶
Unsupported: literalize() rejects BothVariableForms upstream.
- wrap_in_file(content: str, variable_name: str, body_preamble: tuple[str, ...]) str¶
Wrap code in a valid HCL file.
When variable_name is empty (call rendering), bare function calls are not valid HCL, so each is assigned to a unique local
_N. Top-levelname = valuestatements (including multi-line list/object literals) are already valid HCL and pass through unchanged so a mixed file of variable declarations and calls parses correctly.
- class literalizer.languages.Java(*args: object, **kwargs: object)¶
Java language specification.
- Parameters:
date_format –
How to format
datetime.datevalues.date_formats.JAVA—LocalDate.of(...)call, e.g.LocalDate.of(2024, 1, 15).date_formats.ISO— ISO 8601 quoted string, e.g."2024-01-15".
datetime_format –
How to format
datetime.datetimevalues.datetime_formats.INSTANT—Instant.parse(...)call, e.g.Instant.parse("2024-01-15T12:30:00").datetime_formats.ZONED—ZonedDateTime.of(...)call, e.g.ZonedDateTime.of(2024, 1, 15, 12, 30, 0, 0, ZoneId.of("UTC")).datetime_formats.ISO— ISO 8601 quoted string, e.g."2024-01-15T12:30:00".
sequence_format –
How to format sequences.
sequence_formats.ARRAY— Java array literal, e.g.new Object[]{1, 2, 3}.sequence_formats.LIST—List.of(...)call, e.g.List.of(1, 2, 3).
json_type – When set to
json_types.JACKSON_JSON_NODE, render values through Jackson’sObjectMapper.readTree(...)so the output produces acom.fasterxml.jackson.databind.JsonNodeinstead of Java’s narrowList/Map/ array types.
- class BoolFormats(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
Empty: this language has no alternative boolean formats.
- class BytesFormats(*values)¶
Bytes formatting options.
- BASE64 = <function format_bytes_base64>¶
- HEX = <function format_bytes_hex>¶
- class CallStyles(*values)¶
Java call style options.
- POSITIONAL = PositionalCallStyle(arg_separator=', ', parenthesize_each_arg=False)¶
- class CommentFormats(*values)¶
Comment style options.
- BLOCK = CommentConfig(prefix='/*', suffix=' */')¶
- DOUBLE_SLASH = CommentConfig(prefix='//', suffix='')¶
- class DateFormats(*values)¶
Date formatting options for Java.
- ISO = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- JAVA = DateFormatConfig(formatter=<function date_ymd_formatter.<locals>._format>, preamble_lines=('import java.time.LocalDate;',), type_produced=<class 'datetime.date'>)¶
- class DatetimeFormats(*values)¶
Datetime formatting options for Java.
- EPOCH = DatetimeFormatConfig(formatter=<function format_datetime_epoch>, preamble_lines=(), type_produced=<class 'int'>)¶
- INSTANT = DatetimeFormatConfig(formatter=<function _format_datetime_java_instant>, preamble_lines=('import java.time.Instant;',), type_produced=<class 'datetime.datetime'>)¶
- ISO = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- ZONED = DatetimeFormatConfig(formatter=<function _format_datetime_java_zoned>, preamble_lines=('import java.time.ZoneId;', 'import java.time.ZonedDateTime;'), type_produced=<class 'datetime.datetime'>)¶
- class DeclarationStyles(*values)¶
Declaration style options.
- VAR = DeclarationStyleConfig(formatter=<function _format_java_var_declaration>, supports_redefinition=True)¶
- class DictFormats(*values)¶
Dict/map format options.
- HASH_MAP = DictFormatConfig(dict_open=<function fixed_open.<locals>._open>, close='))', format_entry=<function dict_entry_with_template.<locals>._format>, empty_dict='new HashMap<>()', preamble_lines=('import java.util.HashMap;', 'import java.util.Map;'), narrowed_open=None, supports_trailing_comma=False)¶
- MAP_OF_ENTRIES = DictFormatConfig(dict_open=<function fixed_open.<locals>._open>, close=')', format_entry=<function dict_entry_with_template.<locals>._format>, empty_dict=None, preamble_lines=('import java.util.Map;',), narrowed_open=None, supports_trailing_comma=False)¶
- class FloatFormats(*values)¶
Float format options.
- FIXED = <function format_float_fixed>¶
- REPR = <function format_float_repr>¶
- SCIENTIFIC = <function format_float_scientific>¶
- class HeterogeneousStrategies(*values)¶
Strategy for dicts whose values span more than one Java type.
ERRORkeeps Java’s strict-typing behavior (mixed-value dicts that cannot be represented raise).RECORDrenders each record-shaped dict (non-empty, string-keyed) as a generatedrecorddeclared in the preamble plus a matching positionalnew Record0(...)literal, so fields may legitimately mix scalars and containers.- ERROR = 1¶
- RECORD = 2¶
- class IntegerFormats(*values)¶
Integer format options.
- BINARY = mappingproxy({'NONE': <function format_integer_binary>, 'UNDERSCORE': <function format_integer_binary>})¶
- DECIMAL = mappingproxy({'NONE': <class 'str'>, 'UNDERSCORE': <function format_integer_underscore>})¶
- HEX = mappingproxy({'NONE': <function format_integer_hex>, 'UNDERSCORE': <function format_integer_hex>})¶
- OCTAL = mappingproxy({'NONE': <function format_integer_octal_c_style>, 'UNDERSCORE': <function format_integer_octal_c_style>})¶
- get_formatter(numeric_separator: Enum) Callable[[int], str]¶
Return the integer formatter for the given separator.
- class JsonTypes(*values)¶
JSON value type options for Java.
- JACKSON_JSON_NODE = 'com.fasterxml.jackson.databind.JsonNode'¶
Jackson’s dynamic JSON value type.
- Modifiers¶
alias of
_JavaModifiers
- class SequenceFormats(*values)¶
Sequence type options for Java.
- ARRAY = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close='}', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback='new Object[]{', uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)¶
- LIST = SequenceFormatConfig(sequence_open=<function _list_of_open>, close=')', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=False, empty_sequence='List.of()', preamble_lines=('import java.util.List;',), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)¶
- class SetFormats(*values)¶
Set type options for Java.
- SET = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close=')', empty_set=None, preamble_lines=('import java.util.Set;',), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=False)¶
- TREE_SET = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close='))', empty_set='new TreeSet<>()', preamble_lines=('import java.util.Set;', 'import java.util.TreeSet;'), set_opener_template='', supports_heterogeneity=False, supports_trailing_comma=False)¶
- class TrailingCommas(*values)¶
Trailing comma options.
- NO = TrailingCommaConfig(multiline_trailing_comma=False)¶
- YES = TrailingCommaConfig(multiline_trailing_comma=True)¶
- class VariableTypeHints(*values)¶
Variable type hint options.
- ALWAYS = 2¶
- NEVER = 1¶
- SAFE = 3¶
- formatter(*, auto_formatter: Callable[[str, str, Value, frozenset[Enum]], str], int_type: str, date_hint: str, datetime_hint: str, seq_is_array: bool, dict_outer: str, set_outer: str) Callable[[str, str, Value, frozenset[Enum]], str]¶
Return the variable declaration formatter.
- class VersionFormats(*values)¶
Version options for Java.
VersionFormats.JDK_11: target Java 11.VersionFormats.JDK_16: target Java 16.
The
RECORDheterogeneous_strategyemitsrecorddeclarations, which require Java 16 or newer, so aRECORDspec pinslanguage_versiontoJDK_16.- JDK_11 = 1¶
- JDK_16 = 2¶
- allows_empty_call_parens = True¶
- bool_formats¶
alias of
BoolFormats
- bytes_format: BytesFormats = <function format_bytes_hex>¶
- bytes_formats¶
alias of
BytesFormats
- property call_data_dependent_preamble: Callable[[Value], tuple[str, ...]]¶
Return data-dependent preamble lines for call rendering.
- call_returns_expression = True¶
- call_style: CallStyles = PositionalCallStyle(arg_separator=', ', parenthesize_each_arg=False)¶
- property call_style_config: PositionalCallStyle | KeywordCallStyle | ObjectCallStyle | PostfixCallStyle | PrefixCallStyle | CommandCallStyle¶
Configuration for the chosen call style.
- call_styles¶
alias of
CallStyles
- property comment_config: CommentConfig¶
Configuration for the language’s comment syntax.
- comment_format: CommentFormats = CommentConfig(prefix='//', suffix='')¶
- comment_formats¶
alias of
CommentFormats
- property compute_body_preamble: Callable[[frozenset[type], Value], tuple[str, ...]]¶
Compute body-preamble lines from the scalar map.
- property consumable_ref_value_inhibits_consuming_form: Callable[[Value], bool]¶
Predicate deciding whether a ref’s underlying value type inhibits the consume form.
Delegates to
never_inhibits_consuming_form. Languages whose consume operator rejects certain value types (notably the Mojo^on register-trivial scalars) override this.
- property data_dependent_preamble: Callable[[Value], tuple[str, ...]]¶
Return data-dependent preamble lines.
Always emits
import java.math.BigInteger;when the data needs it; underHeterogeneousStrategies.RECORDalso emits onerecorddeclaration per record shape present in the data. Whenjson_typeis active, neither the BigInteger import nor record declarations apply: integers outside the 64-bit range ride inside the JSON text, and the data flows through a singleObjectMapper.readTreecall instead of typed records.
- date_format: DateFormats = DateFormatConfig(formatter=<function date_ymd_formatter.<locals>._format>, preamble_lines=('import java.time.LocalDate;',), type_produced=<class 'datetime.date'>)¶
- date_formats¶
alias of
DateFormats
- datetime_format: DatetimeFormats = DatetimeFormatConfig(formatter=<function _format_datetime_java_instant>, preamble_lines=('import java.time.Instant;',), type_produced=<class 'datetime.datetime'>)¶
- datetime_formats¶
alias of
DatetimeFormats
- declaration_style: DeclarationStyles = DeclarationStyleConfig(formatter=<function _format_java_var_declaration>, supports_redefinition=True)¶
- declaration_styles¶
alias of
DeclarationStyles
- dict_entry_style: DictEntryStyles = 1¶
- dict_entry_styles¶
alias of
DictEntryStyles
- dict_format: DictFormats = DictFormatConfig(dict_open=<function fixed_open.<locals>._open>, close=')', format_entry=<function dict_entry_with_template.<locals>._format>, empty_dict=None, preamble_lines=('import java.util.Map;',), narrowed_open=None, supports_trailing_comma=False)¶
- property dict_format_config: DictFormatConfig¶
Configuration for dict formatting.
- dict_formats¶
alias of
DictFormats
- dict_supports_heterogeneous_values = True¶
- element_separator: ClassVar[str] = ', '¶
- empty_dict_keys¶
alias of
EmptyDictKey
- extension = '.java'¶
- false_literal: ClassVar[str] = 'false'¶
- float_format: FloatFormats = <function format_float_repr>¶
- float_formats¶
alias of
FloatFormats
- property format_bytes: Callable[[bytes], str]¶
Callable that formats a bytes value as a string literal.
- property format_call_arg: Callable[[Value, str], str]¶
Callable that rewrites a formatted direct call argument.
- property format_call_arg_ref_identifier: Callable[[str, Value | None], str]¶
Rewrite a
{"$ref": "name"}identifier in a call-argument context.Delegates to
format_call_ref_identifier. Override this to allow call-argument$refvalues that would otherwise be rejected.
- property format_call_arg_ref_identifier_consumable: Callable[[str, Value | None], str]¶
Format a
$refthe caller authorized as consumable.Delegates to
format_call_arg_ref_identifier. Override this to opt into a consuming form (e.g. C++std::move).
- format_call_binding_body_preamble() tuple[str, ...]¶
Default
format_call_binding_body_preamble– no extra body preamble lines for an inference-bound call result.
- format_call_binding_file_pragmas() tuple[str, ...]¶
Default
format_call_binding_file_pragmas– no file-level compiler-pragma line for an inference-bound call result.
- property format_call_preamble_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]¶
Return file-scope stubs for a call expression.
- property format_call_ref_identifier: Callable[[str, Value | None], str]¶
Rewrite a
{"$ref": "name"}identifier into the language’s call expression syntax.
- property format_call_statement: Callable[[str], str]¶
Return call-statement formatting for this language.
- property format_call_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]¶
Return stub declarations for a call expression.
- property format_call_target: Callable[[Sequence[str]], str]¶
Rewrite a dotted call target into the language’s call syntax.
- property format_call_variable_assignment: Callable[[str, str, Value], str]¶
Default
format_call_variable_assignment– reuse the literal-binding assignment formatter unchanged.
- property format_call_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]¶
Default
format_call_variable_declaration– reuse the literal-binding declaration formatter unchanged.
- static format_constructor_target(class_name: str, /) str¶
Return a
new ClassNameconstructor call target.
- property format_date: Callable[[date], str]¶
Callable that formats a date as a string literal.
- property format_datetime: Callable[[datetime], str]¶
Callable that formats a datetime as a string literal.
EPOCHseconds are routed throughformat_integerso a post-2038 value carries theLsuffix Java requires for an integer literal outside 32-bit range: a bare4085195400fails to compile as anintliteral even when assigned to along. In-range epoch seconds format identically to the plain integer, so every checked-in golden file stays byte-identical.
- property format_float: Callable[[float], str]¶
Callable that formats a float value as a literal.
- property format_integer: Callable[[int], str]¶
Callable that formats an int value as a literal.
- property format_integer_widened: Callable[[int], str]¶
Always-
L-suffixed integer formatter for widened collections (mixed-magnitude int sets/lists).
- property format_ordered_map_entry: Callable[[str, Value, str], str]¶
Callable that formats one ordered-map entry.
- property format_sequence_entry: Callable[[Value, str], str]¶
Format a sequence entry.
- property format_set_entry: Callable[[Value, str], str]¶
Format a set entry.
- property format_string: Callable[[str], str]¶
Format a string value as a quoted literal.
- property format_time: Callable[[time], str]¶
Callable that formats a time as a string literal.
- property format_variable_assignment: Callable[[str, str, Value], str]¶
Format an assignment to an existing variable.
- property format_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]¶
Callable that formats a new variable declaration.
- has_free_function_calls = True¶
- property heterogeneous_behavior: HeterogeneousBehavior¶
Return the behavior for the chosen heterogeneous strategy.
- heterogeneous_strategies¶
alias of
HeterogeneousStrategies
- heterogeneous_strategy: HeterogeneousStrategies = 1¶
- identifier_cases: ClassVar[tuple[IdentifierCase, ...]] = (IdentifierCase.CAMEL, IdentifierCase.PASCAL, IdentifierCase.UPPER_SNAKE)¶
- indent: str = ' '¶
- indent_closing_delimiter: ClassVar[bool] = False¶
- integer_format: IntegerFormats = mappingproxy({'NONE': <class 'str'>, 'UNDERSCORE': <function format_integer_underscore>})¶
- integer_formats¶
alias of
IntegerFormats
- integer_width_strategies¶
alias of
BareIntegerWidthStrategies
- integer_width_strategy: BareIntegerWidthStrategies = 1¶
- language_version: VersionFormats = 1¶
- property leading_preamble: LeadingPreamble¶
Default
leading_preamble– no preamble lines that must precedeLanguage.static_preamble.
- max_call_parameters = 9223372036854775807¶
- modifier_combinations: ClassVar[tuple[ModifierCombination, ...]] = (ModifierCombination(name='public_static_final', modifiers=frozenset({<_JavaModifiers.PUBLIC: 'public'>, <_JavaModifiers.FINAL: 'final'>, <_JavaModifiers.STATIC: 'static'>})),)¶
- modifiers¶
alias of
_JavaModifiers
- module_name: str = 'Module'¶
- module_name_case: ClassVar[IdentifierCase] = 'pascal'¶
- null_literal: ClassVar[str] = 'null'¶
- numeric_literal_suffix: NumericLiteralSuffixes = 1¶
- numeric_literal_suffixes¶
alias of
NumericLiteralSuffixes
- numeric_separator: NumericSeparators = 1¶
- numeric_separators¶
alias of
NumericSeparators
- numeric_style: NumericStyles = 1¶
- numeric_styles¶
alias of
NumericStyles
- property ordered_map_format_config: OrderedMapFormatConfig¶
Configuration for ordered-map formatting.
- pygments_name = 'java'¶
- record_shape_names: Mapping[frozenset[str], str]¶
- record_struct_name_prefix: str = 'Record'¶
- reserved_identifiers: ClassVar[frozenset[str]] = frozenset({})¶
- property scalar_body_preamble: dict[type, tuple[str, ...]]¶
Per-instance scalar body preamble (Java needs none).
- property scalar_preamble: dict[type, tuple[str, ...]]¶
Per-instance scalar preamble computed from date/datetime format.
Under
json_typeevery temporal value is folded into the JSON text as an ISO-8601 string, so the temporal Java imports that the configureddate_format/datetime_formatwould otherwise add do not apply.
- sequence_binding_declarations(declarations: tuple[str, ...]) str¶
Default
sequence_binding_declarations– join the per-binding snippets with newlines.
- sequence_format: SequenceFormats = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close='}', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback='new Object[]{', uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)¶
- property sequence_format_config: SequenceFormatConfig¶
Configuration for the chosen sequence format.
- sequence_formats¶
alias of
SequenceFormats
- property sequence_open: Callable[[list[Value]], str]¶
Callable that returns the opening delimiter for a sequence.
- set_format: SetFormats = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close=')', empty_set=None, preamble_lines=('import java.util.Set;',), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=False)¶
- property set_format_config: SetFormatConfig¶
Configuration for the chosen set format.
- set_formats¶
alias of
SetFormats
- skip_null_dict_values: ClassVar[bool] = True¶
- special_float_preamble: ClassVar[tuple[str, ...]] = ()¶
- statement_terminator: ClassVar[str] = ';'¶
- statement_terminator_style: StatementTerminatorStyles = 1¶
- statement_terminator_styles¶
alias of
StatementTerminatorStyles
- static_body_preamble: ClassVar[Sequence[str]] = ()¶
- property static_preamble: Sequence[str]¶
Static preamble lines emitted once per file.
When
json_typeis active the JacksonJsonNodeandObjectMapperimports are emitted here so every fixture has them in scope regardless of the rendered data.
- string_format: StringFormats = 1¶
- string_formats¶
alias of
StringFormats
- supported_ref_cases: ClassVar[frozenset[IdentifierCase]] = frozenset({IdentifierCase.CAMEL, IdentifierCase.PASCAL, IdentifierCase.SNAKE, IdentifierCase.UPPER_SNAKE})¶
- supports_call_style = True¶
- supports_collection_comments: ClassVar[bool] = True¶
- supports_default_dict_key_type = False¶
- supports_default_dict_value_type = False¶
- supports_default_ordered_map_value_type = False¶
- supports_default_sequence_element_type = False¶
- supports_default_set_element_type = False¶
- supports_dict_literal_as_free_expression = True¶
- supports_dotted_call_stub = True¶
- supports_dotted_calls = True¶
- supports_empty_dict_key = False¶
- supports_inline_multiline_dict_args = True¶
- supports_module_name = True¶
- supports_multi_param_call_wrapper_stub = True¶
- supports_no_variable_wrap_in_file = False¶
- supports_non_string_dict_keys = True¶
- supports_record_shape_names = True¶
- supports_record_struct_name_prefix = True¶
- supports_scalar_before_comments: ClassVar[bool] = False¶
- supports_scalar_inline_comments: ClassVar[bool] = False¶
- supports_special_floats = True¶
- supports_standalone_comments_in_wrapped_calls = True¶
- supports_variable_names = True¶
- supports_zero_parameter_calls = True¶
- trailing_comma: TrailingCommas = TrailingCommaConfig(multiline_trailing_comma=False)¶
- property trailing_comma_config: TrailingCommaConfig¶
Configuration for trailing-comma behavior.
- trailing_commas¶
alias of
TrailingCommas
- true_literal: ClassVar[str] = 'true'¶
- property type_hint_collection_preamble_lines: Callable[[frozenset[type]], tuple[str, ...]]¶
Return preamble lines for empty-collection type hints.
- property validate_call_arg: Callable[[Value], None]¶
Return call-argument validation for this language.
- validate_spec_for_data(data: Value) None¶
Raise if the spec cannot produce valid code for data.
Under the
RECORDheterogeneous strategy a list-valued record component is typed from the array opener (new <type>[]{) the value formatter emits, so its declared type matches the rendered literal. Onlysequence_format=ARRAYproduces that opener; every other sequence format (e.g.LIST->List.of(...)) carries no element type in its opener and is outside theRECORDstrategy’s MVP (cf. the set / non-record-dict boundary in #2317), so the combination is rejected here rather than emitting arecorddeclaration that fails to compile. This check is spec-only; data is unused.When
json_typeis active, additionally walk data to reject non-string dict keys, which JSON objects cannot represent.
- variable_type_hints: VariableTypeHints = 1¶
- variable_type_hints_formats¶
alias of
VariableTypeHints
- version_formats¶
alias of
VersionFormats
- wrap_calls_with_declarations(declarations: tuple[str, ...], calls: str, body_preamble: tuple[str, ...]) str¶
Default
wrap_calls_with_declarations— concatenate the declarations and calls and route throughwrap_in_file()in call mode.
- wrap_combined_in_file(declaration: str, assignment: str, variable_name: str, body_preamble: tuple[str, ...]) str¶
Wrap Java declaration + assignment in a static method.
- wrap_in_file(content: str, variable_name: str, body_preamble: tuple[str, ...]) str¶
Wrap a Java declaration in a
classscope named after the configured module name.When content starts with a class-field modifier keyword (
public,private,protected,static) the declaration is placed at class-field scope, which is the only context where those modifiers are valid. Otherwise the declaration goes inside apublic static voidmethod named after the configured module name so that local-only forms likevar x = 42;compile.
- class literalizer.languages.JavaScript(*args: object, **kwargs: object)¶
JavaScript language specification.
- Parameters:
date_format –
How to format
datetime.datevalues.date_formats.JS—new Date(...)call, e.g.new Date("2024-01-15").date_formats.ISO— ISO 8601 quoted string, e.g."2024-01-15".
datetime_format –
How to format
datetime.datetimevalues.datetime_formats.JS—new Date(...)call, e.g.new Date("2024-01-15T12:30:00").datetime_formats.ISO— ISO 8601 quoted string, e.g."2024-01-15T12:30:00".
- class BoolFormats(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
Empty: this language has no alternative boolean formats.
- class BytesFormats(*values)¶
Bytes formatting options.
- BASE64 = <function format_bytes_base64>¶
- HEX = <function format_bytes_hex>¶
- class CallStyles(*values)¶
JavaScript call style options.
- OBJECT = ObjectCallStyle(separator=': ')¶
- POSITIONAL = PositionalCallStyle(arg_separator=', ', parenthesize_each_arg=False)¶
- class CommentFormats(*values)¶
Comment style options.
- BLOCK = CommentConfig(prefix='/*', suffix=' */')¶
- DOUBLE_SLASH = CommentConfig(prefix='//', suffix='')¶
- class DateFormats(*values)¶
Date formatting options for JavaScript.
- ISO = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- JS = DateFormatConfig(formatter=<function date_iso_formatter.<locals>._format>, preamble_lines=(), type_produced=<class 'datetime.date'>)¶
- class DatetimeFormats(*values)¶
Datetime formatting options for JavaScript.
- EPOCH = DatetimeFormatConfig(formatter=<function format_datetime_epoch>, preamble_lines=(), type_produced=<class 'int'>)¶
- ISO = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- JS = DatetimeFormatConfig(formatter=<function datetime_iso_formatter.<locals>._format>, preamble_lines=(), type_produced=<class 'datetime.datetime'>)¶
- class DeclarationStyles(*values)¶
Declaration style options.
- CONST = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=False)¶
- LET = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=True)¶
- class DictFormats(*values)¶
Dict/map format options.
- MAP = DictFormatConfig(dict_open=<function fixed_open.<locals>._open>, close='])', format_entry=<function dict_entry_with_template.<locals>._format>, empty_dict='new Map()', preamble_lines=(), narrowed_open=None, supports_trailing_comma=True)¶
- OBJECT = DictFormatConfig(dict_open=<function fixed_open.<locals>._open>, close='}', format_entry=<function dict_entry_with_separator.<locals>._format>, empty_dict=None, preamble_lines=(), narrowed_open=None, supports_trailing_comma=True)¶
- class FloatFormats(*values)¶
Float format options.
- FIXED = <function format_float_fixed>¶
- REPR = <function format_float_repr>¶
- SCIENTIFIC = <function format_float_scientific>¶
- class HeterogeneousStrategies(*values)¶
Heterogeneous-scalar strategy options — this language only supports raising.
- ERROR = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)¶
- class IntegerFormats(*values)¶
Integer format options.
- BINARY = mappingproxy({'NONE': <function format_integer_binary>, 'UNDERSCORE': <function format_integer_binary>})¶
- DECIMAL = mappingproxy({'NONE': <class 'str'>, 'UNDERSCORE': <function format_integer_underscore>})¶
- HEX = mappingproxy({'NONE': <function format_integer_hex>, 'UNDERSCORE': <function format_integer_hex>})¶
- OCTAL = mappingproxy({'NONE': <function format_integer_octal>, 'UNDERSCORE': <function format_integer_octal>})¶
- get_formatter(numeric_separator: Enum) Callable[[int], str]¶
Return the integer formatter for the given separator.
- class JsonTypes(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
Empty: this language has no JSON value-type variants.
- class Modifiers(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
C++/Java/C#-style declaration modifiers: this language has none.
- class SequenceFormats(*values)¶
Sequence type options for JavaScript.
- ARRAY = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=']', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)¶
- class SetFormats(*values)¶
Set type options for JavaScript.
- SET = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close='])', empty_set='new Set()', preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)¶
- class StatementTerminatorStyles(*values)¶
Statement terminator options.
- NONE = 'none'¶
- SEMICOLON = 1¶
- wrap_formatter(formatter: Callable[[str, str, Value, frozenset[Enum]], str]) Callable[[str, str, Value, frozenset[Enum]], str]¶
Wrap a formatter to match this statement terminator style.
- class StringFormats(*values)¶
String format options.
- DOUBLE = <function _build_backslash_formatter.<locals>._format>¶
- SINGLE = <function _build_backslash_formatter.<locals>._format>¶
- class TrailingCommas(*values)¶
Trailing comma options.
- NO = TrailingCommaConfig(multiline_trailing_comma=False)¶
- YES = TrailingCommaConfig(multiline_trailing_comma=True)¶
- allows_empty_call_parens = True¶
- bool_formats¶
alias of
BoolFormats
- bytes_format: BytesFormats = <function format_bytes_hex>¶
- bytes_formats¶
alias of
BytesFormats
- property call_data_dependent_preamble: Callable[[Value], tuple[str, ...]]¶
Return data-dependent preamble lines for call rendering.
- call_returns_expression = True¶
- call_style: CallStyles = ObjectCallStyle(separator=': ')¶
- property call_style_config: PositionalCallStyle | KeywordCallStyle | ObjectCallStyle | PostfixCallStyle | PrefixCallStyle | CommandCallStyle¶
Configuration for the chosen call style.
- call_styles¶
alias of
CallStyles
- property comment_config: CommentConfig¶
Configuration for the language’s comment syntax.
- comment_format: CommentFormats = CommentConfig(prefix='//', suffix='')¶
- comment_formats¶
alias of
CommentFormats
- property compute_body_preamble: Callable[[frozenset[type], Value], tuple[str, ...]]¶
Compute body-preamble lines from the scalar map.
- property consumable_ref_value_inhibits_consuming_form: Callable[[Value], bool]¶
Predicate deciding whether a ref’s underlying value type inhibits the consume form.
Delegates to
never_inhibits_consuming_form. Languages whose consume operator rejects certain value types (notably the Mojo^on register-trivial scalars) override this.
- property data_dependent_preamble: Callable[[Value], tuple[str, ...]]¶
Return data-dependent preamble lines.
- date_format: DateFormats = DateFormatConfig(formatter=<function date_iso_formatter.<locals>._format>, preamble_lines=(), type_produced=<class 'datetime.date'>)¶
- date_formats¶
alias of
DateFormats
- datetime_format: DatetimeFormats = DatetimeFormatConfig(formatter=<function datetime_iso_formatter.<locals>._format>, preamble_lines=(), type_produced=<class 'datetime.datetime'>)¶
- datetime_formats¶
alias of
DatetimeFormats
- declaration_style: DeclarationStyles = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=False)¶
- declaration_styles¶
alias of
DeclarationStyles
- dict_entry_style: DictEntryStyles = 1¶
- dict_entry_styles¶
alias of
DictEntryStyles
- dict_format: DictFormats = DictFormatConfig(dict_open=<function fixed_open.<locals>._open>, close='}', format_entry=<function dict_entry_with_separator.<locals>._format>, empty_dict=None, preamble_lines=(), narrowed_open=None, supports_trailing_comma=True)¶
- property dict_format_config: DictFormatConfig¶
Configuration for dict formatting.
- dict_formats¶
alias of
DictFormats
- dict_supports_heterogeneous_values = True¶
- element_separator: ClassVar[str] = ', '¶
- empty_dict_keys¶
alias of
EmptyDictKey
- extension = '.js'¶
- false_literal: ClassVar[str] = 'false'¶
- float_format: FloatFormats = <function format_float_repr>¶
- float_formats¶
alias of
FloatFormats
- property format_bytes: Callable[[bytes], str]¶
Callable that formats a bytes value as a string literal.
- static format_call_arg(_value: Value, formatted: str, /) str¶
Callable that rewrites a formatted direct call argument.
- property format_call_arg_ref_identifier: Callable[[str, Value | None], str]¶
Rewrite a
{"$ref": "name"}identifier in a call-argument context.Delegates to
format_call_ref_identifier. Override this to allow call-argument$refvalues that would otherwise be rejected.
- property format_call_arg_ref_identifier_consumable: Callable[[str, Value | None], str]¶
Format a
$refthe caller authorized as consumable.Delegates to
format_call_arg_ref_identifier. Override this to opt into a consuming form (e.g. C++std::move).
- format_call_binding_body_preamble() tuple[str, ...]¶
Default
format_call_binding_body_preamble– no extra body preamble lines for an inference-bound call result.
- format_call_binding_file_pragmas() tuple[str, ...]¶
Default
format_call_binding_file_pragmas– no file-level compiler-pragma line for an inference-bound call result.
- property format_call_preamble_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]¶
Return file-scope stubs for a call expression.
- property format_call_ref_identifier: Callable[[str, Value | None], str]¶
Rewrite a
{"$ref": "name"}identifier into the language’s call expression syntax.
- property format_call_statement: Callable[[str], str]¶
Return call-statement formatting for this language.
- property format_call_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]¶
Return stub declarations for a call expression.
- property format_call_target: Callable[[Sequence[str]], str]¶
Rewrite a dotted call target into the language’s call syntax.
- property format_call_variable_assignment: Callable[[str, str, Value], str]¶
Default
format_call_variable_assignment– reuse the literal-binding assignment formatter unchanged.
- property format_call_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]¶
Default
format_call_variable_declaration– reuse the literal-binding declaration formatter unchanged.
- static format_constructor_target(class_name: str, /) str¶
Return a
new ClassNameconstructor call target.
- property format_date: Callable[[date], str]¶
Callable that formats a date as a string literal.
- property format_datetime: Callable[[datetime], str]¶
Callable that formats a datetime as a string literal.
- property format_float: Callable[[float], str]¶
Callable that formats a float value as a literal.
- property format_integer: Callable[[int], str]¶
Callable that formats an int value as a literal.
- property format_integer_widened: None¶
Default
format_integer_widened– no mixed-magnitude integer widening, so the renderer keeps the normal integer formatter.
- property format_ordered_map_entry: Callable[[str, Value, str], str]¶
Callable that formats one ordered-map entry.
- property format_sequence_entry: Callable[[Value, str], str]¶
Format a sequence entry.
- property format_set_entry: Callable[[Value, str], str]¶
Format a set entry.
- property format_string: Callable[[str], str]¶
Callable that formats a string value as a quoted literal.
- property format_time: Callable[[time], str]¶
Callable that formats a time as a string literal.
- property format_variable_assignment: Callable[[str, str, Value], str]¶
Callable that formats an assignment to an existing variable.
- property format_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]¶
Callable that formats a new variable declaration.
- has_free_function_calls = True¶
- property heterogeneous_behavior: HeterogeneousBehavior¶
Return the heterogeneous-behavior config.
- heterogeneous_strategies¶
alias of
HeterogeneousStrategies
- heterogeneous_strategy: HeterogeneousStrategies = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)¶
- identifier_cases: ClassVar[tuple[IdentifierCase, ...]] = (IdentifierCase.CAMEL, IdentifierCase.PASCAL, IdentifierCase.UPPER_SNAKE)¶
- indent: str = ' '¶
- indent_closing_delimiter: ClassVar[bool] = False¶
- integer_format: IntegerFormats = mappingproxy({'NONE': <class 'str'>, 'UNDERSCORE': <function format_integer_underscore>})¶
- integer_formats¶
alias of
IntegerFormats
- integer_width_strategies¶
alias of
BareIntegerWidthStrategies
- integer_width_strategy: BareIntegerWidthStrategies = 1¶
- language_version: VersionFormats = 1¶
- property leading_preamble: LeadingPreamble¶
Default
leading_preamble– no preamble lines that must precedeLanguage.static_preamble.
- max_call_parameters = 9223372036854775807¶
- modifier_combinations: ClassVar[tuple[ModifierCombination, ...]] = ()¶
- null_literal: ClassVar[str] = 'null'¶
- numeric_literal_suffix: NumericLiteralSuffixes = 1¶
- numeric_literal_suffixes¶
alias of
NumericLiteralSuffixes
- numeric_separator: NumericSeparators = 1¶
- numeric_separators¶
alias of
NumericSeparators
- numeric_style: NumericStyles = 1¶
- numeric_styles¶
alias of
NumericStyles
- property ordered_map_format_config: OrderedMapFormatConfig¶
Configuration for ordered-map formatting.
- pygments_name = 'javascript'¶
- reserved_identifiers: ClassVar[frozenset[str]] = frozenset({})¶
- property scalar_body_preamble: dict[type, tuple[str, ...]]¶
Per-instance scalar body preamble (JavaScript needs none).
- property scalar_preamble: dict[type, tuple[str, ...]]¶
Per-instance scalar preamble (JavaScript needs none).
- sequence_binding_declarations(declarations: tuple[str, ...]) str¶
Default
sequence_binding_declarations– join the per-binding snippets with newlines.
- sequence_format: SequenceFormats = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=']', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)¶
- property sequence_format_config: SequenceFormatConfig¶
Configuration for the chosen sequence format.
- sequence_formats¶
alias of
SequenceFormats
- property sequence_open: Callable[[list[Value]], str]¶
Callable that returns the opening delimiter for a sequence.
- set_format: SetFormats = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close='])', empty_set='new Set()', preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)¶
- property set_format_config: SetFormatConfig¶
Configuration for the chosen set format.
- set_formats¶
alias of
SetFormats
- skip_null_dict_values: ClassVar[bool] = False¶
- special_float_preamble: ClassVar[tuple[str, ...]] = ()¶
- statement_terminator: ClassVar[str] = ';'¶
- statement_terminator_style: StatementTerminatorStyles = 1¶
- statement_terminator_styles¶
alias of
StatementTerminatorStyles
- static_body_preamble: ClassVar[Sequence[str]] = ()¶
- static_preamble: ClassVar[Sequence[str]] = ()¶
- string_format: StringFormats = <function _build_backslash_formatter.<locals>._format>¶
- string_formats¶
alias of
StringFormats
- supported_ref_cases: ClassVar[frozenset[IdentifierCase]] = frozenset({IdentifierCase.CAMEL, IdentifierCase.PASCAL, IdentifierCase.SNAKE, IdentifierCase.UPPER_SNAKE})¶
- supports_call_style = True¶
- supports_collection_comments: ClassVar[bool] = True¶
- supports_default_dict_key_type = False¶
- supports_default_dict_value_type = False¶
- supports_default_ordered_map_value_type = False¶
- supports_default_sequence_element_type = False¶
- supports_default_set_element_type = False¶
- supports_dict_literal_as_free_expression = True¶
- supports_dotted_call_stub = True¶
- supports_dotted_calls = True¶
- supports_empty_dict_key = False¶
- supports_inline_multiline_dict_args = True¶
- supports_module_name = False¶
- supports_multi_param_call_wrapper_stub = True¶
- supports_no_variable_wrap_in_file = True¶
- supports_non_string_dict_keys = False¶
- supports_record_shape_names = False¶
- supports_record_struct_name_prefix = False¶
- supports_scalar_before_comments: ClassVar[bool] = True¶
- supports_scalar_inline_comments: ClassVar[bool] = True¶
- supports_special_floats = True¶
- supports_standalone_comments_in_wrapped_calls = True¶
- supports_variable_names = True¶
- supports_zero_parameter_calls = True¶
- trailing_comma: TrailingCommas = TrailingCommaConfig(multiline_trailing_comma=True)¶
- property trailing_comma_config: TrailingCommaConfig¶
Configuration for trailing-comma behavior.
- trailing_commas¶
alias of
TrailingCommas
- true_literal: ClassVar[str] = 'true'¶
- property type_hint_collection_preamble_lines: Callable[[frozenset[type]], tuple[str, ...]]¶
Return preamble lines for empty-collection type hints.
- property validate_call_arg: Callable[[Value], None]¶
Return call-argument validation for this language.
- validate_spec_for_data(data: Value) None¶
Default
validate_spec_for_data— no spec/data constraints.
- variable_type_hints: VariableTypeHints = 1¶
- variable_type_hints_formats¶
alias of
VariableTypeHints
- version_formats¶
alias of
VersionFormats
- wrap_calls_with_declarations(declarations: tuple[str, ...], calls: str, body_preamble: tuple[str, ...]) str¶
Default
wrap_calls_with_declarations— concatenate the declarations and calls and route throughwrap_in_file()in call mode.
- static wrap_combined_in_file(declaration: str, assignment: str, variable_name: str, body_preamble: tuple[str, ...]) str¶
Wrap declaration and assignment in a valid file (no-op).
- static wrap_in_file(content: str, variable_name: str, body_preamble: tuple[str, ...]) str¶
Wrap code in a valid file (no-op).
- class literalizer.languages.Json5(*args: object, **kwargs: object)¶
JSON5 language specification.
Produces JSON5 values — objects for mappings, and arrays for sequences and sets — following the JSON5 Data Interchange Format.
JSON5 is a superset of JSON that permits unquoted identifier keys, trailing commas, single- and double-quoted strings, comments, and several other syntactic relaxations.
Dates and datetimes are rendered as quoted ISO 8601 strings because JSON5 has no native date type.
- class BoolFormats(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
Empty: this language has no alternative boolean formats.
- class BytesFormats(*values)¶
Bytes formatting options.
- BASE64 = <function format_bytes_base64>¶
- HEX = <function format_bytes_hex>¶
- class CallStyles(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
Json5 call style options.
- class CommentFormats(*values)¶
Comment style options.
- DOUBLE_SLASH = CommentConfig(prefix='//', suffix='')¶
- class DateFormats(*values)¶
Date format options for Json5.
- ISO = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- class DatetimeFormats(*values)¶
Datetime format options for Json5.
- EPOCH = DatetimeFormatConfig(formatter=<function format_datetime_epoch>, preamble_lines=(), type_produced=<class 'int'>)¶
- ISO = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- class DeclarationStyles(*values)¶
Declaration style options.
- ASSIGN = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=False)¶
- class FloatFormats(*values)¶
Float format options.
- FIXED = <function format_float_fixed>¶
- REPR = <function format_float_repr>¶
- SCIENTIFIC = <function format_float_scientific>¶
- class HeterogeneousStrategies(*values)¶
Heterogeneous-scalar strategy options — this language only supports raising.
- ERROR = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)¶
- class JsonTypes(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
Empty: this language has no JSON value-type variants.
- class Modifiers(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
C++/Java/C#-style declaration modifiers: this language has none.
- class SequenceFormats(*values)¶
Sequence type options for JSON5.
- ARRAY = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=']', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)¶
- class SetFormats(*values)¶
Set type options for JSON5.
- SET = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close=']', empty_set=None, preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)¶
- class TrailingCommas(*values)¶
Trailing comma options.
- NO = TrailingCommaConfig(multiline_trailing_comma=False)¶
- YES = TrailingCommaConfig(multiline_trailing_comma=True)¶
- allows_empty_call_parens = True¶
- bool_formats¶
alias of
BoolFormats
- bytes_format: BytesFormats = <function format_bytes_hex>¶
- bytes_formats¶
alias of
BytesFormats
- property call_data_dependent_preamble: Callable[[Value], tuple[str, ...]]¶
Return data-dependent preamble lines for call rendering.
- call_returns_expression = True¶
- call_style_config: ClassVar[PositionalCallStyle | KeywordCallStyle | ObjectCallStyle | PostfixCallStyle | PrefixCallStyle | CommandCallStyle | CallSupport] = 'not_in_language'¶
- call_styles¶
alias of
CallStyles
- property comment_config: CommentConfig¶
Configuration for the language’s comment syntax.
- comment_format: CommentFormats = CommentConfig(prefix='//', suffix='')¶
- comment_formats¶
alias of
CommentFormats
- property compute_body_preamble: Callable[[frozenset[type], Value], tuple[str, ...]]¶
Compute body-preamble lines from the scalar map.
- property consumable_ref_value_inhibits_consuming_form: Callable[[Value], bool]¶
Predicate deciding whether a ref’s underlying value type inhibits the consume form.
Delegates to
never_inhibits_consuming_form. Languages whose consume operator rejects certain value types (notably the Mojo^on register-trivial scalars) override this.
- property data_dependent_preamble: Callable[[Value], tuple[str, ...]]¶
Return data-dependent preamble lines.
- date_format: DateFormats = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- date_formats¶
alias of
DateFormats
- datetime_format: DatetimeFormats = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- datetime_formats¶
alias of
DatetimeFormats
- declaration_style: DeclarationStyles = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=False)¶
- declaration_styles¶
alias of
DeclarationStyles
- dict_entry_style: DictEntryStyles = 1¶
- dict_entry_styles¶
alias of
DictEntryStyles
- dict_format: DictFormats = 1¶
- property dict_format_config: DictFormatConfig¶
Configuration for dict formatting.
- dict_formats¶
alias of
DictFormats
- dict_supports_heterogeneous_values = True¶
- element_separator: ClassVar[str] = ', '¶
- empty_dict_keys¶
alias of
EmptyDictKey
- extension = '.json5'¶
- false_literal: ClassVar[str] = 'false'¶
- float_format: FloatFormats = <function format_float_repr>¶
- float_formats¶
alias of
FloatFormats
- property format_bytes: Callable[[bytes], str]¶
Callable that formats a bytes value as a string literal.
- static format_call_arg(_value: Value, formatted: str, /) str¶
Callable that rewrites a formatted direct call argument.
- property format_call_arg_ref_identifier: Callable[[str, Value | None], str]¶
Rewrite a
{"$ref": "name"}identifier in a call-argument context.Delegates to
format_call_ref_identifier. Override this to allow call-argument$refvalues that would otherwise be rejected.
- property format_call_arg_ref_identifier_consumable: Callable[[str, Value | None], str]¶
Format a
$refthe caller authorized as consumable.Delegates to
format_call_arg_ref_identifier. Override this to opt into a consuming form (e.g. C++std::move).
- format_call_binding_body_preamble() tuple[str, ...]¶
Default
format_call_binding_body_preamble– no extra body preamble lines for an inference-bound call result.
- format_call_binding_file_pragmas() tuple[str, ...]¶
Default
format_call_binding_file_pragmas– no file-level compiler-pragma line for an inference-bound call result.
- property format_call_preamble_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]¶
Return file-scope stubs for a call expression.
- property format_call_ref_identifier: Callable[[str, Value | None], str]¶
Raise for any
{"$ref": "name"}identifier.JSON5 is a data format; values must be literals, not variable references, so refs are not supported.
- property format_call_statement: Callable[[str], str]¶
Return call-statement formatting for this language.
- property format_call_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]¶
Return stub declarations for a call expression.
- property format_call_target: Callable[[Sequence[str]], str]¶
Rewrite a dotted call target into the language’s call syntax.
- property format_call_variable_assignment: Callable[[str, str, Value], str]¶
Default
format_call_variable_assignment– reuse the literal-binding assignment formatter unchanged.
- property format_call_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]¶
Default
format_call_variable_declaration– reuse the literal-binding declaration formatter unchanged.
- static format_constructor_target(class_name: str, /) str¶
Return class_name as a zero-argument constructor call target.
- property format_date: Callable[[date], str]¶
Callable that formats a date as a string literal.
- property format_datetime: Callable[[datetime], str]¶
Callable that formats a datetime as a string literal.
- property format_float: Callable[[float], str]¶
Callable that formats a float value as a literal.
- property format_integer: Callable[[int], str]¶
Format an int value as a literal.
- property format_integer_widened: None¶
Default
format_integer_widened– no mixed-magnitude integer widening, so the renderer keeps the normal integer formatter.
- property format_ordered_map_entry: Callable[[str, Value, str], str]¶
Callable that formats one ordered-map entry.
- property format_sequence_entry: Callable[[Value, str], str]¶
Format a sequence entry.
- property format_set_entry: Callable[[Value, str], str]¶
Format a set entry.
- property format_string: Callable[[str], str]¶
Callable that formats a string value as a quoted literal.
- property format_time: Callable[[time], str]¶
Callable that formats a time as a string literal.
- property format_variable_assignment: Callable[[str, str, Value], str]¶
Callable that formats an assignment to an existing variable.
- property format_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]¶
Callable that formats a new variable declaration.
- has_free_function_calls = True¶
- property heterogeneous_behavior: HeterogeneousBehavior¶
Return the heterogeneous-behavior config.
- heterogeneous_strategies¶
alias of
HeterogeneousStrategies
- heterogeneous_strategy: HeterogeneousStrategies = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)¶
- identifier_cases: ClassVar[tuple[IdentifierCase, ...]] = (IdentifierCase.SNAKE, IdentifierCase.CAMEL)¶
- indent: str = ' '¶
- indent_closing_delimiter: ClassVar[bool] = False¶
- integer_format: IntegerFormats = 1¶
- integer_formats¶
alias of
IntegerFormats
- integer_width_strategies¶
alias of
BareIntegerWidthStrategies
- integer_width_strategy: BareIntegerWidthStrategies = 1¶
- language_version: VersionFormats = 1¶
- property leading_preamble: LeadingPreamble¶
Default
leading_preamble– no preamble lines that must precedeLanguage.static_preamble.
- max_call_parameters = 9223372036854775807¶
- modifier_combinations: ClassVar[tuple[ModifierCombination, ...]] = ()¶
- null_literal: ClassVar[str] = 'null'¶
- numeric_literal_suffix: NumericLiteralSuffixes = 1¶
- numeric_literal_suffixes¶
alias of
NumericLiteralSuffixes
- numeric_separator: NumericSeparators = 1¶
- numeric_separators¶
alias of
NumericSeparators
- numeric_style: NumericStyles = 1¶
- numeric_styles¶
alias of
NumericStyles
- property ordered_map_format_config: OrderedMapFormatConfig¶
Configuration for ordered-map formatting.
- pygments_name = 'json5'¶
- reserved_identifiers: ClassVar[frozenset[str]] = frozenset({})¶
- property scalar_body_preamble: dict[type, tuple[str, ...]]¶
Per-instance scalar body preamble (JSON5 needs none).
- property scalar_preamble: dict[type, tuple[str, ...]]¶
Per-instance scalar preamble (JSON5 needs none).
- sequence_binding_declarations(declarations: tuple[str, ...]) str¶
Default
sequence_binding_declarations– join the per-binding snippets with newlines.
- sequence_format: SequenceFormats = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=']', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)¶
- property sequence_format_config: SequenceFormatConfig¶
Configuration for the chosen sequence format.
- sequence_formats¶
alias of
SequenceFormats
- property sequence_open: Callable[[list[Value]], str]¶
Callable that returns the opening delimiter for a sequence.
- set_format: SetFormats = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close=']', empty_set=None, preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)¶
- property set_format_config: SetFormatConfig¶
Configuration for the chosen set format.
- set_formats¶
alias of
SetFormats
- skip_null_dict_values: ClassVar[bool] = False¶
- special_float_preamble: ClassVar[tuple[str, ...]] = ()¶
- statement_terminator: ClassVar[str] = ''¶
- statement_terminator_style: StatementTerminatorStyles = 1¶
- statement_terminator_styles¶
alias of
StatementTerminatorStyles
- static_body_preamble: ClassVar[Sequence[str]] = ()¶
- static_preamble: ClassVar[Sequence[str]] = ()¶
- string_format: StringFormats = 1¶
- string_formats¶
alias of
StringFormats
- supported_ref_cases: ClassVar[frozenset[IdentifierCase]] = frozenset({IdentifierCase.CAMEL, IdentifierCase.PASCAL, IdentifierCase.SNAKE, IdentifierCase.UPPER_SNAKE})¶
- supports_call_style = False¶
- supports_collection_comments: ClassVar[bool] = True¶
- supports_default_dict_key_type = False¶
- supports_default_dict_value_type = False¶
- supports_default_ordered_map_value_type = False¶
- supports_default_sequence_element_type = False¶
- supports_default_set_element_type = False¶
- supports_dict_literal_as_free_expression = True¶
- supports_dotted_call_stub = True¶
- supports_dotted_calls = True¶
- supports_empty_dict_key = False¶
- supports_inline_multiline_dict_args = True¶
- supports_module_name = False¶
- supports_multi_param_call_wrapper_stub = True¶
- supports_no_variable_wrap_in_file = True¶
- supports_non_string_dict_keys = False¶
- supports_record_shape_names = False¶
- supports_record_struct_name_prefix = False¶
- supports_scalar_before_comments: ClassVar[bool] = True¶
- supports_scalar_inline_comments: ClassVar[bool] = True¶
- supports_special_floats = True¶
- supports_standalone_comments_in_wrapped_calls = True¶
- supports_variable_names = False¶
- supports_zero_parameter_calls = True¶
- trailing_comma: TrailingCommas = TrailingCommaConfig(multiline_trailing_comma=True)¶
- property trailing_comma_config: TrailingCommaConfig¶
Configuration for trailing-comma behavior.
- trailing_commas¶
alias of
TrailingCommas
- true_literal: ClassVar[str] = 'true'¶
- property type_hint_collection_preamble_lines: Callable[[frozenset[type]], tuple[str, ...]]¶
Return preamble lines for empty-collection type hints.
- property validate_call_arg: Callable[[Value], None]¶
Return call-argument validation for this language.
- validate_spec_for_data(data: Value) None¶
Default
validate_spec_for_data— no spec/data constraints.
- variable_type_hints: VariableTypeHints = 1¶
- variable_type_hints_formats¶
alias of
VariableTypeHints
- version_formats¶
alias of
VersionFormats
- wrap_calls_with_declarations(declarations: tuple[str, ...], calls: str, body_preamble: tuple[str, ...]) str¶
Default
wrap_calls_with_declarations— concatenate the declarations and calls and route throughwrap_in_file()in call mode.
- static wrap_combined_in_file(declaration: str, assignment: str, variable_name: str, body_preamble: tuple[str, ...]) str¶
Unsupported: literalize() rejects BothVariableForms upstream.
- static wrap_in_file(content: str, variable_name: str, body_preamble: tuple[str, ...]) str¶
Wrap code in a valid file (no-op).
- class literalizer.languages.Jsonnet(*args: object, **kwargs: object)¶
Jsonnet language specification.
Produces Jsonnet values — objects for mappings, and arrays for sequences and sets — following the Jsonnet data templating language.
Jsonnet is a superset of JSON that permits unquoted identifier keys, trailing commas, single- and double-quoted strings, comments, and powerful data templating features.
Dates and datetimes are rendered as quoted ISO 8601 strings because Jsonnet has no native date type.
- class BoolFormats(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
Empty: this language has no alternative boolean formats.
- class BytesFormats(*values)¶
Bytes formatting options.
- BASE64 = <function format_bytes_base64>¶
- HEX = <function format_bytes_hex>¶
- class CommentFormats(*values)¶
Comment style options.
- DOUBLE_SLASH = CommentConfig(prefix='//', suffix='')¶
- HASH = CommentConfig(prefix='#', suffix='')¶
- class DateFormats(*values)¶
Date format options for Jsonnet.
- ISO = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- class DatetimeFormats(*values)¶
Datetime format options for Jsonnet.
- EPOCH = DatetimeFormatConfig(formatter=<function format_datetime_epoch>, preamble_lines=(), type_produced=<class 'int'>)¶
- ISO = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- class DeclarationStyles(*values)¶
Declaration style options.
- ASSIGN = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=False)¶
- class FloatFormats(*values)¶
Float format options.
- FIXED = <function format_float_fixed>¶
- REPR = <function format_float_repr>¶
- SCIENTIFIC = <function format_float_scientific>¶
- class HeterogeneousStrategies(*values)¶
Heterogeneous-scalar strategy options — this language only supports raising.
- ERROR = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)¶
- class JsonTypes(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
Empty: this language has no JSON value-type variants.
- class Modifiers(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
C++/Java/C#-style declaration modifiers: this language has none.
- class SequenceFormats(*values)¶
Sequence type options for Jsonnet.
- ARRAY = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=']', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)¶
- class SetFormats(*values)¶
Set type options for Jsonnet.
- SET = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close=']', empty_set=None, preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)¶
- class TrailingCommas(*values)¶
Trailing comma options.
- NO = TrailingCommaConfig(multiline_trailing_comma=False)¶
- YES = TrailingCommaConfig(multiline_trailing_comma=True)¶
- allows_empty_call_parens = True¶
- bool_formats¶
alias of
BoolFormats
- bytes_format: BytesFormats = <function format_bytes_hex>¶
- bytes_formats¶
alias of
BytesFormats
- property call_data_dependent_preamble: Callable[[Value], tuple[str, ...]]¶
Return data-dependent preamble lines for call rendering.
- call_returns_expression = True¶
- call_style: CallStyles = KeywordCallStyle(separator='=')¶
- property call_style_config: PositionalCallStyle | KeywordCallStyle | ObjectCallStyle | PostfixCallStyle | PrefixCallStyle | CommandCallStyle¶
Configuration for the chosen call style.
- call_styles¶
alias of
CallStyles
- property comment_config: CommentConfig¶
Configuration for the language’s comment syntax.
- comment_format: CommentFormats = CommentConfig(prefix='//', suffix='')¶
- comment_formats¶
alias of
CommentFormats
- property compute_body_preamble: Callable[[frozenset[type], Value], tuple[str, ...]]¶
Compute body-preamble lines from the scalar map.
- property consumable_ref_value_inhibits_consuming_form: Callable[[Value], bool]¶
Predicate deciding whether a ref’s underlying value type inhibits the consume form.
Delegates to
never_inhibits_consuming_form. Languages whose consume operator rejects certain value types (notably the Mojo^on register-trivial scalars) override this.
- property data_dependent_preamble: Callable[[Value], tuple[str, ...]]¶
Return data-dependent preamble lines.
- date_format: DateFormats = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- date_formats¶
alias of
DateFormats
- datetime_format: DatetimeFormats = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- datetime_formats¶
alias of
DatetimeFormats
- declaration_style: DeclarationStyles = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=False)¶
- declaration_styles¶
alias of
DeclarationStyles
- dict_entry_style: DictEntryStyles = 1¶
- dict_entry_styles¶
alias of
DictEntryStyles
- dict_format: DictFormats = 1¶
- property dict_format_config: DictFormatConfig¶
Configuration for dict formatting.
- dict_formats¶
alias of
DictFormats
- dict_supports_heterogeneous_values = True¶
- element_separator: ClassVar[str] = ', '¶
- empty_dict_keys¶
alias of
EmptyDictKey
- extension = '.jsonnet'¶
- false_literal: ClassVar[str] = 'false'¶
- float_format: FloatFormats = <function format_float_repr>¶
- float_formats¶
alias of
FloatFormats
- property format_bytes: Callable[[bytes], str]¶
Callable that formats a bytes value as a string literal.
- static format_call_arg(_value: Value, formatted: str, /) str¶
Callable that rewrites a formatted direct call argument.
- property format_call_arg_ref_identifier: Callable[[str, Value | None], str]¶
Rewrite a
{"$ref": "name"}identifier in a call-argument context.Delegates to
format_call_ref_identifier. Override this to allow call-argument$refvalues that would otherwise be rejected.
- property format_call_arg_ref_identifier_consumable: Callable[[str, Value | None], str]¶
Format a
$refthe caller authorized as consumable.Delegates to
format_call_arg_ref_identifier. Override this to opt into a consuming form (e.g. C++std::move).
- format_call_binding_body_preamble() tuple[str, ...]¶
Default
format_call_binding_body_preamble– no extra body preamble lines for an inference-bound call result.
- format_call_binding_file_pragmas() tuple[str, ...]¶
Default
format_call_binding_file_pragmas– no file-level compiler-pragma line for an inference-bound call result.
- property format_call_preamble_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]¶
Return file-scope stubs for a call expression.
- property format_call_ref_identifier: Callable[[str, Value | None], str]¶
Raise for any
{"$ref": "name"}identifier.Jsonnet output snippets do not include a
localpreamble, so variable references cannot be resolved.
- property format_call_statement: Callable[[str], str]¶
Return call-statement formatting for this language.
- property format_call_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]¶
Return stub declarations for a call expression.
- property format_call_target: Callable[[Sequence[str]], str]¶
Rewrite a dotted call target into the language’s call syntax.
- property format_call_variable_assignment: Callable[[str, str, Value], str]¶
Default
format_call_variable_assignment– reuse the literal-binding assignment formatter unchanged.
- property format_call_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]¶
Default
format_call_variable_declaration– reuse the literal-binding declaration formatter unchanged.
- static format_constructor_target(class_name: str, /) str¶
Return class_name as a zero-argument constructor call target.
- property format_date: Callable[[date], str]¶
Callable that formats a date as a string literal.
- property format_datetime: Callable[[datetime], str]¶
Callable that formats a datetime as a string literal.
- property format_float: Callable[[float], str]¶
Callable that formats a float value as a literal.
- property format_integer: Callable[[int], str]¶
Format an int value as a literal.
- property format_integer_widened: None¶
Default
format_integer_widened– no mixed-magnitude integer widening, so the renderer keeps the normal integer formatter.
- property format_ordered_map_entry: Callable[[str, Value, str], str]¶
Callable that formats one ordered-map entry.
- property format_sequence_entry: Callable[[Value, str], str]¶
Format a sequence entry.
- property format_set_entry: Callable[[Value, str], str]¶
Format a set entry.
- property format_string: Callable[[str], str]¶
Callable that formats a string value as a quoted literal.
- property format_time: Callable[[time], str]¶
Callable that formats a time as a string literal.
- property format_variable_assignment: Callable[[str, str, Value], str]¶
Callable that formats an assignment to an existing variable.
- property format_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]¶
Callable that formats a new variable declaration.
- has_free_function_calls = True¶
- property heterogeneous_behavior: HeterogeneousBehavior¶
Return the heterogeneous-behavior config.
- heterogeneous_strategies¶
alias of
HeterogeneousStrategies
- heterogeneous_strategy: HeterogeneousStrategies = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)¶
- identifier_cases: ClassVar[tuple[IdentifierCase, ...]] = (IdentifierCase.SNAKE, IdentifierCase.CAMEL)¶
- indent: str = ' '¶
- indent_closing_delimiter: ClassVar[bool] = False¶
- integer_format: IntegerFormats = 1¶
- integer_formats¶
alias of
IntegerFormats
- integer_width_strategies¶
alias of
BareIntegerWidthStrategies
- integer_width_strategy: BareIntegerWidthStrategies = 1¶
- language_version: VersionFormats = 1¶
- property leading_preamble: LeadingPreamble¶
Default
leading_preamble– no preamble lines that must precedeLanguage.static_preamble.
- max_call_parameters = 9223372036854775807¶
- modifier_combinations: ClassVar[tuple[ModifierCombination, ...]] = ()¶
- null_literal: ClassVar[str] = 'null'¶
- numeric_literal_suffix: NumericLiteralSuffixes = 1¶
- numeric_literal_suffixes¶
alias of
NumericLiteralSuffixes
- numeric_separator: NumericSeparators = 1¶
- numeric_separators¶
alias of
NumericSeparators
- numeric_style: NumericStyles = 1¶
- numeric_styles¶
alias of
NumericStyles
- property ordered_map_format_config: OrderedMapFormatConfig¶
Configuration for ordered-map formatting.
- pygments_name = 'jsonnet'¶
- reserved_identifiers: ClassVar[frozenset[str]] = frozenset({})¶
- property scalar_body_preamble: dict[type, tuple[str, ...]]¶
Per-instance scalar body preamble (Jsonnet needs none).
- property scalar_preamble: dict[type, tuple[str, ...]]¶
Per-instance scalar preamble (Jsonnet needs none).
- sequence_binding_declarations(declarations: tuple[str, ...]) str¶
Default
sequence_binding_declarations– join the per-binding snippets with newlines.
- sequence_format: SequenceFormats = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=']', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)¶
- property sequence_format_config: SequenceFormatConfig¶
Configuration for the chosen sequence format.
- sequence_formats¶
alias of
SequenceFormats
- property sequence_open: Callable[[list[Value]], str]¶
Callable that returns the opening delimiter for a sequence.
- set_format: SetFormats = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close=']', empty_set=None, preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)¶
- property set_format_config: SetFormatConfig¶
Configuration for the chosen set format.
- set_formats¶
alias of
SetFormats
- skip_null_dict_values: ClassVar[bool] = False¶
- special_float_preamble: ClassVar[tuple[str, ...]] = ()¶
- statement_terminator: ClassVar[str] = ''¶
- statement_terminator_style: StatementTerminatorStyles = 1¶
- statement_terminator_styles¶
alias of
StatementTerminatorStyles
- static_body_preamble: ClassVar[Sequence[str]] = ()¶
- static_preamble: ClassVar[Sequence[str]] = ()¶
- string_format: StringFormats = 1¶
- string_formats¶
alias of
StringFormats
- supported_ref_cases: ClassVar[frozenset[IdentifierCase]] = frozenset({IdentifierCase.CAMEL, IdentifierCase.PASCAL, IdentifierCase.SNAKE, IdentifierCase.UPPER_SNAKE})¶
- supports_call_style = True¶
- supports_collection_comments: ClassVar[bool] = True¶
- supports_default_dict_key_type = False¶
- supports_default_dict_value_type = False¶
- supports_default_ordered_map_value_type = False¶
- supports_default_sequence_element_type = False¶
- supports_default_set_element_type = False¶
- supports_dict_literal_as_free_expression = True¶
- supports_dotted_call_stub = True¶
- supports_dotted_calls = True¶
- supports_empty_dict_key = False¶
- supports_inline_multiline_dict_args = True¶
- supports_module_name = False¶
- supports_multi_param_call_wrapper_stub = True¶
- supports_no_variable_wrap_in_file = True¶
- supports_non_string_dict_keys = False¶
- supports_record_shape_names = False¶
- supports_record_struct_name_prefix = False¶
- supports_scalar_before_comments: ClassVar[bool] = True¶
- supports_scalar_inline_comments: ClassVar[bool] = True¶
- supports_special_floats = True¶
- supports_standalone_comments_in_wrapped_calls = False¶
- supports_variable_names = False¶
- supports_zero_parameter_calls = True¶
- trailing_comma: TrailingCommas = TrailingCommaConfig(multiline_trailing_comma=True)¶
- property trailing_comma_config: TrailingCommaConfig¶
Configuration for trailing-comma behavior.
- trailing_commas¶
alias of
TrailingCommas
- true_literal: ClassVar[str] = 'true'¶
- property type_hint_collection_preamble_lines: Callable[[frozenset[type]], tuple[str, ...]]¶
Return preamble lines for empty-collection type hints.
- property validate_call_arg: Callable[[Value], None]¶
Return call-argument validation for this language.
- validate_spec_for_data(data: Value) None¶
Default
validate_spec_for_data— no spec/data constraints.
- variable_type_hints: VariableTypeHints = 1¶
- variable_type_hints_formats¶
alias of
VariableTypeHints
- version_formats¶
alias of
VersionFormats
- wrap_calls_with_declarations(declarations: tuple[str, ...], calls: str, body_preamble: tuple[str, ...]) str¶
Default
wrap_calls_with_declarations— concatenate the declarations and calls and route throughwrap_in_file()in call mode.
- static wrap_combined_in_file(declaration: str, assignment: str, variable_name: str, body_preamble: tuple[str, ...]) str¶
Unsupported: literalize() rejects BothVariableForms upstream.
- wrap_in_file(content: str, variable_name: str, body_preamble: tuple[str, ...]) str¶
Wrap code in a valid Jsonnet file.
When variable_name is empty (call mode), wrap the content lines in an array so the file evaluates to a single expression.
- class literalizer.languages.Julia(*args: object, **kwargs: object)¶
Julia language specification.
- Parameters:
date_format –
How to format
datetime.datevalues.date_formats.JULIA—Date(...)constructor call, e.g.Date(2024, 1, 15).date_formats.ISO— ISO 8601 quoted string, e.g."2024-01-15".
datetime_format –
How to format
datetime.datetimevalues.datetime_formats.JULIA—DateTime(...)constructor call, e.g.DateTime(2024, 1, 15, 12, 30, 0).datetime_formats.ISO— ISO 8601 quoted string, e.g."2024-01-15T12:30:00".
sequence_format –
Which Julia sequence type to use.
sequence_formats.ARRAY— array literal, e.g.[1, 2, 3].sequence_formats.TUPLE— tuple literal, e.g.(1, 2, 3).
- class BoolFormats(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
Empty: this language has no alternative boolean formats.
- class BytesFormats(*values)¶
Bytes formatting options.
- BASE64 = <function format_bytes_base64>¶
- HEX = <function format_bytes_hex>¶
- class CallStyles(*values)¶
Julia call style options.
- KEYWORD = KeywordCallStyle(separator='=')¶
- POSITIONAL = PositionalCallStyle(arg_separator=', ', parenthesize_each_arg=False)¶
- class CommentFormats(*values)¶
Comment style options.
- BLOCK = CommentConfig(prefix='#=', suffix=' =#')¶
- HASH = CommentConfig(prefix='#', suffix='')¶
- class DateFormats(*values)¶
Date formatting options for Julia.
- ISO = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- JULIA = DateFormatConfig(formatter=<function date_ymd_formatter.<locals>._format>, preamble_lines=('using Dates',), type_produced=<class 'datetime.date'>)¶
- class DatetimeFormats(*values)¶
Datetime formatting options for Julia.
- EPOCH = DatetimeFormatConfig(formatter=<function format_datetime_epoch>, preamble_lines=(), type_produced=<class 'int'>)¶
- ISO = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- JULIA = DatetimeFormatConfig(formatter=<function datetime_ymdhms_formatter.<locals>._format>, preamble_lines=('using Dates',), type_produced=<class 'datetime.datetime'>)¶
- class DeclarationStyles(*values)¶
Declaration style options.
- ASSIGN = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=True)¶
- class DictFormats(*values)¶
Dict/map format options.
- DICT = DictFormatConfig(dict_open=<function fixed_open.<locals>._open>, close=')', format_entry=<function dict_entry_with_separator.<locals>._format>, empty_dict='Dict()', preamble_lines=(), narrowed_open=None, supports_trailing_comma=True)¶
- ORDERED = DictFormatConfig(dict_open=<function fixed_open.<locals>._open>, close=')', format_entry=<function dict_entry_with_separator.<locals>._format>, empty_dict='OrderedDict()', preamble_lines=('using DataStructures',), narrowed_open=None, supports_trailing_comma=True)¶
- class FloatFormats(*values)¶
Float format options.
- FIXED = <function format_float_fixed>¶
- REPR = <function format_float_repr>¶
- SCIENTIFIC = <function format_float_scientific>¶
- class HeterogeneousStrategies(*values)¶
Heterogeneous-scalar strategy options — this language only supports raising.
- ERROR = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)¶
- class IntegerFormats(*values)¶
Integer format options.
- BINARY = mappingproxy({'NONE': <function format_integer_binary>, 'UNDERSCORE': <function format_integer_binary>})¶
- DECIMAL = mappingproxy({'NONE': <class 'str'>, 'UNDERSCORE': <function format_integer_underscore>})¶
- HEX = mappingproxy({'NONE': <function format_integer_hex>, 'UNDERSCORE': <function format_integer_hex>})¶
- OCTAL = mappingproxy({'NONE': <function format_integer_octal>, 'UNDERSCORE': <function format_integer_octal>})¶
- get_formatter(numeric_separator: Enum) Callable[[int], str]¶
Return the integer formatter for the given separator.
- class JsonTypes(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
Empty: this language has no JSON value-type variants.
- class Modifiers(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
C++/Java/C#-style declaration modifiers: this language has none.
- class SequenceFormats(*values)¶
Sequence type options for Julia.
- ARRAY = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=']', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)¶
- TUPLE = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=')', supports_heterogeneity=True, single_element_trailing_comma=True, supports_trailing_comma=True, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)¶
- class SetFormats(*values)¶
Set type options for Julia.
- SET = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close='])', empty_set='Set()', preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)¶
- class TrailingCommas(*values)¶
Trailing comma options.
- NO = TrailingCommaConfig(multiline_trailing_comma=False)¶
- YES = TrailingCommaConfig(multiline_trailing_comma=True)¶
- allows_empty_call_parens = True¶
- bool_formats¶
alias of
BoolFormats
- bytes_format: BytesFormats = <function format_bytes_hex>¶
- bytes_formats¶
alias of
BytesFormats
- property call_data_dependent_preamble: Callable[[Value], tuple[str, ...]]¶
Return data-dependent preamble lines for call rendering.
- call_returns_expression = True¶
- call_style: CallStyles = KeywordCallStyle(separator='=')¶
- property call_style_config: PositionalCallStyle | KeywordCallStyle | ObjectCallStyle | PostfixCallStyle | PrefixCallStyle | CommandCallStyle¶
Configuration for the chosen call style.
- call_styles¶
alias of
CallStyles
- property comment_config: CommentConfig¶
Configuration for the language’s comment syntax.
- comment_format: CommentFormats = CommentConfig(prefix='#', suffix='')¶
- comment_formats¶
alias of
CommentFormats
- property compute_body_preamble: Callable[[frozenset[type], Value], tuple[str, ...]]¶
Compute body-preamble lines from the scalar map.
- property consumable_ref_value_inhibits_consuming_form: Callable[[Value], bool]¶
Predicate deciding whether a ref’s underlying value type inhibits the consume form.
Delegates to
never_inhibits_consuming_form. Languages whose consume operator rejects certain value types (notably the Mojo^on register-trivial scalars) override this.
- property data_dependent_preamble: Callable[[Value], tuple[str, ...]]¶
Return data-dependent preamble lines.
- date_format: DateFormats = DateFormatConfig(formatter=<function date_ymd_formatter.<locals>._format>, preamble_lines=('using Dates',), type_produced=<class 'datetime.date'>)¶
- date_formats¶
alias of
DateFormats
- datetime_format: DatetimeFormats = DatetimeFormatConfig(formatter=<function datetime_ymdhms_formatter.<locals>._format>, preamble_lines=('using Dates',), type_produced=<class 'datetime.datetime'>)¶
- datetime_formats¶
alias of
DatetimeFormats
- declaration_style: DeclarationStyles = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=True)¶
- declaration_styles¶
alias of
DeclarationStyles
- dict_entry_style: DictEntryStyles = 1¶
- dict_entry_styles¶
alias of
DictEntryStyles
- dict_format: DictFormats = DictFormatConfig(dict_open=<function fixed_open.<locals>._open>, close=')', format_entry=<function dict_entry_with_separator.<locals>._format>, empty_dict='Dict()', preamble_lines=(), narrowed_open=None, supports_trailing_comma=True)¶
- property dict_format_config: DictFormatConfig¶
Configuration for dict formatting.
- dict_formats¶
alias of
DictFormats
- dict_supports_heterogeneous_values = True¶
- element_separator: ClassVar[str] = ', '¶
- empty_dict_keys¶
alias of
EmptyDictKey
- extension = '.jl'¶
- false_literal: ClassVar[str] = 'false'¶
- float_format: FloatFormats = <function format_float_repr>¶
- float_formats¶
alias of
FloatFormats
- property format_bytes: Callable[[bytes], str]¶
Callable that formats a bytes value as a string literal.
- static format_call_arg(_value: Value, formatted: str, /) str¶
Callable that rewrites a formatted direct call argument.
- property format_call_arg_ref_identifier: Callable[[str, Value | None], str]¶
Rewrite a
{"$ref": "name"}identifier in a call-argument context.Delegates to
format_call_ref_identifier. Override this to allow call-argument$refvalues that would otherwise be rejected.
- property format_call_arg_ref_identifier_consumable: Callable[[str, Value | None], str]¶
Format a
$refthe caller authorized as consumable.Delegates to
format_call_arg_ref_identifier. Override this to opt into a consuming form (e.g. C++std::move).
- format_call_binding_body_preamble() tuple[str, ...]¶
Default
format_call_binding_body_preamble– no extra body preamble lines for an inference-bound call result.
- format_call_binding_file_pragmas() tuple[str, ...]¶
Default
format_call_binding_file_pragmas– no file-level compiler-pragma line for an inference-bound call result.
- property format_call_preamble_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]¶
Return file-scope stubs for a call expression.
- property format_call_ref_identifier: Callable[[str, Value | None], str]¶
Raise for any
{"$ref": "name"}identifier.Julia output is not wrapped in a function body, so variable references require a surrounding assignment that cannot be injected.
- property format_call_statement: Callable[[str], str]¶
Return call-statement formatting for this language.
- property format_call_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]¶
Return stub declarations for a call expression.
- property format_call_target: Callable[[Sequence[str]], str]¶
Rewrite a dotted call target into the language’s call syntax.
- property format_call_variable_assignment: Callable[[str, str, Value], str]¶
Default
format_call_variable_assignment– reuse the literal-binding assignment formatter unchanged.
- property format_call_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]¶
Default
format_call_variable_declaration– reuse the literal-binding declaration formatter unchanged.
- static format_constructor_target(class_name: str, /) str¶
Return class_name as a zero-argument constructor call target.
- property format_date: Callable[[date], str]¶
Callable that formats a date as a string literal.
- property format_datetime: Callable[[datetime], str]¶
Callable that formats a datetime as a string literal.
- property format_float: Callable[[float], str]¶
Callable that formats a float value as a literal.
- property format_integer: Callable[[int], str]¶
Callable that formats an int value as a literal.
- property format_integer_widened: None¶
Default
format_integer_widened– no mixed-magnitude integer widening, so the renderer keeps the normal integer formatter.
- property format_ordered_map_entry: Callable[[str, Value, str], str]¶
Callable that formats one ordered-map entry.
- property format_sequence_entry: Callable[[Value, str], str]¶
Format a sequence entry.
- property format_set_entry: Callable[[Value, str], str]¶
Format a set entry.
- property format_string: Callable[[str], str]¶
Format a string value as a quoted literal.
- property format_time: Callable[[time], str]¶
Callable that formats a time as a string literal.
- property format_variable_assignment: Callable[[str, str, Value], str]¶
Callable that formats an assignment to an existing variable.
- property format_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]¶
Callable that formats a new variable declaration.
- has_free_function_calls = True¶
- property heterogeneous_behavior: HeterogeneousBehavior¶
Return the heterogeneous-behavior config.
- heterogeneous_strategies¶
alias of
HeterogeneousStrategies
- heterogeneous_strategy: HeterogeneousStrategies = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)¶
- identifier_cases: ClassVar[tuple[IdentifierCase, ...]] = (IdentifierCase.SNAKE, IdentifierCase.PASCAL)¶
- indent: str = ' '¶
- indent_closing_delimiter: ClassVar[bool] = False¶
- integer_format: IntegerFormats = mappingproxy({'NONE': <class 'str'>, 'UNDERSCORE': <function format_integer_underscore>})¶
- integer_formats¶
alias of
IntegerFormats
- integer_width_strategies¶
alias of
BareIntegerWidthStrategies
- integer_width_strategy: BareIntegerWidthStrategies = 1¶
- language_version: VersionFormats = 1¶
- property leading_preamble: LeadingPreamble¶
Default
leading_preamble– no preamble lines that must precedeLanguage.static_preamble.
- max_call_parameters = 9223372036854775807¶
- modifier_combinations: ClassVar[tuple[ModifierCombination, ...]] = ()¶
- null_literal: ClassVar[str] = 'nothing'¶
- numeric_literal_suffix: NumericLiteralSuffixes = 1¶
- numeric_literal_suffixes¶
alias of
NumericLiteralSuffixes
- numeric_separator: NumericSeparators = 1¶
- numeric_separators¶
alias of
NumericSeparators
- numeric_style: NumericStyles = 1¶
- numeric_styles¶
alias of
NumericStyles
- property ordered_map_format_config: OrderedMapFormatConfig¶
Configuration for ordered-map formatting.
- pygments_name = 'julia'¶
- reserved_identifiers: ClassVar[frozenset[str]] = frozenset({})¶
- property scalar_body_preamble: dict[type, tuple[str, ...]]¶
Per-instance scalar body preamble (Julia needs none).
- property scalar_preamble: dict[type, tuple[str, ...]]¶
Per-instance scalar preamble computed from date/datetime format.
- sequence_binding_declarations(declarations: tuple[str, ...]) str¶
Default
sequence_binding_declarations– join the per-binding snippets with newlines.
- sequence_format: SequenceFormats = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=']', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)¶
- property sequence_format_config: SequenceFormatConfig¶
Configuration for the chosen sequence format.
- sequence_formats¶
alias of
SequenceFormats
- property sequence_open: Callable[[list[Value]], str]¶
Callable that returns the opening delimiter for a sequence.
- set_format: SetFormats = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close='])', empty_set='Set()', preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)¶
- property set_format_config: SetFormatConfig¶
Configuration for the chosen set format.
- set_formats¶
alias of
SetFormats
- skip_null_dict_values: ClassVar[bool] = False¶
- special_float_preamble: ClassVar[tuple[str, ...]] = ()¶
- statement_terminator: ClassVar[str] = ''¶
- statement_terminator_style: StatementTerminatorStyles = 1¶
- statement_terminator_styles¶
alias of
StatementTerminatorStyles
- static_body_preamble: ClassVar[Sequence[str]] = ()¶
- static_preamble: ClassVar[Sequence[str]] = ()¶
- string_format: StringFormats = 1¶
- string_formats¶
alias of
StringFormats
- supported_ref_cases: ClassVar[frozenset[IdentifierCase]] = frozenset({IdentifierCase.CAMEL, IdentifierCase.PASCAL, IdentifierCase.SNAKE, IdentifierCase.UPPER_SNAKE})¶
- supports_call_style = True¶
- supports_collection_comments: ClassVar[bool] = True¶
- supports_default_dict_key_type = False¶
- supports_default_dict_value_type = False¶
- supports_default_ordered_map_value_type = False¶
- supports_default_sequence_element_type = False¶
- supports_default_set_element_type = False¶
- supports_dict_literal_as_free_expression = True¶
- supports_dotted_call_stub = True¶
- supports_dotted_calls = True¶
- supports_empty_dict_key = False¶
- supports_inline_multiline_dict_args = True¶
- supports_module_name = False¶
- supports_multi_param_call_wrapper_stub = True¶
- supports_no_variable_wrap_in_file = True¶
- supports_non_string_dict_keys = True¶
- supports_record_shape_names = False¶
- supports_record_struct_name_prefix = False¶
- supports_scalar_before_comments: ClassVar[bool] = True¶
- supports_scalar_inline_comments: ClassVar[bool] = True¶
- supports_special_floats = True¶
- supports_standalone_comments_in_wrapped_calls = True¶
- supports_variable_names = True¶
- supports_zero_parameter_calls = True¶
- trailing_comma: TrailingCommas = TrailingCommaConfig(multiline_trailing_comma=True)¶
- property trailing_comma_config: TrailingCommaConfig¶
Configuration for trailing-comma behavior.
- trailing_commas¶
alias of
TrailingCommas
- true_literal: ClassVar[str] = 'true'¶
- property type_hint_collection_preamble_lines: Callable[[frozenset[type]], tuple[str, ...]]¶
Return preamble lines for empty-collection type hints.
- property validate_call_arg: Callable[[Value], None]¶
Return call-argument validation for this language.
- validate_spec_for_data(data: Value) None¶
Default
validate_spec_for_data— no spec/data constraints.
- variable_type_hints: VariableTypeHints = 1¶
- variable_type_hints_formats¶
alias of
VariableTypeHints
- version_formats¶
alias of
VersionFormats
- wrap_calls_with_declarations(declarations: tuple[str, ...], calls: str, body_preamble: tuple[str, ...]) str¶
Default
wrap_calls_with_declarations— concatenate the declarations and calls and route throughwrap_in_file()in call mode.
- static wrap_combined_in_file(declaration: str, assignment: str, variable_name: str, body_preamble: tuple[str, ...]) str¶
Wrap declaration and assignment in a valid file (no-op).
- static wrap_in_file(content: str, variable_name: str, body_preamble: tuple[str, ...]) str¶
Wrap code in a valid file (no-op).
- class literalizer.languages.Kotlin(*args: object, **kwargs: object)¶
Kotlin language specification.
- Parameters:
date_format –
How to format
datetime.datevalues.date_formats.KOTLIN—LocalDate.of(...)call, e.g.LocalDate.of(2024, 1, 15).date_formats.ISO— ISO 8601 quoted string, e.g."2024-01-15".
datetime_format –
How to format
datetime.datetimevalues.datetime_formats.KOTLIN—LocalDateTime.of(...)call, e.g.LocalDateTime.of(2024, 1, 15, 12, 30, 0).datetime_formats.ISO— ISO 8601 quoted string, e.g."2024-01-15T12:30:00".
sequence_format –
Which Kotlin sequence type to use.
sequence_formats.LIST— typed array calls (e.g.intArrayOf(1, 2, 3)). Heterogeneous sequences fall back tolistOf<Any?>(…).sequence_formats.TUPLE—Pair(…)for two-element sequences,Triple(…)for three-element sequences, e.g.Pair("a", 1). Other sizes fall back tolistOf<Any?>(…).
json_type – When set to
json_types.KOTLINX_JSON_ELEMENT, render values throughJson.parseToJsonElement(...)so the output produces akotlinx.serialization.json.JsonElementinstead of Kotlin’s narrowList/Map/ array types.
- class BoolFormats(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
Empty: this language has no alternative boolean formats.
- class BytesFormats(*values)¶
Bytes formatting options.
- BASE64 = <function format_bytes_base64>¶
- HEX = <function format_bytes_hex>¶
- class CallStyles(*values)¶
Kotlin call style options.
- KEYWORD = KeywordCallStyle(separator=' = ')¶
- POSITIONAL = PositionalCallStyle(arg_separator=', ', parenthesize_each_arg=False)¶
- class CommentFormats(*values)¶
Comment style options.
- BLOCK = CommentConfig(prefix='/*', suffix=' */')¶
- DOUBLE_SLASH = CommentConfig(prefix='//', suffix='')¶
- class DateFormats(*values)¶
Date format options for Kotlin.
- ISO = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- KOTLIN = DateFormatConfig(formatter=<function date_ymd_formatter.<locals>._format>, preamble_lines=('import java.time.LocalDate',), type_produced=<class 'datetime.date'>)¶
- class DatetimeFormats(*values)¶
Datetime format options for Kotlin.
- EPOCH = DatetimeFormatConfig(formatter=<function format_datetime_epoch>, preamble_lines=(), type_produced=<class 'int'>)¶
- ISO = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- KOTLIN = DatetimeFormatConfig(formatter=<function datetime_ymdhms_formatter.<locals>._format>, preamble_lines=('import java.time.LocalDateTime',), type_produced=<class 'datetime.datetime'>)¶
- class DeclarationStyles(*values)¶
Declaration style options.
- VAL = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=False)¶
- VAR = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=True)¶
- class DictFormats(*values)¶
Dict/map format options.
- HASH_MAP = _KotlinDictSpec(opener_template='hashMapOf<{key_type}, {type_name}>(')¶
- MAP = _KotlinDictSpec(opener_template='mapOf<{key_type}, {type_name}>(')¶
- class FloatFormats(*values)¶
Float format options.
- FIXED = <function format_float_fixed>¶
- REPR = <function format_float_repr>¶
- SCIENTIFIC = <function format_float_scientific>¶
- class HeterogeneousStrategies(*values)¶
Strategy for dicts whose values span more than one Kotlin type.
ERRORkeeps Kotlin’s strict-typing behavior (mixed-value dicts that cannot be represented raise).RECORDrenders each record-shaped dict (non-empty, string-keyed) as a generateddata classdeclared in the preamble plus a matching constructor-call literal, so fields may legitimately mix scalars and containers.TUPLEcomposesRECORDand additionally renders a fixed-length heterogeneous scalar array that is a dict value or the document root as a two-elementPair(...)or three-elementTriple(...)typedPair<...>/Triple<...>– a record field whose value is such an array becomes a tuple-typed field. Kotlin has no general N-tuple, so an array of any other length raisesTupleArityNotRepresentableErrorrather than degrading to a homogeneous list.- ERROR = 1¶
- RECORD = 2¶
- TUPLE = 3¶
- class IntegerFormats(*values)¶
Integer format options.
- BINARY = mappingproxy({'NONE': <function format_integer_binary>, 'UNDERSCORE': <function format_integer_binary>})¶
- DECIMAL = mappingproxy({'NONE': <class 'str'>, 'UNDERSCORE': <function format_integer_underscore>})¶
- HEX = mappingproxy({'NONE': <function format_integer_hex>, 'UNDERSCORE': <function format_integer_hex>})¶
- get_formatter(numeric_separator: Enum) Callable[[int], str]¶
Return the integer formatter for the given separator.
- class JsonTypes(*values)¶
JSON value type options for Kotlin.
- KOTLINX_JSON_ELEMENT = 'kotlinx.serialization.json.JsonElement'¶
Dynamic JSON value type from
kotlinx.serialization.json.
- class Modifiers(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
C++/Java/C#-style declaration modifiers: this language has none.
- class SequenceFormats(*values)¶
Sequence type options for Kotlin.
- ARRAY = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=')', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)¶
- LIST = SequenceFormatConfig(sequence_open=<function typed_collection_open.<locals>._open>, close=')', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback='listOf<Any?>(', uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)¶
- TUPLE = SequenceFormatConfig(sequence_open=<function _kotlin_tuple_open>, close=')', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)¶
- class SetFormats(*values)¶
Set type options for Kotlin.
- SET = <function set_format_factory.<locals>._build>¶
- SORTED_SET = <function set_format_factory.<locals>._build>¶
- class TrailingCommas(*values)¶
Trailing comma options.
- NO = TrailingCommaConfig(multiline_trailing_comma=False)¶
- YES = TrailingCommaConfig(multiline_trailing_comma=True)¶
- class VariableTypeHints(*values)¶
Variable type hint options.
- ALWAYS = 2¶
- NEVER = 1¶
- SAFE = 3¶
- formatter(*, auto_formatter: Callable[[str, str, Value, frozenset[Enum]], str], keyword: str, date_hint: str, datetime_hint: str, default_set_element_type: str, default_dict_key_type: str, default_dict_value_type: str, dict_outer: str, set_outer: str, sequence_format_name: str) Callable[[str, str, Value, frozenset[Enum]], str]¶
Return the variable declaration formatter.
- allows_empty_call_parens = True¶
- bool_formats¶
alias of
BoolFormats
- bytes_format: BytesFormats = <function format_bytes_hex>¶
- bytes_formats¶
alias of
BytesFormats
- property call_data_dependent_preamble: Callable[[Value], tuple[str, ...]]¶
Return data-dependent preamble lines for call rendering.
- call_returns_expression = True¶
- call_style: CallStyles = KeywordCallStyle(separator=' = ')¶
- property call_style_config: PositionalCallStyle | KeywordCallStyle | ObjectCallStyle | PostfixCallStyle | PrefixCallStyle | CommandCallStyle¶
Configuration for the chosen call style.
- call_styles¶
alias of
CallStyles
- property comment_config: CommentConfig¶
Configuration for the language’s comment syntax.
- comment_format: CommentFormats = CommentConfig(prefix='//', suffix='')¶
- comment_formats¶
alias of
CommentFormats
- property compute_body_preamble: Callable[[frozenset[type], Value], tuple[str, ...]]¶
Compute body-preamble lines from the scalar map.
- property consumable_ref_value_inhibits_consuming_form: Callable[[Value], bool]¶
Predicate deciding whether a ref’s underlying value type inhibits the consume form.
Delegates to
never_inhibits_consuming_form. Languages whose consume operator rejects certain value types (notably the Mojo^on register-trivial scalars) override this.
- property data_dependent_preamble: Callable[[Value], tuple[str, ...]]¶
Return data-dependent preamble lines.
Always emits
import java.math.BigIntegerwhen the data carries an out-of-range integer; underHeterogeneousStrategies.RECORDadditionally emits onedata classdeclaration per record shape present in the data. Whenjson_typeis active neither applies: integers outside the 64-bit range ride inside the JSON text, and the data flows through a singleJson.parseToJsonElementcall instead of typed records.
- date_format: DateFormats = DateFormatConfig(formatter=<function date_ymd_formatter.<locals>._format>, preamble_lines=('import java.time.LocalDate',), type_produced=<class 'datetime.date'>)¶
- date_formats¶
alias of
DateFormats
- datetime_format: DatetimeFormats = DatetimeFormatConfig(formatter=<function datetime_ymdhms_formatter.<locals>._format>, preamble_lines=('import java.time.LocalDateTime',), type_produced=<class 'datetime.datetime'>)¶
- datetime_formats¶
alias of
DatetimeFormats
- declaration_style: DeclarationStyles = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=False)¶
- declaration_styles¶
alias of
DeclarationStyles
- default_dict_key_type: str = 'String'¶
- default_dict_value_type: str = 'Any?'¶
- default_set_element_type: str = 'Any?'¶
- dict_entry_style: DictEntryStyles = 1¶
- dict_entry_styles¶
alias of
DictEntryStyles
- dict_format: DictFormats = _KotlinDictSpec(opener_template='mapOf<{key_type}, {type_name}>(')¶
- property dict_format_config: DictFormatConfig¶
Configuration for dict formatting.
- dict_formats¶
alias of
DictFormats
- dict_supports_heterogeneous_values = True¶
- element_separator: ClassVar[str] = ', '¶
- empty_dict_keys¶
alias of
EmptyDictKey
- extension = '.kts'¶
- false_literal: ClassVar[str] = 'false'¶
- float_format: FloatFormats = <function format_float_repr>¶
- float_formats¶
alias of
FloatFormats
- property format_bytes: Callable[[bytes], str]¶
Callable that formats a bytes value as a string literal.
- property format_call_arg: Callable[[Value, str], str]¶
Callable that rewrites a formatted direct call argument.
- property format_call_arg_ref_identifier: Callable[[str, Value | None], str]¶
Rewrite a
{"$ref": "name"}identifier in a call-argument context.Delegates to
format_call_ref_identifier. Override this to allow call-argument$refvalues that would otherwise be rejected.
- property format_call_arg_ref_identifier_consumable: Callable[[str, Value | None], str]¶
Format a
$refthe caller authorized as consumable.Delegates to
format_call_arg_ref_identifier. Override this to opt into a consuming form (e.g. C++std::move).
- format_call_binding_body_preamble() tuple[str, ...]¶
Default
format_call_binding_body_preamble– no extra body preamble lines for an inference-bound call result.
- format_call_binding_file_pragmas() tuple[str, ...]¶
Default
format_call_binding_file_pragmas– no file-level compiler-pragma line for an inference-bound call result.
- property format_call_preamble_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]¶
Return file-scope stubs for a call expression.
- property format_call_ref_identifier: Callable[[str, Value | None], str]¶
Rewrite a
{"$ref": "name"}identifier into the language’s call expression syntax.
- property format_call_statement: Callable[[str], str]¶
Return call-statement formatting for this language.
- property format_call_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]¶
Return stub declarations for a call expression.
- property format_call_target: Callable[[Sequence[str]], str]¶
Rewrite a dotted call target into the language’s call syntax.
- property format_call_variable_assignment: Callable[[str, str, Value], str]¶
Default
format_call_variable_assignment– reuse the literal-binding assignment formatter unchanged.
- property format_call_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]¶
Default
format_call_variable_declaration– reuse the literal-binding declaration formatter unchanged.
- static format_constructor_target(class_name: str, /) str¶
Return class_name as a zero-argument constructor call target.
- property format_date: Callable[[date], str]¶
Callable that formats a date as a string literal.
- property format_datetime: Callable[[datetime], str]¶
Callable that formats a datetime as a string literal.
- property format_float: Callable[[float], str]¶
Callable that formats a float value as a literal.
- property format_integer: Callable[[int], str]¶
Callable that formats an int value as a literal.
- property format_integer_widened: Callable[[int], str]¶
Always-
L-suffixed integer formatter for widened collections (mixed-magnitude int sets/lists).
- property format_ordered_map_entry: Callable[[str, Value, str], str]¶
Callable that formats one ordered-map entry.
- property format_sequence_entry: Callable[[Value, str], str]¶
Format a sequence entry.
- property format_set_entry: Callable[[Value, str], str]¶
Format a set entry.
- property format_string: Callable[[str], str]¶
Format a string value as a quoted literal.
- property format_time: Callable[[time], str]¶
Callable that formats a time as a string literal.
- property format_variable_assignment: Callable[[str, str, Value], str]¶
Format an assignment to an existing variable.
- property format_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]¶
Callable that formats a new variable declaration.
- has_free_function_calls = True¶
- property heterogeneous_behavior: HeterogeneousBehavior¶
Return the behavior for the chosen heterogeneous strategy.
- heterogeneous_strategies¶
alias of
HeterogeneousStrategies
- heterogeneous_strategy: HeterogeneousStrategies = 1¶
- identifier_cases: ClassVar[tuple[IdentifierCase, ...]] = (IdentifierCase.CAMEL, IdentifierCase.PASCAL, IdentifierCase.UPPER_SNAKE)¶
- indent: str = ' '¶
- indent_closing_delimiter: ClassVar[bool] = False¶
- integer_format: IntegerFormats = mappingproxy({'NONE': <class 'str'>, 'UNDERSCORE': <function format_integer_underscore>})¶
- integer_formats¶
alias of
IntegerFormats
- integer_width_strategies¶
alias of
BareIntegerWidthStrategies
- integer_width_strategy: BareIntegerWidthStrategies = 1¶
- language_version: VersionFormats = 1¶
- property leading_preamble: LeadingPreamble¶
Default
leading_preamble– no preamble lines that must precedeLanguage.static_preamble.
- max_call_parameters = 9223372036854775807¶
- modifier_combinations: ClassVar[tuple[ModifierCombination, ...]] = ()¶
- null_literal: ClassVar[str] = 'null'¶
- numeric_literal_suffix: NumericLiteralSuffixes = 1¶
- numeric_literal_suffixes¶
alias of
NumericLiteralSuffixes
- numeric_separator: NumericSeparators = 1¶
- numeric_separators¶
alias of
NumericSeparators
- numeric_style: NumericStyles = 1¶
- numeric_styles¶
alias of
NumericStyles
- property ordered_map_format_config: OrderedMapFormatConfig¶
Configuration for ordered-map formatting.
- pygments_name = 'kotlin'¶
- record_shape_names: Mapping[frozenset[str], str]¶
- record_struct_name_prefix: str = 'Record'¶
- reserved_identifiers: ClassVar[frozenset[str]] = frozenset({})¶
- property scalar_body_preamble: dict[type, tuple[str, ...]]¶
Per-instance scalar body preamble (Kotlin needs none).
- property scalar_preamble: dict[type, tuple[str, ...]]¶
Per-instance scalar preamble computed from date/datetime format.
Under
json_typeevery temporal value is folded into the JSON text as an ISO-8601 string, so the temporal Kotlin imports that the configureddate_format/datetime_formatwould otherwise add do not apply.
- sequence_binding_declarations(declarations: tuple[str, ...]) str¶
Default
sequence_binding_declarations– join the per-binding snippets with newlines.
- sequence_format: SequenceFormats = SequenceFormatConfig(sequence_open=<function typed_collection_open.<locals>._open>, close=')', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback='listOf<Any?>(', uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)¶
- property sequence_format_config: SequenceFormatConfig¶
Configuration for the chosen sequence format.
- sequence_formats¶
alias of
SequenceFormats
- property sequence_open: Callable[[list[Value]], str]¶
Callable that returns the opening delimiter for a sequence.
Under any record-rendering strategy (
RECORD, orTUPLEwhich composes it) a list whose elements are record-shaped dicts opens aslistOf<Any?>((the elements format asRecordN(...)literals, not theMap<...>the typed opener would otherwise infer).
- set_format: SetFormats = <function set_format_factory.<locals>._build>¶
- property set_format_config: SetFormatConfig¶
Configuration for the chosen set format.
- set_formats¶
alias of
SetFormats
- skip_null_dict_values: ClassVar[bool] = False¶
- special_float_preamble: ClassVar[tuple[str, ...]] = ()¶
- statement_terminator: ClassVar[str] = ''¶
- statement_terminator_style: StatementTerminatorStyles = 1¶
- statement_terminator_styles¶
alias of
StatementTerminatorStyles
- static_body_preamble: ClassVar[Sequence[str]] = ()¶
- property static_preamble: Sequence[str]¶
Static preamble lines emitted once per file.
When
json_typeis active theJsonandJsonElementimports are emitted here so every fixture has them in scope regardless of the rendered data.
- string_format: StringFormats = 1¶
- string_formats¶
alias of
StringFormats
- supported_ref_cases: ClassVar[frozenset[IdentifierCase]] = frozenset({IdentifierCase.CAMEL, IdentifierCase.PASCAL, IdentifierCase.SNAKE, IdentifierCase.UPPER_SNAKE})¶
- supports_call_style = True¶
- supports_collection_comments: ClassVar[bool] = True¶
- supports_default_dict_key_type = True¶
- supports_default_dict_value_type = True¶
- supports_default_ordered_map_value_type = False¶
- supports_default_sequence_element_type = False¶
- supports_default_set_element_type = True¶
- supports_dict_literal_as_free_expression = True¶
- supports_dotted_call_stub = True¶
- supports_dotted_calls = True¶
- supports_empty_dict_key = False¶
- supports_inline_multiline_dict_args = True¶
- supports_module_name = False¶
- supports_multi_param_call_wrapper_stub = True¶
- supports_no_variable_wrap_in_file = False¶
- supports_non_string_dict_keys = False¶
- supports_record_shape_names = True¶
- supports_record_struct_name_prefix = True¶
- supports_scalar_before_comments: ClassVar[bool] = True¶
- supports_scalar_inline_comments: ClassVar[bool] = True¶
- supports_special_floats = True¶
- supports_standalone_comments_in_wrapped_calls = True¶
- supports_variable_names = True¶
- supports_zero_parameter_calls = True¶
- trailing_comma: TrailingCommas = TrailingCommaConfig(multiline_trailing_comma=True)¶
- property trailing_comma_config: TrailingCommaConfig¶
Configuration for trailing-comma behavior.
- trailing_commas¶
alias of
TrailingCommas
- true_literal: ClassVar[str] = 'true'¶
- property type_hint_collection_preamble_lines: Callable[[frozenset[type]], tuple[str, ...]]¶
Return preamble lines for empty-collection type hints.
- property validate_call_arg: Callable[[Value], None]¶
Return call-argument validation for this language.
- validate_spec_for_data(data: Value) None¶
Validate the spec against the data.
When
json_typeis active, walk data to reject non- string dict keys, which JSON objects cannot represent.
- variable_type_hints: VariableTypeHints = 1¶
- variable_type_hints_formats¶
alias of
VariableTypeHints
- version_formats¶
alias of
VersionFormats
- wrap_calls_with_declarations(declarations: tuple[str, ...], calls: str, body_preamble: tuple[str, ...]) str¶
Default
wrap_calls_with_declarations— concatenate the declarations and calls and route throughwrap_in_file()in call mode.
- static wrap_combined_in_file(declaration: str, assignment: str, variable_name: str, body_preamble: tuple[str, ...]) str¶
Wrap declaration and assignment in a valid file (no-op).
- static wrap_in_file(content: str, variable_name: str, body_preamble: tuple[str, ...]) str¶
Wrap code in a valid file (no-op).
- class literalizer.languages.Lua(*args: object, **kwargs: object)¶
Lua language specification.
- class BoolFormats(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
Empty: this language has no alternative boolean formats.
- class BytesFormats(*values)¶
Bytes formatting options.
- BASE64 = <function format_bytes_base64>¶
- HEX = <function format_bytes_hex>¶
- class CallStyles(*values)¶
Lua call style options.
- POSITIONAL = PositionalCallStyle(arg_separator=', ', parenthesize_each_arg=False)¶
- class CommentFormats(*values)¶
Comment style options.
- BLOCK = CommentConfig(prefix='--[[', suffix=' ]]')¶
- DOUBLE_DASH = CommentConfig(prefix='--', suffix='')¶
- class DateFormats(*values)¶
Date format options for Lua.
- ISO = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- LUA = DateFormatConfig(formatter=<function _format_date_lua>, preamble_lines=(), type_produced=<class 'datetime.date'>)¶
- class DatetimeFormats(*values)¶
Datetime format options for Lua.
- EPOCH = DatetimeFormatConfig(formatter=<function format_datetime_epoch>, preamble_lines=(), type_produced=<class 'int'>)¶
- ISO = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- LUA = DatetimeFormatConfig(formatter=<function _format_datetime_lua>, preamble_lines=(), type_produced=<class 'datetime.datetime'>)¶
- class DeclarationStyles(*values)¶
Declaration style options.
- LOCAL = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=True)¶
- class FloatFormats(*values)¶
Float format options.
- FIXED = <function format_float_fixed>¶
- REPR = <function format_float_repr>¶
- SCIENTIFIC = <function format_float_scientific>¶
- class HeterogeneousStrategies(*values)¶
Heterogeneous-scalar strategy options — this language only supports raising.
- ERROR = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)¶
- class IntegerFormats(*values)¶
Integer format options.
- DECIMAL = <class 'str'>¶
- HEX = <function format_integer_hex>¶
- class JsonTypes(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
Empty: this language has no JSON value-type variants.
- class Modifiers(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
C++/Java/C#-style declaration modifiers: this language has none.
- class SequenceFormats(*values)¶
Sequence type options for Lua.
- TABLE = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close='}', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)¶
- class SetFormats(*values)¶
Set type options for Lua.
- SET = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close='}', empty_set=None, preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)¶
- class StringFormats(*values)¶
String format options.
- DOUBLE = <function _build_backslash_formatter.<locals>._format>¶
- SINGLE = <function _build_backslash_formatter.<locals>._format>¶
- class TrailingCommas(*values)¶
Trailing comma options.
- NO = TrailingCommaConfig(multiline_trailing_comma=False)¶
- YES = TrailingCommaConfig(multiline_trailing_comma=True)¶
- allows_empty_call_parens = True¶
- bool_formats¶
alias of
BoolFormats
- bytes_format: BytesFormats = <function format_bytes_hex>¶
- bytes_formats¶
alias of
BytesFormats
- property call_data_dependent_preamble: Callable[[Value], tuple[str, ...]]¶
Return data-dependent preamble lines for call rendering.
- call_returns_expression = True¶
- call_style: CallStyles = PositionalCallStyle(arg_separator=', ', parenthesize_each_arg=False)¶
- property call_style_config: PositionalCallStyle | KeywordCallStyle | ObjectCallStyle | PostfixCallStyle | PrefixCallStyle | CommandCallStyle¶
Configuration for the chosen call style.
- call_styles¶
alias of
CallStyles
- property comment_config: CommentConfig¶
Configuration for the language’s comment syntax.
- comment_format: CommentFormats = CommentConfig(prefix='--', suffix='')¶
- comment_formats¶
alias of
CommentFormats
- property compute_body_preamble: Callable[[frozenset[type], Value], tuple[str, ...]]¶
Compute body-preamble lines from the scalar map.
- property consumable_ref_value_inhibits_consuming_form: Callable[[Value], bool]¶
Predicate deciding whether a ref’s underlying value type inhibits the consume form.
Delegates to
never_inhibits_consuming_form. Languages whose consume operator rejects certain value types (notably the Mojo^on register-trivial scalars) override this.
- property data_dependent_preamble: Callable[[Value], tuple[str, ...]]¶
Return data-dependent preamble lines.
- date_format: DateFormats = DateFormatConfig(formatter=<function _format_date_lua>, preamble_lines=(), type_produced=<class 'datetime.date'>)¶
- date_formats¶
alias of
DateFormats
- datetime_format: DatetimeFormats = DatetimeFormatConfig(formatter=<function _format_datetime_lua>, preamble_lines=(), type_produced=<class 'datetime.datetime'>)¶
- datetime_formats¶
alias of
DatetimeFormats
- declaration_style: DeclarationStyles = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=True)¶
- declaration_styles¶
alias of
DeclarationStyles
- dict_entry_style: DictEntryStyles = 1¶
- dict_entry_styles¶
alias of
DictEntryStyles
- dict_format: DictFormats = 1¶
- property dict_format_config: DictFormatConfig¶
Configuration for dict formatting.
- dict_formats¶
alias of
DictFormats
- dict_supports_heterogeneous_values = True¶
- element_separator: ClassVar[str] = ', '¶
- empty_dict_keys¶
alias of
EmptyDictKey
- extension = '.lua'¶
- false_literal: ClassVar[str] = 'false'¶
- float_format: FloatFormats = <function format_float_repr>¶
- float_formats¶
alias of
FloatFormats
- property format_bytes: Callable[[bytes], str]¶
Callable that formats a bytes value as a string literal.
- static format_call_arg(_value: Value, formatted: str, /) str¶
Callable that rewrites a formatted direct call argument.
- property format_call_arg_ref_identifier: Callable[[str, Value | None], str]¶
Rewrite a
{"$ref": "name"}identifier in a call-argument context.Delegates to
format_call_ref_identifier. Override this to allow call-argument$refvalues that would otherwise be rejected.
- property format_call_arg_ref_identifier_consumable: Callable[[str, Value | None], str]¶
Format a
$refthe caller authorized as consumable.Delegates to
format_call_arg_ref_identifier. Override this to opt into a consuming form (e.g. C++std::move).
- format_call_binding_body_preamble() tuple[str, ...]¶
Default
format_call_binding_body_preamble– no extra body preamble lines for an inference-bound call result.
- format_call_binding_file_pragmas() tuple[str, ...]¶
Default
format_call_binding_file_pragmas– no file-level compiler-pragma line for an inference-bound call result.
- property format_call_preamble_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]¶
Return file-scope stubs for a call expression.
- property format_call_ref_identifier: Callable[[str, Value | None], str]¶
Rewrite a
{"$ref": "name"}identifier into the language’s call expression syntax.
- property format_call_statement: Callable[[str], str]¶
Return call-statement formatting for this language.
- property format_call_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]¶
Return stub declarations for a call expression.
- property format_call_target: Callable[[Sequence[str]], str]¶
Rewrite a dotted call target into the language’s call syntax.
- property format_call_variable_assignment: Callable[[str, str, Value], str]¶
Default
format_call_variable_assignment– reuse the literal-binding assignment formatter unchanged.
- property format_call_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]¶
Default
format_call_variable_declaration– reuse the literal-binding declaration formatter unchanged.
- static format_constructor_target(class_name: str, /) str¶
Return class_name as a zero-argument constructor call target.
- property format_date: Callable[[date], str]¶
Callable that formats a date as a string literal.
- property format_datetime: Callable[[datetime], str]¶
Callable that formats a datetime as a string literal.
- property format_float: Callable[[float], str]¶
Callable that formats a float value as a literal.
- property format_integer: Callable[[int], str]¶
Callable that formats an int value as a literal.
- property format_integer_widened: None¶
Default
format_integer_widened– no mixed-magnitude integer widening, so the renderer keeps the normal integer formatter.
- property format_ordered_map_entry: Callable[[str, Value, str], str]¶
Callable that formats one ordered-map entry.
- property format_sequence_entry: Callable[[Value, str], str]¶
Format a sequence entry.
- property format_set_entry: Callable[[Value, str], str]¶
Format a set entry.
- property format_string: Callable[[str], str]¶
Callable that formats a string value as a quoted literal.
- property format_time: Callable[[time], str]¶
Callable that formats a time as a string literal.
- property format_variable_assignment: Callable[[str, str, Value], str]¶
Callable that formats an assignment to an existing variable.
- property format_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]¶
Callable that formats a new variable declaration.
- has_free_function_calls = True¶
- property heterogeneous_behavior: HeterogeneousBehavior¶
Return the heterogeneous-behavior config.
- heterogeneous_strategies¶
alias of
HeterogeneousStrategies
- heterogeneous_strategy: HeterogeneousStrategies = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)¶
- identifier_cases: ClassVar[tuple[IdentifierCase, ...]] = (IdentifierCase.SNAKE, IdentifierCase.CAMEL)¶
- indent: str = ' '¶
- indent_closing_delimiter: ClassVar[bool] = False¶
- integer_format: IntegerFormats = <class 'str'>¶
- integer_formats¶
alias of
IntegerFormats
- integer_width_strategies¶
alias of
BareIntegerWidthStrategies
- integer_width_strategy: BareIntegerWidthStrategies = 1¶
- language_version: VersionFormats = 1¶
- property leading_preamble: LeadingPreamble¶
Default
leading_preamble– no preamble lines that must precedeLanguage.static_preamble.
- max_call_parameters = 9223372036854775807¶
- modifier_combinations: ClassVar[tuple[ModifierCombination, ...]] = ()¶
- null_literal: ClassVar[str] = 'nil'¶
- numeric_literal_suffix: NumericLiteralSuffixes = 1¶
- numeric_literal_suffixes¶
alias of
NumericLiteralSuffixes
- numeric_separator: NumericSeparators = 1¶
- numeric_separators¶
alias of
NumericSeparators
- numeric_style: NumericStyles = 1¶
- numeric_styles¶
alias of
NumericStyles
- property ordered_map_format_config: OrderedMapFormatConfig¶
Configuration for ordered-map formatting.
- pygments_name = 'lua'¶
- reserved_identifiers: ClassVar[frozenset[str]] = frozenset({})¶
- property scalar_body_preamble: dict[type, tuple[str, ...]]¶
Per-instance scalar body preamble (Lua needs none).
- property scalar_preamble: dict[type, tuple[str, ...]]¶
Per-instance scalar preamble (Lua needs none).
- sequence_binding_declarations(declarations: tuple[str, ...]) str¶
Default
sequence_binding_declarations– join the per-binding snippets with newlines.
- sequence_format: SequenceFormats = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close='}', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)¶
- property sequence_format_config: SequenceFormatConfig¶
Configuration for the chosen sequence format.
- sequence_formats¶
alias of
SequenceFormats
- property sequence_open: Callable[[list[Value]], str]¶
Callable that returns the opening delimiter for a sequence.
- set_format: SetFormats = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close='}', empty_set=None, preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)¶
- property set_format_config: SetFormatConfig¶
Configuration for the chosen set format.
- set_formats¶
alias of
SetFormats
- skip_null_dict_values: ClassVar[bool] = True¶
- special_float_preamble: ClassVar[tuple[str, ...]] = ()¶
- statement_terminator: ClassVar[str] = ''¶
- statement_terminator_style: StatementTerminatorStyles = 1¶
- statement_terminator_styles¶
alias of
StatementTerminatorStyles
- static_body_preamble: ClassVar[Sequence[str]] = ()¶
- static_preamble: ClassVar[Sequence[str]] = ()¶
- string_format: StringFormats = <function _build_backslash_formatter.<locals>._format>¶
- string_formats¶
alias of
StringFormats
- supported_ref_cases: ClassVar[frozenset[IdentifierCase]] = frozenset({IdentifierCase.CAMEL, IdentifierCase.PASCAL, IdentifierCase.SNAKE, IdentifierCase.UPPER_SNAKE})¶
- supports_call_style = True¶
- supports_collection_comments: ClassVar[bool] = True¶
- supports_default_dict_key_type = False¶
- supports_default_dict_value_type = False¶
- supports_default_ordered_map_value_type = False¶
- supports_default_sequence_element_type = False¶
- supports_default_set_element_type = False¶
- supports_dict_literal_as_free_expression = True¶
- supports_dotted_call_stub = True¶
- supports_dotted_calls = True¶
- supports_empty_dict_key = False¶
- supports_inline_multiline_dict_args = True¶
- supports_module_name = False¶
- supports_multi_param_call_wrapper_stub = True¶
- supports_no_variable_wrap_in_file = False¶
- supports_non_string_dict_keys = True¶
- supports_record_shape_names = False¶
- supports_record_struct_name_prefix = False¶
- supports_scalar_before_comments: ClassVar[bool] = True¶
- supports_scalar_inline_comments: ClassVar[bool] = True¶
- supports_special_floats = True¶
- supports_standalone_comments_in_wrapped_calls = True¶
- supports_variable_names = True¶
- supports_zero_parameter_calls = True¶
- trailing_comma: TrailingCommas = TrailingCommaConfig(multiline_trailing_comma=True)¶
- property trailing_comma_config: TrailingCommaConfig¶
Configuration for trailing-comma behavior.
- trailing_commas¶
alias of
TrailingCommas
- true_literal: ClassVar[str] = 'true'¶
- property type_hint_collection_preamble_lines: Callable[[frozenset[type]], tuple[str, ...]]¶
Return preamble lines for empty-collection type hints.
- property validate_call_arg: Callable[[Value], None]¶
Return call-argument validation for this language.
- static validate_spec_for_data(data: Value) None¶
Reject inputs containing an empty mapping on Lua.
- variable_type_hints: VariableTypeHints = 1¶
- variable_type_hints_formats¶
alias of
VariableTypeHints
- version_formats¶
alias of
VersionFormats
- wrap_calls_with_declarations(declarations: tuple[str, ...], calls: str, body_preamble: tuple[str, ...]) str¶
Default
wrap_calls_with_declarations— concatenate the declarations and calls and route throughwrap_in_file()in call mode.
- static wrap_combined_in_file(declaration: str, assignment: str, variable_name: str, body_preamble: tuple[str, ...]) str¶
Wrap declaration and assignment in a valid file (no-op).
- static wrap_in_file(content: str, variable_name: str, body_preamble: tuple[str, ...]) str¶
Wrap code in a valid file (no-op).
- class literalizer.languages.Matlab(*args: object, **kwargs: object)¶
MATLAB language specification.
- class BoolFormats(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
Empty: this language has no alternative boolean formats.
- class BytesFormats(*values)¶
Bytes formatting options.
- BASE64 = <function format_bytes_base64>¶
- HEX = <function format_bytes_hex>¶
- class CallStyles(*values)¶
Matlab call style options.
- POSITIONAL = PositionalCallStyle(arg_separator=', ', parenthesize_each_arg=False)¶
- class CommentFormats(*values)¶
Comment style options.
- BLOCK = CommentConfig(prefix='%{', suffix=' %}')¶
- PERCENT = CommentConfig(prefix='%', suffix='')¶
- class DateFormats(*values)¶
Date format options for Matlab.
- ISO = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- MATLAB = DateFormatConfig(formatter=<function date_ymd_formatter.<locals>._format>, preamble_lines=(), type_produced=<class 'datetime.date'>)¶
- class DatetimeFormats(*values)¶
Datetime format options for Matlab.
- EPOCH = DatetimeFormatConfig(formatter=<function format_datetime_epoch>, preamble_lines=(), type_produced=<class 'int'>)¶
- ISO = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- MATLAB = DatetimeFormatConfig(formatter=<function _format_datetime_matlab>, preamble_lines=(), type_produced=<class 'datetime.datetime'>)¶
- class DeclarationStyles(*values)¶
Declaration style options.
- ASSIGN = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=True)¶
- class DictFormats(*values)¶
Dict/map format options.
- CONTAINERS_MAP = DictFormatConfig(dict_open=<function _containers_map_open>, close='})', format_entry=<function _format_containers_map_entry>, empty_dict='containers.Map()', preamble_lines=(), narrowed_open=None, supports_trailing_comma=True)¶
- STRUCT = DictFormatConfig(dict_open=<function fixed_open.<locals>._open>, close=')', format_entry=<function _format_matlab_dict_entry>, empty_dict='struct()', preamble_lines=(), narrowed_open=None, supports_trailing_comma=True)¶
- class FloatFormats(*values)¶
Float format options.
- FIXED = <function format_float_fixed>¶
- REPR = <function format_float_repr>¶
- SCIENTIFIC = <function format_float_scientific>¶
- class HeterogeneousStrategies(*values)¶
Heterogeneous-scalar strategy options — this language only supports raising.
- ERROR = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)¶
- class JsonTypes(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
Empty: this language has no JSON value-type variants.
- class Modifiers(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
C++/Java/C#-style declaration modifiers: this language has none.
- class SequenceFormats(*values)¶
Sequence type options for MATLAB.
- CELL_ARRAY = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close='}', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=False, empty_sequence='{}', preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)¶
- class SetFormats(*values)¶
Set type options for MATLAB.
- SET = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close='}', empty_set='{}', preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)¶
- class TrailingCommas(*values)¶
Trailing comma options.
- NO = TrailingCommaConfig(multiline_trailing_comma=False)¶
- allows_empty_call_parens = True¶
- bool_formats¶
alias of
BoolFormats
- bytes_format: BytesFormats = <function format_bytes_hex>¶
- bytes_formats¶
alias of
BytesFormats
- property call_data_dependent_preamble: Callable[[Value], tuple[str, ...]]¶
Return data-dependent preamble lines for call rendering.
- call_returns_expression = True¶
- call_style: CallStyles = PositionalCallStyle(arg_separator=', ', parenthesize_each_arg=False)¶
- property call_style_config: PositionalCallStyle¶
Configuration for the chosen call style.
- call_styles¶
alias of
CallStyles
- property comment_config: CommentConfig¶
Configuration for the language’s comment syntax.
- comment_format: CommentFormats = CommentConfig(prefix='%', suffix='')¶
- comment_formats¶
alias of
CommentFormats
- property compute_body_preamble: Callable[[frozenset[type], Value], tuple[str, ...]]¶
Compute body-preamble lines from the scalar map.
- property consumable_ref_value_inhibits_consuming_form: Callable[[Value], bool]¶
Predicate deciding whether a ref’s underlying value type inhibits the consume form.
Delegates to
never_inhibits_consuming_form. Languages whose consume operator rejects certain value types (notably the Mojo^on register-trivial scalars) override this.
- property data_dependent_preamble: Callable[[Value], tuple[str, ...]]¶
Return data-dependent preamble lines.
- date_format: DateFormats = DateFormatConfig(formatter=<function date_ymd_formatter.<locals>._format>, preamble_lines=(), type_produced=<class 'datetime.date'>)¶
- date_formats¶
alias of
DateFormats
- datetime_format: DatetimeFormats = DatetimeFormatConfig(formatter=<function _format_datetime_matlab>, preamble_lines=(), type_produced=<class 'datetime.datetime'>)¶
- datetime_formats¶
alias of
DatetimeFormats
- declaration_style: DeclarationStyles = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=True)¶
- declaration_styles¶
alias of
DeclarationStyles
- dict_entry_style: DictEntryStyles = 1¶
- dict_entry_styles¶
alias of
DictEntryStyles
- dict_format: DictFormats = DictFormatConfig(dict_open=<function fixed_open.<locals>._open>, close=')', format_entry=<function _format_matlab_dict_entry>, empty_dict='struct()', preamble_lines=(), narrowed_open=None, supports_trailing_comma=True)¶
- property dict_format_config: DictFormatConfig¶
Configuration for dict formatting.
- dict_formats¶
alias of
DictFormats
- dict_supports_heterogeneous_values = True¶
- element_separator: ClassVar[str] = ', '¶
- empty_dict_keys¶
alias of
EmptyDictKey
- extension = '.m'¶
- false_literal: ClassVar[str] = 'false'¶
- float_format: FloatFormats = <function format_float_repr>¶
- float_formats¶
alias of
FloatFormats
- property format_bytes: Callable[[bytes], str]¶
Callable that formats a bytes value as a string literal.
- static format_call_arg(_value: Value, formatted: str, /) str¶
Callable that rewrites a formatted direct call argument.
- property format_call_arg_ref_identifier: Callable[[str, Value | None], str]¶
Rewrite a
{"$ref": "name"}identifier in a call-argument context.Delegates to
format_call_ref_identifier. Override this to allow call-argument$refvalues that would otherwise be rejected.
- property format_call_arg_ref_identifier_consumable: Callable[[str, Value | None], str]¶
Format a
$refthe caller authorized as consumable.Delegates to
format_call_arg_ref_identifier. Override this to opt into a consuming form (e.g. C++std::move).
- format_call_binding_body_preamble() tuple[str, ...]¶
Default
format_call_binding_body_preamble– no extra body preamble lines for an inference-bound call result.
- format_call_binding_file_pragmas() tuple[str, ...]¶
Default
format_call_binding_file_pragmas– no file-level compiler-pragma line for an inference-bound call result.
- property format_call_preamble_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]¶
Return file-scope stubs for a call expression.
- property format_call_ref_identifier: Callable[[str, Value | None], str]¶
Rewrite a
{"$ref": "name"}identifier into the language’s call expression syntax.
- property format_call_statement: Callable[[str], str]¶
Return call-statement formatting for this language.
- property format_call_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]¶
Return stub declarations for a call expression.
- property format_call_target: Callable[[Sequence[str]], str]¶
Rewrite a dotted call target into the language’s call syntax.
- property format_call_variable_assignment: Callable[[str, str, Value], str]¶
Default
format_call_variable_assignment– reuse the literal-binding assignment formatter unchanged.
- property format_call_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]¶
Default
format_call_variable_declaration– reuse the literal-binding declaration formatter unchanged.
- static format_constructor_target(class_name: str, /) str¶
Return class_name as a zero-argument constructor call target.
- property format_date: Callable[[date], str]¶
Callable that formats a date as a string literal.
- property format_datetime: Callable[[datetime], str]¶
Callable that formats a datetime as a string literal.
- property format_float: Callable[[float], str]¶
Callable that formats a float value as a literal.
- property format_integer: Callable[[int], str]¶
Format an int value as a literal.
- property format_integer_widened: None¶
Default
format_integer_widened– no mixed-magnitude integer widening, so the renderer keeps the normal integer formatter.
- property format_ordered_map_entry: Callable[[str, Value, str], str]¶
Callable that formats one ordered-map entry.
- property format_sequence_entry: Callable[[Value, str], str]¶
Format a sequence entry.
- property format_set_entry: Callable[[Value, str], str]¶
Format a set entry.
- property format_string: Callable[[str], str]¶
Callable that formats a string value as a quoted literal.
- property format_time: Callable[[time], str]¶
Callable that formats a time as a string literal.
- property format_variable_assignment: Callable[[str, str, Value], str]¶
Callable that formats an assignment to an existing variable.
- property format_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]¶
Callable that formats a new variable declaration.
- has_free_function_calls = True¶
- property heterogeneous_behavior: HeterogeneousBehavior¶
Return the heterogeneous-behavior config.
- heterogeneous_strategies¶
alias of
HeterogeneousStrategies
- heterogeneous_strategy: HeterogeneousStrategies = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)¶
- identifier_cases: ClassVar[tuple[IdentifierCase, ...]] = (IdentifierCase.CAMEL, IdentifierCase.PASCAL, IdentifierCase.SNAKE)¶
- indent: str = ' '¶
- indent_closing_delimiter: ClassVar[bool] = False¶
- integer_format: IntegerFormats = 1¶
- integer_formats¶
alias of
IntegerFormats
- integer_width_strategies¶
alias of
BareIntegerWidthStrategies
- integer_width_strategy: BareIntegerWidthStrategies = 1¶
- language_version: VersionFormats = 1¶
- property leading_preamble: LeadingPreamble¶
Default
leading_preamble– no preamble lines that must precedeLanguage.static_preamble.
- max_call_parameters = 9223372036854775807¶
- modifier_combinations: ClassVar[tuple[ModifierCombination, ...]] = ()¶
- null_literal: ClassVar[str] = '[]'¶
- numeric_literal_suffix: NumericLiteralSuffixes = 1¶
- numeric_literal_suffixes¶
alias of
NumericLiteralSuffixes
- numeric_separator: NumericSeparators = 1¶
- numeric_separators¶
alias of
NumericSeparators
- numeric_style: NumericStyles = 1¶
- numeric_styles¶
alias of
NumericStyles
- property ordered_map_format_config: OrderedMapFormatConfig¶
Configuration for ordered-map formatting.
- pygments_name = 'matlab'¶
- reserved_identifiers: ClassVar[frozenset[str]] = frozenset({})¶
- property scalar_body_preamble: dict[type, tuple[str, ...]]¶
Per-instance scalar body preamble (MATLAB needs none).
- property scalar_preamble: dict[type, tuple[str, ...]]¶
Per-instance scalar preamble (MATLAB needs none).
- sequence_binding_declarations(declarations: tuple[str, ...]) str¶
Default
sequence_binding_declarations– join the per-binding snippets with newlines.
- sequence_format: SequenceFormats = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close='}', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=False, empty_sequence='{}', preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)¶
- property sequence_format_config: SequenceFormatConfig¶
Configuration for the chosen sequence format.
- sequence_formats¶
alias of
SequenceFormats
- property sequence_open: Callable[[list[Value]], str]¶
Callable that returns the opening delimiter for a sequence.
- set_format: SetFormats = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close='}', empty_set='{}', preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)¶
- property set_format_config: SetFormatConfig¶
Configuration for the chosen set format.
- set_formats¶
alias of
SetFormats
- skip_null_dict_values: ClassVar[bool] = False¶
- special_float_preamble: ClassVar[tuple[str, ...]] = ()¶
- statement_terminator: ClassVar[str] = ''¶
- statement_terminator_style: StatementTerminatorStyles = 1¶
- statement_terminator_styles¶
alias of
StatementTerminatorStyles
- static_body_preamble: ClassVar[Sequence[str]] = ()¶
- static_preamble: ClassVar[Sequence[str]] = ()¶
- string_format: StringFormats = 1¶
- string_formats¶
alias of
StringFormats
- supported_ref_cases: ClassVar[frozenset[IdentifierCase]] = frozenset({IdentifierCase.CAMEL, IdentifierCase.PASCAL, IdentifierCase.SNAKE, IdentifierCase.UPPER_SNAKE})¶
- supports_call_style = True¶
- supports_collection_comments: ClassVar[bool] = True¶
- supports_default_dict_key_type = False¶
- supports_default_dict_value_type = False¶
- supports_default_ordered_map_value_type = False¶
- supports_default_sequence_element_type = False¶
- supports_default_set_element_type = False¶
- supports_dict_literal_as_free_expression = True¶
- supports_dotted_call_stub = True¶
- supports_dotted_calls = True¶
- supports_empty_dict_key = False¶
- supports_inline_multiline_dict_args = True¶
- supports_module_name = False¶
- supports_multi_param_call_wrapper_stub = True¶
- supports_no_variable_wrap_in_file = True¶
- supports_non_string_dict_keys = False¶
- supports_record_shape_names = False¶
- supports_record_struct_name_prefix = False¶
- supports_scalar_before_comments: ClassVar[bool] = False¶
- supports_scalar_inline_comments: ClassVar[bool] = True¶
- supports_special_floats = True¶
- supports_standalone_comments_in_wrapped_calls = True¶
- supports_variable_names = True¶
- supports_zero_parameter_calls = True¶
- trailing_comma: TrailingCommas = TrailingCommaConfig(multiline_trailing_comma=False)¶
- property trailing_comma_config: TrailingCommaConfig¶
Configuration for trailing-comma behavior.
- trailing_commas¶
alias of
TrailingCommas
- true_literal: ClassVar[str] = 'true'¶
- property type_hint_collection_preamble_lines: Callable[[frozenset[type]], tuple[str, ...]]¶
Return preamble lines for empty-collection type hints.
- property validate_call_arg: Callable[[Value], None]¶
Return call-argument validation for this language.
- validate_spec_for_data(data: Value) None¶
Default
validate_spec_for_data— no spec/data constraints.
- variable_type_hints: VariableTypeHints = 1¶
- variable_type_hints_formats¶
alias of
VariableTypeHints
- version_formats¶
alias of
VersionFormats
- wrap_calls_with_declarations(declarations: tuple[str, ...], calls: str, body_preamble: tuple[str, ...]) str¶
Default
wrap_calls_with_declarations— concatenate the declarations and calls and route throughwrap_in_file()in call mode.
- static wrap_combined_in_file(declaration: str, assignment: str, variable_name: str, body_preamble: tuple[str, ...]) str¶
Wrap declaration and assignment in a valid file (no-op).
- static wrap_in_file(content: str, variable_name: str, body_preamble: tuple[str, ...]) str¶
Wrap code in a valid file (no-op).
- class literalizer.languages.Mojo(*args: object, **kwargs: object)¶
Mojo language specification.
By default Mojo raises on heterogeneous input because its native collections require a single element type. Opt into
HeterogeneousStrategies.VARIANTto wrap mixed scalars in a generatedcomptime Value = Variant[...]and render each scalar asValue(...)so heterogeneous dicts and lists become homogeneous in the Variant type.- class BoolFormats(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
Empty: this language has no alternative boolean formats.
- class BytesFormats(*values)¶
Bytes formatting options.
- BASE64 = <function format_bytes_base64>¶
- HEX = <function format_bytes_hex>¶
- class CallStyles(*values)¶
Mojo call style options.
- POSITIONAL = PositionalCallStyle(arg_separator=', ', parenthesize_each_arg=False)¶
- class DateFormats(*values)¶
Date format options for Mojo.
- ISO = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- class DatetimeFormats(*values)¶
Datetime format options for Mojo.
- EPOCH = DatetimeFormatConfig(formatter=<function format_datetime_epoch>, preamble_lines=(), type_produced=<class 'int'>)¶
- ISO = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- class DeclarationStyles(*values)¶
Declaration style options.
- ASSIGN = DeclarationStyleConfig(formatter=<function _mojo_format_variable_declaration>, supports_redefinition=True)¶
- class DictFormats(*values)¶
Dict/map format options.
- DEFAULT = <function dict_format_factory.<locals>._build>¶
- class FloatFormats(*values)¶
Float format options.
- FIXED = <function format_float_fixed>¶
- REPR = <function format_float_repr>¶
- SCIENTIFIC = <function format_float_scientific>¶
- class HeterogeneousStrategies(*values)¶
Strategy for representing dicts or lists whose scalar values span more than one Mojo type.
- ERROR = _HeterogeneousStrategyConfig(build_behavior=<function _build_error_behavior>, build_preamble=<function _build_error_preamble>)¶
Raise
HeterogeneousScalarCollectionError(orHeterogeneousSiblingListsError) when scalar values of mixed types appear in a container that cannot represent them. This is the default, matching the single-element-type convention of the MojoList,Dict, andSetcontainers.
- VARIANT = _HeterogeneousStrategyConfig(build_behavior=<function _build_variant_behavior>, build_preamble=<function _build_variant_preamble>)¶
Auto-generate a
comptimebinding in the preamble for the configured name to aVariant[...]over only the Mojo types actually present in heterogeneous positions, together with afrom std.utils.variant import Variantimport, and wrap each such scalar as{Name}(value)(with an explicitString(...)orFloat64(...)cast when needed so the constructor resolves to the intended Variant alternative, andNoneType()for nulls).The alias name is configurable via
Mojo.heterogeneous_value_variant_name(default"Value").
- class JsonTypes(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
Empty: this language has no JSON value-type variants.
- class Modifiers(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
C++/Java/C#-style declaration modifiers: this language has none.
- class SequenceFormats(*values)¶
Sequence type options for Mojo.
- LIST = <function _mojo_list_format>¶
- class SetFormats(*values)¶
Set type options for Mojo.
- SET = <function set_format_factory.<locals>._build>¶
- class TrailingCommas(*values)¶
Trailing comma options.
- YES = TrailingCommaConfig(multiline_trailing_comma=True)¶
- allows_empty_call_parens = True¶
- bool_formats¶
alias of
BoolFormats
- bytes_format: BytesFormats = <function format_bytes_hex>¶
- bytes_formats¶
alias of
BytesFormats
- property call_data_dependent_preamble: Callable[[Value], tuple[str, ...]]¶
Return data-dependent preamble lines for call rendering.
- call_returns_expression = True¶
- call_style: CallStyles = PositionalCallStyle(arg_separator=', ', parenthesize_each_arg=False)¶
- property call_style_config: PositionalCallStyle | KeywordCallStyle | ObjectCallStyle | PostfixCallStyle | PrefixCallStyle | CommandCallStyle¶
Configuration for the chosen call style.
- call_styles¶
alias of
CallStyles
- property comment_config: CommentConfig¶
Configuration for the language’s comment syntax.
- comment_format: CommentFormats = CommentConfig(prefix='#', suffix='')¶
- comment_formats¶
alias of
CommentFormats
- property compute_body_preamble: Callable[[frozenset[type], Value], tuple[str, ...]]¶
Compute body-preamble lines from the scalar map.
- property consumable_ref_value_inhibits_consuming_form: Callable[[Value], bool]¶
Return
Truefor ref values whose Mojo type is register- trivial.Mojo 0.26.1.0+ rejects
^onInt,Bool, andFloat64values under--Werrorbecause the transfer has no effect. The trivial-register set is derived from_mojo_variant_for_scalar()so the formatter layer avoids hard-coded Mojo type-name strings.
- property data_dependent_preamble: Callable[[Value], tuple[str, ...]]¶
Return data-dependent preamble lines.
For
HeterogeneousStrategies.VARIANTemits analiasline declaring theVariantover only the Mojo types actually used in heterogeneous positions. Other strategies produce no preamble.
- date_format: DateFormats = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- date_formats¶
alias of
DateFormats
- datetime_format: DatetimeFormats = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- datetime_formats¶
alias of
DatetimeFormats
- declaration_style: DeclarationStyles = DeclarationStyleConfig(formatter=<function _mojo_format_variable_declaration>, supports_redefinition=True)¶
- declaration_styles¶
alias of
DeclarationStyles
- default_dict_key_type: str = 'String'¶
- default_dict_value_type: str = 'String'¶
- default_sequence_element_type: str = 'String'¶
- default_set_element_type: str = 'String'¶
- dict_entry_style: DictEntryStyles = 1¶
- dict_entry_styles¶
alias of
DictEntryStyles
- dict_format: DictFormats = <function dict_format_factory.<locals>._build>¶
- property dict_format_config: DictFormatConfig¶
Configuration for dict formatting.
- dict_formats¶
alias of
DictFormats
- dict_supports_heterogeneous_values = False¶
- element_separator: ClassVar[str] = ', '¶
- empty_dict_keys¶
alias of
EmptyDictKey
- extension = '.mojo'¶
- false_literal: ClassVar[str] = 'False'¶
- float_format: FloatFormats = <function format_float_repr>¶
- float_formats¶
alias of
FloatFormats
- property format_bytes: Callable[[bytes], str]¶
Callable that formats a bytes value as a string literal.
- static format_call_arg(_value: Value, formatted: str, /) str¶
Callable that rewrites a formatted direct call argument.
- property format_call_arg_ref_identifier: Callable[[str, Value | None], str]¶
Emit a call-argument
$refas the bare identifier.The Mojo transfer operator
^consumes the variable, which is unsafe when the caller may use it again in a later call (or after theliteralize_callblock). Callers opt in to transferring a specific ref by listing it inliteralize_call’sconsumable_refsset; in that caseformat_call_arg_ref_identifier_consumableis used instead and appends^.
- property format_call_arg_ref_identifier_consumable: Callable[[str, Value | None], str]¶
Append
^to a consumable call-argument$ref.Used only for refs the caller declared as consumable on
literalize_call()and that appear in just one call argument, so the transfer cannot strand a later use. Refs whose underlying value is a register-trivial scalar (Int,Bool,Float64) are routed away from this formatter at the call site (seeconsumable_ref_value_inhibits_consuming_form), because applying^to such a value is a hard error under--Werror.
- format_call_binding_body_preamble() tuple[str, ...]¶
Default
format_call_binding_body_preamble– no extra body preamble lines for an inference-bound call result.
- format_call_binding_file_pragmas() tuple[str, ...]¶
Default
format_call_binding_file_pragmas– no file-level compiler-pragma line for an inference-bound call result.
- property format_call_preamble_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]¶
Return file-scope stubs for a call expression.
- property format_call_ref_identifier: Callable[[str, Value | None], str]¶
Append
^to trigger move/transfer semantics in Mojo, except for register-trivial scalars.Mojo
Dictdoes not implementCopyable, so a bare variable reference fails to compile and^transfers ownership instead. Applying^to a register-trivial scalar (Int,Bool,Float64) is a hard error under--Werror, so we drop the operator when the caller’sref_valuesidentifies the ref as one of those types. When the value is unknown we keep the historical^form.
- property format_call_statement: Callable[[str], str]¶
Return call-statement formatting for this language.
- property format_call_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]¶
Return stub declarations for a call expression.
- property format_call_target: Callable[[Sequence[str]], str]¶
Rewrite a dotted call target into the language’s call syntax.
- property format_call_variable_assignment: Callable[[str, str, Value], str]¶
Default
format_call_variable_assignment– reuse the literal-binding assignment formatter unchanged.
- property format_call_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]¶
Default
format_call_variable_declaration– reuse the literal-binding declaration formatter unchanged.
- static format_constructor_target(class_name: str, /) str¶
Return class_name as a zero-argument constructor call target.
- property format_date: Callable[[date], str]¶
Callable that formats a date as a string literal.
- property format_datetime: Callable[[datetime], str]¶
Callable that formats a datetime as a string literal.
- property format_float: Callable[[float], str]¶
Callable that formats a float value as a literal.
- property format_integer: Callable[[int], str]¶
Format an int value as a literal.
- property format_integer_widened: None¶
Default
format_integer_widened– no mixed-magnitude integer widening, so the renderer keeps the normal integer formatter.
- property format_ordered_map_entry: Callable[[str, Value, str], str]¶
Callable that formats one ordered-map entry.
- property format_sequence_entry: Callable[[Value, str], str]¶
Format a sequence entry.
- property format_set_entry: Callable[[Value, str], str]¶
Format a set entry.
- property format_string: Callable[[str], str]¶
Format a string value as a quoted literal.
- property format_time: Callable[[time], str]¶
Callable that formats a time as a string literal.
- property format_variable_assignment: Callable[[str, str, Value], str]¶
Callable that formats an assignment to an existing variable.
- property format_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]¶
Callable that formats a new variable declaration.
Wraps the configured declaration formatter so a non-empty list of string-rendering elements gets an explicit
List[String]annotation. Mojo infersList[StringLiteral]from a bare["a", "b"]literal, which is rejected when assigned into aVariantslot expectingList[String].
- has_free_function_calls = True¶
- property heterogeneous_behavior: HeterogeneousBehavior¶
Return the behavior for the chosen heterogeneous strategy.
- heterogeneous_strategies¶
alias of
HeterogeneousStrategies
- heterogeneous_strategy: HeterogeneousStrategies = _HeterogeneousStrategyConfig(build_behavior=<function _build_error_behavior>, build_preamble=<function _build_error_preamble>)¶
- heterogeneous_value_variant_name: str = 'Value'¶
- identifier_cases: ClassVar[tuple[IdentifierCase, ...]] = (IdentifierCase.SNAKE, IdentifierCase.UPPER_SNAKE)¶
- indent: str = ' '¶
- indent_closing_delimiter: ClassVar[bool] = False¶
- integer_format: IntegerFormats = 1¶
- integer_formats¶
alias of
IntegerFormats
- integer_width_strategies¶
alias of
BareIntegerWidthStrategies
- integer_width_strategy: BareIntegerWidthStrategies = 1¶
- language_version: VersionFormats = 1¶
- property leading_preamble: LeadingPreamble¶
Default
leading_preamble– no preamble lines that must precedeLanguage.static_preamble.
- max_call_parameters = 9223372036854775807¶
- modifier_combinations: ClassVar[tuple[ModifierCombination, ...]] = ()¶
- null_literal: ClassVar[str] = 'None'¶
- numeric_literal_suffix: NumericLiteralSuffixes = 1¶
- numeric_literal_suffixes¶
alias of
NumericLiteralSuffixes
- numeric_separator: NumericSeparators = 1¶
- numeric_separators¶
alias of
NumericSeparators
- numeric_style: NumericStyles = 1¶
- numeric_styles¶
alias of
NumericStyles
- property ordered_map_format_config: OrderedMapFormatConfig¶
Configuration for ordered-map formatting.
- pygments_name = 'mojo'¶
- reserved_identifiers: ClassVar[frozenset[str]] = frozenset({})¶
- property scalar_body_preamble: dict[type, tuple[str, ...]]¶
Per-instance scalar body preamble (Mojo needs none).
- property scalar_preamble: dict[type, tuple[str, ...]]¶
Per-instance scalar preamble (Mojo needs none).
- sequence_binding_declarations(declarations: tuple[str, ...]) str¶
Default
sequence_binding_declarations– join the per-binding snippets with newlines.
- sequence_format: SequenceFormats = <function _mojo_list_format>¶
- property sequence_format_config: SequenceFormatConfig¶
Configuration for the chosen sequence format.
- sequence_formats¶
alias of
SequenceFormats
- property sequence_open: Callable[[list[Value]], str]¶
Callable that returns the opening delimiter for a sequence.
- set_format: SetFormats = <function set_format_factory.<locals>._build>¶
- property set_format_config: SetFormatConfig¶
Configuration for the chosen set format.
- set_formats¶
alias of
SetFormats
- property skip_null_dict_values: bool¶
Drop
Nonedict values for the default ERROR strategy so the homogeneous-dict rendering stays valid Mojo.VARIANTwraps every scalar asValue(...), soNonevalues must flow through unchanged to be wrapped asValue(None)against aNoneTypeVariant alternative.
- special_float_preamble: ClassVar[tuple[str, ...]] = ('import std.math',)¶
- statement_terminator: ClassVar[str] = ''¶
- statement_terminator_style: StatementTerminatorStyles = 1¶
- statement_terminator_styles¶
alias of
StatementTerminatorStyles
- static_body_preamble: ClassVar[Sequence[str]] = ()¶
- static_preamble: ClassVar[Sequence[str]] = ()¶
- string_format: StringFormats = 1¶
- string_formats¶
alias of
StringFormats
- supported_ref_cases: ClassVar[frozenset[IdentifierCase]] = frozenset({IdentifierCase.CAMEL, IdentifierCase.PASCAL, IdentifierCase.SNAKE, IdentifierCase.UPPER_SNAKE})¶
- supports_call_style = True¶
- supports_collection_comments: ClassVar[bool] = True¶
- supports_default_dict_key_type = True¶
- supports_default_dict_value_type = True¶
- supports_default_ordered_map_value_type = False¶
- supports_default_sequence_element_type = True¶
- supports_default_set_element_type = True¶
- supports_dict_literal_as_free_expression = True¶
- supports_dotted_call_stub = True¶
- supports_dotted_calls = True¶
- supports_empty_dict_key = False¶
- supports_inline_multiline_dict_args = True¶
- supports_module_name = False¶
- supports_multi_param_call_wrapper_stub = True¶
- supports_no_variable_wrap_in_file = False¶
- supports_non_string_dict_keys = True¶
- supports_record_shape_names = False¶
- supports_record_struct_name_prefix = False¶
- supports_scalar_before_comments: ClassVar[bool] = False¶
- supports_scalar_inline_comments: ClassVar[bool] = True¶
- supports_special_floats = True¶
- supports_standalone_comments_in_wrapped_calls = True¶
- supports_variable_names = True¶
- supports_zero_parameter_calls = True¶
- trailing_comma: TrailingCommas = TrailingCommaConfig(multiline_trailing_comma=True)¶
- property trailing_comma_config: TrailingCommaConfig¶
Configuration for trailing-comma behavior.
- trailing_commas¶
alias of
TrailingCommas
- true_literal: ClassVar[str] = 'True'¶
- property type_hint_collection_preamble_lines: Callable[[frozenset[type]], tuple[str, ...]]¶
Return preamble lines for empty-collection type hints.
- property validate_call_arg: Callable[[Value], None]¶
Return call-argument validation for this language.
- validate_spec_for_data(data: Value) None¶
Default
validate_spec_for_data— no spec/data constraints.
- variable_type_hints: VariableTypeHints = 1¶
- variable_type_hints_formats¶
alias of
VariableTypeHints
- version_formats¶
alias of
VersionFormats
- wrap_calls_with_declarations(declarations: tuple[str, ...], calls: str, body_preamble: tuple[str, ...]) str¶
Default
wrap_calls_with_declarations— concatenate the declarations and calls and route throughwrap_in_file()in call mode.
- wrap_combined_in_file(declaration: str, assignment: str, variable_name: str, body_preamble: tuple[str, ...]) str¶
Wrap Mojo declaration and assignment in a main function.
- wrap_in_file(content: str, variable_name: str, body_preamble: tuple[str, ...]) str¶
Wrap a Mojo variable declaration in a main function.
- class literalizer.languages.Nim(*args: object, **kwargs: object)¶
Nim language specification.
- Parameters:
date_format –
How to format
datetime.datevalues.date_formats.NIM— table literal, e.g.{"year": 2024, "month": 1, "day": 15}.date_formats.ISO— ISO 8601 quoted string, e.g."2024-01-15".
datetime_format –
How to format
datetime.datetimevalues.datetime_formats.NIM— table literal, e.g.{"year": 2024, "month": 1, "day": 15, "hour": 12, "minute": 30, "second": 0}.datetime_formats.ISO— ISO 8601 quoted string, e.g."2024-01-15T12:30:00".
- class BoolFormats(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
Empty: this language has no alternative boolean formats.
- class BytesFormats(*values)¶
Bytes formatting options.
- BASE64 = <function format_bytes_base64>¶
- HEX = <function format_bytes_hex>¶
- class CallStyles(*values)¶
Nim call style options.
- POSITIONAL = PositionalCallStyle(arg_separator=', ', parenthesize_each_arg=False)¶
- class CommentFormats(*values)¶
Comment style options.
- BLOCK = CommentConfig(prefix='#[', suffix=' ]#')¶
- HASH = CommentConfig(prefix='#', suffix='')¶
- class DateFormats(*values)¶
Date format options for Nim.
- ISO = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- NIM = DateFormatConfig(formatter=<function date_ymd_formatter.<locals>._format>, preamble_lines=(), type_produced=<class 'datetime.date'>)¶
- class DatetimeFormats(*values)¶
Datetime format options for Nim.
- EPOCH = DatetimeFormatConfig(formatter=<function format_datetime_epoch>, preamble_lines=(), type_produced=<class 'int'>)¶
- ISO = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- NIM = DatetimeFormatConfig(formatter=<function datetime_ymdhms_formatter.<locals>._format>, preamble_lines=(), type_produced=<class 'datetime.datetime'>)¶
- class DeclarationStyles(*values)¶
Declaration style options.
- CONST = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=False)¶
- LET = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=False)¶
- VAR = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=True)¶
- class FloatFormats(*values)¶
Float format options.
- FIXED = <function format_float_fixed>¶
- REPR = <function format_float_repr>¶
- SCIENTIFIC = <function format_float_scientific>¶
- class HeterogeneousStrategies(*values)¶
Strategy for representing dicts or lists whose scalar values span more than one Nim type.
- ERROR = _HeterogeneousStrategyConfig(build_behavior=<function _build_error_behavior>, build_preamble=<function _build_error_preamble>)¶
Raise
HeterogeneousScalarCollectionError(orHeterogeneousSiblingListsError) when scalar values of mixed types appear in a container that cannot represent them. This is the default, matching the strict-typing convention of Nim when tables and sequences are used without JSON wrapping.
- OBJECT_VARIANT = _HeterogeneousStrategyConfig(build_behavior=<function _build_object_variant_behavior>, build_preamble=<function _build_object_variant_preamble>)¶
Auto-generate a Nim object variant in the preamble containing only the branches actually present in the data, and wrap each heterogeneous scalar value as
{VariantName}(kind: vkX, xVal: value).Switches the dict rendering from
%* {key: value}(which relies on thejsonmodule) to{key: value}.toTableso that the object-variant values can be stored directly. Nested sequences emit@[...]at every level, and thejsonimport is dropped unless a date or datetime format still produces aJsonNodepayload.The variant-type name is configurable via
Nim.heterogeneous_value_variant_name(default"Value"). Incompatible withDeclarationStyles.CONST:.toTableand@[]are runtime constructors, soCONSTrequires a compile-time-expressible initializer.
- RECORD = _HeterogeneousStrategyConfig(build_behavior=<function _build_error_behavior>, build_preamble=<function _build_error_preamble>)¶
Render each record-shaped dict (non-empty, string-keyed) as a generated module-scope
type Record0 = objectdeclaration plus a matchingRecord0(field: value, ...)literal, so a dict mixing scalars with a container is representable even though a NimTablerequires a homogeneous value type.Like
OBJECT_VARIANTthis switches collections to their native Nim constructors (@[...],{...}.toTable) so aseq/Tablefield is well-typed, but it wraps no scalars and emits nojson/%*rendering. Auto namesRecord0,Record1, … (prefix configurable viaNim.record_struct_name_prefix); norecord_shape_names, norecord_unify_optional_fields, consistent with the other non-Rust ports. Its behavior and struct preamble need the per-instance renderer, so they are resolved inheterogeneous_behavior/data_dependent_preamblerather than from the enum member’s config builders (it reuses the no-opERRORbuilders, kept a distinct member by_HeterogeneousStrategyConfig’s identity equality). Incompatible withDeclarationStyles.CONSTfor the same reason asOBJECT_VARIANT:@[...]/.toTableare runtime constructors.
- class IntegerFormats(*values)¶
Integer format options.
- BINARY = mappingproxy({'NONE': <function format_integer_binary>, 'UNDERSCORE': <function format_integer_binary>})¶
- DECIMAL = mappingproxy({'NONE': <class 'str'>, 'UNDERSCORE': <function format_integer_underscore>})¶
- HEX = mappingproxy({'NONE': <function format_integer_hex>, 'UNDERSCORE': <function format_integer_hex>})¶
- OCTAL = mappingproxy({'NONE': <function format_integer_octal>, 'UNDERSCORE': <function format_integer_octal>})¶
- get_formatter(numeric_separator: Enum) Callable[[int], str]¶
Return the integer formatter for the given separator.
- class JsonTypes(*values)¶
JSON value type options for Nim.
- JSON_NODE = 'JsonNode'¶
Standard-library
json.JsonNodevalue constructed via the%*macro.
- class Modifiers(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
C++/Java/C#-style declaration modifiers: this language has none.
- class SequenceFormats(*values)¶
Sequence type options for Nim.
- ARRAY = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=']', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)¶
- SEQ = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=']', supports_heterogeneity=False, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=True, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)¶
- class SetFormats(*values)¶
Set type options for Nim.
- SET = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close=']', empty_set=None, preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)¶
- class TrailingCommas(*values)¶
Trailing comma options.
- NO = TrailingCommaConfig(multiline_trailing_comma=False)¶
- YES = TrailingCommaConfig(multiline_trailing_comma=True)¶
- allows_empty_call_parens = True¶
- bool_formats¶
alias of
BoolFormats
- bytes_format: BytesFormats = <function format_bytes_hex>¶
- bytes_formats¶
alias of
BytesFormats
- property call_data_dependent_preamble: Callable[[Value], tuple[str, ...]]¶
Return data-dependent preamble lines for a call context.
For
HeterogeneousStrategies.RECORDemits thetype Record0 = objectblocks a record-shaped call argument’s literal references, preceded – exactly as the non-calldata_dependent_preamble– by theUnusedImportopt-out andimport tables(dict_format_configno longer contributes it underRECORD). The opt-out is needed both for a record-only call (the import is then unused) and because avarargs[untyped]stub never evaluates its arguments, so even a non-record dict argument’s{...}.toTablewould leave the import unused. ForHeterogeneousStrategies.OBJECT_VARIANTemits the Nimtypeblock declaring the object variant used to wrap heterogeneous scalars; the call rendering references that type by name, so the declaration must be present. For other strategies, call arguments are inline literals that never use%*, soimport jsonis never needed in a call context.json_typewraps every call argument in%*, so theimport jsonline is contributed unconditionally here too.
- call_returns_expression = True¶
- call_style: CallStyles = PositionalCallStyle(arg_separator=', ', parenthesize_each_arg=False)¶
- property call_style_config: PositionalCallStyle | KeywordCallStyle | ObjectCallStyle | PostfixCallStyle | PrefixCallStyle | CommandCallStyle¶
Configuration for the chosen call style.
- call_styles¶
alias of
CallStyles
- property comment_config: CommentConfig¶
Configuration for the language’s comment syntax.
- comment_format: CommentFormats = CommentConfig(prefix='#', suffix='')¶
- comment_formats¶
alias of
CommentFormats
- property compute_body_preamble: Callable[[frozenset[type], Value], tuple[str, ...]]¶
Compute body-preamble lines from the scalar map.
- property consumable_ref_value_inhibits_consuming_form: Callable[[Value], bool]¶
Predicate deciding whether a ref’s underlying value type inhibits the consume form.
Delegates to
never_inhibits_consuming_form. Languages whose consume operator rejects certain value types (notably the Mojo^on register-trivial scalars) override this.
- property data_dependent_preamble: Callable[[Value], tuple[str, ...]]¶
Return data-dependent preamble lines.
For
HeterogeneousStrategies.RECORDemits onetype Record0 = objectblock per distinct record shape in the data, preceded byimport tablesand theUnusedImportopt-out: a non-record dict (the empty dict, or an ordered map) renders as a runtimeTablethat needs the import, while a pure-record fixture leaves it unused, so the pragma keeps the always-present import warning-free rather than making the import data-dependent. ForHeterogeneousStrategies.OBJECT_VARIANTemits a Nimtypeblock declaring the object variant used to wrap heterogeneous scalars. ForHeterogeneousStrategies.ERRORemits("import json",)when the rendered output will use the%*JSON-construction operator (every variable declaration / assignment exceptconstdeclarations and@-prefixed sequences of simple scalars); importingjsonunconditionally would trigger the Nim compiler’sUnusedImportwarning. Underjson_typethe rendered output always uses%*(andnewJ*builders), so the import is emitted unconditionally and takes precedence over any configured heterogeneous strategy.
- date_format: DateFormats = DateFormatConfig(formatter=<function date_ymd_formatter.<locals>._format>, preamble_lines=(), type_produced=<class 'datetime.date'>)¶
- date_formats¶
alias of
DateFormats
- datetime_format: DatetimeFormats = DatetimeFormatConfig(formatter=<function datetime_ymdhms_formatter.<locals>._format>, preamble_lines=(), type_produced=<class 'datetime.datetime'>)¶
- datetime_formats¶
alias of
DatetimeFormats
- declaration_style: DeclarationStyles = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=True)¶
- declaration_styles¶
alias of
DeclarationStyles
- dict_entry_style: DictEntryStyles = 1¶
- dict_entry_styles¶
alias of
DictEntryStyles
- dict_format: DictFormats = 1¶
- property dict_format_config: DictFormatConfig¶
Configuration for dict formatting.
OBJECT_VARIANTandRECORDappend.toTableto the closing brace so every rendered (non-record) dict becomes a runtimetables.Table. An empty dict widens toinitTable[string, string]()so the compiler does not reject{}.toTable: an empty{}literal is an empty set rather than a table, so the call does not resolve and the key/value types cannot be inferred. This mirrors thenewSeq[string]()widening for empty sequences.OBJECT_VARIANTalways wraps its dicts as tables, so it carries theimport tablespreamble here. UnderRECORDa record-shaped dict never reaches this config (it is intercepted by the record renderer and emitted as aRecord0(...)literal), soimport tableswould be anUnusedImportfor the common record-only fixture; the import is instead added bydata_dependent_preambleonly when the data still carries a genuinely non-record dict that renders as a table.json_typetakes precedence: every dict literal is wrapped in%*({...})so it renders as a JSON object, and an empty dict widens tonewJObject()(the explicit builder). Theimport jsonline that powers%*is contributed bydata_dependent_preamble, not by this config, so a heterogeneous-strategy-free fixture still imports it exactly once.
- dict_formats¶
alias of
DictFormats
- dict_supports_heterogeneous_values = False¶
- element_separator: ClassVar[str] = ', '¶
- empty_dict_keys¶
alias of
EmptyDictKey
- extension = '.nim'¶
- false_literal: ClassVar[str] = 'false'¶
- float_format: FloatFormats = <function format_float_repr>¶
- float_formats¶
alias of
FloatFormats
- property format_bytes: Callable[[bytes], str]¶
Callable that formats a bytes value as a string literal.
- property format_call_arg: Callable[[Value, str], str]¶
Callable that rewrites a formatted direct call argument.
Under
json_typeevery call argument is wrapped in%*so the underlying proc receives aJsonNode; under any other mode call arguments pass through unchanged.
- property format_call_arg_ref_identifier: Callable[[str, Value | None], str]¶
Rewrite a
{"$ref": "name"}identifier in a call-argument context.Delegates to
format_call_ref_identifier. Override this to allow call-argument$refvalues that would otherwise be rejected.
- property format_call_arg_ref_identifier_consumable: Callable[[str, Value | None], str]¶
Format a
$refthe caller authorized as consumable.Delegates to
format_call_arg_ref_identifier. Override this to opt into a consuming form (e.g. C++std::move).
- format_call_binding_body_preamble() tuple[str, ...]¶
Default
format_call_binding_body_preamble– no extra body preamble lines for an inference-bound call result.
- format_call_binding_file_pragmas() tuple[str, ...]¶
Default
format_call_binding_file_pragmas– no file-level compiler-pragma line for an inference-bound call result.
- property format_call_preamble_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]¶
Return file-scope stubs for a call expression.
- property format_call_ref_identifier: Callable[[str, Value | None], str]¶
Rewrite a
{"$ref": "name"}identifier into the language’s call expression syntax.
- property format_call_statement: Callable[[str], str]¶
Return call-statement formatting for this language.
- property format_call_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]¶
Return stub declarations for a call expression.
- property format_call_target: Callable[[Sequence[str]], str]¶
Rewrite a dotted call target into the language’s call syntax.
- property format_call_variable_assignment: Callable[[str, str, Value], str]¶
Callable that formats an assignment binding a call result.
The call-expression counterpart of
format_variable_assignment; the%*/@wrapping is dropped since a call result is bound directly. Unlike the declaration form this carries novar/let/constkeyword, so it does not reuse the declaration-style formatter.
- property format_call_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]¶
Callable that formats a declaration binding a call result.
The literal-binding declaration prefixes the right-hand side with the
%*json macro (or@for sequences) chosen from the parsed literal’s type; that JSON-constructs a literal and is invalid for a call result. The plain<keyword> <name> = <value>declaration-style formatter binds the call result directly with no wrapping.
- static format_constructor_target(class_name: str, /) str¶
Return class_name as a zero-argument constructor call target.
- property format_date: Callable[[date], str]¶
Callable that formats a date as a string literal.
json_typeoverrides the configureddate_formatwith the ISO 8601 string form because theNIMtable-literal form would not round-trip through JSON.
- property format_datetime: Callable[[datetime], str]¶
Callable that formats a datetime as a string literal.
json_typeoverrides the configureddatetime_formatwith the ISO 8601 string form unless the user has explicitly chosen theEPOCHinteger form, which remains a valid JSON number.
- property format_float: Callable[[float], str]¶
Callable that formats a float value as a literal.
- property format_integer: Callable[[int], str]¶
Callable that formats an int value as a literal.
- property format_integer_widened: None¶
Default
format_integer_widened– no mixed-magnitude integer widening, so the renderer keeps the normal integer formatter.
- property format_ordered_map_entry: Callable[[str, Value, str], str]¶
Callable that formats one ordered-map entry.
- property format_sequence_entry: Callable[[Value, str], str]¶
Format a sequence entry.
- property format_set_entry: Callable[[Value, str], str]¶
Format a set entry.
- property format_string: Callable[[str], str]¶
Format a string value as a quoted literal.
- property format_time: Callable[[time], str]¶
Callable that formats a time as a string literal.
- property format_variable_assignment: Callable[[str, str, Value], str]¶
Callable that formats an assignment to an existing variable.
Under
json_typethe assigned expression is wrapped by%*through the same helper as the declaration form so the two halves of a combined declaration / assignment stay consistent.
- property format_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]¶
Callable that formats a new variable declaration.
Under
json_typethe declaration carries an explicit: JsonNodetype annotation and the right-hand side is wrapped by%*only when the value is not already aJsonNodeexpression (the wrapping check in_nim_json_value_expression()skips re-wrapping%*(...)andnewJ*builders so the rendered output stays flat).
- has_free_function_calls = True¶
- property heterogeneous_behavior: HeterogeneousBehavior¶
Return the behavior for the chosen heterogeneous strategy.
json_typerelaxes scalar-type checks unconditionally, because the%*macro accepts heterogeneous JSON values.RECORDresolves to the shared record behavior (its value needs the per-instance renderer, so it cannot be stored on the enum member);ERRORandOBJECT_VARIANTuse their config-built behaviors.
- heterogeneous_strategies¶
alias of
HeterogeneousStrategies
- heterogeneous_strategy: HeterogeneousStrategies = _HeterogeneousStrategyConfig(build_behavior=<function _build_error_behavior>, build_preamble=<function _build_error_preamble>)¶
- heterogeneous_value_variant_name: str = 'Value'¶
- identifier_cases: ClassVar[tuple[IdentifierCase, ...]] = (IdentifierCase.CAMEL, IdentifierCase.PASCAL)¶
- indent: str = ' '¶
- indent_closing_delimiter: ClassVar[bool] = False¶
- integer_format: IntegerFormats = mappingproxy({'NONE': <class 'str'>, 'UNDERSCORE': <function format_integer_underscore>})¶
- integer_formats¶
alias of
IntegerFormats
- integer_width_strategies¶
alias of
BareIntegerWidthStrategies
- integer_width_strategy: BareIntegerWidthStrategies = 1¶
- language_version: VersionFormats = 1¶
- property leading_preamble: LeadingPreamble¶
Default
leading_preamble– no preamble lines that must precedeLanguage.static_preamble.
- max_call_parameters = 9223372036854775807¶
- modifier_combinations: ClassVar[tuple[ModifierCombination, ...]] = ()¶
- null_literal: ClassVar[str] = 'nil'¶
- numeric_literal_suffix: NumericLiteralSuffixes = 1¶
- numeric_literal_suffixes¶
alias of
NumericLiteralSuffixes
- numeric_separator: NumericSeparators = 1¶
- numeric_separators¶
alias of
NumericSeparators
- numeric_style: NumericStyles = 1¶
- numeric_styles¶
alias of
NumericStyles
- property ordered_map_format_config: OrderedMapFormatConfig¶
Configuration for ordered-map formatting.
OBJECT_VARIANTandRECORDrender an ordered map with its native{...}.toOrderedTableconstructor (an ordered map is never record-shaped, soRECORDleaves it on this path).json_typerenders an ordered map as a JSON object (the%*macro preserves object-key insertion order in the rendered output).
- pygments_name = 'nim'¶
- record_struct_name_prefix: str = 'Record'¶
- reserved_identifiers: ClassVar[frozenset[str]] = frozenset({})¶
- property scalar_body_preamble: dict[type, tuple[str, ...]]¶
Per-instance scalar body preamble (Nim needs none).
- property scalar_preamble: dict[type, tuple[str, ...]]¶
Per-instance scalar preamble for Nim scalar types.
Under the default
ERRORheterogeneous strategyimport jsonis added bydata_dependent_preambleonly when the rendered output uses%*. UnderOBJECT_VARIANTscalars are emitted as native Nim values, except that theNIMdate / datetime formats still produce ajson.JsonNodepayload and requireimport jsonwhenever a date or datetime is present. Underjson_typetheimport jsonline is contributed unconditionally bydata_dependent_preamble, so this method returns an empty per-scalar map to avoid duplicating it.
- sequence_binding_declarations(declarations: tuple[str, ...]) str¶
Default
sequence_binding_declarations– join the per-binding snippets with newlines.
- sequence_format: SequenceFormats = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=']', supports_heterogeneity=False, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=True, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)¶
- property sequence_format_config: SequenceFormatConfig¶
Configuration for the chosen sequence format.
json_typewraps every sequence literal in the%*macro so it renders as aJsonNodearray, and widens an empty sequence tonewJArray()(the explicit JSON array builder).OBJECT_VARIANTandRECORDreplace the JSON-array opener with@[so nested sequences render as Nim-nativeseqliterals at every level (the declaration formatter no longer adds a leading@becauseuses_typed_literal_for_scalarsis turned off). Empty sequences widen tonewSeq[string]()so the compiler does not rejectvar x = @[]with “cannot infer the type of the sequence” – and, underRECORD, so the widened element type matches theseq[string]an empty-list record field is declared.
- sequence_formats¶
alias of
SequenceFormats
- property sequence_open: Callable[[list[Value]], str]¶
Callable that returns the opening delimiter for a sequence.
- set_format: SetFormats = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close=']', empty_set=None, preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)¶
- property set_format_config: SetFormatConfig¶
Configuration for the chosen set format.
json_typerenders a set as a JSON array via%*([...])because JSON has no native set type; empty sets widen tonewJArray()for the same reason empty sequences do.
- set_formats¶
alias of
SetFormats
- skip_null_dict_values: ClassVar[bool] = False¶
- special_float_preamble: ClassVar[tuple[str, ...]] = ()¶
- statement_terminator: ClassVar[str] = ''¶
- statement_terminator_style: StatementTerminatorStyles = 1¶
- statement_terminator_styles¶
alias of
StatementTerminatorStyles
- static_body_preamble: ClassVar[Sequence[str]] = ()¶
- static_preamble: ClassVar[Sequence[str]] = ()¶
- string_format: StringFormats = 1¶
- string_formats¶
alias of
StringFormats
- supported_ref_cases: ClassVar[frozenset[IdentifierCase]] = frozenset({IdentifierCase.CAMEL, IdentifierCase.PASCAL, IdentifierCase.SNAKE, IdentifierCase.UPPER_SNAKE})¶
- supports_call_style = True¶
- supports_collection_comments: ClassVar[bool] = True¶
- supports_default_dict_key_type = False¶
- supports_default_dict_value_type = False¶
- supports_default_ordered_map_value_type = False¶
- supports_default_sequence_element_type = False¶
- supports_default_set_element_type = False¶
- supports_dict_literal_as_free_expression = True¶
- supports_dotted_call_stub = True¶
- supports_dotted_calls = True¶
- supports_empty_dict_key = False¶
- supports_inline_multiline_dict_args = True¶
- supports_module_name = False¶
- supports_multi_param_call_wrapper_stub = True¶
- supports_no_variable_wrap_in_file = False¶
- supports_non_string_dict_keys = False¶
- supports_record_shape_names = False¶
- supports_record_struct_name_prefix = True¶
- supports_scalar_before_comments: ClassVar[bool] = False¶
- supports_scalar_inline_comments: ClassVar[bool] = True¶
- supports_special_floats = True¶
- supports_standalone_comments_in_wrapped_calls = True¶
- supports_variable_names = True¶
- supports_zero_parameter_calls = True¶
- trailing_comma: TrailingCommas = TrailingCommaConfig(multiline_trailing_comma=False)¶
- property trailing_comma_config: TrailingCommaConfig¶
Configuration for trailing-comma behavior.
- trailing_commas¶
alias of
TrailingCommas
- true_literal: ClassVar[str] = 'true'¶
- property type_hint_collection_preamble_lines: Callable[[frozenset[type]], tuple[str, ...]]¶
Return preamble lines for empty-collection type hints.
- property validate_call_arg: Callable[[Value], None]¶
Return call-argument validation for this language.
- validate_spec_for_data(data: Value) None¶
Default
validate_spec_for_data— no spec/data constraints.
- variable_type_hints: VariableTypeHints = 1¶
- variable_type_hints_formats¶
alias of
VariableTypeHints
- version_formats¶
alias of
VersionFormats
- wrap_calls_with_declarations(declarations: tuple[str, ...], calls: str, body_preamble: tuple[str, ...]) str¶
Default
wrap_calls_with_declarations— concatenate the declarations and calls and route throughwrap_in_file()in call mode.
- static wrap_combined_in_file(declaration: str, assignment: str, variable_name: str, body_preamble: tuple[str, ...]) str¶
Wrap declaration and assignment in a valid file (no-op).
- static wrap_in_file(content: str, variable_name: str, body_preamble: tuple[str, ...]) str¶
Wrap code in a valid file (no-op).
- class literalizer.languages.Nix(*args: object, **kwargs: object)¶
Nix language specification.
Produces Nix values — attribute sets for mappings, and lists for sequences and sets — following Nix syntax.
Nix is a purely functional, lazy language used primarily for the Nix package manager. It supports attribute sets (
{ key = value; }), lists ([ elem1 elem2 ]), strings, integers, floats, booleans, andnull.Lists are space-separated with no commas. Attribute set entries end with semicolons.
Dates and datetimes are rendered as quoted ISO 8601 strings because Nix has no native date type.
Dict keys that cannot be represented as Nix attribute names raise
InvalidDictKeyError.- class BoolFormats(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
Empty: this language has no alternative boolean formats.
- class BytesFormats(*values)¶
Bytes formatting options.
- BASE64 = <function format_bytes_base64>¶
- HEX = <function format_bytes_hex>¶
- class CallStyles(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
Nix call style options.
- class DateFormats(*values)¶
Date format options for Nix.
- ISO = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- class DatetimeFormats(*values)¶
Datetime format options for Nix.
- EPOCH = DatetimeFormatConfig(formatter=<function format_datetime_epoch>, preamble_lines=(), type_produced=<class 'int'>)¶
- ISO = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- class DeclarationStyles(*values)¶
Declaration style options.
- LET = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=False)¶
- class FloatFormats(*values)¶
Float format options.
- FIXED = <function format_float_fixed>¶
- REPR = <function format_float_repr>¶
- SCIENTIFIC = <function format_float_scientific>¶
- class HeterogeneousStrategies(*values)¶
Heterogeneous-scalar strategy options — this language only supports raising.
- ERROR = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)¶
- class JsonTypes(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
Empty: this language has no JSON value-type variants.
- class Modifiers(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
C++/Java/C#-style declaration modifiers: this language has none.
- class SequenceFormats(*values)¶
Sequence type options for Nix.
- LIST = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=']', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=False, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)¶
- class SetFormats(*values)¶
Set type options for Nix.
- SET = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close=']', empty_set=None, preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)¶
- class TrailingCommas(*values)¶
Trailing comma options.
- NO = TrailingCommaConfig(multiline_trailing_comma=False)¶
- allows_empty_call_parens = True¶
- bool_formats¶
alias of
BoolFormats
- bytes_format: BytesFormats = <function format_bytes_hex>¶
- bytes_formats¶
alias of
BytesFormats
- property call_data_dependent_preamble: Callable[[Value], tuple[str, ...]]¶
Return data-dependent preamble lines for call rendering.
- call_returns_expression = True¶
- call_style_config: ClassVar[PositionalCallStyle | KeywordCallStyle | ObjectCallStyle | PostfixCallStyle | PrefixCallStyle | CommandCallStyle | CallSupport] = 'not_implemented_by_tool'¶
- call_styles¶
alias of
CallStyles
- property comment_config: CommentConfig¶
Configuration for the language’s comment syntax.
- comment_format: CommentFormats = CommentConfig(prefix='#', suffix='')¶
- comment_formats¶
alias of
CommentFormats
- property compute_body_preamble: Callable[[frozenset[type], Value], tuple[str, ...]]¶
Compute body-preamble lines from the scalar map.
- property consumable_ref_value_inhibits_consuming_form: Callable[[Value], bool]¶
Predicate deciding whether a ref’s underlying value type inhibits the consume form.
Delegates to
never_inhibits_consuming_form. Languages whose consume operator rejects certain value types (notably the Mojo^on register-trivial scalars) override this.
- property data_dependent_preamble: Callable[[Value], tuple[str, ...]]¶
Return data-dependent preamble lines.
- date_format: DateFormats = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- date_formats¶
alias of
DateFormats
- datetime_format: DatetimeFormats = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- datetime_formats¶
alias of
DatetimeFormats
- declaration_style: DeclarationStyles = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=False)¶
- declaration_styles¶
alias of
DeclarationStyles
- dict_entry_style: DictEntryStyles = 1¶
- dict_entry_styles¶
alias of
DictEntryStyles
- dict_format: DictFormats = 1¶
- property dict_format_config: DictFormatConfig¶
Configuration for dict formatting.
- dict_formats¶
alias of
DictFormats
- dict_supports_heterogeneous_values = True¶
- element_separator: ClassVar[str] = ' '¶
- empty_dict_keys¶
alias of
EmptyDictKey
- extension = '.nix'¶
- false_literal: ClassVar[str] = 'false'¶
- float_format: FloatFormats = <function format_float_repr>¶
- float_formats¶
alias of
FloatFormats
- property format_bytes: Callable[[bytes], str]¶
Callable that formats a bytes value as a string literal.
- static format_call_arg(_value: Value, formatted: str, /) str¶
Callable that rewrites a formatted direct call argument.
- property format_call_arg_ref_identifier: Callable[[str, Value | None], str]¶
Rewrite a
{"$ref": "name"}identifier in a call-argument context.Delegates to
format_call_ref_identifier. Override this to allow call-argument$refvalues that would otherwise be rejected.
- property format_call_arg_ref_identifier_consumable: Callable[[str, Value | None], str]¶
Format a
$refthe caller authorized as consumable.Delegates to
format_call_arg_ref_identifier. Override this to opt into a consuming form (e.g. C++std::move).
- format_call_binding_body_preamble() tuple[str, ...]¶
Default
format_call_binding_body_preamble– no extra body preamble lines for an inference-bound call result.
- format_call_binding_file_pragmas() tuple[str, ...]¶
Default
format_call_binding_file_pragmas– no file-level compiler-pragma line for an inference-bound call result.
- property format_call_preamble_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]¶
Return file-scope stubs for a call expression.
- property format_call_ref_identifier: Callable[[str, Value | None], str]¶
Rewrite a
{"$ref": "name"}identifier into the language’s call expression syntax.
- property format_call_statement: Callable[[str], str]¶
Return call-statement formatting for this language.
- property format_call_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]¶
Return stub declarations for a call expression.
- property format_call_target: Callable[[Sequence[str]], str]¶
Rewrite a dotted call target into the language’s call syntax.
- property format_call_variable_assignment: Callable[[str, str, Value], str]¶
Default
format_call_variable_assignment– reuse the literal-binding assignment formatter unchanged.
- property format_call_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]¶
Default
format_call_variable_declaration– reuse the literal-binding declaration formatter unchanged.
- static format_constructor_target(class_name: str, /) str¶
Return class_name as a zero-argument constructor call target.
- property format_date: Callable[[date], str]¶
Callable that formats a date as a string literal.
- property format_datetime: Callable[[datetime], str]¶
Callable that formats a datetime as a string literal.
- property format_float: Callable[[float], str]¶
Callable that formats a float value as a literal.
- property format_integer: Callable[[int], str]¶
Format an int value as a literal.
- property format_integer_widened: None¶
Default
format_integer_widened– no mixed-magnitude integer widening, so the renderer keeps the normal integer formatter.
- property format_ordered_map_entry: Callable[[str, Value, str], str]¶
Callable that formats one ordered-map entry.
- property format_sequence_entry: Callable[[Value, str], str]¶
Format a sequence entry.
- property format_set_entry: Callable[[Value, str], str]¶
Format a set entry.
- property format_string: Callable[[str], str]¶
Format a string value as a quoted literal.
- property format_time: Callable[[time], str]¶
Callable that formats a time as a string literal.
- property format_variable_assignment: Callable[[str, str, Value], str]¶
Format an assignment to an existing variable.
- property format_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]¶
Callable that formats a new variable declaration.
- has_free_function_calls = True¶
- property heterogeneous_behavior: HeterogeneousBehavior¶
Return the heterogeneous-behavior config.
- heterogeneous_strategies¶
alias of
HeterogeneousStrategies
- heterogeneous_strategy: HeterogeneousStrategies = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)¶
- identifier_cases: ClassVar[tuple[IdentifierCase, ...]] = (IdentifierCase.SNAKE, IdentifierCase.CAMEL)¶
- indent: str = ' '¶
- indent_closing_delimiter: ClassVar[bool] = False¶
- integer_format: IntegerFormats = 1¶
- integer_formats¶
alias of
IntegerFormats
- integer_width_strategies¶
alias of
BareIntegerWidthStrategies
- integer_width_strategy: BareIntegerWidthStrategies = 1¶
- language_version: VersionFormats = 1¶
- property leading_preamble: LeadingPreamble¶
Default
leading_preamble– no preamble lines that must precedeLanguage.static_preamble.
- max_call_parameters = 9223372036854775807¶
- modifier_combinations: ClassVar[tuple[ModifierCombination, ...]] = ()¶
- null_literal: ClassVar[str] = 'null'¶
- numeric_literal_suffix: NumericLiteralSuffixes = 1¶
- numeric_literal_suffixes¶
alias of
NumericLiteralSuffixes
- numeric_separator: NumericSeparators = 1¶
- numeric_separators¶
alias of
NumericSeparators
- numeric_style: NumericStyles = 1¶
- numeric_styles¶
alias of
NumericStyles
- property ordered_map_format_config: OrderedMapFormatConfig¶
Configuration for ordered-map formatting.
- pygments_name = 'nix'¶
- reserved_identifiers: ClassVar[frozenset[str]] = frozenset({})¶
- property scalar_body_preamble: dict[type, tuple[str, ...]]¶
Per-instance scalar body preamble (Nix needs none).
- property scalar_preamble: dict[type, tuple[str, ...]]¶
Per-instance scalar preamble (Nix needs none).
- static sequence_binding_declarations(declarations: tuple[str, ...]) str¶
Chain Nix bindings as nested
letblocks.Each Nix binding’s
bare_codehas the shapelet NAME = VALUE; in NAME(the language’s declaration template). Concatenating these verbatim is invalid Nix, so every binding except the last has its trailingin NAMEresult expression dropped, leavinglet NAME = VALUE; in; the bindings are then chained so each subsequent binding is the body of the previouslet. The final binding keeps its full; in NAMEtail so the file evaluates to that value. The identifier is removed structurally using the known; in <name>suffix shape, not a regex over the rendered value.
- sequence_format: SequenceFormats = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=']', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=False, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)¶
- property sequence_format_config: SequenceFormatConfig¶
Configuration for the chosen sequence format.
- sequence_formats¶
alias of
SequenceFormats
- property sequence_open: Callable[[list[Value]], str]¶
Callable that returns the opening delimiter for a sequence.
- set_format: SetFormats = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close=']', empty_set=None, preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)¶
- property set_format_config: SetFormatConfig¶
Configuration for the chosen set format.
- set_formats¶
alias of
SetFormats
- skip_null_dict_values: ClassVar[bool] = False¶
- special_float_preamble: ClassVar[tuple[str, ...]] = ()¶
- statement_terminator: ClassVar[str] = ''¶
- statement_terminator_style: StatementTerminatorStyles = 1¶
- statement_terminator_styles¶
alias of
StatementTerminatorStyles
- static_body_preamble: ClassVar[Sequence[str]] = ()¶
- static_preamble: ClassVar[Sequence[str]] = ()¶
- string_format: StringFormats = 1¶
- string_formats¶
alias of
StringFormats
- supported_ref_cases: ClassVar[frozenset[IdentifierCase]] = frozenset({IdentifierCase.CAMEL, IdentifierCase.KEBAB, IdentifierCase.PASCAL, IdentifierCase.SNAKE, IdentifierCase.UPPER_SNAKE})¶
- supports_call_style = False¶
- supports_collection_comments: ClassVar[bool] = True¶
- supports_default_dict_key_type = False¶
- supports_default_dict_value_type = False¶
- supports_default_ordered_map_value_type = False¶
- supports_default_sequence_element_type = False¶
- supports_default_set_element_type = False¶
- supports_dict_literal_as_free_expression = True¶
- supports_dotted_call_stub = True¶
- supports_dotted_calls = True¶
- supports_empty_dict_key = False¶
- supports_inline_multiline_dict_args = True¶
- supports_module_name = False¶
- supports_multi_param_call_wrapper_stub = True¶
- supports_no_variable_wrap_in_file = True¶
- supports_non_string_dict_keys = False¶
- supports_record_shape_names = False¶
- supports_record_struct_name_prefix = False¶
- supports_scalar_before_comments: ClassVar[bool] = True¶
- supports_scalar_inline_comments: ClassVar[bool] = False¶
- supports_special_floats = True¶
- supports_standalone_comments_in_wrapped_calls = True¶
- supports_variable_names = True¶
- supports_zero_parameter_calls = True¶
- trailing_comma: TrailingCommas = TrailingCommaConfig(multiline_trailing_comma=False)¶
- property trailing_comma_config: TrailingCommaConfig¶
Configuration for trailing-comma behavior.
- trailing_commas¶
alias of
TrailingCommas
- true_literal: ClassVar[str] = 'true'¶
- property type_hint_collection_preamble_lines: Callable[[frozenset[type]], tuple[str, ...]]¶
Return preamble lines for empty-collection type hints.
- property validate_call_arg: Callable[[Value], None]¶
Return call-argument validation for this language.
- validate_spec_for_data(data: Value) None¶
Default
validate_spec_for_data— no spec/data constraints.
- variable_type_hints: VariableTypeHints = 1¶
- variable_type_hints_formats¶
alias of
VariableTypeHints
- version_formats¶
alias of
VersionFormats
- wrap_calls_with_declarations(declarations: tuple[str, ...], calls: str, body_preamble: tuple[str, ...]) str¶
Default
wrap_calls_with_declarations— concatenate the declarations and calls and route throughwrap_in_file()in call mode.
- static wrap_combined_in_file(declaration: str, assignment: str, variable_name: str, body_preamble: tuple[str, ...]) str¶
Unsupported: literalize() rejects BothVariableForms upstream.
- static wrap_in_file(content: str, variable_name: str, body_preamble: tuple[str, ...]) str¶
Wrap code in a valid file (no-op).
- class literalizer.languages.Norg(*args: object, **kwargs: object)¶
Norg markup language specification.
Produces data literals using Norg-compatible syntax — square brackets for sequences and sets, curly braces for mappings, and
key: valuefor dict entries.Norg comments use the null attached modifier:
% comment %.Variable declarations use a heading followed by a ranged verbatim tag:
* namethen@code json/@end.- class BoolFormats(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
Empty: this language has no alternative boolean formats.
- class BytesFormats(*values)¶
Bytes formatting options.
- BASE64 = <function format_bytes_base64>¶
- HEX = <function format_bytes_hex>¶
- class CallStyles(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
Norg call style options.
- class CommentFormats(*values)¶
Comment style options.
- PERCENT = CommentConfig(prefix='%', suffix='%')¶
- class DateFormats(*values)¶
Date format options for Norg.
- ISO = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- class DatetimeFormats(*values)¶
Datetime format options for Norg.
- EPOCH = DatetimeFormatConfig(formatter=<function format_datetime_epoch>, preamble_lines=(), type_produced=<class 'int'>)¶
- ISO = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- class DeclarationStyles(*values)¶
Declaration style options.
- BLOCK = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=False)¶
- class FloatFormats(*values)¶
Float format options.
- FIXED = <function format_float_fixed>¶
- REPR = <function format_float_repr>¶
- SCIENTIFIC = <function format_float_scientific>¶
- class HeterogeneousStrategies(*values)¶
Heterogeneous-scalar strategy options — this language only supports raising.
- ERROR = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)¶
- class JsonTypes(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
Empty: this language has no JSON value-type variants.
- class Modifiers(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
C++/Java/C#-style declaration modifiers: this language has none.
- class SequenceFormats(*values)¶
Sequence type options for Norg.
- ARRAY = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=']', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)¶
- class SetFormats(*values)¶
Set type options for Norg.
- SET = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close=']', empty_set=None, preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)¶
- class TrailingCommas(*values)¶
Trailing comma options.
- NO = TrailingCommaConfig(multiline_trailing_comma=False)¶
- allows_empty_call_parens = True¶
- bool_formats¶
alias of
BoolFormats
- bytes_format: BytesFormats = <function format_bytes_hex>¶
- bytes_formats¶
alias of
BytesFormats
- property call_data_dependent_preamble: Callable[[Value], tuple[str, ...]]¶
Return data-dependent preamble lines for call rendering.
- call_returns_expression = True¶
- call_style_config: ClassVar[PositionalCallStyle | KeywordCallStyle | ObjectCallStyle | PostfixCallStyle | PrefixCallStyle | CommandCallStyle | CallSupport] = 'not_in_language'¶
- call_styles¶
alias of
CallStyles
- property comment_config: CommentConfig¶
Configuration for the language’s comment syntax.
- comment_format: CommentFormats = CommentConfig(prefix='%', suffix='%')¶
- comment_formats¶
alias of
CommentFormats
- property compute_body_preamble: Callable[[frozenset[type], Value], tuple[str, ...]]¶
Compute body-preamble lines from the scalar map.
- property consumable_ref_value_inhibits_consuming_form: Callable[[Value], bool]¶
Predicate deciding whether a ref’s underlying value type inhibits the consume form.
Delegates to
never_inhibits_consuming_form. Languages whose consume operator rejects certain value types (notably the Mojo^on register-trivial scalars) override this.
- property data_dependent_preamble: Callable[[Value], tuple[str, ...]]¶
Return data-dependent preamble lines.
- date_format: DateFormats = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- date_formats¶
alias of
DateFormats
- datetime_format: DatetimeFormats = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- datetime_formats¶
alias of
DatetimeFormats
- declaration_style: DeclarationStyles = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=False)¶
- declaration_styles¶
alias of
DeclarationStyles
- dict_entry_style: DictEntryStyles = 1¶
- dict_entry_styles¶
alias of
DictEntryStyles
- dict_format: DictFormats = 1¶
- property dict_format_config: DictFormatConfig¶
Configuration for dict formatting.
- dict_formats¶
alias of
DictFormats
- dict_supports_heterogeneous_values = True¶
- element_separator: ClassVar[str] = ', '¶
- empty_dict_keys¶
alias of
EmptyDictKey
- extension = '.norg'¶
- false_literal: ClassVar[str] = 'false'¶
- float_format: FloatFormats = <function format_float_repr>¶
- float_formats¶
alias of
FloatFormats
- property format_bytes: Callable[[bytes], str]¶
Callable that formats a bytes value as a string literal.
- static format_call_arg(_value: Value, formatted: str, /) str¶
Callable that rewrites a formatted direct call argument.
- property format_call_arg_ref_identifier: Callable[[str, Value | None], str]¶
Rewrite a
{"$ref": "name"}identifier in a call-argument context.Delegates to
format_call_ref_identifier. Override this to allow call-argument$refvalues that would otherwise be rejected.
- property format_call_arg_ref_identifier_consumable: Callable[[str, Value | None], str]¶
Format a
$refthe caller authorized as consumable.Delegates to
format_call_arg_ref_identifier. Override this to opt into a consuming form (e.g. C++std::move).
- format_call_binding_body_preamble() tuple[str, ...]¶
Default
format_call_binding_body_preamble– no extra body preamble lines for an inference-bound call result.
- format_call_binding_file_pragmas() tuple[str, ...]¶
Default
format_call_binding_file_pragmas– no file-level compiler-pragma line for an inference-bound call result.
- property format_call_preamble_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]¶
Return file-scope stubs for a call expression.
- property format_call_ref_identifier: Callable[[str, Value | None], str]¶
Rewrite a
{"$ref": "name"}identifier into the language’s call expression syntax.
- property format_call_statement: Callable[[str], str]¶
Return call-statement formatting for this language.
- property format_call_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]¶
Return stub declarations for a call expression.
- property format_call_target: Callable[[Sequence[str]], str]¶
Rewrite a dotted call target into the language’s call syntax.
- property format_call_variable_assignment: Callable[[str, str, Value], str]¶
Default
format_call_variable_assignment– reuse the literal-binding assignment formatter unchanged.
- property format_call_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]¶
Default
format_call_variable_declaration– reuse the literal-binding declaration formatter unchanged.
- static format_constructor_target(class_name: str, /) str¶
Return class_name as a zero-argument constructor call target.
- property format_date: Callable[[date], str]¶
Callable that formats a date as a string literal.
- property format_datetime: Callable[[datetime], str]¶
Callable that formats a datetime as a string literal.
- property format_float: Callable[[float], str]¶
Callable that formats a float value as a literal.
- property format_integer: Callable[[int], str]¶
Format an int value as a literal.
- property format_integer_widened: None¶
Default
format_integer_widened– no mixed-magnitude integer widening, so the renderer keeps the normal integer formatter.
- property format_ordered_map_entry: Callable[[str, Value, str], str]¶
Callable that formats one ordered-map entry.
- property format_sequence_entry: Callable[[Value, str], str]¶
Format a sequence entry.
- property format_set_entry: Callable[[Value, str], str]¶
Format a set entry.
- property format_string: Callable[[str], str]¶
Format a string value as a quoted literal.
- property format_time: Callable[[time], str]¶
Callable that formats a time as a string literal.
- property format_variable_assignment: Callable[[str, str, Value], str]¶
Format an assignment to an existing variable.
- property format_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]¶
Callable that formats a new variable declaration.
- has_free_function_calls = True¶
- property heterogeneous_behavior: HeterogeneousBehavior¶
Return the heterogeneous-behavior config.
- heterogeneous_strategies¶
alias of
HeterogeneousStrategies
- heterogeneous_strategy: HeterogeneousStrategies = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)¶
- identifier_cases: ClassVar[tuple[IdentifierCase, ...]] = (IdentifierCase.SNAKE,)¶
- indent: str = ' '¶
- indent_closing_delimiter: ClassVar[bool] = False¶
- integer_format: IntegerFormats = 1¶
- integer_formats¶
alias of
IntegerFormats
- integer_width_strategies¶
alias of
BareIntegerWidthStrategies
- integer_width_strategy: BareIntegerWidthStrategies = 1¶
- language_version: VersionFormats = 1¶
- property leading_preamble: LeadingPreamble¶
Default
leading_preamble– no preamble lines that must precedeLanguage.static_preamble.
- max_call_parameters = 9223372036854775807¶
- modifier_combinations: ClassVar[tuple[ModifierCombination, ...]] = ()¶
- null_literal: ClassVar[str] = 'null'¶
- numeric_literal_suffix: NumericLiteralSuffixes = 1¶
- numeric_literal_suffixes¶
alias of
NumericLiteralSuffixes
- numeric_separator: NumericSeparators = 1¶
- numeric_separators¶
alias of
NumericSeparators
- numeric_style: NumericStyles = 1¶
- numeric_styles¶
alias of
NumericStyles
- property ordered_map_format_config: OrderedMapFormatConfig¶
Configuration for ordered-map formatting.
- pygments_name: ClassVar[str | None] = None¶
- reserved_identifiers: ClassVar[frozenset[str]] = frozenset({})¶
- property scalar_body_preamble: dict[type, tuple[str, ...]]¶
Per-instance scalar body preamble (Norg needs none).
- property scalar_preamble: dict[type, tuple[str, ...]]¶
Per-instance scalar preamble (Norg needs none).
- sequence_binding_declarations(declarations: tuple[str, ...]) str¶
Default
sequence_binding_declarations– join the per-binding snippets with newlines.
- sequence_format: SequenceFormats = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=']', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)¶
- property sequence_format_config: SequenceFormatConfig¶
Configuration for the chosen sequence format.
- sequence_formats¶
alias of
SequenceFormats
- property sequence_open: Callable[[list[Value]], str]¶
Callable that returns the opening delimiter for a sequence.
- set_format: SetFormats = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close=']', empty_set=None, preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)¶
- property set_format_config: SetFormatConfig¶
Configuration for the chosen set format.
- set_formats¶
alias of
SetFormats
- skip_null_dict_values: ClassVar[bool] = False¶
- special_float_preamble: ClassVar[tuple[str, ...]] = ()¶
- statement_terminator: ClassVar[str] = ''¶
- statement_terminator_style: StatementTerminatorStyles = 1¶
- statement_terminator_styles¶
alias of
StatementTerminatorStyles
- static_body_preamble: ClassVar[Sequence[str]] = ()¶
- static_preamble: ClassVar[Sequence[str]] = ()¶
- string_format: StringFormats = 1¶
- string_formats¶
alias of
StringFormats
- supported_ref_cases: ClassVar[frozenset[IdentifierCase]] = frozenset({IdentifierCase.CAMEL, IdentifierCase.PASCAL, IdentifierCase.SNAKE, IdentifierCase.UPPER_SNAKE})¶
- supports_call_style = False¶
- supports_collection_comments: ClassVar[bool] = True¶
- supports_default_dict_key_type = False¶
- supports_default_dict_value_type = False¶
- supports_default_ordered_map_value_type = False¶
- supports_default_sequence_element_type = False¶
- supports_default_set_element_type = False¶
- supports_dict_literal_as_free_expression = True¶
- supports_dotted_call_stub = True¶
- supports_dotted_calls = True¶
- supports_empty_dict_key = False¶
- supports_inline_multiline_dict_args = True¶
- supports_module_name = False¶
- supports_multi_param_call_wrapper_stub = True¶
- supports_no_variable_wrap_in_file = True¶
- supports_non_string_dict_keys = True¶
- supports_record_shape_names = False¶
- supports_record_struct_name_prefix = False¶
- supports_scalar_before_comments: ClassVar[bool] = True¶
- supports_scalar_inline_comments: ClassVar[bool] = True¶
- supports_special_floats = True¶
- supports_standalone_comments_in_wrapped_calls = True¶
- supports_variable_names = True¶
- supports_zero_parameter_calls = True¶
- trailing_comma: TrailingCommas = TrailingCommaConfig(multiline_trailing_comma=False)¶
- property trailing_comma_config: TrailingCommaConfig¶
Configuration for trailing-comma behavior.
- trailing_commas¶
alias of
TrailingCommas
- true_literal: ClassVar[str] = 'true'¶
- property type_hint_collection_preamble_lines: Callable[[frozenset[type]], tuple[str, ...]]¶
Return preamble lines for empty-collection type hints.
- property validate_call_arg: Callable[[Value], None]¶
Return call-argument validation for this language.
- validate_spec_for_data(data: Value) None¶
Default
validate_spec_for_data— no spec/data constraints.
- variable_type_hints: VariableTypeHints = 1¶
- variable_type_hints_formats¶
alias of
VariableTypeHints
- version_formats¶
alias of
VersionFormats
- wrap_calls_with_declarations(declarations: tuple[str, ...], calls: str, body_preamble: tuple[str, ...]) str¶
Default
wrap_calls_with_declarations— concatenate the declarations and calls and route throughwrap_in_file()in call mode.
- static wrap_combined_in_file(declaration: str, assignment: str, variable_name: str, body_preamble: tuple[str, ...]) str¶
Unsupported: literalize() rejects BothVariableForms upstream.
- static wrap_in_file(content: str, variable_name: str, body_preamble: tuple[str, ...]) str¶
Wrap code in a valid file (no-op).
- class literalizer.languages.OCaml(*args: object, **kwargs: object)¶
OCaml language specification.
- Parameters:
date_format –
How to format
datetime.datevalues.date_formats.OCAML— tuple literal, e.g.(2024, 1, 15).date_formats.ISO— ISO 8601 quoted string, e.g."2024-01-15".
datetime_format –
How to format
datetime.datetimevalues.datetime_formats.OCAML— pair of tuples, e.g.((2024, 1, 15), (12, 30, 0)).datetime_formats.ISO— ISO 8601 quoted string, e.g."2024-01-15T12:30:00".
type_name – Name of the generated custom type. Defaults to
"val_t".constructor_prefix – Prefix for generated constructor names. Defaults to
"O", producing constructors likeONull,OBool,OInt, etc.json_type –
Opt into rendering through a JSON value type instead of the generated tagged ADT.
None(default) — emit the customval_tADT.json_types.YOJSON_SAFE_T— emitYojson.Safe.tpolymorphic-variant literals using the standardyojsontag set (Bool,Int,Float,String,Null,List,Assoc,Intlit). Dates, datetimes, times, and bytes reformat to JSON-friendly strings; arbitrary-precision integers route through theIntlitescape hatch; thetype val_tpreamble is dropped.
- class BoolFormats(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
Empty: this language has no alternative boolean formats.
- class BytesFormats(*values)¶
Bytes formatting options.
- BASE64 = <function format_bytes_base64>¶
- HEX = <function format_bytes_hex>¶
- class CallStyles(*values)¶
OCaml call style options.
- CURRIED = CommandCallStyle(arg_separator=' ')¶
- POSITIONAL = PositionalCallStyle(arg_separator=', ', parenthesize_each_arg=False)¶
- class CommentFormats(*values)¶
Comment style options.
- PAREN_STAR = CommentConfig(prefix='(*', suffix=' *)')¶
- class DateFormats(*values)¶
Date format options for OCaml.
- ISO = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- OCAML = DateFormatConfig(formatter=<function date_ymd_formatter.<locals>._format>, preamble_lines=(), type_produced=<class 'datetime.date'>)¶
- class DatetimeFormats(*values)¶
Datetime format options for OCaml.
- EPOCH = DatetimeFormatConfig(formatter=<function format_datetime_epoch>, preamble_lines=(), type_produced=<class 'int'>)¶
- ISO = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- OCAML = DatetimeFormatConfig(formatter=<function datetime_ymdhms_formatter.<locals>._format>, preamble_lines=(), type_produced=<class 'datetime.datetime'>)¶
- class DeclarationStyles(*values)¶
Declaration style options.
- LET = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=False)¶
- class FloatFormats(*values)¶
Float format options.
- FIXED = <function format_float_fixed>¶
- REPR = <function format_float_repr>¶
- SCIENTIFIC = <function format_float_scientific>¶
- class HeterogeneousStrategies(*values)¶
Heterogeneous-scalar strategy options — this language only supports raising.
- ERROR = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)¶
- class IntegerFormats(*values)¶
Integer format options.
- BINARY = mappingproxy({'NONE': <function format_integer_binary>, 'UNDERSCORE': <function format_integer_binary>})¶
- DECIMAL = mappingproxy({'NONE': <class 'str'>, 'UNDERSCORE': <function format_integer_underscore>})¶
- HEX = mappingproxy({'NONE': <function format_integer_hex>, 'UNDERSCORE': <function format_integer_hex>})¶
- OCTAL = mappingproxy({'NONE': <function format_integer_octal>, 'UNDERSCORE': <function format_integer_octal>})¶
- get_formatter(numeric_separator: Enum) Callable[[int], str]¶
Return the integer formatter for the given separator.
- class JsonTypes(*values)¶
JSON value type options for OCaml.
- YOJSON_SAFE_T = 'Yojson.Safe.t'¶
Yojson.Safe.t— the polymorphic-variant JSON value type from theyojsonpackage.
- class Modifiers(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
C++/Java/C#-style declaration modifiers: this language has none.
- class SequenceFormats(*values)¶
Sequence type options for OCaml.
- ARRAY = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close='|]', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=False, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type='val_t array', narrowed_empty_form=None)¶
- LIST = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=']', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=False, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type='val_t', narrowed_empty_form=None)¶
- class SetFormats(*values)¶
Set type options for OCaml.
- SET = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close=']', empty_set=None, preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)¶
- class TrailingCommas(*values)¶
Trailing comma options.
- NO = TrailingCommaConfig(multiline_trailing_comma=False)¶
- allows_empty_call_parens = True¶
- bool_formats¶
alias of
BoolFormats
- bytes_format: BytesFormats = <function format_bytes_hex>¶
- bytes_formats¶
alias of
BytesFormats
- property call_data_dependent_preamble: Callable[[Value], tuple[str, ...]]¶
Return data-dependent preamble lines for call rendering.
- call_returns_expression = True¶
- call_style: CallStyles = PositionalCallStyle(arg_separator=', ', parenthesize_each_arg=False)¶
- property call_style_config: PositionalCallStyle | KeywordCallStyle | ObjectCallStyle | PostfixCallStyle | PrefixCallStyle | CommandCallStyle¶
Configuration for the chosen call style.
- call_styles¶
alias of
CallStyles
- property comment_config: CommentConfig¶
Configuration for the language’s comment syntax.
- comment_format: CommentFormats = CommentConfig(prefix='(*', suffix=' *)')¶
- comment_formats¶
alias of
CommentFormats
- property compute_body_preamble: Callable[[frozenset[type], Value], tuple[str, ...]]¶
Compute body-preamble lines from the scalar map.
- constructor_prefix: str = 'O'¶
- property consumable_ref_value_inhibits_consuming_form: Callable[[Value], bool]¶
Predicate deciding whether a ref’s underlying value type inhibits the consume form.
Delegates to
never_inhibits_consuming_form. Languages whose consume operator rejects certain value types (notably the Mojo^on register-trivial scalars) override this.
- property data_dependent_preamble: Callable[[Value], tuple[str, ...]]¶
Return data-dependent preamble lines.
- date_format: DateFormats = DateFormatConfig(formatter=<function date_ymd_formatter.<locals>._format>, preamble_lines=(), type_produced=<class 'datetime.date'>)¶
- date_formats¶
alias of
DateFormats
- datetime_format: DatetimeFormats = DatetimeFormatConfig(formatter=<function datetime_ymdhms_formatter.<locals>._format>, preamble_lines=(), type_produced=<class 'datetime.datetime'>)¶
- datetime_formats¶
alias of
DatetimeFormats
- declaration_style: DeclarationStyles = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=False)¶
- declaration_styles¶
alias of
DeclarationStyles
- dict_entry_style: DictEntryStyles = 1¶
- dict_entry_styles¶
alias of
DictEntryStyles
- dict_format: DictFormats = 1¶
- property dict_format_config: DictFormatConfig¶
Configuration for dict formatting.
- dict_formats¶
alias of
DictFormats
- dict_supports_heterogeneous_values = True¶
- element_separator: ClassVar[str] = '; '¶
- empty_dict_keys¶
alias of
EmptyDictKey
- extension = '.ml'¶
- property false_literal: str¶
False literal using the configured constructor prefix.
- float_format: FloatFormats = <function format_float_repr>¶
- float_formats¶
alias of
FloatFormats
- property format_bytes: Callable[[bytes], str]¶
Callable that formats a bytes value as a string literal.
- property format_call_arg: Callable[[Value, str], str]¶
Callable that rewrites a formatted direct call argument.
Curried calls parenthesize each argument so that constructor applications are not parsed as additional arguments to the outer call.
- property format_call_arg_ref_identifier: Callable[[str, Value | None], str]¶
Rewrite a
{"$ref": "name"}identifier in a call-argument context.Delegates to
format_call_ref_identifier. Override this to allow call-argument$refvalues that would otherwise be rejected.
- property format_call_arg_ref_identifier_consumable: Callable[[str, Value | None], str]¶
Format a
$refthe caller authorized as consumable.Delegates to
format_call_arg_ref_identifier. Override this to opt into a consuming form (e.g. C++std::move).
- format_call_binding_body_preamble() tuple[str, ...]¶
Default
format_call_binding_body_preamble– no extra body preamble lines for an inference-bound call result.
- format_call_binding_file_pragmas() tuple[str, ...]¶
Default
format_call_binding_file_pragmas– no file-level compiler-pragma line for an inference-bound call result.
- property format_call_preamble_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]¶
Return file-scope stubs for a call expression.
- property format_call_ref_identifier: Callable[[str, Value | None], str]¶
Rewrite a
{"$ref": "name"}identifier into the language’s call expression syntax.
- property format_call_statement: Callable[[str], str]¶
Wrap a call expression as a let binding.
- property format_call_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]¶
Return stub declarations for a call expression.
- property format_call_target: Callable[[Sequence[str]], str]¶
Rewrite a dotted call target into the language’s call syntax.
- property format_call_variable_assignment: Callable[[str, str, Value], str]¶
Callable that formats an existing-variable binding of a call expression.
OCaml has no mutable reassignment, so an
ExistingVariablebinding is just anotherlet. Likeformat_call_variable_declaration, the: val_tannotation and tag constructor are omitted so OCaml infers the call’s return type instead of the literal-binding formatter producinglet x : val_t = OInt make_widget(42).
- property format_call_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]¶
Callable that formats a declaration binding a call expression.
The literal-binding declaration annotates the binding with the custom type and wraps the value in a tag constructor derived from its runtime type (
let x : val_t = OInt 42); a call expression has no such tag, so both the annotation and the tag are omitted and OCaml infers the call’s return type instead (let x = make_widget(42)).
- static format_constructor_target(class_name: str, /) str¶
Return class_name as a zero-argument constructor call target.
- property format_date: Callable[[date], str]¶
Callable that formats a date as a string literal.
- property format_datetime: Callable[[datetime], str]¶
Callable that formats a datetime as a string literal.
- property format_float: Callable[[float], str]¶
Callable that formats a float value as a literal.
- property format_integer: Callable[[int], str]¶
Callable that formats an int value as a literal.
- property format_integer_widened: None¶
Default
format_integer_widened– no mixed-magnitude integer widening, so the renderer keeps the normal integer formatter.
- property format_ordered_map_entry: Callable[[str, Value, str], str]¶
Callable that formats one ordered-map entry.
- property format_sequence_entry: Callable[[Value, str], str]¶
Callable that formats a sequence entry.
- property format_set_entry: Callable[[Value, str], str]¶
Callable that formats a set entry.
- property format_string: Callable[[str], str]¶
Format a string value as a quoted literal.
- property format_time: Callable[[time], str]¶
Callable that formats a time as a string literal.
- property format_variable_assignment: Callable[[str, str, Value], str]¶
Callable that formats an assignment to an existing variable.
- property format_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]¶
Callable that formats a new variable declaration.
- has_free_function_calls = True¶
- property heterogeneous_behavior: HeterogeneousBehavior¶
Return the heterogeneous-behavior config.
- heterogeneous_strategies¶
alias of
HeterogeneousStrategies
- heterogeneous_strategy: HeterogeneousStrategies = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)¶
- identifier_cases: ClassVar[tuple[IdentifierCase, ...]] = (IdentifierCase.SNAKE, IdentifierCase.PASCAL)¶
- indent: str = ' '¶
- indent_closing_delimiter: ClassVar[bool] = False¶
- integer_format: IntegerFormats = mappingproxy({'NONE': <class 'str'>, 'UNDERSCORE': <function format_integer_underscore>})¶
- integer_formats¶
alias of
IntegerFormats
- integer_width_strategies¶
alias of
BareIntegerWidthStrategies
- integer_width_strategy: BareIntegerWidthStrategies = 1¶
- language_version: VersionFormats = 1¶
- property leading_preamble: LeadingPreamble¶
Default
leading_preamble– no preamble lines that must precedeLanguage.static_preamble.
- max_call_parameters = 9223372036854775807¶
- modifier_combinations: ClassVar[tuple[ModifierCombination, ...]] = ()¶
- property null_literal: str¶
Null literal using the configured constructor prefix.
- numeric_literal_suffix: NumericLiteralSuffixes = 1¶
- numeric_literal_suffixes¶
alias of
NumericLiteralSuffixes
- numeric_separator: NumericSeparators = 1¶
- numeric_separators¶
alias of
NumericSeparators
- numeric_style: NumericStyles = 1¶
- numeric_styles¶
alias of
NumericStyles
- property ordered_map_format_config: OrderedMapFormatConfig¶
Configuration for ordered-map formatting.
- pygments_name = 'ocaml'¶
- reserved_identifiers: ClassVar[frozenset[str]] = frozenset({})¶
- property scalar_body_preamble: dict[type, tuple[str, ...]]¶
Per-instance scalar body preamble for OCaml.
- property scalar_preamble: dict[type, tuple[str, ...]]¶
Per-instance scalar preamble (OCaml needs none).
- sequence_binding_declarations(declarations: tuple[str, ...]) str¶
Default
sequence_binding_declarations– join the per-binding snippets with newlines.
- sequence_format: SequenceFormats = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=']', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=False, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type='val_t', narrowed_empty_form=None)¶
- property sequence_format_config: SequenceFormatConfig¶
Configuration for the chosen sequence format.
- sequence_formats¶
alias of
SequenceFormats
- property sequence_open: Callable[[list[Value]], str]¶
Callable that returns the opening delimiter for a sequence.
- set_format: SetFormats = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close=']', empty_set=None, preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)¶
- property set_format_config: SetFormatConfig¶
Configuration for the chosen set format.
- set_formats¶
alias of
SetFormats
- skip_null_dict_values: ClassVar[bool] = False¶
- special_float_preamble: ClassVar[tuple[str, ...]] = ()¶
- statement_terminator: ClassVar[str] = ''¶
- statement_terminator_style: StatementTerminatorStyles = 1¶
- statement_terminator_styles¶
alias of
StatementTerminatorStyles
- static_body_preamble: ClassVar[Sequence[str]] = ()¶
- static_preamble: ClassVar[Sequence[str]] = ()¶
- string_format: StringFormats = 1¶
- string_formats¶
alias of
StringFormats
- supported_ref_cases: ClassVar[frozenset[IdentifierCase]] = frozenset({IdentifierCase.CAMEL, IdentifierCase.PASCAL, IdentifierCase.SNAKE, IdentifierCase.UPPER_SNAKE})¶
- supports_call_style = True¶
- supports_collection_comments: ClassVar[bool] = True¶
- supports_default_dict_key_type = False¶
- supports_default_dict_value_type = False¶
- supports_default_ordered_map_value_type = False¶
- supports_default_sequence_element_type = False¶
- supports_default_set_element_type = False¶
- supports_dict_literal_as_free_expression = True¶
- supports_dotted_call_stub = False¶
- supports_dotted_calls = True¶
- supports_empty_dict_key = False¶
- supports_inline_multiline_dict_args = True¶
- supports_module_name = False¶
- supports_multi_param_call_wrapper_stub = True¶
- supports_no_variable_wrap_in_file = False¶
- supports_non_string_dict_keys = False¶
- supports_record_shape_names = False¶
- supports_record_struct_name_prefix = False¶
- supports_scalar_before_comments: ClassVar[bool] = True¶
- supports_scalar_inline_comments: ClassVar[bool] = True¶
- supports_special_floats = True¶
- supports_standalone_comments_in_wrapped_calls = True¶
- supports_variable_names = True¶
- supports_zero_parameter_calls = True¶
- trailing_comma: TrailingCommas = TrailingCommaConfig(multiline_trailing_comma=False)¶
- property trailing_comma_config: TrailingCommaConfig¶
Configuration for trailing-comma behavior.
- trailing_commas¶
alias of
TrailingCommas
- property true_literal: str¶
True literal using the configured constructor prefix.
- property type_hint_collection_preamble_lines: Callable[[frozenset[type]], tuple[str, ...]]¶
Return preamble lines for empty-collection type hints.
- type_name: str = 'val_t'¶
- property validate_call_arg: Callable[[Value], None]¶
Return call-argument validation for this language.
- validate_spec_for_data(data: Value) None¶
Default
validate_spec_for_data— no spec/data constraints.
- variable_type_hints: VariableTypeHints = 1¶
- variable_type_hints_formats¶
alias of
VariableTypeHints
- version_formats¶
alias of
VersionFormats
- wrap_calls_with_declarations(declarations: tuple[str, ...], calls: str, body_preamble: tuple[str, ...]) str¶
Default
wrap_calls_with_declarations— concatenate the declarations and calls and route throughwrap_in_file()in call mode.
- static wrap_combined_in_file(declaration: str, assignment: str, variable_name: str, body_preamble: tuple[str, ...]) str¶
Unsupported: literalize() rejects BothVariableForms upstream.
- static wrap_in_file(content: str, variable_name: str, body_preamble: tuple[str, ...]) str¶
Wrap an OCaml let declaration in a module.
- class literalizer.languages.ObjectiveC(*args: object, **kwargs: object)¶
Objective-C language specification.
- class BoolFormats(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
Empty: this language has no alternative boolean formats.
- class BytesFormats(*values)¶
Bytes formatting options.
- BASE64 = <function _format_objc_bytes_base64>¶
- HEX = <function _format_objc_bytes>¶
- class CallStyles(*values)¶
ObjectiveC call style options.
- POSITIONAL = PositionalCallStyle(arg_separator=', ', parenthesize_each_arg=False)¶
- class CommentFormats(*values)¶
Comment style options.
- BLOCK = CommentConfig(prefix='/*', suffix=' */')¶
- DOUBLE_SLASH = CommentConfig(prefix='//', suffix='')¶
- class DateFormats(*values)¶
Date format options for ObjectiveC.
- ISO = DateFormatConfig(formatter=<function date_iso_formatter.<locals>._format>, preamble_lines=(), type_produced=<class 'str'>)¶
- OBJC = DateFormatConfig(formatter=<function date_iso_formatter.<locals>._format>, preamble_lines=(), type_produced=<class 'datetime.date'>)¶
- class DatetimeFormats(*values)¶
Datetime format options for ObjectiveC.
- EPOCH = DatetimeFormatConfig(formatter=<function format_datetime_epoch>, preamble_lines=(), type_produced=<class 'int'>)¶
- ISO = DatetimeFormatConfig(formatter=<function datetime_iso_formatter.<locals>._format>, preamble_lines=(), type_produced=<class 'str'>)¶
- OBJC = DatetimeFormatConfig(formatter=<function datetime_iso_formatter.<locals>._format>, preamble_lines=(), type_produced=<class 'datetime.datetime'>)¶
- class DeclarationStyles(*values)¶
Declaration style options.
- TYPED = DeclarationStyleConfig(formatter=<function _format_objc_declaration>, supports_redefinition=True)¶
- class FloatFormats(*values)¶
Float format options.
- FIXED = <function format_float_fixed>¶
- REPR = <function format_float_repr>¶
- SCIENTIFIC = <function format_float_scientific>¶
- class HeterogeneousStrategies(*values)¶
Heterogeneous-scalar strategy options — this language only supports raising.
- ERROR = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)¶
- class IntegerFormats(*values)¶
Integer format options.
- DECIMAL = <class 'str'>¶
- HEX = <function format_integer_hex>¶
- OCTAL = <function format_integer_octal_c_style>¶
- class JsonTypes(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
Empty: this language has no JSON value-type variants.
- class Modifiers(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
C++/Java/C#-style declaration modifiers: this language has none.
- class SequenceFormats(*values)¶
Sequence type options for Objective-C.
- ARRAY = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=']', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence='@[]', preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)¶
- class SetFormats(*values)¶
Set type options for Objective-C.
- SET = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close=']]', empty_set='[NSSet set]', preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)¶
- class TrailingCommas(*values)¶
Trailing comma options.
- NO = TrailingCommaConfig(multiline_trailing_comma=False)¶
- YES = TrailingCommaConfig(multiline_trailing_comma=True)¶
- allows_empty_call_parens = True¶
- bool_formats¶
alias of
BoolFormats
- bytes_format: BytesFormats = <function _format_objc_bytes>¶
- bytes_formats¶
alias of
BytesFormats
- property call_data_dependent_preamble: Callable[[Value], tuple[str, ...]]¶
Return data-dependent preamble lines for call rendering.
- call_returns_expression = True¶
- call_style: CallStyles = PositionalCallStyle(arg_separator=', ', parenthesize_each_arg=False)¶
- property call_style_config: PositionalCallStyle¶
Configuration for the chosen call style.
- call_styles¶
alias of
CallStyles
- property comment_config: CommentConfig¶
Configuration for the language’s comment syntax.
- comment_format: CommentFormats = CommentConfig(prefix='//', suffix='')¶
- comment_formats¶
alias of
CommentFormats
- property compute_body_preamble: Callable[[frozenset[type], Value], tuple[str, ...]]¶
Compute body-preamble lines from the scalar map.
- property consumable_ref_value_inhibits_consuming_form: Callable[[Value], bool]¶
Predicate deciding whether a ref’s underlying value type inhibits the consume form.
Delegates to
never_inhibits_consuming_form. Languages whose consume operator rejects certain value types (notably the Mojo^on register-trivial scalars) override this.
- property data_dependent_preamble: Callable[[Value], tuple[str, ...]]¶
Return data-dependent preamble lines.
- date_format: DateFormats = DateFormatConfig(formatter=<function date_iso_formatter.<locals>._format>, preamble_lines=(), type_produced=<class 'datetime.date'>)¶
- date_formats¶
alias of
DateFormats
- datetime_format: DatetimeFormats = DatetimeFormatConfig(formatter=<function datetime_iso_formatter.<locals>._format>, preamble_lines=(), type_produced=<class 'datetime.datetime'>)¶
- datetime_formats¶
alias of
DatetimeFormats
- declaration_style: DeclarationStyles = DeclarationStyleConfig(formatter=<function _format_objc_declaration>, supports_redefinition=True)¶
- declaration_styles¶
alias of
DeclarationStyles
- dict_entry_style: DictEntryStyles = 1¶
- dict_entry_styles¶
alias of
DictEntryStyles
- dict_format: DictFormats = 1¶
- property dict_format_config: DictFormatConfig¶
Configuration for dict formatting.
- dict_formats¶
alias of
DictFormats
- dict_supports_heterogeneous_values = True¶
- element_separator: ClassVar[str] = ', '¶
- empty_dict_keys¶
alias of
EmptyDictKey
- extension = '.m'¶
- false_literal: ClassVar[str] = '@NO'¶
- float_format: FloatFormats = <function format_float_repr>¶
- float_formats¶
alias of
FloatFormats
- property format_bytes: Callable[[bytes], str]¶
Callable that formats a bytes value as a string literal.
- property format_call_arg: Callable[[Value, str], str]¶
Box each call argument as an
idso call sites match the concrete prototype emitted by_objc_call_stub().
- property format_call_arg_ref_identifier: Callable[[str, Value | None], str]¶
Rewrite a
{"$ref": "name"}identifier in a call-argument context.Delegates to
format_call_ref_identifier. Override this to allow call-argument$refvalues that would otherwise be rejected.
- property format_call_arg_ref_identifier_consumable: Callable[[str, Value | None], str]¶
Format a
$refthe caller authorized as consumable.Delegates to
format_call_arg_ref_identifier. Override this to opt into a consuming form (e.g. C++std::move).
- format_call_binding_body_preamble() tuple[str, ...]¶
Default
format_call_binding_body_preamble– no extra body preamble lines for an inference-bound call result.
- format_call_binding_file_pragmas() tuple[str, ...]¶
Default
format_call_binding_file_pragmas– no file-level compiler-pragma line for an inference-bound call result.
- property format_call_preamble_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]¶
Return file-scope stubs for a call expression.
- property format_call_ref_identifier: Callable[[str, Value | None], str]¶
Rewrite a
{"$ref": "name"}identifier into the language’s call expression syntax.
- property format_call_statement: Callable[[str], str]¶
Return call-statement formatting for this language.
- property format_call_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]¶
Return stub declarations for a call expression.
- property format_call_target: Callable[[Sequence[str]], str]¶
Rewrite a dotted call target so the root matches the
k-prefixed const global emitted by_objc_call_stub().
- property format_call_variable_assignment: Callable[[str, str, Value], str]¶
Callable that formats an assignment binding a call expression.
The call-expression counterpart of
format_variable_assignment; the@(...)boxing is dropped since a call already yields an object pointer.
- property format_call_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]¶
Callable that formats a declaration binding a call expression.
The literal-binding declaration boxes a primitive right-hand side as
NSNumber/NSString(anidis a pointer type); a call expression already yields an object pointer, so the@(...)boxing is dropped and the call result is bound directly.
- static format_constructor_target(class_name: str, /) str¶
Return class_name as a zero-argument constructor call target.
- property format_date: Callable[[date], str]¶
Callable that formats a date as a string literal.
- property format_datetime: Callable[[datetime], str]¶
Callable that formats a datetime as a string literal.
- property format_float: Callable[[float], str]¶
Callable that formats a float value as a literal.
- property format_integer: Callable[[int], str]¶
Callable that formats an int value as a literal.
Values above
LLONG_MAXget aULLsuffix so clang does not reinterpret the literal as an unsigned type and emit the warning the lint workflow treats as an error; values belowLLONG_MINraiseUnrepresentableIntegerErrorsince no signed or unsigned 64-bit integer can hold them.
- property format_integer_widened: None¶
Default
format_integer_widened– no mixed-magnitude integer widening, so the renderer keeps the normal integer formatter.
- property format_ordered_map_entry: Callable[[str, Value, str], str]¶
Callable that formats one ordered-map entry.
- property format_sequence_entry: Callable[[Value, str], str]¶
Format a sequence entry.
- property format_set_entry: Callable[[Value, str], str]¶
Format a set entry.
- property format_string: Callable[[str], str]¶
Format a string value as a quoted literal.
- property format_time: Callable[[time], str]¶
Callable that formats a time as a string literal.
- property format_variable_assignment: Callable[[str, str, Value], str]¶
Format an assignment to an existing variable.
- property format_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]¶
Callable that formats a new variable declaration.
- has_free_function_calls = True¶
- property heterogeneous_behavior: HeterogeneousBehavior¶
Return the heterogeneous-behavior config.
- heterogeneous_strategies¶
alias of
HeterogeneousStrategies
- heterogeneous_strategy: HeterogeneousStrategies = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)¶
- identifier_cases: ClassVar[tuple[IdentifierCase, ...]] = (IdentifierCase.CAMEL, IdentifierCase.PASCAL)¶
- indent: str = ' '¶
- indent_closing_delimiter: ClassVar[bool] = False¶
- integer_format: IntegerFormats = <class 'str'>¶
- integer_formats¶
alias of
IntegerFormats
- integer_width_strategies¶
alias of
BareIntegerWidthStrategies
- integer_width_strategy: BareIntegerWidthStrategies = 1¶
- language_version: VersionFormats = 1¶
- property leading_preamble: LeadingPreamble¶
Default
leading_preamble– no preamble lines that must precedeLanguage.static_preamble.
- max_call_parameters = 9223372036854775807¶
- modifier_combinations: ClassVar[tuple[ModifierCombination, ...]] = ()¶
- module_name: str = 'Module'¶
- module_name_case: ClassVar[IdentifierCase] = 'snake'¶
- null_literal: ClassVar[str] = '[NSNull null]'¶
- numeric_literal_suffix: NumericLiteralSuffixes = 1¶
- numeric_literal_suffixes¶
alias of
NumericLiteralSuffixes
- numeric_separator: NumericSeparators = 1¶
- numeric_separators¶
alias of
NumericSeparators
- numeric_style: NumericStyles = 1¶
- numeric_styles¶
alias of
NumericStyles
- property ordered_map_format_config: OrderedMapFormatConfig¶
Configuration for ordered-map formatting.
- pygments_name = 'objective-c'¶
- reserved_identifiers: ClassVar[frozenset[str]] = frozenset({})¶
- property scalar_body_preamble: dict[type, tuple[str, ...]]¶
Per-instance scalar body preamble (Objective-C needs none).
- property scalar_preamble: dict[type, tuple[str, ...]]¶
Per-instance scalar preamble (Objective-C needs none).
- sequence_binding_declarations(declarations: tuple[str, ...]) str¶
Default
sequence_binding_declarations– join the per-binding snippets with newlines.
- sequence_format: SequenceFormats = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=']', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence='@[]', preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)¶
- property sequence_format_config: SequenceFormatConfig¶
Configuration for the chosen sequence format.
- sequence_formats¶
alias of
SequenceFormats
- property sequence_open: Callable[[list[Value]], str]¶
Callable that returns the opening delimiter for a sequence.
- set_format: SetFormats = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close=']]', empty_set='[NSSet set]', preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)¶
- property set_format_config: SetFormatConfig¶
Configuration for the chosen set format.
- set_formats¶
alias of
SetFormats
- skip_null_dict_values: ClassVar[bool] = False¶
- special_float_preamble: ClassVar[tuple[str, ...]] = ()¶
- statement_terminator: ClassVar[str] = ';'¶
- statement_terminator_style: StatementTerminatorStyles = 1¶
- statement_terminator_styles¶
alias of
StatementTerminatorStyles
- static_body_preamble: ClassVar[Sequence[str]] = ()¶
- static_preamble: ClassVar[Sequence[str]] = ('#import <Foundation/Foundation.h>',)¶
- string_format: StringFormats = 1¶
- string_formats¶
alias of
StringFormats
- supported_ref_cases: ClassVar[frozenset[IdentifierCase]] = frozenset({IdentifierCase.CAMEL, IdentifierCase.PASCAL, IdentifierCase.SNAKE, IdentifierCase.UPPER_SNAKE})¶
- supports_call_style = True¶
- supports_collection_comments: ClassVar[bool] = True¶
- supports_default_dict_key_type = False¶
- supports_default_dict_value_type = False¶
- supports_default_ordered_map_value_type = False¶
- supports_default_sequence_element_type = False¶
- supports_default_set_element_type = False¶
- supports_dict_literal_as_free_expression = True¶
- supports_dotted_call_stub = False¶
- supports_dotted_calls = True¶
- supports_empty_dict_key = False¶
- supports_inline_multiline_dict_args = True¶
- supports_module_name = True¶
- supports_multi_param_call_wrapper_stub = True¶
- supports_no_variable_wrap_in_file = False¶
- supports_non_string_dict_keys = False¶
- supports_record_shape_names = False¶
- supports_record_struct_name_prefix = False¶
- supports_scalar_before_comments: ClassVar[bool] = False¶
- supports_scalar_inline_comments: ClassVar[bool] = False¶
- supports_special_floats = True¶
- supports_standalone_comments_in_wrapped_calls = True¶
- supports_variable_names = True¶
- supports_zero_parameter_calls = True¶
- trailing_comma: TrailingCommas = TrailingCommaConfig(multiline_trailing_comma=True)¶
- property trailing_comma_config: TrailingCommaConfig¶
Configuration for trailing-comma behavior.
- trailing_commas¶
alias of
TrailingCommas
- true_literal: ClassVar[str] = '@YES'¶
- property type_hint_collection_preamble_lines: Callable[[frozenset[type]], tuple[str, ...]]¶
Return preamble lines for empty-collection type hints.
- property validate_call_arg: Callable[[Value], None]¶
Return call-argument validation for this language.
- validate_spec_for_data(data: Value) None¶
Default
validate_spec_for_data— no spec/data constraints.
- variable_type_hints: VariableTypeHints = 1¶
- variable_type_hints_formats¶
alias of
VariableTypeHints
- version_formats¶
alias of
VersionFormats
- wrap_calls_with_declarations(declarations: tuple[str, ...], calls: str, body_preamble: tuple[str, ...]) str¶
Default
wrap_calls_with_declarations— concatenate the declarations and calls and route throughwrap_in_file()in call mode.
- wrap_combined_in_file(declaration: str, assignment: str, variable_name: str, body_preamble: tuple[str, ...]) str¶
Wrap Objective-C declaration + assignment in a function.
Reads
variable_namebetween the declaration and the assignment so the initial value is not a dead store flagged by clang-tidy’sclang-analyzer-deadcode.DeadStorescheck.
- wrap_in_file(content: str, variable_name: str, body_preamble: tuple[str, ...]) str¶
Wrap an Objective-C declaration in a main function.
- class literalizer.languages.Occam(*args: object, **kwargs: object)¶
Occam-pi language specification.
- class BoolFormats(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
Empty: this language has no alternative boolean formats.
- class BytesFormats(*values)¶
Bytes formatting options.
- BASE64 = <function format_bytes_base64>¶
- HEX = <function format_bytes_hex>¶
- class CallStyles(*values)¶
Occam call style options.
- POSITIONAL = PositionalCallStyle(arg_separator=', ', parenthesize_each_arg=False)¶
- class CommentFormats(*values)¶
Comment style options.
- DOUBLE_DASH = CommentConfig(prefix='--', suffix='')¶
- class DateFormats(*values)¶
Date format options for Occam.
- ISO = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- class DatetimeFormats(*values)¶
Datetime format options for Occam.
- EPOCH = DatetimeFormatConfig(formatter=<function format_datetime_epoch>, preamble_lines=(), type_produced=<class 'int'>)¶
- ISO = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- class DeclarationStyles(*values)¶
Declaration style options.
- VAL = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=False)¶
- class FloatFormats(*values)¶
Float format options.
- FIXED = <function format_float_fixed>¶
- REPR = <function format_float_repr>¶
- SCIENTIFIC = <function format_float_scientific>¶
- class HeterogeneousStrategies(*values)¶
Heterogeneous-scalar strategy options — this language only supports raising.
- ERROR = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)¶
- class JsonTypes(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
Empty: this language has no JSON value-type variants.
- class Modifiers(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
C++/Java/C#-style declaration modifiers: this language has none.
- class SequenceFormats(*values)¶
Sequence type options for Occam.
- LIST = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close='])', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=False, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)¶
- class SetFormats(*values)¶
Set type options for Occam.
- SET = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close='])', empty_set=None, preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)¶
- class TrailingCommas(*values)¶
Trailing comma options.
- NO = TrailingCommaConfig(multiline_trailing_comma=False)¶
- allows_empty_call_parens = True¶
- bool_formats¶
alias of
BoolFormats
- bytes_format: BytesFormats = <function format_bytes_hex>¶
- bytes_formats¶
alias of
BytesFormats
- property call_data_dependent_preamble: Callable[[Value], tuple[str, ...]]¶
Return data-dependent preamble lines for call rendering.
- call_returns_expression = True¶
- call_style: CallStyles = PositionalCallStyle(arg_separator=', ', parenthesize_each_arg=False)¶
- property call_style_config: PositionalCallStyle | KeywordCallStyle | ObjectCallStyle | PostfixCallStyle | PrefixCallStyle | CommandCallStyle¶
Configuration for the chosen call style.
- call_styles¶
alias of
CallStyles
- property comment_config: CommentConfig¶
Configuration for the language’s comment syntax.
- comment_format: CommentFormats = CommentConfig(prefix='--', suffix='')¶
- comment_formats¶
alias of
CommentFormats
- property compute_body_preamble: Callable[[frozenset[type], Value], tuple[str, ...]]¶
Compute body-preamble lines from the scalar map.
- property consumable_ref_value_inhibits_consuming_form: Callable[[Value], bool]¶
Predicate deciding whether a ref’s underlying value type inhibits the consume form.
Delegates to
never_inhibits_consuming_form. Languages whose consume operator rejects certain value types (notably the Mojo^on register-trivial scalars) override this.
- property data_dependent_preamble: Callable[[Value], tuple[str, ...]]¶
Return data-dependent preamble lines.
- date_format: DateFormats = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- date_formats¶
alias of
DateFormats
- datetime_format: DatetimeFormats = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- datetime_formats¶
alias of
DatetimeFormats
- declaration_style: DeclarationStyles = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=False)¶
- declaration_styles¶
alias of
DeclarationStyles
- dict_entry_style: DictEntryStyles = 1¶
- dict_entry_styles¶
alias of
DictEntryStyles
- dict_format: DictFormats = 1¶
- property dict_format_config: DictFormatConfig¶
Configuration for dict formatting.
- dict_formats¶
alias of
DictFormats
- dict_supports_heterogeneous_values = True¶
- element_separator: ClassVar[str] = ', '¶
- empty_dict_keys¶
alias of
EmptyDictKey
- extension = '.occ'¶
- false_literal: ClassVar[str] = 'MOBILE LIT(lit.bool; FALSE)'¶
- float_format: FloatFormats = <function format_float_repr>¶
- float_formats¶
alias of
FloatFormats
- property format_bytes: Callable[[bytes], str]¶
Callable that formats a bytes value as a string literal.
- property format_call_arg: Callable[[Value, str], str]¶
Wrap direct call arguments in
MOBILE LITconstructors.
- property format_call_arg_ref_identifier: Callable[[str, Value | None], str]¶
Rewrite a
{"$ref": "name"}identifier in a call-argument context.Delegates to
format_call_ref_identifier. Override this to allow call-argument$refvalues that would otherwise be rejected.
- property format_call_arg_ref_identifier_consumable: Callable[[str, Value | None], str]¶
Format a
$refthe caller authorized as consumable.Delegates to
format_call_arg_ref_identifier. Override this to opt into a consuming form (e.g. C++std::move).
- format_call_binding_body_preamble() tuple[str, ...]¶
Default
format_call_binding_body_preamble– no extra body preamble lines for an inference-bound call result.
- format_call_binding_file_pragmas() tuple[str, ...]¶
Default
format_call_binding_file_pragmas– no file-level compiler-pragma line for an inference-bound call result.
- property format_call_preamble_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]¶
Return file-scope stubs for a call expression.
- property format_call_ref_identifier: Callable[[str, Value | None], str]¶
Rewrite a
{"$ref": "name"}identifier into the language’s call expression syntax.
- property format_call_statement: Callable[[str], str]¶
Return call-statement formatting for this language.
- property format_call_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]¶
Return stub declarations for a call expression.
- property format_call_target: Callable[[Sequence[str]], str]¶
Rewrite a dotted call target into the language’s call syntax.
- property format_call_variable_assignment: Callable[[str, str, Value], str]¶
Default
format_call_variable_assignment– reuse the literal-binding assignment formatter unchanged.
- property format_call_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]¶
Default
format_call_variable_declaration– reuse the literal-binding declaration formatter unchanged.
- static format_constructor_target(class_name: str, /) str¶
Return class_name as a zero-argument constructor call target.
- property format_date: Callable[[date], str]¶
Callable that formats a date as a string literal.
- property format_datetime: Callable[[datetime], str]¶
Callable that formats a datetime as a string literal.
- property format_float: Callable[[float], str]¶
Callable that formats a float value as a literal.
- property format_integer: Callable[[int], str]¶
Format an int value as a literal.
- property format_integer_widened: None¶
Default
format_integer_widened– no mixed-magnitude integer widening, so the renderer keeps the normal integer formatter.
- property format_ordered_map_entry: Callable[[str, Value, str], str]¶
Callable that formats one ordered-map entry.
- property format_sequence_entry: Callable[[Value, str], str]¶
Format a sequence entry.
- property format_set_entry: Callable[[Value, str], str]¶
Format a set entry.
- property format_string: Callable[[str], str]¶
Format a string value as a quoted literal.
- property format_time: Callable[[time], str]¶
Callable that formats a time as a string literal.
- property format_variable_assignment: Callable[[str, str, Value], str]¶
Format an assignment to an existing variable.
- property format_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]¶
Callable that formats a new variable declaration.
- has_free_function_calls = True¶
- property heterogeneous_behavior: HeterogeneousBehavior¶
Return the heterogeneous-behavior config.
- heterogeneous_strategies¶
alias of
HeterogeneousStrategies
- heterogeneous_strategy: HeterogeneousStrategies = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)¶
- identifier_cases: ClassVar[tuple[IdentifierCase, ...]] = (IdentifierCase.UPPER_SNAKE, IdentifierCase.SNAKE)¶
- indent: str = ' '¶
- indent_closing_delimiter: ClassVar[bool] = False¶
- integer_format: IntegerFormats = 1¶
- integer_formats¶
alias of
IntegerFormats
- integer_width_strategies¶
alias of
BareIntegerWidthStrategies
- integer_width_strategy: BareIntegerWidthStrategies = 1¶
- language_version: VersionFormats = 1¶
- property leading_preamble: LeadingPreamble¶
Default
leading_preamble– no preamble lines that must precedeLanguage.static_preamble.
- max_call_parameters = 9223372036854775807¶
- modifier_combinations: ClassVar[tuple[ModifierCombination, ...]] = ()¶
- module_name: str = 'Module'¶
- module_name_case: ClassVar[IdentifierCase] = 'snake'¶
- null_literal: ClassVar[str] = 'MOBILE LIT(lit.null)'¶
- numeric_literal_suffix: NumericLiteralSuffixes = 1¶
- numeric_literal_suffixes¶
alias of
NumericLiteralSuffixes
- numeric_separator: NumericSeparators = 1¶
- numeric_separators¶
alias of
NumericSeparators
- numeric_style: NumericStyles = 1¶
- numeric_styles¶
alias of
NumericStyles
- property ordered_map_format_config: OrderedMapFormatConfig¶
Configuration for ordered-map formatting.
- pygments_name: ClassVar[str | None] = None¶
- reserved_identifiers: ClassVar[frozenset[str]] = frozenset({})¶
- property scalar_body_preamble: dict[type, tuple[str, ...]]¶
Per-instance scalar body preamble (Occam needs none).
- property scalar_preamble: dict[type, tuple[str, ...]]¶
Per-instance scalar preamble (Occam needs none).
- sequence_binding_declarations(declarations: tuple[str, ...]) str¶
Default
sequence_binding_declarations– join the per-binding snippets with newlines.
- sequence_format: SequenceFormats = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close='])', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=False, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)¶
- property sequence_format_config: SequenceFormatConfig¶
Configuration for the chosen sequence format.
- sequence_formats¶
alias of
SequenceFormats
- property sequence_open: Callable[[list[Value]], str]¶
Callable that returns the opening delimiter for a sequence.
- set_format: SetFormats = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close='])', empty_set=None, preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)¶
- property set_format_config: SetFormatConfig¶
Configuration for the chosen set format.
- set_formats¶
alias of
SetFormats
- skip_null_dict_values: ClassVar[bool] = False¶
- special_float_preamble: ClassVar[tuple[str, ...]] = ()¶
- statement_terminator: ClassVar[str] = ''¶
- statement_terminator_style: StatementTerminatorStyles = 1¶
- statement_terminator_styles¶
alias of
StatementTerminatorStyles
- static_body_preamble: ClassVar[Sequence[str]] = ()¶
- static_preamble: ClassVar[Sequence[str]] = ('MOBILE DATA TYPE LIT IS\n CASE\n lit.null\n lit.bool ; BOOL\n lit.int ; INT\n lit.float ; REAL32\n lit.str ; MOBILE []BYTE\n lit.list ; MOBILE []MOBILE LIT\n lit.map ; MOBILE []MOBILE LIT\n lit.pair ; MOBILE []BYTE ; MOBILE LIT\n lit.set ; MOBILE []MOBILE LIT\n:',)¶
- string_format: StringFormats = 1¶
- string_formats¶
alias of
StringFormats
- supported_ref_cases: ClassVar[frozenset[IdentifierCase]] = frozenset({IdentifierCase.CAMEL, IdentifierCase.PASCAL, IdentifierCase.SNAKE, IdentifierCase.UPPER_SNAKE})¶
- supports_call_style = True¶
- supports_collection_comments: ClassVar[bool] = True¶
- supports_default_dict_key_type = False¶
- supports_default_dict_value_type = False¶
- supports_default_ordered_map_value_type = False¶
- supports_default_sequence_element_type = False¶
- supports_default_set_element_type = False¶
- supports_dict_literal_as_free_expression = True¶
- supports_dotted_call_stub = True¶
- supports_dotted_calls = True¶
- supports_empty_dict_key = False¶
- supports_inline_multiline_dict_args = True¶
- supports_module_name = True¶
- supports_multi_param_call_wrapper_stub = True¶
- supports_no_variable_wrap_in_file = False¶
- supports_non_string_dict_keys = False¶
- supports_record_shape_names = False¶
- supports_record_struct_name_prefix = False¶
- supports_scalar_before_comments: ClassVar[bool] = True¶
- supports_scalar_inline_comments: ClassVar[bool] = True¶
- supports_special_floats = True¶
- supports_standalone_comments_in_wrapped_calls = True¶
- supports_variable_names = True¶
- supports_zero_parameter_calls = True¶
- trailing_comma: TrailingCommas = TrailingCommaConfig(multiline_trailing_comma=False)¶
- property trailing_comma_config: TrailingCommaConfig¶
Configuration for trailing-comma behavior.
- trailing_commas¶
alias of
TrailingCommas
- true_literal: ClassVar[str] = 'MOBILE LIT(lit.bool; TRUE)'¶
- property type_hint_collection_preamble_lines: Callable[[frozenset[type]], tuple[str, ...]]¶
Return preamble lines for empty-collection type hints.
- property validate_call_arg: Callable[[Value], None]¶
Return call-argument validation for this language.
- validate_spec_for_data(data: Value) None¶
Default
validate_spec_for_data— no spec/data constraints.
- variable_type_hints: VariableTypeHints = 1¶
- variable_type_hints_formats¶
alias of
VariableTypeHints
- version_formats¶
alias of
VersionFormats
- wrap_calls_with_declarations(declarations: tuple[str, ...], calls: str, body_preamble: tuple[str, ...]) str¶
Default
wrap_calls_with_declarations— concatenate the declarations and calls and route throughwrap_in_file()in call mode.
- static wrap_combined_in_file(declaration: str, assignment: str, variable_name: str, body_preamble: tuple[str, ...]) str¶
Unsupported: literalize() rejects BothVariableForms upstream.
- wrap_in_file(content: str, variable_name: str, body_preamble: tuple[str, ...]) str¶
Wrap an occam-pi VAL declaration in a PROC.
- class literalizer.languages.Odin(*args: object, **kwargs: object)¶
Odin language specification.
- class BoolFormats(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
Empty: this language has no alternative boolean formats.
- class BytesFormats(*values)¶
Bytes formatting options.
- BASE64 = <function format_bytes_base64>¶
- HEX = <function format_bytes_hex>¶
- class CallStyles(*values)¶
Odin call style options.
- POSITIONAL = PositionalCallStyle(arg_separator=', ', parenthesize_each_arg=False)¶
- class CommentFormats(*values)¶
Comment style options.
- BLOCK = CommentConfig(prefix='/*', suffix=' */')¶
- DOUBLE_SLASH = CommentConfig(prefix='//', suffix='')¶
- class DateFormats(*values)¶
Date format options for Odin.
- ISO = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- class DatetimeFormats(*values)¶
Datetime format options for Odin.
- EPOCH = DatetimeFormatConfig(formatter=<function format_datetime_epoch>, preamble_lines=(), type_produced=<class 'int'>)¶
- ISO = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- class DeclarationStyles(*values)¶
Declaration style options.
- SHORT = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=False)¶
- class FloatFormats(*values)¶
Float format options.
- FIXED = <function format_float_fixed>¶
- REPR = <function format_float_repr>¶
- SCIENTIFIC = <function format_float_scientific>¶
- class HeterogeneousStrategies(*values)¶
Heterogeneous-scalar strategy options.
ERRORraises on a heterogeneous scalar collection.RECORDinstead renders each record-shaped dict (non-empty, string-keyed) as a generated package-scopestructplus a matchingRecord0{ field = value, ... }literal, so a dict may mix scalars and containers that the homogeneousmap[string]Vcannot.- ERROR = 1¶
- RECORD = 2¶
- class IntegerFormats(*values)¶
Integer format options.
- BINARY = mappingproxy({'NONE': <function format_integer_binary>, 'UNDERSCORE': <function format_integer_binary>})¶
- DECIMAL = mappingproxy({'NONE': <class 'str'>, 'UNDERSCORE': <function format_integer_underscore>})¶
- HEX = mappingproxy({'NONE': <function format_integer_hex>, 'UNDERSCORE': <function format_integer_hex>})¶
- OCTAL = mappingproxy({'NONE': <function format_integer_octal>, 'UNDERSCORE': <function format_integer_octal>})¶
- get_formatter(numeric_separator: Enum) Callable[[int], str]¶
Return the integer formatter for the given separator.
- class JsonTypes(*values)¶
JSON value type options for Odin.
- JSON_VALUE = 'json.Value'¶
Odin’s standard
core:encoding/jsonValuesum type.
- class Modifiers(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
C++/Java/C#-style declaration modifiers: this language has none.
- class SequenceFormats(*values)¶
Sequence type options for Odin.
- DYNAMIC_ARRAY = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close='}', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)¶
- class SetFormats(*values)¶
Set type options for Odin.
- SET = <function set_format_factory.<locals>._build>¶
- class TrailingCommas(*values)¶
Trailing comma options.
- NO = TrailingCommaConfig(multiline_trailing_comma=False)¶
- YES = TrailingCommaConfig(multiline_trailing_comma=True)¶
- allows_empty_call_parens = True¶
- bool_formats¶
alias of
BoolFormats
- bytes_format: BytesFormats = <function format_bytes_hex>¶
- bytes_formats¶
alias of
BytesFormats
- property call_data_dependent_preamble: Callable[[Value], tuple[str, ...]]¶
Return data-dependent preamble lines for call rendering.
- call_returns_expression = True¶
- call_style: CallStyles = PositionalCallStyle(arg_separator=', ', parenthesize_each_arg=False)¶
- property call_style_config: PositionalCallStyle | KeywordCallStyle | ObjectCallStyle | PostfixCallStyle | PrefixCallStyle | CommandCallStyle¶
Configuration for the chosen call style.
- call_styles¶
alias of
CallStyles
- property comment_config: CommentConfig¶
Configuration for the language’s comment syntax.
- comment_format: CommentFormats = CommentConfig(prefix='//', suffix='')¶
- comment_formats¶
alias of
CommentFormats
- property compute_body_preamble: Callable[[frozenset[type], Value], tuple[str, ...]]¶
Compute body-preamble lines from the scalar map.
- property consumable_ref_value_inhibits_consuming_form: Callable[[Value], bool]¶
Predicate deciding whether a ref’s underlying value type inhibits the consume form.
Delegates to
never_inhibits_consuming_form. Languages whose consume operator rejects certain value types (notably the Mojo^on register-trivial scalars) override this.
- property data_dependent_preamble: Callable[[Value], tuple[str, ...]]¶
Return data-dependent preamble lines.
Under
json_typethe data rides inside a single JSON string, so no per-data preamble applies. ForHeterogeneousStrategies.RECORDemits onestructdeclaration per record shape present in the data; otherwise produces no preamble.
- date_format: DateFormats = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- date_formats¶
alias of
DateFormats
- datetime_format: DatetimeFormats = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- datetime_formats¶
alias of
DatetimeFormats
- declaration_style: DeclarationStyles = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=False)¶
- declaration_styles¶
alias of
DeclarationStyles
- default_set_element_type: str = 'string'¶
- dict_entry_style: DictEntryStyles = 1¶
- dict_entry_styles¶
alias of
DictEntryStyles
- dict_format: DictFormats = 1¶
- property dict_format_config: DictFormatConfig¶
Configuration for dict formatting.
- dict_formats¶
alias of
DictFormats
- dict_supports_heterogeneous_values = True¶
- element_separator: ClassVar[str] = ', '¶
- empty_dict_keys¶
alias of
EmptyDictKey
- extension = '.odin'¶
- false_literal: ClassVar[str] = 'false'¶
- float_format: FloatFormats = <function format_float_repr>¶
- float_formats¶
alias of
FloatFormats
- property format_bytes: Callable[[bytes], str]¶
Callable that formats a bytes value as a string literal.
- property format_call_arg: Callable[[Value, str], str]¶
Callable that rewrites a formatted direct call argument.
Under
json_typeeach argument is ajson.Valueproduced by_json_parse; otherwise the framework’s formatted text passes through unchanged.
- property format_call_arg_ref_identifier: Callable[[str, Value | None], str]¶
Rewrite a
{"$ref": "name"}identifier in a call-argument context.Delegates to
format_call_ref_identifier. Override this to allow call-argument$refvalues that would otherwise be rejected.
- property format_call_arg_ref_identifier_consumable: Callable[[str, Value | None], str]¶
Format a
$refthe caller authorized as consumable.Delegates to
format_call_arg_ref_identifier. Override this to opt into a consuming form (e.g. C++std::move).
- format_call_binding_body_preamble() tuple[str, ...]¶
Default
format_call_binding_body_preamble– no extra body preamble lines for an inference-bound call result.
- format_call_binding_file_pragmas() tuple[str, ...]¶
Default
format_call_binding_file_pragmas– no file-level compiler-pragma line for an inference-bound call result.
- property format_call_preamble_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]¶
Return file-scope stubs for a call expression.
- property format_call_ref_identifier: Callable[[str, Value | None], str]¶
Rewrite a
{"$ref": "name"}identifier into the language’s call expression syntax.
- property format_call_statement: Callable[[str], str]¶
Return call-statement formatting for this language.
- property format_call_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]¶
Return stub declarations for a call expression.
- property format_call_target: Callable[[Sequence[str]], str]¶
Rewrite a dotted call target into the language’s call syntax.
- property format_call_variable_assignment: Callable[[str, str, Value], str]¶
Callable that formats an assignment binding a call result.
The call-expression counterpart of
format_call_variable_declaration; the json-mode_json_parseshortcut applied to literal assignments would substitute the argument data for the formatted call expression and is dropped here.
- property format_call_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]¶
Callable that formats a declaration binding a call result.
Always uses the plain
{name} := {value}form regardless ofjson_type: a call’s return type is opaque to the renderer (the generated proc stub returnsany), and the json-mode_json_parseshortcut applied to literal bindings would discard the formatted call expression and substitute the argument data, which is not the call’s return value.
- static format_constructor_target(class_name: str, /) str¶
Return class_name as a zero-argument constructor call target.
- property format_date: Callable[[date], str]¶
Callable that formats a date as a string literal.
- property format_datetime: Callable[[datetime], str]¶
Callable that formats a datetime as a string literal.
- property format_float: Callable[[float], str]¶
Callable that formats a float value as a literal.
- property format_integer: Callable[[int], str]¶
Callable that formats an int value as a literal.
- property format_integer_widened: None¶
Default
format_integer_widened– no mixed-magnitude integer widening, so the renderer keeps the normal integer formatter.
- property format_ordered_map_entry: Callable[[str, Value, str], str]¶
Callable that formats one ordered-map entry.
- property format_sequence_entry: Callable[[Value, str], str]¶
Format a sequence entry.
- property format_set_entry: Callable[[Value, str], str]¶
Format a set entry.
Under
json_typeset entries fold into the JSON text and the per-entry string is discarded, so the framework just needs a permissive identity arm rather than the"key" = {}map-as-set form.
- property format_string: Callable[[str], str]¶
Format a string value as a quoted literal.
- property format_time: Callable[[time], str]¶
Callable that formats a time as a string literal.
- property format_variable_assignment: Callable[[str, str, Value], str]¶
Format an assignment to an existing variable.
Under
json_typethe assignment uses the_json_parsecall shortcut instead of the framework’s formatted value.
- property format_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]¶
Callable that formats a new variable declaration.
Under
json_typethe declaration is a_json_parsecall call (the inferred return type isjson.Value), bypassing both the framework’s formatted value and the nil-safe: any = nilshim.
- has_free_function_calls = True¶
- property heterogeneous_behavior: HeterogeneousBehavior¶
Return the behavior for the chosen heterogeneous strategy.
Under
json_typeheterogeneous scalars all flow through the JSON text, so scalar-uniformity checks are skipped.
- heterogeneous_strategies¶
alias of
HeterogeneousStrategies
- heterogeneous_strategy: HeterogeneousStrategies = 1¶
- identifier_cases: ClassVar[tuple[IdentifierCase, ...]] = (IdentifierCase.SNAKE, IdentifierCase.PASCAL, IdentifierCase.UPPER_SNAKE)¶
- indent: str = '\t'¶
- indent_closing_delimiter: ClassVar[bool] = False¶
- integer_format: IntegerFormats = mappingproxy({'NONE': <class 'str'>, 'UNDERSCORE': <function format_integer_underscore>})¶
- integer_formats¶
alias of
IntegerFormats
- integer_width_strategies¶
alias of
BareIntegerWidthStrategies
- integer_width_strategy: BareIntegerWidthStrategies = 1¶
- language_version: VersionFormats = 1¶
- property leading_preamble: LeadingPreamble¶
Default
leading_preamble– no preamble lines that must precedeLanguage.static_preamble.
- max_call_parameters = 9223372036854775807¶
- modifier_combinations: ClassVar[tuple[ModifierCombination, ...]] = ()¶
- null_literal: ClassVar[str] = 'nil'¶
- numeric_literal_suffix: NumericLiteralSuffixes = 1¶
- numeric_literal_suffixes¶
alias of
NumericLiteralSuffixes
- numeric_separator: NumericSeparators = 1¶
- numeric_separators¶
alias of
NumericSeparators
- numeric_style: NumericStyles = 1¶
- numeric_styles¶
alias of
NumericStyles
- property ordered_map_format_config: OrderedMapFormatConfig¶
Configuration for ordered-map formatting.
- pygments_name = 'odin'¶
- record_struct_name_prefix: str = 'Record'¶
- reserved_identifiers: ClassVar[frozenset[str]] = frozenset({})¶
- property scalar_body_preamble: dict[type, tuple[str, ...]]¶
Per-instance scalar body preamble (Odin needs none).
- property scalar_preamble: dict[type, tuple[str, ...]]¶
Per-instance scalar preamble (Odin needs none).
- sequence_binding_declarations(declarations: tuple[str, ...]) str¶
Default
sequence_binding_declarations– join the per-binding snippets with newlines.
- sequence_format: SequenceFormats = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close='}', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)¶
- property sequence_format_config: SequenceFormatConfig¶
Configuration for the chosen sequence format.
Under
json_typelists fold into the JSON text and the framework’s formatted output is discarded.
- sequence_formats¶
alias of
SequenceFormats
- property sequence_open: Callable[[list[Value]], str]¶
Callable that returns the opening delimiter for a sequence.
- set_format: SetFormats = <function set_format_factory.<locals>._build>¶
- property set_format_config: SetFormatConfig¶
Configuration for the chosen set format.
- set_formats¶
alias of
SetFormats
- skip_null_dict_values: ClassVar[bool] = False¶
- special_float_preamble: ClassVar[tuple[str, ...]] = ('import "core:math"',)¶
- statement_terminator: ClassVar[str] = ';'¶
- statement_terminator_style: StatementTerminatorStyles = 1¶
- statement_terminator_styles¶
alias of
StatementTerminatorStyles
- static_body_preamble: ClassVar[Sequence[str]] = ()¶
- property static_preamble: Sequence[str]¶
File-scope preamble.
Under
json_typethe package gains acore:encoding/jsonimport plus a tiny_json_parsehelper so every literalized value can render as a single_json_parsecall call.
- string_format: StringFormats = 1¶
- string_formats¶
alias of
StringFormats
- supported_ref_cases: ClassVar[frozenset[IdentifierCase]] = frozenset({IdentifierCase.CAMEL, IdentifierCase.PASCAL, IdentifierCase.SNAKE, IdentifierCase.UPPER_SNAKE})¶
- supports_call_style = True¶
- supports_collection_comments: ClassVar[bool] = True¶
- supports_default_dict_key_type = False¶
- supports_default_dict_value_type = False¶
- supports_default_ordered_map_value_type = False¶
- supports_default_sequence_element_type = False¶
- supports_default_set_element_type = True¶
- supports_dict_literal_as_free_expression = True¶
- supports_dotted_call_stub = True¶
- supports_dotted_calls = True¶
- supports_empty_dict_key = False¶
- supports_inline_multiline_dict_args = True¶
- supports_module_name = False¶
- supports_multi_param_call_wrapper_stub = True¶
- supports_no_variable_wrap_in_file = False¶
- supports_non_string_dict_keys = False¶
- supports_record_shape_names = False¶
- supports_record_struct_name_prefix = True¶
- supports_scalar_before_comments: ClassVar[bool] = False¶
- supports_scalar_inline_comments: ClassVar[bool] = True¶
- supports_special_floats = True¶
- supports_standalone_comments_in_wrapped_calls = True¶
- supports_variable_names = True¶
- supports_zero_parameter_calls = True¶
- trailing_comma: TrailingCommas = TrailingCommaConfig(multiline_trailing_comma=True)¶
- property trailing_comma_config: TrailingCommaConfig¶
Configuration for trailing-comma behavior.
- trailing_commas¶
alias of
TrailingCommas
- true_literal: ClassVar[str] = 'true'¶
- property type_hint_collection_preamble_lines: Callable[[frozenset[type]], tuple[str, ...]]¶
Return preamble lines for empty-collection type hints.
- property validate_call_arg: Callable[[Value], None]¶
Return call-argument validation for this language.
Under
json_typedirect call arguments flow through the same_json_parseshortcut as variable bindings, so they need the same dict-key / backtick rejection thatvalidate_spec_for_data()applies on the variable path.
- validate_spec_for_data(data: Value) None¶
Raise if the spec cannot produce valid code for data.
When
json_typeis active, walk data to reject non-string dict keys (which JSON objects cannot represent) and strings (string values or string-typed dict keys) carrying a literal backtick (which would terminate the Odin raw-string delimiter that wraps the embedded JSON text).
- variable_type_hints: VariableTypeHints = 1¶
- variable_type_hints_formats¶
alias of
VariableTypeHints
- version_formats¶
alias of
VersionFormats
- wrap_calls_with_declarations(declarations: tuple[str, ...], calls: str, body_preamble: tuple[str, ...]) str¶
Default
wrap_calls_with_declarations— concatenate the declarations and calls and route throughwrap_in_file()in call mode.
- static wrap_combined_in_file(declaration: str, assignment: str, variable_name: str, body_preamble: tuple[str, ...]) str¶
Unsupported: literalize() rejects BothVariableForms upstream.
- wrap_in_file(content: str, variable_name: str, body_preamble: tuple[str, ...]) str¶
Wrap an Odin declaration in a main procedure.
Under
json_typeanExistingVariableform produces a baremy_data = _json_parse(...)line, which the Odin compiler rejects (the name is undeclared); inject a zero-valuedmy_data: anydeclaration ahead of the assignment so the wrapped file still compiles. Typedany(notjson.Value): the assignment may bind either a_json_parsevalue or a call result whose stub returnsany, and onlyanyaccepts both.
- class literalizer.languages.Perl(*args: object, **kwargs: object)¶
Perl language specification.
- Parameters:
date_format –
How to format
datetime.datevalues.date_formats.PERL–DateTime->new(...)call, e.g.DateTime->new(year => 2024, month => 1, day => 15).date_formats.ISO– ISO 8601 quoted string, e.g."2024-01-15".
datetime_format –
How to format
datetime.datetimevalues.datetime_formats.PERL–DateTime->new(...)call, e.g.DateTime->new(year => 2024, month => 1, day => 15, hour => 12, minute => 30, second => 0, time_zone => 'UTC').datetime_formats.ISO– ISO 8601 quoted string, e.g."2024-01-15T12:30:00+00:00".
bool_format –
How to format
boolvalues. Perl has no native boolean type, so the choice trades off readability against round-trip fidelity through JSON and YAML libraries.bool_formats.INTEGER– bare1/0(default, preserves prior output). Re-encoding to JSON loses the boolean type.bool_formats.JSON_PP_REF–\1/\0scalar references, the conventional form used byJSON::PP,JSON::XS,Cpanel::JSON::XSandMojo::JSON. Round-trips back to JSONtrue/falsewith nousepreamble required.bool_formats.JSON_PP_SINGLETON–JSON::PP::true/JSON::PP::falseblessed singletons; adds ause JSON::PP;preamble (JSON::PPis a core module).
Only boolean values round-trip; Perl coerces every hash key to a string, so a boolean dict key cannot preserve any non-string representation regardless of
bool_format.string_format –
How to format
strvalues.string_formats.DOUBLE(default) – double-quoted with every non-ASCII character escaped as\x{HHHH}. The output is pure ASCII and round-trips regardless of the surrounding source-file encoding.string_formats.DOUBLE_UTF8– double-quoted with non-ASCII characters emitted literally; contributesuse utf8;to the file preamble whenever the literalized value contains a non-ASCII string, so Perl decodes the source as UTF-8. Matches the style a human Perl author would write in a UTF-8 source file.string_formats.SINGLE– single-quoted, with only\\and\'recognized as escapes. Non-ASCII characters are emitted as their raw UTF-8 bytes; the caller is responsible for placing the snippet in a source file whose encoding declaration matches.
- class BoolFormats(*values)¶
Boolean format options for Perl.
- INTEGER = _BoolFormatConfig(true_literal='1', false_literal='0', preamble_lines=())¶
- JSON_PP_REF = _BoolFormatConfig(true_literal='\\1', false_literal='\\0', preamble_lines=())¶
- JSON_PP_SINGLETON = _BoolFormatConfig(true_literal='JSON::PP::true', false_literal='JSON::PP::false', preamble_lines=('use JSON::PP;',))¶
- class BytesFormats(*values)¶
Bytes formatting options.
- BASE64 = <function format_bytes_base64>¶
- HEX = <function format_bytes_hex>¶
- class CallStyles(*values)¶
Perl call style options.
- POSITIONAL = PositionalCallStyle(arg_separator=', ', parenthesize_each_arg=False)¶
- class DateFormats(*values)¶
Date format options for Perl.
- ISO = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- PERL = DateFormatConfig(formatter=<function date_ymd_formatter.<locals>._format>, preamble_lines=('use DateTime;',), type_produced=<class 'datetime.date'>)¶
- class DatetimeFormats(*values)¶
Datetime format options for Perl.
- EPOCH = DatetimeFormatConfig(formatter=<function format_datetime_epoch>, preamble_lines=(), type_produced=<class 'int'>)¶
- ISO = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- PERL = DatetimeFormatConfig(formatter=<function _format_datetime_perl>, preamble_lines=('use DateTime;',), type_produced=<class 'datetime.datetime'>)¶
- class DeclarationStyles(*values)¶
Declaration style options.
- MY = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=True)¶
- class FloatFormats(*values)¶
Float format options.
- FIXED = <function format_float_fixed>¶
- REPR = <function format_float_repr>¶
- SCIENTIFIC = <function format_float_scientific>¶
- class HeterogeneousStrategies(*values)¶
Heterogeneous-scalar strategy options — this language only supports raising.
- ERROR = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)¶
- class IntegerFormats(*values)¶
Integer format options.
- BINARY = mappingproxy({'NONE': <function format_integer_binary>, 'UNDERSCORE': <function format_integer_binary>})¶
- DECIMAL = mappingproxy({'NONE': <class 'str'>, 'UNDERSCORE': <function format_integer_underscore>})¶
- HEX = mappingproxy({'NONE': <function format_integer_hex>, 'UNDERSCORE': <function format_integer_hex>})¶
- OCTAL = mappingproxy({'NONE': <function format_integer_octal_c_style>, 'UNDERSCORE': <function format_integer_octal_c_style>})¶
- get_formatter(numeric_separator: Enum) Callable[[int], str]¶
Return the integer formatter for the given separator.
- class IntegerWidthStrategies(*values)¶
Integer-width rendering strategies.
BARE(default) - emit every integer as a bare numeric literal. Values whose magnitude exceeds2**53silently lose precision on parse because Perl converts them to an NV float; this matches the historical behavior.MATH_BIG_INT- wrap integers whose magnitude exceeds2**53asMath::BigInt->new("...")and emit ause Math::BigInt;preamble. Smaller integers stay as bare literals.
- BARE = 1¶
- MATH_BIG_INT = 2¶
- class JsonTypes(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
Empty: this language has no JSON value-type variants.
- class Modifiers(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
C++/Java/C#-style declaration modifiers: this language has none.
- class SequenceFormats(*values)¶
Sequence type options for Perl.
- ARRAY = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=']', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)¶
- class SetFormats(*values)¶
Set type options for Perl.
- SET = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close=']', empty_set=None, preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)¶
- class StringFormats(*values)¶
String format options.
- DOUBLE = <function _format_perl_string_double>¶
- DOUBLE_UTF8 = <function _format_perl_string_double_utf8>¶
- SINGLE = <function format_string_backslash_single_minimal>¶
- class TrailingCommas(*values)¶
Trailing comma options.
- NO = TrailingCommaConfig(multiline_trailing_comma=False)¶
- YES = TrailingCommaConfig(multiline_trailing_comma=True)¶
- allows_empty_call_parens = True¶
- bool_format: BoolFormats = _BoolFormatConfig(true_literal='1', false_literal='0', preamble_lines=())¶
- bool_formats¶
alias of
BoolFormats
- bytes_format: BytesFormats = <function format_bytes_hex>¶
- bytes_formats¶
alias of
BytesFormats
- property call_data_dependent_preamble: Callable[[Value], tuple[str, ...]]¶
Return data-dependent preamble lines for call rendering.
- call_returns_expression = True¶
- call_style: CallStyles = PositionalCallStyle(arg_separator=', ', parenthesize_each_arg=False)¶
- property call_style_config: PositionalCallStyle | KeywordCallStyle | ObjectCallStyle | PostfixCallStyle | PrefixCallStyle | CommandCallStyle¶
Configuration for the chosen call style.
- call_styles¶
alias of
CallStyles
- property comment_config: CommentConfig¶
Configuration for the language’s comment syntax.
- comment_format: CommentFormats = CommentConfig(prefix='#', suffix='')¶
- comment_formats¶
alias of
CommentFormats
- property compute_body_preamble: Callable[[frozenset[type], Value], tuple[str, ...]]¶
Compute body-preamble lines from the scalar map.
- property consumable_ref_value_inhibits_consuming_form: Callable[[Value], bool]¶
Predicate deciding whether a ref’s underlying value type inhibits the consume form.
Delegates to
never_inhibits_consuming_form. Languages whose consume operator rejects certain value types (notably the Mojo^on register-trivial scalars) override this.
- property data_dependent_preamble: Callable[[Value], tuple[str, ...]]¶
Return data-dependent preamble lines.
Composes the
MATH_BIG_INTinteger-width contribution with theDOUBLE_UTF8string-format contribution so a value triggering both gets both preamble lines in a stable order.
- date_format: DateFormats = DateFormatConfig(formatter=<function date_ymd_formatter.<locals>._format>, preamble_lines=('use DateTime;',), type_produced=<class 'datetime.date'>)¶
- date_formats¶
alias of
DateFormats
- datetime_format: DatetimeFormats = DatetimeFormatConfig(formatter=<function _format_datetime_perl>, preamble_lines=('use DateTime;',), type_produced=<class 'datetime.datetime'>)¶
- datetime_formats¶
alias of
DatetimeFormats
- declaration_style: DeclarationStyles = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=True)¶
- declaration_styles¶
alias of
DeclarationStyles
- dict_entry_style: DictEntryStyles = 1¶
- dict_entry_styles¶
alias of
DictEntryStyles
- dict_format: DictFormats = 1¶
- property dict_format_config: DictFormatConfig¶
Configuration for dict formatting.
- dict_formats¶
alias of
DictFormats
- dict_supports_heterogeneous_values = True¶
- element_separator: ClassVar[str] = ', '¶
- empty_dict_keys¶
alias of
EmptyDictKey
- extension = '.pl'¶
- property false_literal: str¶
Perl literal representing
False.
- float_format: FloatFormats = <function format_float_repr>¶
- float_formats¶
alias of
FloatFormats
- property format_bytes: Callable[[bytes], str]¶
Callable that formats a bytes value as a string literal.
- static format_call_arg(_value: Value, formatted: str, /) str¶
Callable that rewrites a formatted direct call argument.
- property format_call_arg_ref_identifier: Callable[[str, Value | None], str]¶
Rewrite a
{"$ref": "name"}identifier in a call-argument context.Delegates to
format_call_ref_identifier. Override this to allow call-argument$refvalues that would otherwise be rejected.
- property format_call_arg_ref_identifier_consumable: Callable[[str, Value | None], str]¶
Format a
$refthe caller authorized as consumable.Delegates to
format_call_arg_ref_identifier. Override this to opt into a consuming form (e.g. C++std::move).
- format_call_binding_body_preamble() tuple[str, ...]¶
Default
format_call_binding_body_preamble– no extra body preamble lines for an inference-bound call result.
- format_call_binding_file_pragmas() tuple[str, ...]¶
Default
format_call_binding_file_pragmas– no file-level compiler-pragma line for an inference-bound call result.
- property format_call_preamble_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]¶
Return file-scope stubs for a call expression.
- property format_call_ref_identifier: Callable[[str, Value | None], str]¶
Rewrite a
{"$ref": "name"}identifier into the language’s call expression syntax.
- property format_call_statement: Callable[[str], str]¶
Return call-statement formatting for this language.
- property format_call_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]¶
Return stub declarations for a call expression.
- property format_call_target: Callable[[Sequence[str]], str]¶
Rewrite a dotted call target into the language’s call syntax.
- property format_call_variable_assignment: Callable[[str, str, Value], str]¶
Default
format_call_variable_assignment– reuse the literal-binding assignment formatter unchanged.
- property format_call_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]¶
Default
format_call_variable_declaration– reuse the literal-binding declaration formatter unchanged.
- static format_constructor_target(class_name: str, /) str¶
Return class_name as a zero-argument constructor call target.
- property format_date: Callable[[date], str]¶
Callable that formats a date as a string literal.
- property format_datetime: Callable[[datetime], str]¶
Callable that formats a datetime as a string literal.
- property format_float: Callable[[float], str]¶
Callable that formats a float value as a literal.
- property format_integer: Callable[[int], str]¶
Callable that formats an int value as a literal.
- property format_integer_widened: None¶
Default
format_integer_widened– no mixed-magnitude integer widening, so the renderer keeps the normal integer formatter.
- property format_ordered_map_entry: Callable[[str, Value, str], str]¶
Callable that formats one ordered-map entry.
- property format_sequence_entry: Callable[[Value, str], str]¶
Format a sequence entry.
- property format_set_entry: Callable[[Value, str], str]¶
Format a set entry.
- property format_string: Callable[[str], str]¶
Callable that formats a string value as a quoted literal.
- property format_time: Callable[[time], str]¶
Callable that formats a time as a string literal.
- property format_variable_assignment: Callable[[str, str, Value], str]¶
Callable that formats an assignment to an existing variable.
- property format_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]¶
Callable that formats a new variable declaration.
- has_free_function_calls = True¶
- property heterogeneous_behavior: HeterogeneousBehavior¶
Return the heterogeneous-behavior config.
- heterogeneous_strategies¶
alias of
HeterogeneousStrategies
- heterogeneous_strategy: HeterogeneousStrategies = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)¶
- identifier_cases: ClassVar[tuple[IdentifierCase, ...]] = (IdentifierCase.SNAKE, IdentifierCase.CAMEL)¶
- indent: str = ' '¶
- indent_closing_delimiter: ClassVar[bool] = False¶
- integer_format: IntegerFormats = mappingproxy({'NONE': <class 'str'>, 'UNDERSCORE': <function format_integer_underscore>})¶
- integer_formats¶
alias of
IntegerFormats
- integer_width_strategies¶
alias of
IntegerWidthStrategies
- integer_width_strategy: IntegerWidthStrategies = 1¶
- language_version: VersionFormats = 1¶
- property leading_preamble: LeadingPreamble¶
Default
leading_preamble– no preamble lines that must precedeLanguage.static_preamble.
- max_call_parameters = 9223372036854775807¶
- modifier_combinations: ClassVar[tuple[ModifierCombination, ...]] = ()¶
- null_literal: ClassVar[str] = 'undef'¶
- numeric_literal_suffix: NumericLiteralSuffixes = 1¶
- numeric_literal_suffixes¶
alias of
NumericLiteralSuffixes
- numeric_separator: NumericSeparators = 1¶
- numeric_separators¶
alias of
NumericSeparators
- numeric_style: NumericStyles = 1¶
- numeric_styles¶
alias of
NumericStyles
- property ordered_map_format_config: OrderedMapFormatConfig¶
Configuration for ordered-map formatting.
- pygments_name = 'perl'¶
- reserved_identifiers: ClassVar[frozenset[str]] = frozenset({})¶
- property scalar_body_preamble: dict[type, tuple[str, ...]]¶
Per-instance scalar body preamble (Perl needs none).
- property scalar_preamble: dict[type, tuple[str, ...]]¶
Per-instance scalar preamble computed from date/datetime/bool format.
- sequence_binding_declarations(declarations: tuple[str, ...]) str¶
Default
sequence_binding_declarations– join the per-binding snippets with newlines.
- sequence_format: SequenceFormats = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=']', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)¶
- property sequence_format_config: SequenceFormatConfig¶
Configuration for the chosen sequence format.
- sequence_formats¶
alias of
SequenceFormats
- property sequence_open: Callable[[list[Value]], str]¶
Callable that returns the opening delimiter for a sequence.
- set_format: SetFormats = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close=']', empty_set=None, preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)¶
- property set_format_config: SetFormatConfig¶
Configuration for the chosen set format.
- set_formats¶
alias of
SetFormats
- skip_null_dict_values: ClassVar[bool] = False¶
- special_float_preamble: ClassVar[tuple[str, ...]] = ()¶
- statement_terminator: ClassVar[str] = ';'¶
- statement_terminator_style: StatementTerminatorStyles = 1¶
- statement_terminator_styles¶
alias of
StatementTerminatorStyles
- static_body_preamble: ClassVar[Sequence[str]] = ()¶
- static_preamble: ClassVar[Sequence[str]] = ()¶
- string_format: StringFormats = <function _format_perl_string_double>¶
- string_formats¶
alias of
StringFormats
- supported_ref_cases: ClassVar[frozenset[IdentifierCase]] = frozenset({IdentifierCase.CAMEL, IdentifierCase.PASCAL, IdentifierCase.SNAKE, IdentifierCase.UPPER_SNAKE})¶
- supports_call_style = True¶
- supports_collection_comments: ClassVar[bool] = True¶
- supports_default_dict_key_type = False¶
- supports_default_dict_value_type = False¶
- supports_default_ordered_map_value_type = False¶
- supports_default_sequence_element_type = False¶
- supports_default_set_element_type = False¶
- supports_dict_literal_as_free_expression = True¶
- supports_dotted_call_stub = True¶
- supports_dotted_calls = True¶
- supports_empty_dict_key = False¶
- supports_inline_multiline_dict_args = True¶
- supports_module_name = False¶
- supports_multi_param_call_wrapper_stub = True¶
- supports_no_variable_wrap_in_file = True¶
- supports_non_string_dict_keys = True¶
- supports_record_shape_names = False¶
- supports_record_struct_name_prefix = False¶
- supports_scalar_before_comments: ClassVar[bool] = True¶
- supports_scalar_inline_comments: ClassVar[bool] = False¶
- supports_special_floats = True¶
- supports_standalone_comments_in_wrapped_calls = True¶
- supports_variable_names = True¶
- supports_zero_parameter_calls = True¶
- trailing_comma: TrailingCommas = TrailingCommaConfig(multiline_trailing_comma=True)¶
- property trailing_comma_config: TrailingCommaConfig¶
Configuration for trailing-comma behavior.
- trailing_commas¶
alias of
TrailingCommas
- property true_literal: str¶
Perl literal representing
True.
- property type_hint_collection_preamble_lines: Callable[[frozenset[type]], tuple[str, ...]]¶
Return preamble lines for empty-collection type hints.
- property validate_call_arg: Callable[[Value], None]¶
Return call-argument validation for this language.
- validate_spec_for_data(data: Value) None¶
Default
validate_spec_for_data— no spec/data constraints.
- variable_type_hints: VariableTypeHints = 1¶
- variable_type_hints_formats¶
alias of
VariableTypeHints
- version_formats¶
alias of
VersionFormats
- wrap_calls_with_declarations(declarations: tuple[str, ...], calls: str, body_preamble: tuple[str, ...]) str¶
Default
wrap_calls_with_declarations— concatenate the declarations and calls and route throughwrap_in_file()in call mode.
- static wrap_combined_in_file(declaration: str, assignment: str, variable_name: str, body_preamble: tuple[str, ...]) str¶
Wrap declaration and assignment in a valid file (no-op).
- static wrap_in_file(content: str, variable_name: str, body_preamble: tuple[str, ...]) str¶
Wrap code in a valid file (no-op).
- class literalizer.languages.Php(*args: object, **kwargs: object)¶
PHP language specification.
- class BoolFormats(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
Empty: this language has no alternative boolean formats.
- class BytesFormats(*values)¶
Bytes formatting options.
- BASE64 = <function format_bytes_base64>¶
- HEX = <function format_bytes_hex>¶
- class CallStyles(*values)¶
Php call style options.
- KEYWORD = KeywordCallStyle(separator=': ')¶
- POSITIONAL = PositionalCallStyle(arg_separator=', ', parenthesize_each_arg=False)¶
- class CommentFormats(*values)¶
Comment style options.
- BLOCK = CommentConfig(prefix='/*', suffix=' */')¶
- DOUBLE_SLASH = CommentConfig(prefix='//', suffix='')¶
- class DateFormats(*values)¶
Date format options for Php.
- ISO = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- PHP = DateFormatConfig(formatter=<function date_iso_formatter.<locals>._format>, preamble_lines=(), type_produced=<class 'datetime.date'>)¶
- class DatetimeFormats(*values)¶
Datetime format options for Php.
- EPOCH = DatetimeFormatConfig(formatter=<function format_datetime_epoch>, preamble_lines=(), type_produced=<class 'int'>)¶
- ISO = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- PHP = DatetimeFormatConfig(formatter=<function datetime_iso_formatter.<locals>._format>, preamble_lines=(), type_produced=<class 'datetime.datetime'>)¶
- class DeclarationStyles(*values)¶
Declaration style options.
- ASSIGN = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=True)¶
- class FloatFormats(*values)¶
Float format options.
- FIXED = <function format_float_fixed>¶
- REPR = <function format_float_repr>¶
- SCIENTIFIC = <function format_float_scientific>¶
- class HeterogeneousStrategies(*values)¶
Heterogeneous-scalar strategy options — this language only supports raising.
- ERROR = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)¶
- class IntegerFormats(*values)¶
Integer format options.
- BINARY = mappingproxy({'NONE': <function format_integer_binary>, 'UNDERSCORE': <function format_integer_binary>})¶
- DECIMAL = mappingproxy({'NONE': <class 'str'>, 'UNDERSCORE': <function format_integer_underscore>})¶
- HEX = mappingproxy({'NONE': <function format_integer_hex>, 'UNDERSCORE': <function format_integer_hex>})¶
- OCTAL = mappingproxy({'NONE': <function format_integer_octal>, 'UNDERSCORE': <function format_integer_octal>})¶
- OCTAL_C_STYLE = mappingproxy({'NONE': <function format_integer_octal_c_style>, 'UNDERSCORE': <function format_integer_octal_c_style>})¶
- get_formatter(numeric_separator: Enum) Callable[[int], str]¶
Return the integer formatter for the given separator.
- class JsonTypes(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
Empty: this language has no JSON value-type variants.
- class Modifiers(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
C++/Java/C#-style declaration modifiers: this language has none.
- class SequenceFormats(*values)¶
Sequence type options for PHP.
- ARRAY = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=']', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)¶
- class SetFormats(*values)¶
Set type options for PHP.
- SET = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close=']', empty_set=None, preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)¶
- class StringFormats(*values)¶
String format options.
- DOUBLE = <function _build_backslash_formatter.<locals>._format>¶
- SINGLE = <function format_string_backslash_single_minimal>¶
- class TrailingCommas(*values)¶
Trailing comma options.
- NO = TrailingCommaConfig(multiline_trailing_comma=False)¶
- YES = TrailingCommaConfig(multiline_trailing_comma=True)¶
- allows_empty_call_parens = True¶
- bool_formats¶
alias of
BoolFormats
- bytes_format: BytesFormats = <function format_bytes_hex>¶
- bytes_formats¶
alias of
BytesFormats
- property call_data_dependent_preamble: Callable[[Value], tuple[str, ...]]¶
Return data-dependent preamble lines for call rendering.
- call_returns_expression = True¶
- call_style: CallStyles = KeywordCallStyle(separator=': ')¶
- property call_style_config: PositionalCallStyle | KeywordCallStyle | ObjectCallStyle | PostfixCallStyle | PrefixCallStyle | CommandCallStyle¶
Configuration for the chosen call style.
- call_styles¶
alias of
CallStyles
- property comment_config: CommentConfig¶
Configuration for the language’s comment syntax.
- comment_format: CommentFormats = CommentConfig(prefix='//', suffix='')¶
- comment_formats¶
alias of
CommentFormats
- property compute_body_preamble: Callable[[frozenset[type], Value], tuple[str, ...]]¶
Compute body-preamble lines from the scalar map.
- property consumable_ref_value_inhibits_consuming_form: Callable[[Value], bool]¶
Predicate deciding whether a ref’s underlying value type inhibits the consume form.
Delegates to
never_inhibits_consuming_form. Languages whose consume operator rejects certain value types (notably the Mojo^on register-trivial scalars) override this.
- property data_dependent_preamble: Callable[[Value], tuple[str, ...]]¶
Return data-dependent preamble lines.
- date_format: DateFormats = DateFormatConfig(formatter=<function date_iso_formatter.<locals>._format>, preamble_lines=(), type_produced=<class 'datetime.date'>)¶
- date_formats¶
alias of
DateFormats
- datetime_format: DatetimeFormats = DatetimeFormatConfig(formatter=<function datetime_iso_formatter.<locals>._format>, preamble_lines=(), type_produced=<class 'datetime.datetime'>)¶
- datetime_formats¶
alias of
DatetimeFormats
- declaration_style: DeclarationStyles = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=True)¶
- declaration_styles¶
alias of
DeclarationStyles
- dict_entry_style: DictEntryStyles = 1¶
- dict_entry_styles¶
alias of
DictEntryStyles
- dict_format: DictFormats = 1¶
- property dict_format_config: DictFormatConfig¶
Configuration for dict formatting.
- dict_formats¶
alias of
DictFormats
- dict_supports_heterogeneous_values = True¶
- element_separator: ClassVar[str] = ', '¶
- empty_dict_keys¶
alias of
EmptyDictKey
- extension = '.php'¶
- false_literal: ClassVar[str] = 'false'¶
- float_format: FloatFormats = <function format_float_repr>¶
- float_formats¶
alias of
FloatFormats
- property format_bytes: Callable[[bytes], str]¶
Callable that formats a bytes value as a string literal.
- static format_call_arg(_value: Value, formatted: str, /) str¶
Callable that rewrites a formatted direct call argument.
- property format_call_arg_ref_identifier: Callable[[str, Value | None], str]¶
Rewrite a
{"$ref": "name"}identifier in a call-argument context.Delegates to
format_call_ref_identifier. Override this to allow call-argument$refvalues that would otherwise be rejected.
- property format_call_arg_ref_identifier_consumable: Callable[[str, Value | None], str]¶
Format a
$refthe caller authorized as consumable.Delegates to
format_call_arg_ref_identifier. Override this to opt into a consuming form (e.g. C++std::move).
- format_call_binding_body_preamble() tuple[str, ...]¶
Default
format_call_binding_body_preamble– no extra body preamble lines for an inference-bound call result.
- format_call_binding_file_pragmas() tuple[str, ...]¶
Default
format_call_binding_file_pragmas– no file-level compiler-pragma line for an inference-bound call result.
- property format_call_preamble_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]¶
Return file-scope stubs for a call expression.
- property format_call_ref_identifier: Callable[[str, Value | None], str]¶
Prepend PHP’s
$sigil so a{"$ref": "name"}argument renders as$nameat the call site.
- property format_call_statement: Callable[[str], str]¶
Return call-statement formatting for this language.
- property format_call_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]¶
Return stub declarations for a call expression.
- property format_call_target: Callable[[Sequence[str]], str]¶
Rewrite a dotted call target into PHP’s
$obj->methodform.
- property format_call_variable_assignment: Callable[[str, str, Value], str]¶
Default
format_call_variable_assignment– reuse the literal-binding assignment formatter unchanged.
- property format_call_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]¶
Default
format_call_variable_declaration– reuse the literal-binding declaration formatter unchanged.
- static format_constructor_target(class_name: str, /) str¶
Return a
new ClassNameconstructor call target.
- property format_date: Callable[[date], str]¶
Callable that formats a date as a string literal.
- property format_datetime: Callable[[datetime], str]¶
Callable that formats a datetime as a string literal.
- property format_float: Callable[[float], str]¶
Callable that formats a float value as a literal.
- property format_integer: Callable[[int], str]¶
Callable that formats an int value as a literal.
- property format_integer_widened: None¶
Default
format_integer_widened– no mixed-magnitude integer widening, so the renderer keeps the normal integer formatter.
- property format_ordered_map_entry: Callable[[str, Value, str], str]¶
Callable that formats one ordered-map entry.
- property format_sequence_entry: Callable[[Value, str], str]¶
Format a sequence entry.
- property format_set_entry: Callable[[Value, str], str]¶
Format a set entry.
- property format_string: Callable[[str], str]¶
Callable that formats a string value as a quoted literal.
- property format_time: Callable[[time], str]¶
Callable that formats a time as a string literal.
- property format_variable_assignment: Callable[[str, str, Value], str]¶
Format an assignment to an existing variable.
- property format_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]¶
Callable that formats a new variable declaration.
- has_free_function_calls = True¶
- property heterogeneous_behavior: HeterogeneousBehavior¶
Return the heterogeneous-behavior config.
- heterogeneous_strategies¶
alias of
HeterogeneousStrategies
- heterogeneous_strategy: HeterogeneousStrategies = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)¶
- identifier_cases: ClassVar[tuple[IdentifierCase, ...]] = (IdentifierCase.SNAKE, IdentifierCase.CAMEL, IdentifierCase.PASCAL, IdentifierCase.UPPER_SNAKE)¶
- indent: str = ' '¶
- indent_closing_delimiter: ClassVar[bool] = False¶
- integer_format: IntegerFormats = mappingproxy({'NONE': <class 'str'>, 'UNDERSCORE': <function format_integer_underscore>})¶
- integer_formats¶
alias of
IntegerFormats
- integer_width_strategies¶
alias of
BareIntegerWidthStrategies
- integer_width_strategy: BareIntegerWidthStrategies = 1¶
- language_version: VersionFormats = 1¶
- property leading_preamble: LeadingPreamble¶
Default
leading_preamble– no preamble lines that must precedeLanguage.static_preamble.
- max_call_parameters = 9223372036854775807¶
- modifier_combinations: ClassVar[tuple[ModifierCombination, ...]] = ()¶
- null_literal: ClassVar[str] = 'null'¶
- numeric_literal_suffix: NumericLiteralSuffixes = 1¶
- numeric_literal_suffixes¶
alias of
NumericLiteralSuffixes
- numeric_separator: NumericSeparators = 1¶
- numeric_separators¶
alias of
NumericSeparators
- numeric_style: NumericStyles = 1¶
- numeric_styles¶
alias of
NumericStyles
- property ordered_map_format_config: OrderedMapFormatConfig¶
Configuration for ordered-map formatting.
- pygments_name = 'php'¶
- reserved_identifiers: ClassVar[frozenset[str]] = frozenset({})¶
- property scalar_body_preamble: dict[type, tuple[str, ...]]¶
Per-instance scalar body preamble (PHP needs none).
- property scalar_preamble: dict[type, tuple[str, ...]]¶
Per-instance scalar preamble (PHP needs none).
- sequence_binding_declarations(declarations: tuple[str, ...]) str¶
Default
sequence_binding_declarations– join the per-binding snippets with newlines.
- sequence_format: SequenceFormats = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=']', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)¶
- property sequence_format_config: SequenceFormatConfig¶
Configuration for the chosen sequence format.
- sequence_formats¶
alias of
SequenceFormats
- property sequence_open: Callable[[list[Value]], str]¶
Callable that returns the opening delimiter for a sequence.
- set_format: SetFormats = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close=']', empty_set=None, preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)¶
- property set_format_config: SetFormatConfig¶
Configuration for the chosen set format.
- set_formats¶
alias of
SetFormats
- skip_null_dict_values: ClassVar[bool] = False¶
- special_float_preamble: ClassVar[tuple[str, ...]] = ()¶
- statement_terminator: ClassVar[str] = ';'¶
- statement_terminator_style: StatementTerminatorStyles = 1¶
- statement_terminator_styles¶
alias of
StatementTerminatorStyles
- static_body_preamble: ClassVar[Sequence[str]] = ()¶
- static_preamble: ClassVar[Sequence[str]] = ('<?php',)¶
- string_format: StringFormats = <function _build_backslash_formatter.<locals>._format>¶
- string_formats¶
alias of
StringFormats
- supported_ref_cases: ClassVar[frozenset[IdentifierCase]] = frozenset({IdentifierCase.CAMEL, IdentifierCase.PASCAL, IdentifierCase.SNAKE, IdentifierCase.UPPER_SNAKE})¶
- supports_call_style = True¶
- supports_collection_comments: ClassVar[bool] = True¶
- supports_default_dict_key_type = False¶
- supports_default_dict_value_type = False¶
- supports_default_ordered_map_value_type = False¶
- supports_default_sequence_element_type = False¶
- supports_default_set_element_type = False¶
- supports_dict_literal_as_free_expression = True¶
- supports_dotted_call_stub = False¶
- supports_dotted_calls = True¶
- supports_empty_dict_key = False¶
- supports_inline_multiline_dict_args = True¶
- supports_module_name = False¶
- supports_multi_param_call_wrapper_stub = True¶
- supports_no_variable_wrap_in_file = False¶
- supports_non_string_dict_keys = False¶
- supports_record_shape_names = False¶
- supports_record_struct_name_prefix = False¶
- supports_scalar_before_comments: ClassVar[bool] = True¶
- supports_scalar_inline_comments: ClassVar[bool] = False¶
- supports_special_floats = True¶
- supports_standalone_comments_in_wrapped_calls = True¶
- supports_variable_names = True¶
- supports_zero_parameter_calls = True¶
- trailing_comma: TrailingCommas = TrailingCommaConfig(multiline_trailing_comma=True)¶
- property trailing_comma_config: TrailingCommaConfig¶
Configuration for trailing-comma behavior.
- trailing_commas¶
alias of
TrailingCommas
- true_literal: ClassVar[str] = 'true'¶
- property type_hint_collection_preamble_lines: Callable[[frozenset[type]], tuple[str, ...]]¶
Return preamble lines for empty-collection type hints.
- property validate_call_arg: Callable[[Value], None]¶
Return call-argument validation for this language.
- static validate_spec_for_data(data: Value) None¶
Reject inputs containing an empty mapping on PHP.
- variable_type_hints: VariableTypeHints = 1¶
- variable_type_hints_formats¶
alias of
VariableTypeHints
- version_formats¶
alias of
VersionFormats
- wrap_calls_with_declarations(declarations: tuple[str, ...], calls: str, body_preamble: tuple[str, ...]) str¶
Default
wrap_calls_with_declarations— concatenate the declarations and calls and route throughwrap_in_file()in call mode.
- static wrap_combined_in_file(declaration: str, assignment: str, variable_name: str, body_preamble: tuple[str, ...]) str¶
Wrap declaration and assignment in a valid file (no-op).
- static wrap_in_file(content: str, variable_name: str, body_preamble: tuple[str, ...]) str¶
Wrap code in a valid file (no-op).
- class literalizer.languages.PowerShell(*args: object, **kwargs: object)¶
PowerShell language specification.
- class BoolFormats(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
Empty: this language has no alternative boolean formats.
- class BytesFormats(*values)¶
Bytes formatting options.
- BASE64 = <function format_bytes_base64>¶
- HEX = <function format_bytes_hex>¶
- class CallStyles(*values)¶
PowerShell call style options.
- POSITIONAL = PositionalCallStyle(arg_separator=', ', parenthesize_each_arg=False)¶
- class CommentFormats(*values)¶
Comment style options.
- BLOCK = CommentConfig(prefix='<#', suffix=' #>')¶
- HASH = CommentConfig(prefix='#', suffix='')¶
- class DateFormats(*values)¶
Date format options for PowerShell.
- ISO = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- class DatetimeFormats(*values)¶
Datetime format options for PowerShell.
- EPOCH = DatetimeFormatConfig(formatter=<function format_datetime_epoch>, preamble_lines=(), type_produced=<class 'int'>)¶
- ISO = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- class DeclarationStyles(*values)¶
Declaration style options.
- ASSIGN = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=True)¶
- class FloatFormats(*values)¶
Float format options.
- FIXED = <function format_float_fixed>¶
- REPR = <function format_float_repr>¶
- SCIENTIFIC = <function format_float_scientific>¶
- class HeterogeneousStrategies(*values)¶
Heterogeneous-scalar strategy options — this language only supports raising.
- ERROR = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)¶
- class JsonTypes(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
Empty: this language has no JSON value-type variants.
- class Modifiers(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
C++/Java/C#-style declaration modifiers: this language has none.
- class SequenceFormats(*values)¶
Sequence type options for PowerShell.
- ARRAY = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=')', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=False, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)¶
- class SetFormats(*values)¶
Set type options for PowerShell.
- SET = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close=')', empty_set=None, preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)¶
- class TrailingCommas(*values)¶
Trailing comma options.
- NO = TrailingCommaConfig(multiline_trailing_comma=False)¶
- allows_empty_call_parens = False¶
- bool_formats¶
alias of
BoolFormats
- bytes_format: BytesFormats = <function format_bytes_hex>¶
- bytes_formats¶
alias of
BytesFormats
- property call_data_dependent_preamble: Callable[[Value], tuple[str, ...]]¶
Return data-dependent preamble lines for call rendering.
- call_returns_expression = True¶
- call_style: CallStyles = PositionalCallStyle(arg_separator=', ', parenthesize_each_arg=False)¶
- property call_style_config: PositionalCallStyle | KeywordCallStyle | ObjectCallStyle | PostfixCallStyle | PrefixCallStyle | CommandCallStyle¶
Configuration for the chosen call style.
- call_styles¶
alias of
CallStyles
- property comment_config: CommentConfig¶
Configuration for the language’s comment syntax.
- comment_format: CommentFormats = CommentConfig(prefix='#', suffix='')¶
- comment_formats¶
alias of
CommentFormats
- property compute_body_preamble: Callable[[frozenset[type], Value], tuple[str, ...]]¶
Compute body-preamble lines from the scalar map.
- property consumable_ref_value_inhibits_consuming_form: Callable[[Value], bool]¶
Predicate deciding whether a ref’s underlying value type inhibits the consume form.
Delegates to
never_inhibits_consuming_form. Languages whose consume operator rejects certain value types (notably the Mojo^on register-trivial scalars) override this.
- property data_dependent_preamble: Callable[[Value], tuple[str, ...]]¶
Return data-dependent preamble lines.
- date_format: DateFormats = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- date_formats¶
alias of
DateFormats
- datetime_format: DatetimeFormats = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- datetime_formats¶
alias of
DatetimeFormats
- declaration_style: DeclarationStyles = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=True)¶
- declaration_styles¶
alias of
DeclarationStyles
- dict_entry_style: DictEntryStyles = 1¶
- dict_entry_styles¶
alias of
DictEntryStyles
- dict_format: DictFormats = 1¶
- property dict_format_config: DictFormatConfig¶
Configuration for dict formatting.
- dict_formats¶
alias of
DictFormats
- dict_supports_heterogeneous_values = True¶
- element_separator: ClassVar[str] = '; '¶
- empty_dict_keys¶
alias of
EmptyDictKey
- extension = '.ps1'¶
- false_literal: ClassVar[str] = '$false'¶
- float_format: FloatFormats = <function format_float_repr>¶
- float_formats¶
alias of
FloatFormats
- property format_bytes: Callable[[bytes], str]¶
Callable that formats a bytes value as a string literal.
- static format_call_arg(_value: Value, formatted: str, /) str¶
Callable that rewrites a formatted direct call argument.
- property format_call_arg_ref_identifier: Callable[[str, Value | None], str]¶
Rewrite a
{"$ref": "name"}identifier in a call-argument context.Delegates to
format_call_ref_identifier. Override this to allow call-argument$refvalues that would otherwise be rejected.
- property format_call_arg_ref_identifier_consumable: Callable[[str, Value | None], str]¶
Format a
$refthe caller authorized as consumable.Delegates to
format_call_arg_ref_identifier. Override this to opt into a consuming form (e.g. C++std::move).
- format_call_binding_body_preamble() tuple[str, ...]¶
Default
format_call_binding_body_preamble– no extra body preamble lines for an inference-bound call result.
- format_call_binding_file_pragmas() tuple[str, ...]¶
Default
format_call_binding_file_pragmas– no file-level compiler-pragma line for an inference-bound call result.
- property format_call_preamble_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]¶
Return file-scope stubs for a call expression.
- property format_call_ref_identifier: Callable[[str, Value | None], str]¶
Rewrite a
{"$ref": "name"}identifier into the language’s call expression syntax.
- property format_call_statement: Callable[[str], str]¶
Return call-statement formatting for this language.
- property format_call_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]¶
Return stub declarations for a call expression.
- property format_call_target: Callable[[Sequence[str]], str]¶
Rewrite a dotted call target into the language’s call syntax.
- property format_call_variable_assignment: Callable[[str, str, Value], str]¶
Default
format_call_variable_assignment– reuse the literal-binding assignment formatter unchanged.
- property format_call_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]¶
Default
format_call_variable_declaration– reuse the literal-binding declaration formatter unchanged.
- static format_constructor_target(class_name: str, /) str¶
Return class_name as a zero-argument constructor call target.
- property format_date: Callable[[date], str]¶
Callable that formats a date as a string literal.
- property format_datetime: Callable[[datetime], str]¶
Callable that formats a datetime as a string literal.
- property format_float: Callable[[float], str]¶
Callable that formats a float value as a literal.
- property format_integer: Callable[[int], str]¶
Format an int value as a literal.
- property format_integer_widened: None¶
Default
format_integer_widened– no mixed-magnitude integer widening, so the renderer keeps the normal integer formatter.
- property format_ordered_map_entry: Callable[[str, Value, str], str]¶
Callable that formats one ordered-map entry.
- property format_sequence_entry: Callable[[Value, str], str]¶
Format a sequence entry.
- property format_set_entry: Callable[[Value, str], str]¶
Format a set entry.
- property format_string: Callable[[str], str]¶
Format a string value as a quoted literal.
- property format_time: Callable[[time], str]¶
Callable that formats a time as a string literal.
- property format_variable_assignment: Callable[[str, str, Value], str]¶
Format an assignment to an existing variable.
- property format_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]¶
Callable that formats a new variable declaration.
- has_free_function_calls = True¶
- property heterogeneous_behavior: HeterogeneousBehavior¶
Return the heterogeneous-behavior config.
- heterogeneous_strategies¶
alias of
HeterogeneousStrategies
- heterogeneous_strategy: HeterogeneousStrategies = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)¶
- identifier_cases: ClassVar[tuple[IdentifierCase, ...]] = (IdentifierCase.PASCAL, IdentifierCase.CAMEL)¶
- indent: str = ' '¶
- indent_closing_delimiter: ClassVar[bool] = False¶
- integer_format: IntegerFormats = 1¶
- integer_formats¶
alias of
IntegerFormats
- integer_width_strategies¶
alias of
BareIntegerWidthStrategies
- integer_width_strategy: BareIntegerWidthStrategies = 1¶
- language_version: VersionFormats = 1¶
- property leading_preamble: LeadingPreamble¶
Default
leading_preamble– no preamble lines that must precedeLanguage.static_preamble.
- max_call_parameters = 9223372036854775807¶
- modifier_combinations: ClassVar[tuple[ModifierCombination, ...]] = ()¶
- null_literal: ClassVar[str] = '$null'¶
- numeric_literal_suffix: NumericLiteralSuffixes = 1¶
- numeric_literal_suffixes¶
alias of
NumericLiteralSuffixes
- numeric_separator: NumericSeparators = 1¶
- numeric_separators¶
alias of
NumericSeparators
- numeric_style: NumericStyles = 1¶
- numeric_styles¶
alias of
NumericStyles
- property ordered_map_format_config: OrderedMapFormatConfig¶
Configuration for ordered-map formatting.
- pygments_name = 'powershell'¶
- reserved_identifiers: ClassVar[frozenset[str]] = frozenset({})¶
- property scalar_body_preamble: dict[type, tuple[str, ...]]¶
Per-instance scalar body preamble (PowerShell needs none).
- property scalar_preamble: dict[type, tuple[str, ...]]¶
Per-instance scalar preamble (PowerShell needs none).
- sequence_binding_declarations(declarations: tuple[str, ...]) str¶
Default
sequence_binding_declarations– join the per-binding snippets with newlines.
- sequence_format: SequenceFormats = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=')', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=False, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)¶
- property sequence_format_config: SequenceFormatConfig¶
Configuration for the chosen sequence format.
- sequence_formats¶
alias of
SequenceFormats
- property sequence_open: Callable[[list[Value]], str]¶
Callable that returns the opening delimiter for a sequence.
- set_format: SetFormats = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close=')', empty_set=None, preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)¶
- property set_format_config: SetFormatConfig¶
Configuration for the chosen set format.
- set_formats¶
alias of
SetFormats
- skip_null_dict_values: ClassVar[bool] = False¶
- special_float_preamble: ClassVar[tuple[str, ...]] = ()¶
- statement_terminator: ClassVar[str] = ''¶
- statement_terminator_style: StatementTerminatorStyles = 1¶
- statement_terminator_styles¶
alias of
StatementTerminatorStyles
- static_body_preamble: ClassVar[Sequence[str]] = ()¶
- static_preamble: ClassVar[Sequence[str]] = ()¶
- string_format: StringFormats = 1¶
- string_formats¶
alias of
StringFormats
- supported_ref_cases: ClassVar[frozenset[IdentifierCase]] = frozenset({IdentifierCase.CAMEL, IdentifierCase.PASCAL, IdentifierCase.SNAKE, IdentifierCase.UPPER_SNAKE})¶
- supports_call_style = True¶
- supports_collection_comments: ClassVar[bool] = True¶
- supports_default_dict_key_type = False¶
- supports_default_dict_value_type = False¶
- supports_default_ordered_map_value_type = False¶
- supports_default_sequence_element_type = False¶
- supports_default_set_element_type = False¶
- supports_dict_literal_as_free_expression = True¶
- supports_dotted_call_stub = False¶
- supports_dotted_calls = True¶
- supports_empty_dict_key = False¶
- supports_inline_multiline_dict_args = True¶
- supports_module_name = False¶
- supports_multi_param_call_wrapper_stub = True¶
- supports_no_variable_wrap_in_file = True¶
- supports_non_string_dict_keys = True¶
- supports_record_shape_names = False¶
- supports_record_struct_name_prefix = False¶
- supports_scalar_before_comments: ClassVar[bool] = True¶
- supports_scalar_inline_comments: ClassVar[bool] = True¶
- supports_special_floats = True¶
- supports_standalone_comments_in_wrapped_calls = True¶
- supports_variable_names = True¶
- supports_zero_parameter_calls = True¶
- trailing_comma: TrailingCommas = TrailingCommaConfig(multiline_trailing_comma=False)¶
- property trailing_comma_config: TrailingCommaConfig¶
Configuration for trailing-comma behavior.
- trailing_commas¶
alias of
TrailingCommas
- true_literal: ClassVar[str] = '$true'¶
- property type_hint_collection_preamble_lines: Callable[[frozenset[type]], tuple[str, ...]]¶
Return preamble lines for empty-collection type hints.
- property validate_call_arg: Callable[[Value], None]¶
Return call-argument validation for this language.
- validate_spec_for_data(data: Value) None¶
Default
validate_spec_for_data— no spec/data constraints.
- variable_type_hints: VariableTypeHints = 1¶
- variable_type_hints_formats¶
alias of
VariableTypeHints
- version_formats¶
alias of
VersionFormats
- wrap_calls_with_declarations(declarations: tuple[str, ...], calls: str, body_preamble: tuple[str, ...]) str¶
Default
wrap_calls_with_declarations— concatenate the declarations and calls and route throughwrap_in_file()in call mode.
- static wrap_combined_in_file(declaration: str, assignment: str, variable_name: str, body_preamble: tuple[str, ...]) str¶
Wrap declaration and assignment in a valid file (no-op).
- static wrap_in_file(content: str, variable_name: str, body_preamble: tuple[str, ...]) str¶
Wrap code in a valid file (no-op).
- class literalizer.languages.PureScript(*args: object, **kwargs: object)¶
PureScript language specification.
The generated output uses custom constructors (
PNull,PBool,PList,PDict,PSet) that are not built-in PureScript types. To compile the generated code, define aValADT in the consuming module:import Prelude data Tuple a b = Tuple a b data Val = PNull | PBool Boolean | PInt Int | PFloat Number | PStr String | PList (Array Val) | PDict (Array (Tuple String Val)) | PSet (Array Val)
The body preamble automatically emits only the constructors that are actually used by the data.
- Parameters:
date_format –
How to format
datetime.datevalues.date_formats.ISO— ISO 8601 string, e.g.PStr "2024-01-15".
datetime_format –
How to format
datetime.datetimevalues.datetime_formats.ISO— ISO 8601 string, e.g.PStr "2024-01-15T12:30:00".
type_name – Name of the generated custom type. Defaults to
"Val".constructor_prefix – Prefix for generated constructor names. Defaults to
"P", producing constructors likePNull,PBool,PInt, etc.
- class BoolFormats(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
Empty: this language has no alternative boolean formats.
- class BytesFormats(*values)¶
Bytes formatting options.
- BASE64 = <function _build_purescript_bytes_base64.<locals>._format>¶
- HEX = <function _build_purescript_bytes_hex.<locals>._format>¶
- class CallStyles(*values)¶
PureScript call style options.
- COMMAND = CommandCallStyle(arg_separator=' ')¶
- class CommentFormats(*values)¶
Comment style options.
- BLOCK = CommentConfig(prefix='{-', suffix=' -}')¶
- DOUBLE_DASH = CommentConfig(prefix='--', suffix='')¶
- class DateFormats(*values)¶
Date format options for PureScript.
- ISO = DateFormatConfig(formatter=<function _build_purescript_date_iso.<locals>._format>, preamble_lines=(), type_produced=<class 'str'>)¶
- class DatetimeFormats(*values)¶
Datetime format options for PureScript.
- EPOCH = DatetimeFormatConfig(formatter=<function datetime_epoch_formatter.<locals>._format>, preamble_lines=(), type_produced=<class 'int'>)¶
- ISO = DatetimeFormatConfig(formatter=<function _build_purescript_datetime_iso.<locals>._format>, preamble_lines=(), type_produced=<class 'str'>)¶
- class DeclarationStyles(*values)¶
Declaration style options.
- ASSIGN = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=False)¶
- class FloatFormats(*values)¶
Float format options.
- FIXED = <function _build_purescript_float_wrapper.<locals>._format>¶
- REPR = <function _build_purescript_float_wrapper.<locals>._format>¶
- SCIENTIFIC = <function _build_purescript_float_wrapper.<locals>._format>¶
- class HeterogeneousStrategies(*values)¶
Heterogeneous-scalar strategy options — this language only supports raising.
- ERROR = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)¶
- class IntegerFormats(*values)¶
Integer format options.
- DECIMAL = <function _build_purescript_integer_formatter.<locals>._format>¶
- HEX = <function _build_purescript_integer_formatter.<locals>._format>¶
- class JsonTypes(*values)¶
JSON value type options for PureScript.
- ARGONAUT_JSON = 'Data.Argonaut.Core.Json'¶
Data.Argonaut.Core.Json– the dynamic JSON value type from theargonaut-corepackage.
- class Modifiers(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
C++/Java/C#-style declaration modifiers: this language has none.
- class SequenceFormats(*values)¶
Sequence type options for PureScript.
- LIST = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=']', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type='Val', narrowed_empty_form=None)¶
- class SetFormats(*values)¶
Set type options for PureScript.
- SET = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close=']', empty_set=None, preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)¶
- class TrailingCommas(*values)¶
Trailing comma options.
- NO = TrailingCommaConfig(multiline_trailing_comma=False)¶
- allows_empty_call_parens = True¶
- bool_formats¶
alias of
BoolFormats
- bytes_format: BytesFormats = <function _build_purescript_bytes_hex.<locals>._format>¶
- bytes_formats¶
alias of
BytesFormats
- property call_data_dependent_preamble: Callable[[Value], tuple[str, ...]]¶
Return data-dependent preamble lines for call rendering.
- call_returns_expression = True¶
- call_style: CallStyles = CommandCallStyle(arg_separator=' ')¶
- property call_style_config: PositionalCallStyle | KeywordCallStyle | ObjectCallStyle | PostfixCallStyle | PrefixCallStyle | CommandCallStyle¶
Configuration for the chosen call style.
- call_styles¶
alias of
CallStyles
- property comment_config: CommentConfig¶
Configuration for the language’s comment syntax.
- comment_format: CommentFormats = CommentConfig(prefix='--', suffix='')¶
- comment_formats¶
alias of
CommentFormats
- property compute_body_preamble: Callable[[frozenset[type], Value], tuple[str, ...]]¶
Compute body-preamble lines from the scalar map.
Under
json_typethe body preamble is reduced to theData.Argonaut.Core,Data.Argonaut.Parser, andData.Eitherimports needed by thejsonParser-backed binding, so the customValalgebraic type and itsTuplehelper are not emitted.
- constructor_prefix: str = 'P'¶
- property consumable_ref_value_inhibits_consuming_form: Callable[[Value], bool]¶
Predicate deciding whether a ref’s underlying value type inhibits the consume form.
Delegates to
never_inhibits_consuming_form. Languages whose consume operator rejects certain value types (notably the Mojo^on register-trivial scalars) override this.
- property data_dependent_preamble: Callable[[Value], tuple[str, ...]]¶
Return data-dependent preamble lines.
- date_format: DateFormats = DateFormatConfig(formatter=<function _build_purescript_date_iso.<locals>._format>, preamble_lines=(), type_produced=<class 'str'>)¶
- date_formats¶
alias of
DateFormats
- datetime_format: DatetimeFormats = DatetimeFormatConfig(formatter=<function _build_purescript_datetime_iso.<locals>._format>, preamble_lines=(), type_produced=<class 'str'>)¶
- datetime_formats¶
alias of
DatetimeFormats
- declaration_style: DeclarationStyles = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=False)¶
- declaration_styles¶
alias of
DeclarationStyles
- dict_entry_style: DictEntryStyles = 1¶
- dict_entry_styles¶
alias of
DictEntryStyles
- dict_format: DictFormats = 1¶
- property dict_format_config: DictFormatConfig¶
Configuration for dict formatting.
- dict_formats¶
alias of
DictFormats
- dict_supports_heterogeneous_values = True¶
- element_separator: ClassVar[str] = ', '¶
- empty_dict_keys¶
alias of
EmptyDictKey
- extension = '.purs'¶
- property false_literal: str¶
False literal using the configured constructor prefix.
- float_format: FloatFormats = <function _build_purescript_float_wrapper.<locals>._format>¶
- float_formats¶
alias of
FloatFormats
- property format_bytes: Callable[[bytes], str]¶
Callable that formats a bytes value as a string literal.
- property format_call_arg: Callable[[Value, str], str]¶
Wrap each formatted call argument in parentheses.
Under
json_typethe argument is rendered as aJsonvalue produced byjsonParserinstead of the framework’s formattedValliteral.
- property format_call_arg_ref_identifier: Callable[[str, Value | None], str]¶
Rewrite a
{"$ref": "name"}identifier in a call-argument context.Delegates to
format_call_ref_identifier. Override this to allow call-argument$refvalues that would otherwise be rejected.
- property format_call_arg_ref_identifier_consumable: Callable[[str, Value | None], str]¶
Format a
$refthe caller authorized as consumable.Delegates to
format_call_arg_ref_identifier. Override this to opt into a consuming form (e.g. C++std::move).
- static format_call_binding_body_preamble() tuple[str, ...]¶
Module-internal preamble lines for an inference-bound call result.
The call stub returns
Unit(make_widget _ = unit), so awrap_in_filescaffold whose top level binds a call result mustimport Preludeto bringUnit/unitinto scope. The literal binding for the same data needs no such import, so this is emitted only on the call-binding path.
- format_call_binding_file_pragmas() tuple[str, ...]¶
Default
format_call_binding_file_pragmas– no file-level compiler-pragma line for an inference-bound call result.
- property format_call_preamble_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]¶
Return file-scope stubs for a call expression.
- property format_call_ref_identifier: Callable[[str, Value | None], str]¶
Rewrite a
{"$ref": "name"}identifier into the language’s call expression syntax.
- property format_call_statement: Callable[[str], str]¶
Return call-statement formatting for this language.
- property format_call_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]¶
Return stub declarations for a call expression.
Under
json_typethe stub’s parameter types areJsonrather than the generatedValADT.
- property format_call_target: Callable[[Sequence[str]], str]¶
Rewrite a dotted call target into the language’s call syntax.
- property format_call_variable_assignment: Callable[[str, str, Value], str]¶
Default
format_call_variable_assignment– reuse the literal-binding assignment formatter unchanged.
- property format_call_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]¶
Callable that formats a declaration binding a call expression.
The literal-binding declaration is prepended with a
name :: Typeannotation derived from the bound value’s runtime tagged-enum type (PInt,PStr, …); a call expression has no such tag, so the annotation is omitted and PureScript infers the call’s return type instead.
- static format_constructor_target(class_name: str, /) str¶
Return class_name as a zero-argument constructor call target.
- property format_date: Callable[[date], str]¶
Callable that formats a date as a string literal.
- property format_datetime: Callable[[datetime], str]¶
Callable that formats a datetime as a string literal.
- property format_float: Callable[[float], str]¶
Callable that formats a float value as a literal.
- property format_integer: Callable[[int], str]¶
Callable that formats an int value as a literal.
- property format_integer_widened: None¶
Default
format_integer_widened– no mixed-magnitude integer widening, so the renderer keeps the normal integer formatter.
- property format_ordered_map_entry: Callable[[str, Value, str], str]¶
Callable that formats one ordered-map entry.
- property format_sequence_entry: Callable[[Value, str], str]¶
Format a sequence entry.
- property format_set_entry: Callable[[Value, str], str]¶
Format a set entry.
- property format_string: Callable[[str], str]¶
Callable that formats a string value as a quoted literal.
- property format_time: Callable[[time], str]¶
Callable that formats a time as a string literal.
- property format_variable_assignment: Callable[[str, str, Value], str]¶
Format an assignment to an existing variable.
- property format_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]¶
Callable that formats a new variable declaration.
- has_free_function_calls = True¶
- property heterogeneous_behavior: HeterogeneousBehavior¶
Return the heterogeneous-behavior config.
Under
json_typeheterogeneous scalars all flow through the JSON text, so the framework’s scalar-uniformity checks are skipped.
- heterogeneous_strategies¶
alias of
HeterogeneousStrategies
- heterogeneous_strategy: HeterogeneousStrategies = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)¶
- identifier_cases: ClassVar[tuple[IdentifierCase, ...]] = (IdentifierCase.CAMEL, IdentifierCase.PASCAL)¶
- indent: str = ' '¶
- indent_closing_delimiter: ClassVar[bool] = True¶
- integer_format: IntegerFormats = <function _build_purescript_integer_formatter.<locals>._format>¶
- integer_formats¶
alias of
IntegerFormats
- integer_width_strategies¶
alias of
BareIntegerWidthStrategies
- integer_width_strategy: BareIntegerWidthStrategies = 1¶
- language_version: VersionFormats = 1¶
- property leading_preamble: LeadingPreamble¶
Default
leading_preamble– no preamble lines that must precedeLanguage.static_preamble.
- max_call_parameters = 9223372036854775807¶
- modifier_combinations: ClassVar[tuple[ModifierCombination, ...]] = ()¶
- property null_literal: str¶
Null literal using the configured constructor prefix.
- numeric_literal_suffix: NumericLiteralSuffixes = 1¶
- numeric_literal_suffixes¶
alias of
NumericLiteralSuffixes
- numeric_separator: NumericSeparators = 1¶
- numeric_separators¶
alias of
NumericSeparators
- numeric_style: NumericStyles = 1¶
- numeric_styles¶
alias of
NumericStyles
- property ordered_map_format_config: OrderedMapFormatConfig¶
Configuration for ordered-map formatting.
- pygments_name: ClassVar[str | None] = None¶
- reserved_identifiers: ClassVar[frozenset[str]] = frozenset({})¶
- scalar_body_preamble: ClassVar[dict[type, tuple[str, ...]]] = {}¶
- scalar_preamble: ClassVar[dict[type, tuple[str, ...]]] = {}¶
- sequence_binding_declarations(declarations: tuple[str, ...]) str¶
Default
sequence_binding_declarations– join the per-binding snippets with newlines.
- sequence_format: SequenceFormats = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=']', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type='Val', narrowed_empty_form=None)¶
- property sequence_format_config: SequenceFormatConfig¶
Configuration for the chosen sequence format.
- sequence_formats¶
alias of
SequenceFormats
- property sequence_open: Callable[[list[Value]], str]¶
Callable that returns the opening delimiter for a sequence.
- set_format: SetFormats = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close=']', empty_set=None, preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)¶
- property set_format_config: SetFormatConfig¶
Configuration for the chosen set format.
- set_formats¶
alias of
SetFormats
- skip_null_dict_values: ClassVar[bool] = False¶
- special_float_preamble: ClassVar[tuple[str, ...]] = ()¶
- statement_terminator: ClassVar[str] = ''¶
- statement_terminator_style: StatementTerminatorStyles = 1¶
- statement_terminator_styles¶
alias of
StatementTerminatorStyles
- static_body_preamble: ClassVar[Sequence[str]] = ()¶
- static_preamble: ClassVar[Sequence[str]] = ()¶
- string_format: StringFormats = 1¶
- string_formats¶
alias of
StringFormats
- supported_ref_cases: ClassVar[frozenset[IdentifierCase]] = frozenset({IdentifierCase.CAMEL, IdentifierCase.PASCAL, IdentifierCase.SNAKE, IdentifierCase.UPPER_SNAKE})¶
- supports_call_style = True¶
- supports_collection_comments: ClassVar[bool] = True¶
- supports_default_dict_key_type = False¶
- supports_default_dict_value_type = False¶
- supports_default_ordered_map_value_type = False¶
- supports_default_sequence_element_type = False¶
- supports_default_set_element_type = False¶
- supports_dict_literal_as_free_expression = True¶
- supports_dotted_call_stub = True¶
- supports_dotted_calls = True¶
- supports_empty_dict_key = False¶
- supports_inline_multiline_dict_args = True¶
- supports_module_name = False¶
- supports_multi_param_call_wrapper_stub = True¶
- supports_no_variable_wrap_in_file = False¶
- supports_non_string_dict_keys = False¶
- supports_record_shape_names = False¶
- supports_record_struct_name_prefix = False¶
- supports_scalar_before_comments: ClassVar[bool] = False¶
- supports_scalar_inline_comments: ClassVar[bool] = True¶
- supports_special_floats = True¶
- supports_standalone_comments_in_wrapped_calls = False¶
- supports_variable_names = True¶
- supports_zero_parameter_calls = True¶
- trailing_comma: TrailingCommas = TrailingCommaConfig(multiline_trailing_comma=False)¶
- property trailing_comma_config: TrailingCommaConfig¶
Configuration for trailing-comma behavior.
- trailing_commas¶
alias of
TrailingCommas
- property true_literal: str¶
True literal using the configured constructor prefix.
- property type_hint_collection_preamble_lines: Callable[[frozenset[type]], tuple[str, ...]]¶
Return preamble lines for empty-collection type hints.
- type_name: str = 'Val'¶
- property validate_call_arg: Callable[[Value], None]¶
Return call-argument validation for this language.
- validate_spec_for_data(data: Value) None¶
Raise if the spec cannot produce valid code for data.
Under
json_typethe data must round-trip through a JSON document, so walk data to reject non-string dict keys and non-finite floats – both inputs JSON cannot represent.
- variable_type_hints: VariableTypeHints = 1¶
- variable_type_hints_formats¶
alias of
VariableTypeHints
- version_formats¶
alias of
VersionFormats
- wrap_calls_with_declarations(declarations: tuple[str, ...], calls: str, body_preamble: tuple[str, ...]) str¶
Wrap declarations and calls in a PureScript module.
Variable declarations go at module scope before
main; call expressions are bound inside alet … in unitblock so that bare expressions are not required at the top level.
- static wrap_combined_in_file(declaration: str, assignment: str, variable_name: str, body_preamble: tuple[str, ...]) str¶
Unsupported: literalize() rejects BothVariableForms upstream.
- wrap_in_file(content: str, variable_name: str, body_preamble: tuple[str, ...]) str¶
Wrap a PureScript value declaration in a module.
- class literalizer.languages.Python(*args: object, **kwargs: object)¶
Python language specification.
- Parameters:
date_format –
How to format
datetime.datevalues.date_formats.PYTHON—datetime.dateconstructor call, e.g.datetime.date(year=2024, month=1, day=15).date_formats.ISO— ISO 8601 quoted string, e.g."2024-01-15".
datetime_format –
How to format
datetime.datetimevalues.datetime_formats.PYTHON—datetime.datetimeconstructor call, e.g.datetime.datetime(year=2024, month=1, day=15, hour=12, minute=30, second=0).datetime_formats.EPOCH— integer Unix epoch seconds, e.g.1705312200.
bytes_format –
How to format
bytesvalues.bytes_formats.HEX— lowercase hex string, e.g."48656c6c6f".bytes_formats.PYTHON— Python bytes literal, e.g.b'Hello'.
sequence_format –
Which Python sequence type to use.
sequence_formats.TUPLE— tuple literal, e.g.(1, 2, 3).sequence_formats.LIST— list literal, e.g.[1, 2, 3].
set_format –
Which Python set type to use.
set_formats.SET— mutable set literal, e.g.{1, 2, 3}.set_formats.FROZENSET— immutable frozenset, e.g.frozenset({1, 2, 3}).
default_set_element_type – Type name used for empty set type hints. Defaults to
"Any".default_sequence_element_type – Type name used for empty list/tuple type hints. Defaults to
"Any".default_dict_key_type – Type name used for empty dict key type hints. Defaults to
"str".default_dict_value_type – Type name used for empty dict value type hints. Defaults to
"Any".variable_type_hints –
Whether to add inline type hints to variable declarations.
VariableTypeHints.NEVER— bare assignment, e.g.my_var = {...}. Empty collections still receive a type annotation so that type-checkers can infer the element types, e.g.my_var: dict[str, Any] = {}.VariableTypeHints.ALWAYS— every declaration has a type annotation, e.g.my_var: dict[str, Any] = {...}.
language_version –
The minimum Python version to target.
VersionFormats.PY38— usetyping.List,typing.Dict, etc. for generic collection type hints (PEP 484 style).VersionFormats.PY39— use built-inlist,dict, etc. directly as generic aliases (PEP 585, default).
heterogeneous_strategy –
How to render a record-shaped dict (non-empty, string-keyed).
HeterogeneousStrategies.ERROR— render a plaindict(default). Python’sdictis already heterogeneous, so every record-shaped dict is representable as one.HeterogeneousStrategies.RECORD— opt-in idiomatic-output strategy: render each record-shaped dict as a generated frozen@dataclasses.dataclassdeclared in the preamble plus a matchingRecordN(field=value, ...)literal. Every dict is still representable as a plaindict; this strategy only produces the more idiomatic dataclass form.
record_struct_name_prefix – Prefix for the auto-generated
@dataclasses.dataclassnames under theRECORDstrategy ("Record"->Record0,Record1, …).
- class BoolFormats(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
Empty: this language has no alternative boolean formats.
- class BytesFormats(*values)¶
Bytes formatting options for Python.
- BASE64 = <function format_bytes_base64>¶
- HEX = <function format_bytes_hex>¶
- PYTHON = <function _format_bytes_python>¶
- property type_hint: str¶
The Python type hint for this bytes format.
- class CallStyles(*values)¶
Call style options for Python.
- KEYWORD = KeywordCallStyle(separator='=')¶
- POSITIONAL = PositionalCallStyle(arg_separator=', ', parenthesize_each_arg=False)¶
- class DateFormats(*values)¶
Date formatting options for Python.
- ISO = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- PYTHON = DateFormatConfig(formatter=<function date_ymd_formatter.<locals>._format>, preamble_lines=('import datetime',), type_produced=<class 'datetime.date'>)¶
- property type_hint: str¶
The Python type hint for this date format.
- class DatetimeFormats(*values)¶
Datetime formatting options for Python.
- EPOCH = DatetimeFormatConfig(formatter=<function format_datetime_epoch>, preamble_lines=(), type_produced=<class 'int'>)¶
- PYTHON = DatetimeFormatConfig(formatter=<function _format_datetime_python>, preamble_lines=('import datetime',), type_produced=<class 'datetime.datetime'>)¶
- property type_hint: str¶
The Python type hint for this datetime format.
- class DeclarationStyles(*values)¶
Declaration style options.
- ASSIGN = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=True)¶
- class FloatFormats(*values)¶
Float format options.
- FIXED = <function format_float_fixed>¶
- REPR = <function format_float_repr>¶
- SCIENTIFIC = <function format_float_scientific>¶
- class HeterogeneousStrategies(*values)¶
Strategy for dicts whose values span more than one Python type.
ERRORkeeps the default behavior. Python’sdictis already heterogeneous, so a record-shaped dict is representable as a plaindictand is rendered that way by default.RECORDis an opt-in idiomatic-output strategy: each record-shaped dict (non-empty, string-keyed) becomes a generated frozen@dataclasses.dataclassdeclared in the preamble plus a matchingRecordN(field=value, ...)literal. Every dict is still representable as a plaindict; this strategy only produces the more idiomatic dataclass form.- ERROR = 1¶
- RECORD = 2¶
- class IntegerFormats(*values)¶
Integer format options.
- BINARY = mappingproxy({'NONE': <function format_integer_binary>, 'UNDERSCORE': <function format_integer_binary>})¶
- DECIMAL = mappingproxy({'NONE': <class 'str'>, 'UNDERSCORE': <function format_integer_underscore>})¶
- HEX = mappingproxy({'NONE': <function format_integer_hex>, 'UNDERSCORE': <function format_integer_hex>})¶
- OCTAL = mappingproxy({'NONE': <function format_integer_octal>, 'UNDERSCORE': <function format_integer_octal>})¶
- get_formatter(numeric_separator: Enum) Callable[[int], str]¶
Return the integer formatter for the given separator.
- class JsonTypes(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
Empty: this language has no JSON value-type variants.
- class Modifiers(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
C++/Java/C#-style declaration modifiers: this language has none.
- class SequenceFormats(*values)¶
Sequence type options for Python.
- LIST = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=']', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)¶
- TUPLE = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=')', supports_heterogeneity=True, single_element_trailing_comma=True, supports_trailing_comma=True, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)¶
- property type_hint: str¶
Python type hint name for this sequence format.
- class SetFormats(*values)¶
Set type options for Python.
- FROZENSET = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close='})', empty_set='frozenset()', preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)¶
- SET = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close='}', empty_set='set()', preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)¶
- property type_hint: str¶
Python type hint name for this set format.
- class StringFormats(*values)¶
String format options.
- DOUBLE = <function _build_backslash_formatter.<locals>._format>¶
- RAW = <function format_string_raw_python>¶
- SINGLE = <function _build_backslash_formatter.<locals>._format>¶
- class TrailingCommas(*values)¶
Trailing comma options.
- NO = TrailingCommaConfig(multiline_trailing_comma=False)¶
- YES = TrailingCommaConfig(multiline_trailing_comma=True)¶
- class VariableTypeHints(*values)¶
Variable type hint options for Python.
- ALWAYS = 2¶
- NEVER = 1¶
- SAFE = 3¶
- formatter(*, bytes_hint: str, date_hint: str, datetime_hint: str, time_hint: str, sequence_hint: str, set_hint: str, dict_hint: str, default_set_element_type: str, default_sequence_element_type: str, default_dict_value_type: str, default_dict_key_type: str, join_union: Callable[[list[str]], str], record_eligible: Callable[[Value], bool]) Callable[[str, str, Value, frozenset[Enum]], str]¶
Return the variable declaration formatter for this hint style.
record_eligible flags
RECORD-strategy record-shaped dicts so a bare assignment is kept for them (the generated dataclass already types every field); it is a constantFalsepredicate for other strategies.
- class VersionFormats(*values)¶
Python version to target.
This selects typing-alias syntax; it is not the runtime version floor. The floor under which the default fixtures are exercised in CI is governed by
requires-pythoninpyproject.toml(>=3.12), not by this enum.VersionFormats.PY38— target Python 3.8; usestyping.List,typing.Dict, etc. for generic type hints, and emitsdatetime.timezone.utcfor UTC.VersionFormats.PY39— uses built-in generic aliaseslist,dict, etc. (PEP 585, valid 3.9+). Note this variant also emitsdatetime.UTC, which requires Python 3.11+, so its true minimum interpreter is 3.11, not 3.9.
- PY38 = 1¶
- PY39 = 2¶
- allows_empty_call_parens = True¶
- bool_formats¶
alias of
BoolFormats
- bytes_format: BytesFormats = <function format_bytes_hex>¶
- bytes_formats¶
alias of
BytesFormats
- property call_data_dependent_preamble: Callable[[Value], tuple[str, ...]]¶
Return data-dependent preamble lines for call rendering.
- call_returns_expression = True¶
- call_style: CallStyles = KeywordCallStyle(separator='=')¶
- property call_style_config: PositionalCallStyle | KeywordCallStyle | ObjectCallStyle | PostfixCallStyle | PrefixCallStyle | CommandCallStyle¶
Configuration for the chosen call style.
- call_styles¶
alias of
CallStyles
- property comment_config: CommentConfig¶
Configuration for the language’s comment syntax.
- comment_format: CommentFormats = CommentConfig(prefix='#', suffix='')¶
- comment_formats¶
alias of
CommentFormats
- property compute_body_preamble: Callable[[frozenset[type], Value], tuple[str, ...]]¶
Compute body-preamble lines from the scalar map.
- property consumable_ref_value_inhibits_consuming_form: Callable[[Value], bool]¶
Predicate deciding whether a ref’s underlying value type inhibits the consume form.
Delegates to
never_inhibits_consuming_form. Languages whose consume operator rejects certain value types (notably the Mojo^on register-trivial scalars) override this.
- property data_dependent_preamble: Callable[[Value], tuple[str, ...]]¶
Return data-dependent preamble lines.
Under
HeterogeneousStrategies.RECORDemitsimport dataclassesfollowed by one frozen@dataclasses.dataclassdeclaration per record shape present in the data; otherwise produces no preamble.
- date_format: DateFormats = DateFormatConfig(formatter=<function date_ymd_formatter.<locals>._format>, preamble_lines=('import datetime',), type_produced=<class 'datetime.date'>)¶
- date_formats¶
alias of
DateFormats
- datetime_format: DatetimeFormats = DatetimeFormatConfig(formatter=<function _format_datetime_python>, preamble_lines=('import datetime',), type_produced=<class 'datetime.datetime'>)¶
- datetime_formats¶
alias of
DatetimeFormats
- declaration_style: DeclarationStyles = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=True)¶
- declaration_styles¶
alias of
DeclarationStyles
- default_dict_key_type: str = 'str'¶
- default_dict_value_type: str = 'Any'¶
- default_sequence_element_type: str = 'Any'¶
- default_set_element_type: str = 'Any'¶
- dict_entry_style: DictEntryStyles = 1¶
- dict_entry_styles¶
alias of
DictEntryStyles
- dict_format: DictFormats = 1¶
- property dict_format_config: DictFormatConfig¶
Configuration for dict formatting.
- dict_formats¶
alias of
DictFormats
- dict_supports_heterogeneous_values = True¶
- element_separator: ClassVar[str] = ', '¶
- empty_dict_keys¶
alias of
EmptyDictKey
- extension = '.py'¶
- false_literal: ClassVar[str] = 'False'¶
- float_format: FloatFormats = <function format_float_repr>¶
- float_formats¶
alias of
FloatFormats
- property format_bytes: Callable[[bytes], str]¶
Callable that formats a bytes value as a string literal.
- static format_call_arg(_value: Value, formatted: str, /) str¶
Callable that rewrites a formatted direct call argument.
- property format_call_arg_ref_identifier: Callable[[str, Value | None], str]¶
Rewrite a
{"$ref": "name"}identifier in a call-argument context.Delegates to
format_call_ref_identifier. Override this to allow call-argument$refvalues that would otherwise be rejected.
- property format_call_arg_ref_identifier_consumable: Callable[[str, Value | None], str]¶
Format a
$refthe caller authorized as consumable.Delegates to
format_call_arg_ref_identifier. Override this to opt into a consuming form (e.g. C++std::move).
- format_call_binding_body_preamble() tuple[str, ...]¶
Default
format_call_binding_body_preamble– no extra body preamble lines for an inference-bound call result.
- format_call_binding_file_pragmas() tuple[str, ...]¶
Default
format_call_binding_file_pragmas– no file-level compiler-pragma line for an inference-bound call result.
- property format_call_preamble_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]¶
Return file-scope stubs for a call expression.
- property format_call_ref_identifier: Callable[[str, Value | None], str]¶
Rewrite a
{"$ref": "name"}identifier into the language’s call expression syntax.
- property format_call_statement: Callable[[str], str]¶
Return call-statement formatting for this language.
- property format_call_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]¶
Return stub declarations for a call expression.
- property format_call_target: Callable[[Sequence[str]], str]¶
Rewrite a dotted call target into the language’s call syntax.
- property format_call_variable_assignment: Callable[[str, str, Value], str]¶
Default
format_call_variable_assignment– reuse the literal-binding assignment formatter unchanged.
- property format_call_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]¶
Callable that formats a declaration binding a call result.
A literal binding adds an inline
name: T = ...annotation for values whose type a checker cannot infer from the literal (empty collections, etc.). A call’s return type is opaque to the renderer – the annotation would be derived from the call’s argument data, not its result, and a strict checker rejects the mismatch – so the call result is bound with a plainname = valueand the type is left to inference. Python has no declaration modifiers, so the modifier set is ignored.
- static format_constructor_target(class_name: str, /) str¶
Return class_name as a zero-argument constructor call target.
- property format_date: Callable[[date], str]¶
Callable that formats a date as a string literal.
- property format_datetime: Callable[[datetime], str]¶
Callable that formats a datetime as a string literal.
- property format_float: Callable[[float], str]¶
Callable that formats a float value as a literal.
- property format_integer: Callable[[int], str]¶
Callable that formats an int value as a literal.
- property format_integer_widened: None¶
Default
format_integer_widened– no mixed-magnitude integer widening, so the renderer keeps the normal integer formatter.
- property format_ordered_map_entry: Callable[[str, Value, str], str]¶
Callable that formats one ordered-map entry.
- property format_sequence_entry: Callable[[Value, str], str]¶
Format a sequence entry.
- property format_set_entry: Callable[[Value, str], str]¶
Format a set entry.
- property format_string: Callable[[str], str]¶
Callable that formats a string value as a quoted literal.
- property format_time: Callable[[time], str]¶
Callable that formats a time as a string literal.
- property format_variable_assignment: Callable[[str, str, Value], str]¶
Format an assignment to an existing variable.
- property format_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]¶
Callable that formats a new variable declaration.
- has_free_function_calls = True¶
- property heterogeneous_behavior: HeterogeneousBehavior¶
Return the behavior for the chosen heterogeneous strategy.
- heterogeneous_strategies¶
alias of
HeterogeneousStrategies
- heterogeneous_strategy: HeterogeneousStrategies = 1¶
- identifier_cases: ClassVar[tuple[IdentifierCase, ...]] = (IdentifierCase.SNAKE, IdentifierCase.UPPER_SNAKE, IdentifierCase.PASCAL)¶
- indent: str = ' '¶
- indent_closing_delimiter: ClassVar[bool] = False¶
- integer_format: IntegerFormats = mappingproxy({'NONE': <class 'str'>, 'UNDERSCORE': <function format_integer_underscore>})¶
- integer_formats¶
alias of
IntegerFormats
- integer_width_strategies¶
alias of
BareIntegerWidthStrategies
- integer_width_strategy: BareIntegerWidthStrategies = 1¶
- language_version: VersionFormats = 2¶
- property leading_preamble: LeadingPreamble¶
Emit the PEP 563 future import, but only when the rendered code actually contains an annotation.
from __future__ import annotationsmakes annotations lazy so generated files stay executable on Python 3.8+, but it serves no purpose (and misleads the reader) when nothing is annotated. An annotation is produced in exactly two cases:the
RECORDstrategy generated one or more@dataclasses.dataclassblocks for the data (their fields are annotated), oran inline variable type hint was produced – which only happens when a new variable is declared and either
variable_type_hintsisALWAYSor the data needs a helper annotation (an empty collection; see_needs_type_annotation()).
The import must be the first statement in the module, so it is emitted via
Language.leading_preamblerather than the data-dependent preamble (which follows other imports).
- max_call_parameters = 9223372036854775807¶
- modifier_combinations: ClassVar[tuple[ModifierCombination, ...]] = ()¶
- null_literal: ClassVar[str] = 'None'¶
- numeric_literal_suffix: NumericLiteralSuffixes = 1¶
- numeric_literal_suffixes¶
alias of
NumericLiteralSuffixes
- numeric_separator: NumericSeparators = 1¶
- numeric_separators¶
alias of
NumericSeparators
- numeric_style: NumericStyles = 1¶
- numeric_styles¶
alias of
NumericStyles
- property ordered_map_format_config: OrderedMapFormatConfig¶
Configuration for ordered-map formatting.
- pygments_name = 'python'¶
- record_struct_name_prefix: str = 'Record'¶
- reserved_identifiers: ClassVar[frozenset[str]] = frozenset({})¶
- scalar_body_preamble: ClassVar[dict[type, tuple[str, ...]]] = {}¶
- property scalar_preamble: dict[type, tuple[str, ...]]¶
Per-instance scalar preamble computed from date/datetime format.
- sequence_binding_declarations(declarations: tuple[str, ...]) str¶
Default
sequence_binding_declarations– join the per-binding snippets with newlines.
- sequence_format: SequenceFormats = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=')', supports_heterogeneity=True, single_element_trailing_comma=True, supports_trailing_comma=True, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)¶
- property sequence_format_config: SequenceFormatConfig¶
Configuration for the chosen sequence format.
- sequence_formats¶
alias of
SequenceFormats
- property sequence_open: Callable[[list[Value]], str]¶
Callable that returns the opening delimiter for a sequence.
- set_format: SetFormats = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close='}', empty_set='set()', preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)¶
- property set_format_config: SetFormatConfig¶
Configuration for the chosen set format.
- set_formats¶
alias of
SetFormats
- skip_null_dict_values: ClassVar[bool] = False¶
- special_float_preamble: ClassVar[tuple[str, ...]] = ()¶
- statement_terminator: ClassVar[str] = ''¶
- statement_terminator_style: StatementTerminatorStyles = 1¶
- statement_terminator_styles¶
alias of
StatementTerminatorStyles
- static_body_preamble: ClassVar[Sequence[str]] = ()¶
- static_preamble: ClassVar[Sequence[str]] = ()¶
- string_format: StringFormats = <function _build_backslash_formatter.<locals>._format>¶
- string_formats¶
alias of
StringFormats
- supported_ref_cases: ClassVar[frozenset[IdentifierCase]] = frozenset({IdentifierCase.CAMEL, IdentifierCase.PASCAL, IdentifierCase.SNAKE, IdentifierCase.UPPER_SNAKE})¶
- supports_call_style = True¶
- supports_collection_comments: ClassVar[bool] = True¶
- supports_default_dict_key_type = True¶
- supports_default_dict_value_type = True¶
- supports_default_ordered_map_value_type = False¶
- supports_default_sequence_element_type = True¶
- supports_default_set_element_type = True¶
- supports_dict_literal_as_free_expression = True¶
- supports_dotted_call_stub = True¶
- supports_dotted_calls = True¶
- supports_empty_dict_key = False¶
- supports_inline_multiline_dict_args = True¶
- supports_module_name = False¶
- supports_multi_param_call_wrapper_stub = True¶
- supports_no_variable_wrap_in_file = True¶
- supports_non_string_dict_keys = True¶
- supports_record_shape_names = False¶
- supports_record_struct_name_prefix = True¶
- supports_scalar_before_comments: ClassVar[bool] = False¶
- supports_scalar_inline_comments: ClassVar[bool] = True¶
- supports_special_floats = True¶
- supports_standalone_comments_in_wrapped_calls = True¶
- supports_variable_names = True¶
- supports_zero_parameter_calls = True¶
- trailing_comma: TrailingCommas = TrailingCommaConfig(multiline_trailing_comma=True)¶
- property trailing_comma_config: TrailingCommaConfig¶
Configuration for trailing-comma behavior.
- trailing_commas¶
alias of
TrailingCommas
- true_literal: ClassVar[str] = 'True'¶
- property type_hint_collection_preamble_lines: Callable[[frozenset[type]], tuple[str, ...]]¶
Type-hint preamble computed from the configured default types.
- property validate_call_arg: Callable[[Value], None]¶
Return call-argument validation for this language.
- validate_spec_for_data(data: Value) None¶
Default
validate_spec_for_data— no spec/data constraints.
- variable_type_hints: VariableTypeHints = 1¶
- variable_type_hints_formats¶
alias of
VariableTypeHints
- version_formats¶
alias of
VersionFormats
- wrap_calls_with_declarations(declarations: tuple[str, ...], calls: str, body_preamble: tuple[str, ...]) str¶
Default
wrap_calls_with_declarations— concatenate the declarations and calls and route throughwrap_in_file()in call mode.
- static wrap_combined_in_file(declaration: str, assignment: str, variable_name: str, body_preamble: tuple[str, ...]) str¶
Wrap Python declaration + assignment in a valid file.
- static wrap_in_file(content: str, variable_name: str, body_preamble: tuple[str, ...]) str¶
Wrap Python code in a valid file (no-op).
- class literalizer.languages.R(*args: object, **kwargs: object)¶
R language specification.
Dicts are represented as named
list()calls where each entry is written as"key" = value. R’s parser rejects zero-length names, so by default dict keys that are empty strings are emitted as positional (unnamed) list elements rather than as"" = value.- Parameters:
date_format –
How to format
datetime.datevalues.date_formats.R—as.Date(...)call, e.g.as.Date("2024-01-15").date_formats.ISO— ISO 8601 quoted string, e.g."2024-01-15".
datetime_format –
How to format
datetime.datetimevalues.datetime_formats.R—as.POSIXct(...)call, e.g.as.POSIXct("2024-01-15T12:30:00").datetime_formats.ISO— ISO 8601 quoted string, e.g."2024-01-15T12:30:00".
empty_dict_key –
How to handle empty-string dict keys.
EmptyDictKey.POSITIONAL— emit as an unnamed positional list element.EmptyDictKey.ERROR— raiseInvalidDictKeyError.
- class BoolFormats(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
Empty: this language has no alternative boolean formats.
- class BytesFormats(*values)¶
Bytes formatting options.
- BASE64 = <function format_bytes_base64>¶
- HEX = <function format_bytes_hex>¶
- class CallStyles(*values)¶
R call style options.
- KEYWORD = KeywordCallStyle(separator=' = ')¶
- POSITIONAL = PositionalCallStyle(arg_separator=', ', parenthesize_each_arg=False)¶
- class DateFormats(*values)¶
Date formatting options for R.
- ISO = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- R = DateFormatConfig(formatter=<function date_iso_formatter.<locals>._format>, preamble_lines=(), type_produced=<class 'datetime.date'>)¶
- class DatetimeFormats(*values)¶
Datetime formatting options for R.
- EPOCH = DatetimeFormatConfig(formatter=<function format_datetime_epoch>, preamble_lines=(), type_produced=<class 'int'>)¶
- ISO = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- R = DatetimeFormatConfig(formatter=<function datetime_iso_formatter.<locals>._format>, preamble_lines=(), type_produced=<class 'datetime.datetime'>)¶
- class DeclarationStyles(*values)¶
Declaration style options.
- ASSIGN = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=True)¶
- class EmptyDictKey(*values)¶
How to handle empty-string dict keys in R.
R’s parser rejects zero-length names (
"" = valueis a parse error).- ERROR = <function _format_r_dict_entry_error>¶
- POSITIONAL = <function _format_r_dict_entry_positional>¶
- class FloatFormats(*values)¶
Float format options.
- FIXED = <function format_float_fixed>¶
- REPR = <function format_float_repr>¶
- SCIENTIFIC = <function format_float_scientific>¶
- class HeterogeneousStrategies(*values)¶
Heterogeneous-scalar strategy options — this language only supports raising.
- ERROR = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)¶
- class IntegerFormats(*values)¶
Integer format options.
- DECIMAL = <class 'str'>¶
- HEX = <function format_integer_hex>¶
- class JsonTypes(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
Empty: this language has no JSON value-type variants.
- class Modifiers(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
C++/Java/C#-style declaration modifiers: this language has none.
- class SequenceFormats(*values)¶
Sequence type options for R.
- LIST = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=')', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=False, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)¶
- class SetFormats(*values)¶
Set type options for R.
- SET = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close=')', empty_set=None, preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)¶
- class TrailingCommas(*values)¶
Trailing comma options.
R’s
list()rejects empty arguments, so a literal trailing comma likelist(1, 2,)parses but raises at runtime; only the comma-free form is supported.- NO = TrailingCommaConfig(multiline_trailing_comma=False)¶
- allows_empty_call_parens = True¶
- bool_formats¶
alias of
BoolFormats
- bytes_format: BytesFormats = <function format_bytes_hex>¶
- bytes_formats¶
alias of
BytesFormats
- property call_data_dependent_preamble: Callable[[Value], tuple[str, ...]]¶
Return data-dependent preamble lines for call rendering.
- call_returns_expression = True¶
- call_style: CallStyles = KeywordCallStyle(separator=' = ')¶
- property call_style_config: PositionalCallStyle | KeywordCallStyle | ObjectCallStyle | PostfixCallStyle | PrefixCallStyle | CommandCallStyle¶
Configuration for the chosen call style.
- call_styles¶
alias of
CallStyles
- property comment_config: CommentConfig¶
Configuration for the language’s comment syntax.
- comment_format: CommentFormats = CommentConfig(prefix='#', suffix='')¶
- comment_formats¶
alias of
CommentFormats
- property compute_body_preamble: Callable[[frozenset[type], Value], tuple[str, ...]]¶
Compute body-preamble lines from the scalar map.
- property consumable_ref_value_inhibits_consuming_form: Callable[[Value], bool]¶
Predicate deciding whether a ref’s underlying value type inhibits the consume form.
Delegates to
never_inhibits_consuming_form. Languages whose consume operator rejects certain value types (notably the Mojo^on register-trivial scalars) override this.
- property data_dependent_preamble: Callable[[Value], tuple[str, ...]]¶
Return data-dependent preamble lines.
- date_format: DateFormats = DateFormatConfig(formatter=<function date_iso_formatter.<locals>._format>, preamble_lines=(), type_produced=<class 'datetime.date'>)¶
- date_formats¶
alias of
DateFormats
- datetime_format: DatetimeFormats = DatetimeFormatConfig(formatter=<function datetime_iso_formatter.<locals>._format>, preamble_lines=(), type_produced=<class 'datetime.datetime'>)¶
- datetime_formats¶
alias of
DatetimeFormats
- declaration_style: DeclarationStyles = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=True)¶
- declaration_styles¶
alias of
DeclarationStyles
- dict_entry_style: DictEntryStyles = 1¶
- dict_entry_styles¶
alias of
DictEntryStyles
- dict_format: DictFormats = 1¶
- property dict_format_config: DictFormatConfig¶
Configuration for dict formatting.
- dict_formats¶
alias of
DictFormats
- dict_supports_heterogeneous_values = True¶
- element_separator: ClassVar[str] = ', '¶
- empty_dict_key: EmptyDictKey = <function _format_r_dict_entry_positional>¶
- empty_dict_keys¶
alias of
EmptyDictKey
- extension = '.R'¶
- false_literal: ClassVar[str] = 'FALSE'¶
- float_format: FloatFormats = <function format_float_repr>¶
- float_formats¶
alias of
FloatFormats
- property format_bytes: Callable[[bytes], str]¶
Callable that formats a bytes value as a string literal.
- static format_call_arg(_value: Value, formatted: str, /) str¶
Callable that rewrites a formatted direct call argument.
- property format_call_arg_ref_identifier: Callable[[str, Value | None], str]¶
Rewrite a
{"$ref": "name"}identifier in a call-argument context.Delegates to
format_call_ref_identifier. Override this to allow call-argument$refvalues that would otherwise be rejected.
- property format_call_arg_ref_identifier_consumable: Callable[[str, Value | None], str]¶
Format a
$refthe caller authorized as consumable.Delegates to
format_call_arg_ref_identifier. Override this to opt into a consuming form (e.g. C++std::move).
- format_call_binding_body_preamble() tuple[str, ...]¶
Default
format_call_binding_body_preamble– no extra body preamble lines for an inference-bound call result.
- format_call_binding_file_pragmas() tuple[str, ...]¶
Default
format_call_binding_file_pragmas– no file-level compiler-pragma line for an inference-bound call result.
- property format_call_preamble_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]¶
Return file-scope stubs for a call expression.
- property format_call_ref_identifier: Callable[[str, Value | None], str]¶
Rewrite a
{"$ref": "name"}identifier into the language’s call expression syntax.
- property format_call_statement: Callable[[str], str]¶
Return call-statement formatting for this language.
- property format_call_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]¶
Return stub declarations for a call expression.
- property format_call_target: Callable[[Sequence[str]], str]¶
Rewrite a dotted call target into the language’s call syntax.
- property format_call_variable_assignment: Callable[[str, str, Value], str]¶
Default
format_call_variable_assignment– reuse the literal-binding assignment formatter unchanged.
- property format_call_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]¶
Default
format_call_variable_declaration– reuse the literal-binding declaration formatter unchanged.
- static format_constructor_target(class_name: str, /) str¶
Return class_name as a zero-argument constructor call target.
- property format_date: Callable[[date], str]¶
Callable that formats a date as a string literal.
- property format_datetime: Callable[[datetime], str]¶
Callable that formats a datetime as a string literal.
- property format_float: Callable[[float], str]¶
Callable that formats a float value as a literal.
- property format_integer: Callable[[int], str]¶
Callable that formats an int value as a literal.
- property format_integer_widened: None¶
Default
format_integer_widened– no mixed-magnitude integer widening, so the renderer keeps the normal integer formatter.
- property format_ordered_map_entry: Callable[[str, Value, str], str]¶
Callable that formats one ordered-map entry.
- property format_sequence_entry: Callable[[Value, str], str]¶
Format a sequence entry.
- property format_set_entry: Callable[[Value, str], str]¶
Format a set entry.
- property format_string: Callable[[str], str]¶
Format a string value as a quoted literal.
- property format_time: Callable[[time], str]¶
Callable that formats a time as a string literal.
- property format_variable_assignment: Callable[[str, str, Value], str]¶
Format an assignment to an existing variable.
- property format_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]¶
Callable that formats a new variable declaration.
- has_free_function_calls = True¶
- property heterogeneous_behavior: HeterogeneousBehavior¶
Return the heterogeneous-behavior config.
- heterogeneous_strategies¶
alias of
HeterogeneousStrategies
- heterogeneous_strategy: HeterogeneousStrategies = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)¶
- identifier_cases: ClassVar[tuple[IdentifierCase, ...]] = (IdentifierCase.SNAKE, IdentifierCase.CAMEL, IdentifierCase.PASCAL)¶
- indent: str = ' '¶
- indent_closing_delimiter: ClassVar[bool] = False¶
- integer_format: IntegerFormats = <class 'str'>¶
- integer_formats¶
alias of
IntegerFormats
- integer_width_strategies¶
alias of
BareIntegerWidthStrategies
- integer_width_strategy: BareIntegerWidthStrategies = 1¶
- language_version: VersionFormats = 1¶
- property leading_preamble: LeadingPreamble¶
Default
leading_preamble– no preamble lines that must precedeLanguage.static_preamble.
- max_call_parameters = 9223372036854775807¶
- modifier_combinations: ClassVar[tuple[ModifierCombination, ...]] = ()¶
- null_literal: ClassVar[str] = 'NULL'¶
- numeric_literal_suffix: NumericLiteralSuffixes = 1¶
- numeric_literal_suffixes¶
alias of
NumericLiteralSuffixes
- numeric_separator: NumericSeparators = 1¶
- numeric_separators¶
alias of
NumericSeparators
- numeric_style: NumericStyles = 1¶
- numeric_styles¶
alias of
NumericStyles
- property ordered_map_format_config: OrderedMapFormatConfig¶
Configuration for ordered-map formatting.
- pygments_name = 'r'¶
- reserved_identifiers: ClassVar[frozenset[str]] = frozenset({})¶
- property scalar_body_preamble: dict[type, tuple[str, ...]]¶
Per-instance scalar body preamble (R needs none).
- property scalar_preamble: dict[type, tuple[str, ...]]¶
Per-instance scalar preamble (R needs none).
- sequence_binding_declarations(declarations: tuple[str, ...]) str¶
Default
sequence_binding_declarations– join the per-binding snippets with newlines.
- sequence_format: SequenceFormats = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=')', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=False, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)¶
- property sequence_format_config: SequenceFormatConfig¶
Configuration for the chosen sequence format.
- sequence_formats¶
alias of
SequenceFormats
- property sequence_open: Callable[[list[Value]], str]¶
Callable that returns the opening delimiter for a sequence.
- set_format: SetFormats = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close=')', empty_set=None, preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)¶
- property set_format_config: SetFormatConfig¶
Configuration for the chosen set format.
- set_formats¶
alias of
SetFormats
- skip_null_dict_values: ClassVar[bool] = False¶
- special_float_preamble: ClassVar[tuple[str, ...]] = ()¶
- statement_terminator: ClassVar[str] = ''¶
- statement_terminator_style: StatementTerminatorStyles = 1¶
- statement_terminator_styles¶
alias of
StatementTerminatorStyles
- static_body_preamble: ClassVar[Sequence[str]] = ()¶
- static_preamble: ClassVar[Sequence[str]] = ()¶
- string_format: StringFormats = 1¶
- string_formats¶
alias of
StringFormats
- supported_ref_cases: ClassVar[frozenset[IdentifierCase]] = frozenset({IdentifierCase.CAMEL, IdentifierCase.PASCAL, IdentifierCase.SNAKE, IdentifierCase.UPPER_SNAKE})¶
- supports_call_style = True¶
- supports_collection_comments: ClassVar[bool] = True¶
- supports_default_dict_key_type = False¶
- supports_default_dict_value_type = False¶
- supports_default_ordered_map_value_type = False¶
- supports_default_sequence_element_type = False¶
- supports_default_set_element_type = False¶
- supports_dict_literal_as_free_expression = True¶
- supports_dotted_call_stub = True¶
- supports_dotted_calls = True¶
- supports_empty_dict_key = True¶
- supports_inline_multiline_dict_args = True¶
- supports_module_name = False¶
- supports_multi_param_call_wrapper_stub = True¶
- supports_no_variable_wrap_in_file = True¶
- supports_non_string_dict_keys = False¶
- supports_record_shape_names = False¶
- supports_record_struct_name_prefix = False¶
- supports_scalar_before_comments: ClassVar[bool] = True¶
- supports_scalar_inline_comments: ClassVar[bool] = True¶
- supports_special_floats = True¶
- supports_standalone_comments_in_wrapped_calls = True¶
- supports_variable_names = True¶
- supports_zero_parameter_calls = True¶
- trailing_comma: TrailingCommas = TrailingCommaConfig(multiline_trailing_comma=False)¶
- property trailing_comma_config: TrailingCommaConfig¶
Configuration for trailing-comma behavior.
- trailing_commas¶
alias of
TrailingCommas
- true_literal: ClassVar[str] = 'TRUE'¶
- property type_hint_collection_preamble_lines: Callable[[frozenset[type]], tuple[str, ...]]¶
Return preamble lines for empty-collection type hints.
- property validate_call_arg: Callable[[Value], None]¶
Return call-argument validation for this language.
- static validate_spec_for_data(data: Value) None¶
Reject inputs containing an empty mapping on R.
- variable_type_hints: VariableTypeHints = 1¶
- variable_type_hints_formats¶
alias of
VariableTypeHints
- version_formats¶
alias of
VersionFormats
- wrap_calls_with_declarations(declarations: tuple[str, ...], calls: str, body_preamble: tuple[str, ...]) str¶
Default
wrap_calls_with_declarations— concatenate the declarations and calls and route throughwrap_in_file()in call mode.
- static wrap_combined_in_file(declaration: str, assignment: str, variable_name: str, body_preamble: tuple[str, ...]) str¶
Wrap declaration and assignment in a valid file (no-op).
- static wrap_in_file(content: str, variable_name: str, body_preamble: tuple[str, ...]) str¶
Wrap code in a valid file (no-op).
- class literalizer.languages.Racket(*args: object, **kwargs: object)¶
Racket language specification.
- class BoolFormats(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
Empty: this language has no alternative boolean formats.
- class BytesFormats(*values)¶
Bytes formatting options.
- BASE64 = <function format_bytes_base64>¶
- HEX = <function format_bytes_hex>¶
- class CallStyles(*values)¶
Racket call style options.
- PREFIX_KEYWORD = PrefixCallStyle(arg_separator=' ', keyword_prefix='#:')¶
- class CommentFormats(*values)¶
Comment style options.
- BLOCK = CommentConfig(prefix='#|', suffix=' |#')¶
- SEMICOLON = CommentConfig(prefix=';', suffix='')¶
- class DateFormats(*values)¶
Date format options for Racket.
- ISO = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- class DatetimeFormats(*values)¶
Datetime format options for Racket.
- EPOCH = DatetimeFormatConfig(formatter=<function format_datetime_epoch>, preamble_lines=(), type_produced=<class 'int'>)¶
- ISO = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- class DeclarationStyles(*values)¶
Declaration style options.
- DEFINE = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=True)¶
- class FloatFormats(*values)¶
Float format options.
- FIXED = <function format_float_fixed>¶
- REPR = <function format_float_repr>¶
- SCIENTIFIC = <function format_float_scientific>¶
- class HeterogeneousStrategies(*values)¶
Heterogeneous-scalar strategy options — this language only supports raising.
- ERROR = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)¶
- class JsonTypes(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
Empty: this language has no JSON value-type variants.
- class Modifiers(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
C++/Java/C#-style declaration modifiers: this language has none.
- class SequenceFormats(*values)¶
Sequence type options for Racket.
- LIST = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=')', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=False, empty_sequence='(list)', preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)¶
- class SetFormats(*values)¶
Set type options for Racket.
- SET = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close=')', empty_set='(set)', preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)¶
- class TrailingCommas(*values)¶
Trailing comma options.
- NO = TrailingCommaConfig(multiline_trailing_comma=False)¶
- allows_empty_call_parens = True¶
- bool_formats¶
alias of
BoolFormats
- bytes_format: BytesFormats = <function format_bytes_hex>¶
- bytes_formats¶
alias of
BytesFormats
- property call_data_dependent_preamble: Callable[[Value], tuple[str, ...]]¶
Return data-dependent preamble lines for call rendering.
- call_returns_expression = True¶
- call_style: CallStyles = PrefixCallStyle(arg_separator=' ', keyword_prefix='#:')¶
- property call_style_config: PositionalCallStyle | KeywordCallStyle | ObjectCallStyle | PostfixCallStyle | PrefixCallStyle | CommandCallStyle¶
Configuration for Racket’s call style.
- call_styles¶
alias of
CallStyles
- property comment_config: CommentConfig¶
Configuration for the language’s comment syntax.
- comment_format: CommentFormats = CommentConfig(prefix=';', suffix='')¶
- comment_formats¶
alias of
CommentFormats
- property compute_body_preamble: Callable[[frozenset[type], Value], tuple[str, ...]]¶
Compute body-preamble lines from the scalar map.
- property consumable_ref_value_inhibits_consuming_form: Callable[[Value], bool]¶
Predicate deciding whether a ref’s underlying value type inhibits the consume form.
Delegates to
never_inhibits_consuming_form. Languages whose consume operator rejects certain value types (notably the Mojo^on register-trivial scalars) override this.
- property data_dependent_preamble: Callable[[Value], tuple[str, ...]]¶
Return data-dependent preamble lines.
- date_format: DateFormats = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- date_formats¶
alias of
DateFormats
- datetime_format: DatetimeFormats = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- datetime_formats¶
alias of
DatetimeFormats
- declaration_style: DeclarationStyles = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=True)¶
- declaration_styles¶
alias of
DeclarationStyles
- dict_entry_style: DictEntryStyles = 1¶
- dict_entry_styles¶
alias of
DictEntryStyles
- dict_format: DictFormats = 1¶
- property dict_format_config: DictFormatConfig¶
Configuration for dict formatting.
- dict_formats¶
alias of
DictFormats
- dict_supports_heterogeneous_values = True¶
- element_separator: ClassVar[str] = ' '¶
- empty_dict_keys¶
alias of
EmptyDictKey
- extension = '.rkt'¶
- false_literal: ClassVar[str] = '#f'¶
- float_format: FloatFormats = <function format_float_repr>¶
- float_formats¶
alias of
FloatFormats
- property format_bytes: Callable[[bytes], str]¶
Callable that formats a bytes value as a string literal.
- static format_call_arg(_value: Value, formatted: str, /) str¶
Callable that rewrites a formatted direct call argument.
- property format_call_arg_ref_identifier: Callable[[str, Value | None], str]¶
Rewrite a
{"$ref": "name"}identifier in a call-argument context.Delegates to
format_call_ref_identifier. Override this to allow call-argument$refvalues that would otherwise be rejected.
- property format_call_arg_ref_identifier_consumable: Callable[[str, Value | None], str]¶
Format a
$refthe caller authorized as consumable.Delegates to
format_call_arg_ref_identifier. Override this to opt into a consuming form (e.g. C++std::move).
- format_call_binding_body_preamble() tuple[str, ...]¶
Default
format_call_binding_body_preamble– no extra body preamble lines for an inference-bound call result.
- format_call_binding_file_pragmas() tuple[str, ...]¶
Default
format_call_binding_file_pragmas– no file-level compiler-pragma line for an inference-bound call result.
- property format_call_preamble_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]¶
Return file-scope stubs for a call expression.
- property format_call_ref_identifier: Callable[[str, Value | None], str]¶
Raise for any
{"$ref": "name"}identifier.Racket output is not wrapped in a function body, so identifier references require a surrounding
definethat cannot be injected.
- property format_call_statement: Callable[[str], str]¶
Return call-statement formatting for this language.
- property format_call_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]¶
Return stub declarations for a call expression.
- property format_call_target: Callable[[Sequence[str]], str]¶
Rewrite a dotted call target into the language’s call syntax.
- property format_call_variable_assignment: Callable[[str, str, Value], str]¶
Default
format_call_variable_assignment– reuse the literal-binding assignment formatter unchanged.
- property format_call_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]¶
Default
format_call_variable_declaration– reuse the literal-binding declaration formatter unchanged.
- static format_constructor_target(class_name: str, /) str¶
Return class_name as a zero-argument constructor call target.
- property format_date: Callable[[date], str]¶
Callable that formats a date as a string literal.
- property format_datetime: Callable[[datetime], str]¶
Callable that formats a datetime as a string literal.
- property format_float: Callable[[float], str]¶
Callable that formats a float value as a literal.
- property format_integer: Callable[[int], str]¶
Format an int value as a literal.
- property format_integer_widened: None¶
Default
format_integer_widened– no mixed-magnitude integer widening, so the renderer keeps the normal integer formatter.
- property format_ordered_map_entry: Callable[[str, Value, str], str]¶
Callable that formats one ordered-map entry.
- property format_sequence_entry: Callable[[Value, str], str]¶
Format a sequence entry.
- property format_set_entry: Callable[[Value, str], str]¶
Format a set entry.
- property format_string: Callable[[str], str]¶
Format a string value as a quoted literal.
- property format_time: Callable[[time], str]¶
Callable that formats a time as a string literal.
- property format_variable_assignment: Callable[[str, str, Value], str]¶
Format an assignment to an existing variable.
- property format_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]¶
Callable that formats a new variable declaration.
- has_free_function_calls = True¶
- property heterogeneous_behavior: HeterogeneousBehavior¶
Return the heterogeneous-behavior config.
- heterogeneous_strategies¶
alias of
HeterogeneousStrategies
- heterogeneous_strategy: HeterogeneousStrategies = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)¶
- identifier_cases: ClassVar[tuple[IdentifierCase, ...]] = (IdentifierCase.KEBAB, IdentifierCase.SNAKE)¶
- indent: str = ' '¶
- indent_closing_delimiter: ClassVar[bool] = False¶
- integer_format: IntegerFormats = 1¶
- integer_formats¶
alias of
IntegerFormats
- integer_width_strategies¶
alias of
BareIntegerWidthStrategies
- integer_width_strategy: BareIntegerWidthStrategies = 1¶
- language_version: VersionFormats = 1¶
- property leading_preamble: LeadingPreamble¶
Default
leading_preamble– no preamble lines that must precedeLanguage.static_preamble.
- max_call_parameters = 9223372036854775807¶
- modifier_combinations: ClassVar[tuple[ModifierCombination, ...]] = ()¶
- null_literal: ClassVar[str] = '(void)'¶
- numeric_literal_suffix: NumericLiteralSuffixes = 1¶
- numeric_literal_suffixes¶
alias of
NumericLiteralSuffixes
- numeric_separator: NumericSeparators = 1¶
- numeric_separators¶
alias of
NumericSeparators
- numeric_style: NumericStyles = 1¶
- numeric_styles¶
alias of
NumericStyles
- property ordered_map_format_config: OrderedMapFormatConfig¶
Configuration for ordered-map formatting.
- pygments_name = 'racket'¶
- reserved_identifiers: ClassVar[frozenset[str]] = frozenset({})¶
- property scalar_body_preamble: dict[type, tuple[str, ...]]¶
Per-instance scalar body preamble (Racket needs none).
- property scalar_preamble: dict[type, tuple[str, ...]]¶
Per-instance scalar preamble (Racket needs none).
- sequence_binding_declarations(declarations: tuple[str, ...]) str¶
Default
sequence_binding_declarations– join the per-binding snippets with newlines.
- sequence_format: SequenceFormats = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=')', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=False, empty_sequence='(list)', preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)¶
- property sequence_format_config: SequenceFormatConfig¶
Configuration for the chosen sequence format.
- sequence_formats¶
alias of
SequenceFormats
- property sequence_open: Callable[[list[Value]], str]¶
Callable that returns the opening delimiter for a sequence.
- set_format: SetFormats = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close=')', empty_set='(set)', preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)¶
- property set_format_config: SetFormatConfig¶
Configuration for the chosen set format.
- set_formats¶
alias of
SetFormats
- skip_null_dict_values: ClassVar[bool] = False¶
- special_float_preamble: ClassVar[tuple[str, ...]] = ()¶
- statement_terminator: ClassVar[str] = ''¶
- statement_terminator_style: StatementTerminatorStyles = 1¶
- statement_terminator_styles¶
alias of
StatementTerminatorStyles
- static_body_preamble: ClassVar[Sequence[str]] = ()¶
- static_preamble: ClassVar[Sequence[str]] = ('#lang racket',)¶
- string_format: StringFormats = 1¶
- string_formats¶
alias of
StringFormats
- supported_ref_cases: ClassVar[frozenset[IdentifierCase]] = frozenset({IdentifierCase.CAMEL, IdentifierCase.KEBAB, IdentifierCase.PASCAL, IdentifierCase.SNAKE, IdentifierCase.UPPER_SNAKE})¶
- supports_call_style = True¶
- supports_collection_comments: ClassVar[bool] = True¶
- supports_default_dict_key_type = False¶
- supports_default_dict_value_type = False¶
- supports_default_ordered_map_value_type = False¶
- supports_default_sequence_element_type = False¶
- supports_default_set_element_type = False¶
- supports_dict_literal_as_free_expression = True¶
- supports_dotted_call_stub = True¶
- supports_dotted_calls = True¶
- supports_empty_dict_key = False¶
- supports_inline_multiline_dict_args = True¶
- supports_module_name = False¶
- supports_multi_param_call_wrapper_stub = True¶
- supports_no_variable_wrap_in_file = True¶
- supports_non_string_dict_keys = True¶
- supports_record_shape_names = False¶
- supports_record_struct_name_prefix = False¶
- supports_scalar_before_comments: ClassVar[bool] = True¶
- supports_scalar_inline_comments: ClassVar[bool] = False¶
- supports_special_floats = True¶
- supports_standalone_comments_in_wrapped_calls = True¶
- supports_variable_names = True¶
- supports_zero_parameter_calls = True¶
- trailing_comma: TrailingCommas = TrailingCommaConfig(multiline_trailing_comma=False)¶
- property trailing_comma_config: TrailingCommaConfig¶
Configuration for trailing-comma behavior.
- trailing_commas¶
alias of
TrailingCommas
- true_literal: ClassVar[str] = '#t'¶
- property type_hint_collection_preamble_lines: Callable[[frozenset[type]], tuple[str, ...]]¶
Return preamble lines for empty-collection type hints.
- property validate_call_arg: Callable[[Value], None]¶
Return call-argument validation for this language.
- validate_spec_for_data(data: Value) None¶
Default
validate_spec_for_data— no spec/data constraints.
- variable_type_hints: VariableTypeHints = 1¶
- variable_type_hints_formats¶
alias of
VariableTypeHints
- version_formats¶
alias of
VersionFormats
- wrap_calls_with_declarations(declarations: tuple[str, ...], calls: str, body_preamble: tuple[str, ...]) str¶
Default
wrap_calls_with_declarations— concatenate the declarations and calls and route throughwrap_in_file()in call mode.
- static wrap_combined_in_file(declaration: str, assignment: str, variable_name: str, body_preamble: tuple[str, ...]) str¶
Wrap declaration and assignment in a valid file (no-op).
- static wrap_in_file(content: str, variable_name: str, body_preamble: tuple[str, ...]) str¶
Wrap code in a valid file (no-op).
- class literalizer.languages.Raku(*args: object, **kwargs: object)¶
Raku language specification.
- Parameters:
date_format –
How to format
datetime.datevalues.date_formats.RAKU—Date.new(...)call, e.g.Date.new(year => 2024, month => 1, day => 15).date_formats.ISO— ISO 8601 quoted string, e.g."2024-01-15".
datetime_format –
How to format
datetime.datetimevalues.datetime_formats.RAKU—DateTime.new(...)call, e.g.DateTime.new(year => 2024, month => 1, day => 15, hour => 12, minute => 30, second => 0, timezone => 0).datetime_formats.ISO— ISO 8601 quoted string, e.g."2024-01-15T12:30:00+00:00".
- class BoolFormats(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
Empty: this language has no alternative boolean formats.
- class BytesFormats(*values)¶
Bytes formatting options.
- BASE64 = <function format_bytes_base64>¶
- HEX = <function format_bytes_hex>¶
- class CallStyles(*values)¶
Raku call style options.
- KEYWORD = KeywordCallStyle(separator=' => ')¶
- POSITIONAL = PositionalCallStyle(arg_separator=', ', parenthesize_each_arg=False)¶
- class DateFormats(*values)¶
Date format options for Raku.
- ISO = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- RAKU = DateFormatConfig(formatter=<function date_ymd_formatter.<locals>._format>, preamble_lines=(), type_produced=<class 'datetime.date'>)¶
- class DatetimeFormats(*values)¶
Datetime format options for Raku.
- EPOCH = DatetimeFormatConfig(formatter=<function format_datetime_epoch>, preamble_lines=(), type_produced=<class 'int'>)¶
- ISO = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- RAKU = DatetimeFormatConfig(formatter=<function _format_datetime_raku>, preamble_lines=(), type_produced=<class 'datetime.datetime'>)¶
- class DeclarationStyles(*values)¶
Declaration style options.
- MY = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=True)¶
- class FloatFormats(*values)¶
Float format options.
- FIXED = <function format_float_fixed>¶
- REPR = <function format_float_repr>¶
- SCIENTIFIC = <function format_float_scientific>¶
- class HeterogeneousStrategies(*values)¶
Heterogeneous-scalar strategy options — this language only supports raising.
- ERROR = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)¶
- class IntegerFormats(*values)¶
Integer format options.
- BINARY = mappingproxy({'NONE': <function format_integer_binary>, 'UNDERSCORE': <function format_integer_binary>})¶
- DECIMAL = mappingproxy({'NONE': <class 'str'>, 'UNDERSCORE': <function format_integer_underscore>})¶
- HEX = mappingproxy({'NONE': <function format_integer_hex>, 'UNDERSCORE': <function format_integer_hex>})¶
- OCTAL = mappingproxy({'NONE': <function format_integer_octal>, 'UNDERSCORE': <function format_integer_octal>})¶
- get_formatter(numeric_separator: Enum) Callable[[int], str]¶
Return the integer formatter for the given separator.
- class JsonTypes(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
Empty: this language has no JSON value-type variants.
- class Modifiers(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
C++/Java/C#-style declaration modifiers: this language has none.
- class SequenceFormats(*values)¶
Sequence type options for Raku.
- ARRAY = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=']', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)¶
- class SetFormats(*values)¶
Set type options for Raku.
- SET = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close=']', empty_set=None, preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)¶
- class StringFormats(*values)¶
String format options.
- DOUBLE = <function _build_backslash_formatter.<locals>._format>¶
- SINGLE = <function format_string_backslash_single_minimal>¶
- class TrailingCommas(*values)¶
Trailing comma options.
- NO = TrailingCommaConfig(multiline_trailing_comma=False)¶
- YES = TrailingCommaConfig(multiline_trailing_comma=True)¶
- allows_empty_call_parens = True¶
- bool_formats¶
alias of
BoolFormats
- bytes_format: BytesFormats = <function format_bytes_hex>¶
- bytes_formats¶
alias of
BytesFormats
- property call_data_dependent_preamble: Callable[[Value], tuple[str, ...]]¶
Return data-dependent preamble lines for call rendering.
- call_returns_expression = True¶
- call_style: CallStyles = PositionalCallStyle(arg_separator=', ', parenthesize_each_arg=False)¶
- property call_style_config: PositionalCallStyle | KeywordCallStyle | ObjectCallStyle | PostfixCallStyle | PrefixCallStyle | CommandCallStyle¶
Configuration for the chosen call style.
- call_styles¶
alias of
CallStyles
- property comment_config: CommentConfig¶
Configuration for the language’s comment syntax.
- comment_format: CommentFormats = CommentConfig(prefix='#', suffix='')¶
- comment_formats¶
alias of
CommentFormats
- property compute_body_preamble: Callable[[frozenset[type], Value], tuple[str, ...]]¶
Compute body-preamble lines from the scalar map.
- property consumable_ref_value_inhibits_consuming_form: Callable[[Value], bool]¶
Predicate deciding whether a ref’s underlying value type inhibits the consume form.
Delegates to
never_inhibits_consuming_form. Languages whose consume operator rejects certain value types (notably the Mojo^on register-trivial scalars) override this.
- property data_dependent_preamble: Callable[[Value], tuple[str, ...]]¶
Return data-dependent preamble lines.
- date_format: DateFormats = DateFormatConfig(formatter=<function date_ymd_formatter.<locals>._format>, preamble_lines=(), type_produced=<class 'datetime.date'>)¶
- date_formats¶
alias of
DateFormats
- datetime_format: DatetimeFormats = DatetimeFormatConfig(formatter=<function _format_datetime_raku>, preamble_lines=(), type_produced=<class 'datetime.datetime'>)¶
- datetime_formats¶
alias of
DatetimeFormats
- declaration_style: DeclarationStyles = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=True)¶
- declaration_styles¶
alias of
DeclarationStyles
- dict_entry_style: DictEntryStyles = 1¶
- dict_entry_styles¶
alias of
DictEntryStyles
- dict_format: DictFormats = 1¶
- property dict_format_config: DictFormatConfig¶
Configuration for dict formatting.
- dict_formats¶
alias of
DictFormats
- dict_supports_heterogeneous_values = True¶
- element_separator: ClassVar[str] = ', '¶
- empty_dict_keys¶
alias of
EmptyDictKey
- extension = '.raku'¶
- false_literal: ClassVar[str] = 'False'¶
- float_format: FloatFormats = <function format_float_repr>¶
- float_formats¶
alias of
FloatFormats
- property format_bytes: Callable[[bytes], str]¶
Callable that formats a bytes value as a string literal.
- static format_call_arg(_value: Value, formatted: str, /) str¶
Callable that rewrites a formatted direct call argument.
- property format_call_arg_ref_identifier: Callable[[str, Value | None], str]¶
Rewrite a
{"$ref": "name"}identifier in a call-argument context.Delegates to
format_call_ref_identifier. Override this to allow call-argument$refvalues that would otherwise be rejected.
- property format_call_arg_ref_identifier_consumable: Callable[[str, Value | None], str]¶
Format a
$refthe caller authorized as consumable.Delegates to
format_call_arg_ref_identifier. Override this to opt into a consuming form (e.g. C++std::move).
- format_call_binding_body_preamble() tuple[str, ...]¶
Default
format_call_binding_body_preamble– no extra body preamble lines for an inference-bound call result.
- format_call_binding_file_pragmas() tuple[str, ...]¶
Default
format_call_binding_file_pragmas– no file-level compiler-pragma line for an inference-bound call result.
- property format_call_preamble_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]¶
Return file-scope stubs for a call expression.
- property format_call_ref_identifier: Callable[[str, Value | None], str]¶
Rewrite a
{"$ref": "name"}identifier into the language’s call expression syntax.
- property format_call_statement: Callable[[str], str]¶
Return call-statement formatting for this language.
- property format_call_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]¶
Return stub declarations for a call expression.
- property format_call_target: Callable[[Sequence[str]], str]¶
Rewrite a dotted call target into the language’s call syntax.
- property format_call_variable_assignment: Callable[[str, str, Value], str]¶
Default
format_call_variable_assignment– reuse the literal-binding assignment formatter unchanged.
- property format_call_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]¶
Default
format_call_variable_declaration– reuse the literal-binding declaration formatter unchanged.
- static format_constructor_target(class_name: str, /) str¶
Return class_name as a zero-argument constructor call target.
- property format_date: Callable[[date], str]¶
Callable that formats a date as a string literal.
- property format_datetime: Callable[[datetime], str]¶
Callable that formats a datetime as a string literal.
- property format_float: Callable[[float], str]¶
Callable that formats a float value as a literal.
- property format_integer: Callable[[int], str]¶
Callable that formats an int value as a literal.
- property format_integer_widened: None¶
Default
format_integer_widened– no mixed-magnitude integer widening, so the renderer keeps the normal integer formatter.
- property format_ordered_map_entry: Callable[[str, Value, str], str]¶
Callable that formats one ordered-map entry.
- property format_sequence_entry: Callable[[Value, str], str]¶
Format a sequence entry.
- property format_set_entry: Callable[[Value, str], str]¶
Format a set entry.
- property format_string: Callable[[str], str]¶
Callable that formats a string value as a quoted literal.
- property format_time: Callable[[time], str]¶
Callable that formats a time as a string literal.
- property format_variable_assignment: Callable[[str, str, Value], str]¶
Format an assignment to an existing variable.
- property format_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]¶
Callable that formats a new variable declaration.
- has_free_function_calls = True¶
- property heterogeneous_behavior: HeterogeneousBehavior¶
Return the heterogeneous-behavior config.
- heterogeneous_strategies¶
alias of
HeterogeneousStrategies
- heterogeneous_strategy: HeterogeneousStrategies = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)¶
- identifier_cases: ClassVar[tuple[IdentifierCase, ...]] = (IdentifierCase.SNAKE, IdentifierCase.KEBAB)¶
- indent: str = ' '¶
- indent_closing_delimiter: ClassVar[bool] = False¶
- integer_format: IntegerFormats = mappingproxy({'NONE': <class 'str'>, 'UNDERSCORE': <function format_integer_underscore>})¶
- integer_formats¶
alias of
IntegerFormats
- integer_width_strategies¶
alias of
BareIntegerWidthStrategies
- integer_width_strategy: BareIntegerWidthStrategies = 1¶
- language_version: VersionFormats = 1¶
- property leading_preamble: LeadingPreamble¶
Default
leading_preamble– no preamble lines that must precedeLanguage.static_preamble.
- max_call_parameters = 9223372036854775807¶
- modifier_combinations: ClassVar[tuple[ModifierCombination, ...]] = ()¶
- null_literal: ClassVar[str] = 'Nil'¶
- numeric_literal_suffix: NumericLiteralSuffixes = 1¶
- numeric_literal_suffixes¶
alias of
NumericLiteralSuffixes
- numeric_separator: NumericSeparators = 1¶
- numeric_separators¶
alias of
NumericSeparators
- numeric_style: NumericStyles = 1¶
- numeric_styles¶
alias of
NumericStyles
- property ordered_map_format_config: OrderedMapFormatConfig¶
Configuration for ordered-map formatting.
- pygments_name = 'raku'¶
- reserved_identifiers: ClassVar[frozenset[str]] = frozenset({})¶
- scalar_body_preamble: ClassVar[dict[type, tuple[str, ...]]] = {}¶
- property scalar_preamble: dict[type, tuple[str, ...]]¶
Per-instance scalar preamble computed from date/datetime format.
- sequence_binding_declarations(declarations: tuple[str, ...]) str¶
Default
sequence_binding_declarations– join the per-binding snippets with newlines.
- sequence_format: SequenceFormats = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=']', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)¶
- property sequence_format_config: SequenceFormatConfig¶
Configuration for the chosen sequence format.
- sequence_formats¶
alias of
SequenceFormats
- property sequence_open: Callable[[list[Value]], str]¶
Callable that returns the opening delimiter for a sequence.
- set_format: SetFormats = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close=']', empty_set=None, preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)¶
- property set_format_config: SetFormatConfig¶
Configuration for the chosen set format.
- set_formats¶
alias of
SetFormats
- skip_null_dict_values: ClassVar[bool] = False¶
- special_float_preamble: ClassVar[tuple[str, ...]] = ()¶
- statement_terminator: ClassVar[str] = ';'¶
- statement_terminator_style: StatementTerminatorStyles = 1¶
- statement_terminator_styles¶
alias of
StatementTerminatorStyles
- static_body_preamble: ClassVar[Sequence[str]] = ()¶
- static_preamble: ClassVar[Sequence[str]] = ()¶
- string_format: StringFormats = <function format_string_backslash_single_minimal>¶
- string_formats¶
alias of
StringFormats
- supported_ref_cases: ClassVar[frozenset[IdentifierCase]] = frozenset({IdentifierCase.CAMEL, IdentifierCase.KEBAB, IdentifierCase.PASCAL, IdentifierCase.SNAKE, IdentifierCase.UPPER_SNAKE})¶
- supports_call_style = True¶
- supports_collection_comments: ClassVar[bool] = True¶
- supports_default_dict_key_type = False¶
- supports_default_dict_value_type = False¶
- supports_default_ordered_map_value_type = False¶
- supports_default_sequence_element_type = False¶
- supports_default_set_element_type = False¶
- supports_dict_literal_as_free_expression = True¶
- supports_dotted_call_stub = False¶
- supports_dotted_calls = True¶
- supports_empty_dict_key = False¶
- supports_inline_multiline_dict_args = True¶
- supports_module_name = False¶
- supports_multi_param_call_wrapper_stub = True¶
- supports_no_variable_wrap_in_file = True¶
- supports_non_string_dict_keys = True¶
- supports_record_shape_names = False¶
- supports_record_struct_name_prefix = False¶
- supports_scalar_before_comments: ClassVar[bool] = True¶
- supports_scalar_inline_comments: ClassVar[bool] = False¶
- supports_special_floats = True¶
- supports_standalone_comments_in_wrapped_calls = True¶
- supports_variable_names = True¶
- supports_zero_parameter_calls = True¶
- trailing_comma: TrailingCommas = TrailingCommaConfig(multiline_trailing_comma=True)¶
- property trailing_comma_config: TrailingCommaConfig¶
Configuration for trailing-comma behavior.
- trailing_commas¶
alias of
TrailingCommas
- true_literal: ClassVar[str] = 'True'¶
- property type_hint_collection_preamble_lines: Callable[[frozenset[type]], tuple[str, ...]]¶
Return preamble lines for empty-collection type hints.
- property validate_call_arg: Callable[[Value], None]¶
Return call-argument validation for this language.
- validate_spec_for_data(data: Value) None¶
Default
validate_spec_for_data— no spec/data constraints.
- variable_type_hints: VariableTypeHints = 1¶
- variable_type_hints_formats¶
alias of
VariableTypeHints
- version_formats¶
alias of
VersionFormats
- wrap_calls_with_declarations(declarations: tuple[str, ...], calls: str, body_preamble: tuple[str, ...]) str¶
Default
wrap_calls_with_declarations— concatenate the declarations and calls and route throughwrap_in_file()in call mode.
- static wrap_combined_in_file(declaration: str, assignment: str, variable_name: str, body_preamble: tuple[str, ...]) str¶
Wrap declaration and assignment in a valid file (no-op).
- static wrap_in_file(content: str, variable_name: str, body_preamble: tuple[str, ...]) str¶
Wrap code in a valid file (no-op).
- class literalizer.languages.Roc(*args: object, **kwargs: object)¶
Roc language specification.
The generated output uses custom tag constructors (
RNull,RBool,RList,RDict,RSet) that are wrapped in aValtag-union type alias emitted in the body preamble. For example, data consisting solely of an integer yields:Val : [ RInt I128, ]- Parameters:
date_format –
How to format
datetime.datevalues.date_formats.ISO— ISO 8601 string, e.g.RStr "2024-01-15".
datetime_format –
How to format
datetime.datetimevalues.datetime_formats.ISO— ISO 8601 string, e.g.RStr "2024-01-15T12:30:00".
type_name – Name of the generated tag-union alias. Defaults to
"Val".constructor_prefix – Prefix for generated constructor names. Defaults to
"R", producing constructors likeRNull,RBool,RInt, etc.
- class BoolFormats(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
Empty: this language has no alternative boolean formats.
- class BytesFormats(*values)¶
Bytes formatting options.
- BASE64 = <function _build_roc_bytes_base64.<locals>._format>¶
- HEX = <function _build_roc_bytes_hex.<locals>._format>¶
- class DateFormats(*values)¶
Date format options for Roc.
- ISO = DateFormatConfig(formatter=<function _build_roc_date_iso.<locals>._format>, preamble_lines=(), type_produced=<class 'str'>)¶
- class DatetimeFormats(*values)¶
Datetime format options for Roc.
- EPOCH = DatetimeFormatConfig(formatter=<function datetime_epoch_formatter.<locals>._format>, preamble_lines=(), type_produced=<class 'int'>)¶
- ISO = DatetimeFormatConfig(formatter=<function _build_roc_datetime_iso.<locals>._format>, preamble_lines=(), type_produced=<class 'str'>)¶
- class DeclarationStyles(*values)¶
Declaration style options.
- ASSIGN = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=False)¶
- class FloatFormats(*values)¶
Float format options.
- FIXED = <function _build_roc_float_formatter.<locals>._format>¶
- REPR = <function _build_roc_float_formatter.<locals>._format>¶
- SCIENTIFIC = <function _build_roc_float_formatter.<locals>._format>¶
- class HeterogeneousStrategies(*values)¶
Heterogeneous-scalar strategy options — this language only supports raising.
- ERROR = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)¶
- class IntegerFormats(*values)¶
Integer format options.
- BINARY = <function _build_roc_integer_formatter.<locals>._format>¶
- DECIMAL = <function _build_roc_integer_formatter.<locals>._format>¶
- HEX = <function _build_roc_integer_formatter.<locals>._format>¶
- OCTAL = <function _build_roc_integer_formatter.<locals>._format>¶
- class JsonTypes(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
Empty: this language has no JSON value-type variants.
- class Modifiers(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
C++/Java/C#-style declaration modifiers: this language has none.
- class SequenceFormats(*values)¶
Sequence type options for Roc.
- LIST = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=']', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)¶
- class SetFormats(*values)¶
Set type options for Roc.
- SET = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close=']', empty_set=None, preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)¶
- class TrailingCommas(*values)¶
Trailing comma options.
- NO = TrailingCommaConfig(multiline_trailing_comma=False)¶
- YES = TrailingCommaConfig(multiline_trailing_comma=True)¶
- allows_empty_call_parens = True¶
- bool_formats¶
alias of
BoolFormats
- bytes_format: BytesFormats = <function _build_roc_bytes_hex.<locals>._format>¶
- bytes_formats¶
alias of
BytesFormats
- property call_data_dependent_preamble: Callable[[Value], tuple[str, ...]]¶
Return data-dependent preamble lines for call rendering.
- call_returns_expression = True¶
- call_style: CallStyles = CommandCallStyle(arg_separator=' ')¶
- property call_style_config: PositionalCallStyle | KeywordCallStyle | ObjectCallStyle | PostfixCallStyle | PrefixCallStyle | CommandCallStyle¶
Configuration for the Roc call style.
- call_styles¶
alias of
CallStyles
- property comment_config: CommentConfig¶
Configuration for the language’s comment syntax.
- comment_format: CommentFormats = CommentConfig(prefix='#', suffix='')¶
- comment_formats¶
alias of
CommentFormats
- property compute_body_preamble: Callable[[frozenset[type], Value], tuple[str, ...]]¶
Emit the tag-union type alias for the types present in the data — placed inside
wrap_in_file()so it sits after the module header.
- constructor_prefix: str = 'R'¶
- property consumable_ref_value_inhibits_consuming_form: Callable[[Value], bool]¶
Predicate deciding whether a ref’s underlying value type inhibits the consume form.
Delegates to
never_inhibits_consuming_form. Languages whose consume operator rejects certain value types (notably the Mojo^on register-trivial scalars) override this.
- property data_dependent_preamble: Callable[[Value], tuple[str, ...]]¶
Return data-dependent preamble lines (none for Roc — the type alias is emitted via
compute_body_preamble()so it sits after the module header insidewrap_in_file()).
- date_format: DateFormats = DateFormatConfig(formatter=<function _build_roc_date_iso.<locals>._format>, preamble_lines=(), type_produced=<class 'str'>)¶
- date_formats¶
alias of
DateFormats
- datetime_format: DatetimeFormats = DatetimeFormatConfig(formatter=<function _build_roc_datetime_iso.<locals>._format>, preamble_lines=(), type_produced=<class 'str'>)¶
- datetime_formats¶
alias of
DatetimeFormats
- declaration_style: DeclarationStyles = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=False)¶
- declaration_styles¶
alias of
DeclarationStyles
- dict_entry_style: DictEntryStyles = 1¶
- dict_entry_styles¶
alias of
DictEntryStyles
- dict_format: DictFormats = 1¶
- property dict_format_config: DictFormatConfig¶
Configuration for dict formatting.
- dict_formats¶
alias of
DictFormats
- dict_supports_heterogeneous_values = True¶
- element_separator: ClassVar[str] = ', '¶
- empty_dict_keys¶
alias of
EmptyDictKey
- extension = '.roc'¶
- property false_literal: str¶
Literal representing
False.
- float_format: FloatFormats = <function _build_roc_float_formatter.<locals>._format>¶
- float_formats¶
alias of
FloatFormats
- property format_bytes: Callable[[bytes], str]¶
Callable that formats a bytes value as a string literal.
- property format_call_arg: Callable[[Value, str], str]¶
Wrap each call argument in parentheses for the Roc space-separated call syntax.
- property format_call_arg_ref_identifier: Callable[[str, Value | None], str]¶
Rewrite a
{"$ref": "name"}identifier in a call-argument context.Delegates to
format_call_ref_identifier. Override this to allow call-argument$refvalues that would otherwise be rejected.
- property format_call_arg_ref_identifier_consumable: Callable[[str, Value | None], str]¶
Format a
$refthe caller authorized as consumable.Delegates to
format_call_arg_ref_identifier. Override this to opt into a consuming form (e.g. C++std::move).
- format_call_binding_body_preamble() tuple[str, ...]¶
Default
format_call_binding_body_preamble– no extra body preamble lines for an inference-bound call result.
- format_call_binding_file_pragmas() tuple[str, ...]¶
Default
format_call_binding_file_pragmas– no file-level compiler-pragma line for an inference-bound call result.
- property format_call_preamble_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]¶
Return file-scope stubs for a call expression.
- property format_call_ref_identifier: Callable[[str, Value | None], str]¶
Rewrite a
{"$ref": "name"}identifier into the language’s call expression syntax.
- property format_call_statement: Callable[[str], str]¶
Return call-statement formatting for this language.
- property format_call_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]¶
Return stub declarations for a call expression — emitted via
body_preambleso they sit after the module header.
- property format_call_target: Callable[[Sequence[str]], str]¶
Rewrite a dotted call target into a Roc identifier.
- property format_call_variable_assignment: Callable[[str, str, Value], str]¶
Default
format_call_variable_assignment– reuse the literal-binding assignment formatter unchanged.
- property format_call_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]¶
Callable that formats a declaration binding a call expression.
The literal-binding declaration emits a
name : Valannotation derived from the bound value’s runtime tag-union type; a call expression has no such tag, so the annotation is omitted and Roc infers the call’s return type instead.
- static format_constructor_target(class_name: str, /) str¶
Return class_name as a zero-argument constructor call target.
- property format_date: Callable[[date], str]¶
Callable that formats a date as a string literal.
- property format_datetime: Callable[[datetime], str]¶
Callable that formats a datetime as a string literal.
- property format_float: Callable[[float], str]¶
Callable that formats a float value as a literal.
- property format_integer: Callable[[int], str]¶
Callable that formats an int value as a literal.
- property format_integer_widened: None¶
Default
format_integer_widened– no mixed-magnitude integer widening, so the renderer keeps the normal integer formatter.
- property format_ordered_map_entry: Callable[[str, Value, str], str]¶
Callable that formats one ordered-map entry.
- property format_sequence_entry: Callable[[Value, str], str]¶
Format a sequence entry.
- property format_set_entry: Callable[[Value, str], str]¶
Format a set entry.
- property format_string: Callable[[str], str]¶
Callable that formats a string value as a quoted literal.
- property format_time: Callable[[time], str]¶
Callable that formats a time as a string literal.
- property format_variable_assignment: Callable[[str, str, Value], str]¶
Callable that formats an assignment to an existing variable.
- property format_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]¶
Callable that formats a new variable declaration.
- has_free_function_calls = True¶
- property heterogeneous_behavior: HeterogeneousBehavior¶
Return the heterogeneous-behavior config.
- heterogeneous_strategies¶
alias of
HeterogeneousStrategies
- heterogeneous_strategy: HeterogeneousStrategies = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)¶
- identifier_cases: ClassVar[tuple[IdentifierCase, ...]] = (IdentifierCase.SNAKE, IdentifierCase.PASCAL)¶
- indent: str = ' '¶
- indent_closing_delimiter: ClassVar[bool] = True¶
- integer_format: IntegerFormats = <function _build_roc_integer_formatter.<locals>._format>¶
- integer_formats¶
alias of
IntegerFormats
- integer_width_strategies¶
alias of
BareIntegerWidthStrategies
- integer_width_strategy: BareIntegerWidthStrategies = 1¶
- language_version: VersionFormats = 1¶
- property leading_preamble: LeadingPreamble¶
Default
leading_preamble– no preamble lines that must precedeLanguage.static_preamble.
- max_call_parameters = 9223372036854775807¶
- modifier_combinations: ClassVar[tuple[ModifierCombination, ...]] = ()¶
- property null_literal: str¶
Literal representing
None.
- numeric_literal_suffix: NumericLiteralSuffixes = 1¶
- numeric_literal_suffixes¶
alias of
NumericLiteralSuffixes
- numeric_separator: NumericSeparators = 1¶
- numeric_separators¶
alias of
NumericSeparators
- numeric_style: NumericStyles = 1¶
- numeric_styles¶
alias of
NumericStyles
- property ordered_map_format_config: OrderedMapFormatConfig¶
Configuration for ordered-map formatting.
- pygments_name = 'text'¶
- reserved_identifiers: ClassVar[frozenset[str]] = frozenset({})¶
- property scalar_body_preamble: dict[type, tuple[str, ...]]¶
Per-instance scalar body preamble (Roc needs none).
- property scalar_preamble: dict[type, tuple[str, ...]]¶
Per-instance scalar preamble (Roc needs none).
- sequence_binding_declarations(declarations: tuple[str, ...]) str¶
Default
sequence_binding_declarations– join the per-binding snippets with newlines.
- sequence_format: SequenceFormats = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=']', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)¶
- property sequence_format_config: SequenceFormatConfig¶
Configuration for the chosen sequence format.
- sequence_formats¶
alias of
SequenceFormats
- property sequence_open: Callable[[list[Value]], str]¶
Callable that returns the opening delimiter for a sequence.
- set_format: SetFormats = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close=']', empty_set=None, preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)¶
- property set_format_config: SetFormatConfig¶
Configuration for the chosen set format.
- set_formats¶
alias of
SetFormats
- skip_null_dict_values: ClassVar[bool] = False¶
- special_float_preamble: ClassVar[tuple[str, ...]] = ()¶
- statement_terminator: ClassVar[str] = ''¶
- statement_terminator_style: StatementTerminatorStyles = 1¶
- statement_terminator_styles¶
alias of
StatementTerminatorStyles
- static_body_preamble: ClassVar[Sequence[str]] = ()¶
- static_preamble: ClassVar[Sequence[str]] = ()¶
- string_format: StringFormats = 1¶
- string_formats¶
alias of
StringFormats
- supported_ref_cases: ClassVar[frozenset[IdentifierCase]] = frozenset({IdentifierCase.CAMEL, IdentifierCase.PASCAL, IdentifierCase.SNAKE, IdentifierCase.UPPER_SNAKE})¶
- supports_call_style = True¶
- supports_collection_comments: ClassVar[bool] = True¶
- supports_default_dict_key_type = False¶
- supports_default_dict_value_type = False¶
- supports_default_ordered_map_value_type = False¶
- supports_default_sequence_element_type = False¶
- supports_default_set_element_type = False¶
- supports_dict_literal_as_free_expression = True¶
- supports_dotted_call_stub = False¶
- supports_dotted_calls = True¶
- supports_empty_dict_key = False¶
- supports_inline_multiline_dict_args = True¶
- supports_module_name = False¶
- supports_multi_param_call_wrapper_stub = True¶
- supports_no_variable_wrap_in_file = False¶
- supports_non_string_dict_keys = False¶
- supports_record_shape_names = False¶
- supports_record_struct_name_prefix = False¶
- supports_scalar_before_comments: ClassVar[bool] = True¶
- supports_scalar_inline_comments: ClassVar[bool] = True¶
- supports_special_floats = True¶
- supports_standalone_comments_in_wrapped_calls = False¶
- supports_variable_names = True¶
- supports_zero_parameter_calls = True¶
- trailing_comma: TrailingCommas = TrailingCommaConfig(multiline_trailing_comma=True)¶
- property trailing_comma_config: TrailingCommaConfig¶
Configuration for trailing-comma behavior.
- trailing_commas¶
alias of
TrailingCommas
- property true_literal: str¶
Literal representing
True.
- property type_hint_collection_preamble_lines: Callable[[frozenset[type]], tuple[str, ...]]¶
Return preamble lines for empty-collection type hints.
- type_name: str = 'Val'¶
- property validate_call_arg: Callable[[Value], None]¶
Return call-argument validation for this language.
- validate_spec_for_data(data: Value) None¶
Default
validate_spec_for_data— no spec/data constraints.
- variable_type_hints: VariableTypeHints = 1¶
- variable_type_hints_formats¶
alias of
VariableTypeHints
- version_formats¶
alias of
VersionFormats
- wrap_calls_with_declarations(declarations: tuple[str, ...], calls: str, body_preamble: tuple[str, ...]) str¶
Wrap Roc declarations and call expressions in a module.
Declarations (variable bindings spanning multiple lines) are kept verbatim at module scope alongside the
Valtype alias and call stubs; only the top-level call lines insidemainare wrapped indbg (...).
- static wrap_combined_in_file(declaration: str, assignment: str, variable_name: str, body_preamble: tuple[str, ...]) str¶
Unsupported: literalize() rejects BothVariableForms upstream.
- wrap_in_file(content: str, variable_name: str, body_preamble: tuple[str, ...]) str¶
Wrap a Roc value declaration in a module.
The module exposes variable_name (or
mainwhen empty, in call mode) so the file is a syntactically valid Roc module. Body-preamble lines (theValtype alias and any call stubs) sit at module scope after the header. In call mode each top-level call expression is wrapped indbg (...)insidemain: a plain_ = pure_callwould trip the RocUNNECESSARY DEFINITIONwarning, whichroc checkexits non-zero on, whereasdbgis treated as side effecting.The
Valtype alias is kept only when the wrapped output actually annotates a binding with: Val(the literal-binding declarationmy_data : Val). It is dropped for every call mode – both the discarded-result form (exposedmain) and the inference-style call bindingmy_data = make_widget ...whose right-hand side is a call expression with no tag, hence no annotation. Keeping an alias nothing uses would trip the RocUNUSED DEFINITIONwarning, whichroc checkexits non-zero on, when the alias has no recursive (List/Dict/Set) self-reference for the compiler to consider load-bearing.
- class literalizer.languages.Ruby(*args: object, **kwargs: object)¶
Ruby language specification.
- Parameters:
date_format –
How to format
datetime.datevalues.date_formats.RUBY—Date.new(...)call, e.g.Date.new(2024, 1, 15).date_formats.ISO— ISO 8601 quoted string, e.g."2024-01-15".
datetime_format –
How to format
datetime.datetimevalues.datetime_formats.RUBY—Time.new(...)call, e.g.Time.new(2024, 1, 15, 12, 30, 0).datetime_formats.ISO— ISO 8601 quoted string, e.g."2024-01-15T12:30:00".
dict_entry_style –
How to format dict/hash entries.
dict_entry_styles.ROCKET— rocket notation, e.g."name" => "Alice".dict_entry_styles.SYMBOL— symbol notation, e.g.name: "Alice".
- class BoolFormats(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
Empty: this language has no alternative boolean formats.
- class BytesFormats(*values)¶
Bytes formatting options.
- BASE64 = <function format_bytes_base64>¶
- HEX = <function format_bytes_hex>¶
- class CallStyles(*values)¶
Ruby call style options.
- KEYWORD = KeywordCallStyle(separator=': ')¶
- POSITIONAL = PositionalCallStyle(arg_separator=', ', parenthesize_each_arg=False)¶
- class DateFormats(*values)¶
Date format options for Ruby.
- ISO = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- RUBY = DateFormatConfig(formatter=<function date_ymd_formatter.<locals>._format>, preamble_lines=("require 'date'",), type_produced=<class 'datetime.date'>)¶
- class DatetimeFormats(*values)¶
Datetime format options for Ruby.
- EPOCH = DatetimeFormatConfig(formatter=<function format_datetime_epoch>, preamble_lines=(), type_produced=<class 'int'>)¶
- ISO = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- RUBY = DatetimeFormatConfig(formatter=<function _format_datetime_ruby>, preamble_lines=(), type_produced=<class 'datetime.datetime'>)¶
- class DeclarationStyles(*values)¶
Declaration style options.
- ASSIGN = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=True)¶
- class DictEntryStyles(*values)¶
Dict entry style options for Ruby.
ROCKET— rocket notation, e.g."key" => "value".SYMBOL— symbol notation, e.g.key: "value".
- ROCKET = (<function dict_entry_with_separator.<locals>._format>,)¶
- SYMBOL = (<function dict_entry_symbol_style.<locals>._format>,)¶
- class FloatFormats(*values)¶
Float format options.
- FIXED = <function format_float_fixed>¶
- REPR = <function format_float_repr>¶
- SCIENTIFIC = <function format_float_scientific>¶
- class HeterogeneousStrategies(*values)¶
Heterogeneous-scalar strategy options — this language only supports raising.
- ERROR = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)¶
- class IntegerFormats(*values)¶
Integer format options.
- BINARY = mappingproxy({'NONE': <function format_integer_binary>, 'UNDERSCORE': <function format_integer_binary>})¶
- DECIMAL = mappingproxy({'NONE': <class 'str'>, 'UNDERSCORE': <function format_integer_underscore>})¶
- HEX = mappingproxy({'NONE': <function format_integer_hex>, 'UNDERSCORE': <function format_integer_hex>})¶
- OCTAL = mappingproxy({'NONE': <function format_integer_octal>, 'UNDERSCORE': <function format_integer_octal>})¶
- get_formatter(numeric_separator: Enum) Callable[[int], str]¶
Return the integer formatter for the given separator.
- class JsonTypes(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
Empty: this language has no JSON value-type variants.
- class Modifiers(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
C++/Java/C#-style declaration modifiers: this language has none.
- class SequenceFormats(*values)¶
Sequence type options for Ruby.
- ARRAY = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=']', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)¶
- class SetFormats(*values)¶
Set type options for Ruby.
- SET = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close='])', empty_set='Set.new', preamble_lines=("require 'set'",), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)¶
- class StringFormats(*values)¶
String format options.
- DOUBLE = <function _build_backslash_formatter.<locals>._format>¶
- SINGLE = <function format_string_backslash_single_minimal>¶
- class TrailingCommas(*values)¶
Trailing comma options.
- NO = TrailingCommaConfig(multiline_trailing_comma=False)¶
- YES = TrailingCommaConfig(multiline_trailing_comma=True)¶
- allows_empty_call_parens = True¶
- bool_formats¶
alias of
BoolFormats
- bytes_format: BytesFormats = <function format_bytes_hex>¶
- bytes_formats¶
alias of
BytesFormats
- property call_data_dependent_preamble: Callable[[Value], tuple[str, ...]]¶
Return data-dependent preamble lines for call rendering.
- call_returns_expression = True¶
- call_style: CallStyles = KeywordCallStyle(separator=': ')¶
- property call_style_config: PositionalCallStyle | KeywordCallStyle | ObjectCallStyle | PostfixCallStyle | PrefixCallStyle | CommandCallStyle¶
Configuration for the chosen call style.
- call_styles¶
alias of
CallStyles
- property comment_config: CommentConfig¶
Configuration for the language’s comment syntax.
- comment_format: CommentFormats = CommentConfig(prefix='#', suffix='')¶
- comment_formats¶
alias of
CommentFormats
- property compute_body_preamble: Callable[[frozenset[type], Value], tuple[str, ...]]¶
Compute body-preamble lines from the scalar map.
- property consumable_ref_value_inhibits_consuming_form: Callable[[Value], bool]¶
Predicate deciding whether a ref’s underlying value type inhibits the consume form.
Delegates to
never_inhibits_consuming_form. Languages whose consume operator rejects certain value types (notably the Mojo^on register-trivial scalars) override this.
- property data_dependent_preamble: Callable[[Value], tuple[str, ...]]¶
Return data-dependent preamble lines.
- date_format: DateFormats = DateFormatConfig(formatter=<function date_ymd_formatter.<locals>._format>, preamble_lines=("require 'date'",), type_produced=<class 'datetime.date'>)¶
- date_formats¶
alias of
DateFormats
- datetime_format: DatetimeFormats = DatetimeFormatConfig(formatter=<function _format_datetime_ruby>, preamble_lines=(), type_produced=<class 'datetime.datetime'>)¶
- datetime_formats¶
alias of
DatetimeFormats
- declaration_style: DeclarationStyles = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=True)¶
- declaration_styles¶
alias of
DeclarationStyles
- dict_entry_style: DictEntryStyles = (<function dict_entry_with_separator.<locals>._format>,)¶
- dict_entry_styles¶
alias of
DictEntryStyles
- dict_format: DictFormats = 1¶
- property dict_format_config: DictFormatConfig¶
Configuration for dict formatting.
- dict_formats¶
alias of
DictFormats
- dict_supports_heterogeneous_values = True¶
- element_separator: ClassVar[str] = ', '¶
- empty_dict_keys¶
alias of
EmptyDictKey
- extension = '.rb'¶
- false_literal: ClassVar[str] = 'false'¶
- float_format: FloatFormats = <function format_float_repr>¶
- float_formats¶
alias of
FloatFormats
- property format_bytes: Callable[[bytes], str]¶
Callable that formats a bytes value as a string literal.
- static format_call_arg(_value: Value, formatted: str, /) str¶
Callable that rewrites a formatted direct call argument.
- property format_call_arg_ref_identifier: Callable[[str, Value | None], str]¶
Rewrite a
{"$ref": "name"}call-argument identifier.Unlike
format_call_ref_identifier, this is used only when the$refappears as a direct call argument (vialiteralize_call()). In that context the referenced variable has already been emitted at the same top-level scope, so the reference is valid.
- property format_call_arg_ref_identifier_consumable: Callable[[str, Value | None], str]¶
Format a
$refthe caller authorized as consumable.Delegates to
format_call_arg_ref_identifier. Override this to opt into a consuming form (e.g. C++std::move).
- format_call_binding_body_preamble() tuple[str, ...]¶
Default
format_call_binding_body_preamble– no extra body preamble lines for an inference-bound call result.
- format_call_binding_file_pragmas() tuple[str, ...]¶
Default
format_call_binding_file_pragmas– no file-level compiler-pragma line for an inference-bound call result.
- property format_call_preamble_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]¶
Return file-scope stubs for a call expression.
- property format_call_ref_identifier: Callable[[str, Value | None], str]¶
Raise for any
{"$ref": "name"}identifier.Ruby output is not wrapped in a function body; variable references require a surrounding assignment that cannot be injected via the call framework.
- property format_call_statement: Callable[[str], str]¶
Return call-statement formatting for this language.
- property format_call_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]¶
Return stub declarations for a call expression.
- property format_call_target: Callable[[Sequence[str]], str]¶
Rewrite a dotted call target into the language’s call syntax.
- property format_call_variable_assignment: Callable[[str, str, Value], str]¶
Default
format_call_variable_assignment– reuse the literal-binding assignment formatter unchanged.
- property format_call_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]¶
Default
format_call_variable_declaration– reuse the literal-binding declaration formatter unchanged.
- static format_constructor_target(class_name: str, /) str¶
Return a Ruby
ClassName.newconstructor call target.
- property format_date: Callable[[date], str]¶
Callable that formats a date as a string literal.
- property format_datetime: Callable[[datetime], str]¶
Callable that formats a datetime as a string literal.
- property format_float: Callable[[float], str]¶
Callable that formats a float value as a literal.
- property format_integer: Callable[[int], str]¶
Callable that formats an int value as a literal.
- property format_integer_widened: None¶
Default
format_integer_widened– no mixed-magnitude integer widening, so the renderer keeps the normal integer formatter.
- property format_ordered_map_entry: Callable[[str, Value, str], str]¶
Callable that formats one ordered-map entry.
- property format_sequence_entry: Callable[[Value, str], str]¶
Format a sequence entry.
- property format_set_entry: Callable[[Value, str], str]¶
Format a set entry.
- property format_string: Callable[[str], str]¶
Callable that formats a string value as a quoted literal.
- property format_time: Callable[[time], str]¶
Callable that formats a time as a string literal.
- property format_variable_assignment: Callable[[str, str, Value], str]¶
Callable that formats an assignment to an existing variable.
- property format_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]¶
Callable that formats a new variable declaration.
- has_free_function_calls = True¶
- property heterogeneous_behavior: HeterogeneousBehavior¶
Return the heterogeneous-behavior config.
- heterogeneous_strategies¶
alias of
HeterogeneousStrategies
- heterogeneous_strategy: HeterogeneousStrategies = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)¶
- identifier_cases: ClassVar[tuple[IdentifierCase, ...]] = (IdentifierCase.SNAKE, IdentifierCase.UPPER_SNAKE, IdentifierCase.PASCAL)¶
- indent: str = ' '¶
- indent_closing_delimiter: ClassVar[bool] = False¶
- integer_format: IntegerFormats = mappingproxy({'NONE': <class 'str'>, 'UNDERSCORE': <function format_integer_underscore>})¶
- integer_formats¶
alias of
IntegerFormats
- integer_width_strategies¶
alias of
BareIntegerWidthStrategies
- integer_width_strategy: BareIntegerWidthStrategies = 1¶
- language_version: VersionFormats = 1¶
- property leading_preamble: LeadingPreamble¶
Default
leading_preamble– no preamble lines that must precedeLanguage.static_preamble.
- max_call_parameters = 9223372036854775807¶
- modifier_combinations: ClassVar[tuple[ModifierCombination, ...]] = ()¶
- null_literal: ClassVar[str] = 'nil'¶
- numeric_literal_suffix: NumericLiteralSuffixes = 1¶
- numeric_literal_suffixes¶
alias of
NumericLiteralSuffixes
- numeric_separator: NumericSeparators = 1¶
- numeric_separators¶
alias of
NumericSeparators
- numeric_style: NumericStyles = 1¶
- numeric_styles¶
alias of
NumericStyles
- property ordered_map_format_config: OrderedMapFormatConfig¶
Configuration for ordered-map formatting.
- pygments_name = 'ruby'¶
- reserved_identifiers: ClassVar[frozenset[str]] = frozenset({})¶
- property scalar_body_preamble: dict[type, tuple[str, ...]]¶
Per-instance scalar body preamble (Ruby needs none).
- property scalar_preamble: dict[type, tuple[str, ...]]¶
Per-instance scalar preamble computed from date/datetime format.
- sequence_binding_declarations(declarations: tuple[str, ...]) str¶
Default
sequence_binding_declarations– join the per-binding snippets with newlines.
- sequence_format: SequenceFormats = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=']', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)¶
- property sequence_format_config: SequenceFormatConfig¶
Configuration for the chosen sequence format.
- sequence_formats¶
alias of
SequenceFormats
- property sequence_open: Callable[[list[Value]], str]¶
Callable that returns the opening delimiter for a sequence.
- set_format: SetFormats = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close='])', empty_set='Set.new', preamble_lines=("require 'set'",), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)¶
- property set_format_config: SetFormatConfig¶
Configuration for the chosen set format.
- set_formats¶
alias of
SetFormats
- skip_null_dict_values: ClassVar[bool] = False¶
- special_float_preamble: ClassVar[tuple[str, ...]] = ()¶
- statement_terminator: ClassVar[str] = ''¶
- statement_terminator_style: StatementTerminatorStyles = 1¶
- statement_terminator_styles¶
alias of
StatementTerminatorStyles
- static_body_preamble: ClassVar[Sequence[str]] = ()¶
- static_preamble: ClassVar[Sequence[str]] = ()¶
- string_format: StringFormats = <function _build_backslash_formatter.<locals>._format>¶
- string_formats¶
alias of
StringFormats
- supported_ref_cases: ClassVar[frozenset[IdentifierCase]] = frozenset({IdentifierCase.CAMEL, IdentifierCase.PASCAL, IdentifierCase.SNAKE, IdentifierCase.UPPER_SNAKE})¶
- supports_call_style = True¶
- supports_collection_comments: ClassVar[bool] = True¶
- supports_default_dict_key_type = False¶
- supports_default_dict_value_type = False¶
- supports_default_ordered_map_value_type = False¶
- supports_default_sequence_element_type = False¶
- supports_default_set_element_type = False¶
- supports_dict_literal_as_free_expression = True¶
- supports_dotted_call_stub = True¶
- supports_dotted_calls = True¶
- supports_empty_dict_key = False¶
- supports_inline_multiline_dict_args = True¶
- supports_module_name = False¶
- supports_multi_param_call_wrapper_stub = True¶
- supports_no_variable_wrap_in_file = True¶
- supports_non_string_dict_keys = True¶
- supports_record_shape_names = False¶
- supports_record_struct_name_prefix = False¶
- supports_scalar_before_comments: ClassVar[bool] = True¶
- supports_scalar_inline_comments: ClassVar[bool] = True¶
- supports_special_floats = True¶
- supports_standalone_comments_in_wrapped_calls = True¶
- supports_variable_names = True¶
- supports_zero_parameter_calls = True¶
- trailing_comma: TrailingCommas = TrailingCommaConfig(multiline_trailing_comma=True)¶
- property trailing_comma_config: TrailingCommaConfig¶
Configuration for trailing-comma behavior.
- trailing_commas¶
alias of
TrailingCommas
- true_literal: ClassVar[str] = 'true'¶
- property type_hint_collection_preamble_lines: Callable[[frozenset[type]], tuple[str, ...]]¶
Return preamble lines for empty-collection type hints.
- property validate_call_arg: Callable[[Value], None]¶
Return call-argument validation for this language.
- validate_spec_for_data(data: Value) None¶
Default
validate_spec_for_data— no spec/data constraints.
- variable_type_hints: VariableTypeHints = 1¶
- variable_type_hints_formats¶
alias of
VariableTypeHints
- version_formats¶
alias of
VersionFormats
- wrap_calls_with_declarations(declarations: tuple[str, ...], calls: str, body_preamble: tuple[str, ...]) str¶
Default
wrap_calls_with_declarations— concatenate the declarations and calls and route throughwrap_in_file()in call mode.
- static wrap_combined_in_file(declaration: str, assignment: str, variable_name: str, body_preamble: tuple[str, ...]) str¶
Wrap declaration and assignment in a valid file (no-op).
- static wrap_in_file(content: str, variable_name: str, body_preamble: tuple[str, ...]) str¶
Wrap code in a valid file (no-op).
- class literalizer.languages.Rust(*args: object, **kwargs: object)¶
Rust language specification.
- Parameters:
date_format –
How to format
datetime.datevalues.date_formats.RUST—NaiveDate::from_ymd_opt(...)call, e.g.NaiveDate::from_ymd_opt(2024, 1, 15).unwrap(). Requires thechronocrate.date_formats.ISO— ISO 8601 quoted string, e.g."2024-01-15".
datetime_format –
How to format
datetime.datetimevalues.datetime_formats.RUST—NaiveDateTime::new(...)call, e.g.NaiveDateTime::new(NaiveDate::from_ymd_opt(2024, 1, 15) .unwrap(), NaiveTime::from_hms_opt(12, 30, 0).unwrap()). Requires thechronocrate.datetime_formats.ISO— ISO 8601 quoted string, e.g."2024-01-15T12:30:00".
sequence_format –
Which Rust sequence type to use.
sequence_formats.VEC—vec![]macro, e.g.vec![1, 2, 3]. BecauseVecis homogeneous, heterogeneous-scalar inputs raise.sequence_formats.ARRAY— fixed-size array literal, e.g.[1, 2, 3]. Because Rust arrays are homogeneous, heterogeneous-scalar inputs raise.sequence_formats.TUPLE— tuple literal, e.g.(1, 2, 3).
default_sequence_element_type – Type name used for empty
Vecliterals, e.g.Vec::<String>::new(). Defaults to"String".json_type – When set to
json_types.SERDE_JSON_VALUE, render values throughserde_json::json!instead of Rust’s narrow collection types.
- class BoolFormats(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
Empty: this language has no alternative boolean formats.
- class BytesFormats(*values)¶
Bytes formatting options.
- BASE64 = <function format_bytes_base64>¶
- HEX = <function format_bytes_hex>¶
- class CallStyles(*values)¶
Rust call style options.
- POSITIONAL = PositionalCallStyle(arg_separator=', ', parenthesize_each_arg=False)¶
- class CommentFormats(*values)¶
Comment style options.
- BLOCK = CommentConfig(prefix='/*', suffix=' */')¶
- DOUBLE_SLASH = CommentConfig(prefix='//', suffix='')¶
- class DateFormats(*values)¶
Date format options for Rust.
- ISO = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- RUST = DateFormatConfig(formatter=<function _format_date_rust>, preamble_lines=('use chrono::NaiveDate;',), type_produced=<class 'datetime.date'>)¶
- class DatetimeFormats(*values)¶
Datetime format options for Rust.
- EPOCH = DatetimeFormatConfig(formatter=<function format_datetime_epoch>, preamble_lines=(), type_produced=<class 'int'>)¶
- ISO = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- RUST = DatetimeFormatConfig(formatter=<function _format_datetime_rust>, preamble_lines=('use chrono::NaiveDate;', 'use chrono::NaiveDateTime;', 'use chrono::NaiveTime;'), type_produced=<class 'datetime.datetime'>)¶
- class DeclarationStyles(*values)¶
Declaration style options.
- CONST = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=False)¶
- LAZY_STATIC = DeclarationStyleConfig(formatter=<function _lazy_static_placeholder_formatter>, supports_redefinition=False)¶
- LET = DeclarationStyleConfig(formatter=<function _format_let_declaration>, supports_redefinition=False)¶
- LET_MUT = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=True)¶
- STATIC = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=False)¶
- build_formatter(*, date_type: str, datetime_type: str, sequence_format_type_annotation: Callable[[str, int], str], sequence_supports_heterogeneity: bool, set_format_type_annotation: Callable[[str], str], dict_format_type_annotation: Callable[[str, str], str], default_sequence_element_type: str, default_set_element_type: str, default_dict_key_type: str, default_dict_value_type: str) Callable[[str, str, Value, frozenset[Enum]], str]¶
Return a formatter for this declaration style.
For
LETandLET_MUTthe formatter is used directly. ForCONSTandSTATICa type-annotated formatter is built from the language configuration.LAZY_STATICadditionally wraps the inferred type inLazyLock<…>and the value in aLazyLock::new(|| …)call, enabling module-level declarations of runtime-initialized collections likeHashMapandVec.
- class DictFormats(*values)¶
Dict/map format options.
- BTREE_MAP = <function dict_format_factory.<locals>._build>¶
- HASH_MAP = <function dict_format_factory.<locals>._build>¶
- format_type_annotation(key_type: str, value_type: str) str¶
Return the Rust type annotation for this dict format.
- class FloatFormats(*values)¶
Float format options.
- FIXED = <function format_float_fixed>¶
- REPR = <function format_float_repr>¶
- SCIENTIFIC = <function format_float_scientific>¶
- class HeterogeneousStrategies(*values)¶
Strategy for representing dicts or lists whose scalar values span more than one Rust type.
- ERROR = _HeterogeneousStrategyConfig(build_behavior=<function _build_error_behavior>, build_preamble=<function _build_error_preamble>)¶
Raise
HeterogeneousScalarCollectionError(orHeterogeneousSiblingListsError) when scalar values of mixed types appear in a container that cannot represent them. This is the default, matching Rust’s strict-typing convention.
- RECORD = _HeterogeneousStrategyConfig(build_behavior=<function _build_record_behavior>, build_preamble=<function _build_record_preamble>)¶
Render record-shaped dicts (non-empty, string-keyed) as generated
structliterals.Each distinct ordered-key tuple becomes a struct declared in the preamble (
struct Record0 { field: Type, ... }) and each matching dict in the data renders as a struct literal (Record0 { field: value, ... }) rather than aHashMap::from([...])call. Useful for inputs whose dict values span multiple Rust scalar types but always share the same field set. The prefix is configurable viaRust.record_struct_name_prefix.
- TAGGED_ENUM = _HeterogeneousStrategyConfig(build_behavior=<function _build_tagged_enum_behavior>, build_preamble=<function _build_tagged_enum_preamble>)¶
Auto-generate a tagged
enumin the preamble containing only the variants actually present in the data, and wrap each heterogeneous scalar value with{EnumName}::{Variant}(value).Integer variants use narrowest-width names (
I32,I64,I128) matching Rust’s default integer-type inference. The enum name is configurable viaRust.heterogeneous_value_enum_name.
- TUPLE = _HeterogeneousStrategyConfig(build_behavior=<function _build_tuple_behavior>, build_preamble=<function _build_tuple_preamble>)¶
Render a fixed-length heterogeneous scalar array (a dict value, record field value, or the document root, all elements scalar and spanning at least two scalar buckets) as a native Rust tuple
(e0, e1, ...)typed(T0, T1, ...)instead of rejecting it.Composes with
RECORD: a record field whose value is such an array becomes a tuple-typed struct field (e.g.struct Record0 { call: &'static str, args: (i32, &'static str, &'static str, i32) }). Heterogeneous arrays nested inside another list, or containing a non-scalar element, are out of scope and still raise. Rust tuples have no length limit.
- class IntegerFormats(*values)¶
Integer format options.
- BINARY = mappingproxy({'NONE': <function format_integer_binary>, 'UNDERSCORE': <function format_integer_binary>})¶
- DECIMAL = mappingproxy({'NONE': <class 'str'>, 'UNDERSCORE': <function format_integer_underscore>})¶
- HEX = mappingproxy({'NONE': <function format_integer_hex>, 'UNDERSCORE': <function format_integer_hex>})¶
- OCTAL = mappingproxy({'NONE': <function format_integer_octal>, 'UNDERSCORE': <function format_integer_octal>})¶
- get_formatter(numeric_separator: Enum) Callable[[int], str]¶
Return the integer formatter for the given separator.
- class JsonTypes(*values)¶
JSON value type options for Rust.
- SERDE_JSON_VALUE = 'serde_json::Value'¶
Serde’s dynamic JSON value type.
- Modifiers¶
alias of
_RustModifiers
- class SequenceFormats(*values)¶
Sequence type options for Rust.
- ARRAY = <function sequence_format_factory.<locals>._build>¶
- TUPLE = <function sequence_format_factory.<locals>._build>¶
- VEC = <function sequence_format_factory.<locals>._build>¶
- format_type_annotation(element_type: str, length: int) str¶
Return the Rust type annotation for this format.
- property supports_heterogeneity: bool¶
Whether this sequence format supports mixed-type elements.
- class SetFormats(*values)¶
Set type options for Rust.
- BTREE_SET = <function set_format_factory.<locals>._build>¶
- HASH_SET = <function set_format_factory.<locals>._build>¶
- format_type_annotation(element_type: str) str¶
Return the Rust type annotation for this set format.
- class StringFormats(*values)¶
String format options.
- DOUBLE = <function _build_backslash_formatter.<locals>._format>¶
- RAW = <function format_string_raw_rust>¶
- class TrailingCommas(*values)¶
Trailing comma options.
- NO = TrailingCommaConfig(multiline_trailing_comma=False)¶
- YES = TrailingCommaConfig(multiline_trailing_comma=True)¶
- allows_empty_call_parens = True¶
- bool_formats¶
alias of
BoolFormats
- bytes_format: BytesFormats = <function format_bytes_hex>¶
- bytes_formats¶
alias of
BytesFormats
- property call_data_dependent_preamble: Callable[[Value], tuple[str, ...]]¶
Return data-dependent preamble lines for call rendering.
- call_returns_expression = True¶
- call_style: CallStyles = PositionalCallStyle(arg_separator=', ', parenthesize_each_arg=False)¶
- property call_style_config: PositionalCallStyle | KeywordCallStyle | ObjectCallStyle | PostfixCallStyle | PrefixCallStyle | CommandCallStyle¶
Configuration for the chosen call style.
- call_styles¶
alias of
CallStyles
- property comment_config: CommentConfig¶
Configuration for the language’s comment syntax.
- comment_format: CommentFormats = CommentConfig(prefix='//', suffix='')¶
- comment_formats¶
alias of
CommentFormats
- property compute_body_preamble: Callable[[frozenset[type], Value], tuple[str, ...]]¶
Compute body-preamble lines from the scalar map.
- property consumable_ref_value_inhibits_consuming_form: Callable[[Value], bool]¶
Predicate deciding whether a ref’s underlying value type inhibits the consume form.
Delegates to
never_inhibits_consuming_form. Languages whose consume operator rejects certain value types (notably the Mojo^on register-trivial scalars) override this.
- property data_dependent_preamble: Callable[[Value], tuple[str, ...]]¶
Return data-dependent preamble lines.
For
HeterogeneousStrategies.TAGGED_ENUMemits a minimalenumdeclaration listing only the variants actually used in heterogeneous positions in the data. ForHeterogeneousStrategies.RECORDemits onestructdeclaration per record shape present in the data. Other strategies produce no preamble.
- date_format: DateFormats = DateFormatConfig(formatter=<function _format_date_rust>, preamble_lines=('use chrono::NaiveDate;',), type_produced=<class 'datetime.date'>)¶
- date_formats¶
alias of
DateFormats
- datetime_format: DatetimeFormats = DatetimeFormatConfig(formatter=<function _format_datetime_rust>, preamble_lines=('use chrono::NaiveDate;', 'use chrono::NaiveDateTime;', 'use chrono::NaiveTime;'), type_produced=<class 'datetime.datetime'>)¶
- datetime_formats¶
alias of
DatetimeFormats
- declaration_style: DeclarationStyles = DeclarationStyleConfig(formatter=<function _format_let_declaration>, supports_redefinition=False)¶
- declaration_styles¶
alias of
DeclarationStyles
- default_dict_key_type: str = 'String'¶
- default_dict_value_type: str = 'String'¶
- default_sequence_element_type: str = 'String'¶
- default_set_element_type: str = 'String'¶
- dict_entry_style: DictEntryStyles = 1¶
- dict_entry_styles¶
alias of
DictEntryStyles
- dict_format: DictFormats = <function dict_format_factory.<locals>._build>¶
- property dict_format_config: DictFormatConfig¶
Configuration for dict formatting.
- dict_formats¶
alias of
DictFormats
- dict_supports_heterogeneous_values = False¶
- element_separator: ClassVar[str] = ', '¶
- empty_dict_keys¶
alias of
EmptyDictKey
- extension = '.rs'¶
- false_literal: ClassVar[str] = 'false'¶
- float_format: FloatFormats = <function format_float_repr>¶
- float_formats¶
alias of
FloatFormats
- property format_bytes: Callable[[bytes], str]¶
Callable that formats a bytes value as a string literal.
- property format_call_arg: Callable[[Value, str], str]¶
Callable that rewrites a formatted direct call argument.
- property format_call_arg_ref_identifier: Callable[[str, Value | None], str]¶
Rewrite a
{"$ref": "name"}identifier in a call-argument context.Delegates to
format_call_ref_identifier. Override this to allow call-argument$refvalues that would otherwise be rejected.
- property format_call_arg_ref_identifier_consumable: Callable[[str, Value | None], str]¶
Format a
$refthe caller authorized as consumable.Delegates to
format_call_arg_ref_identifier. Override this to opt into a consuming form (e.g. C++std::move).
- format_call_binding_body_preamble() tuple[str, ...]¶
Default
format_call_binding_body_preamble– no extra body preamble lines for an inference-bound call result.
- format_call_binding_file_pragmas() tuple[str, ...]¶
Default
format_call_binding_file_pragmas– no file-level compiler-pragma line for an inference-bound call result.
- property format_call_preamble_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]¶
Return file-scope stubs for a call expression.
- property format_call_ref_identifier: Callable[[str, Value | None], str]¶
Rewrite a
{"$ref": "name"}identifier into the language’s call expression syntax.
- property format_call_statement: Callable[[str], str]¶
Return call-statement formatting for this language.
- property format_call_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]¶
Return stub declarations for a call expression.
- property format_call_target: Callable[[Sequence[str]], str]¶
Rewrite a dotted call target into the language’s call syntax.
- property format_call_variable_assignment: Callable[[str, str, Value], str]¶
Default
format_call_variable_assignment– reuse the literal-binding assignment formatter unchanged.
- property format_call_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]¶
Default
format_call_variable_declaration– reuse the literal-binding declaration formatter unchanged.
- static format_constructor_target(class_name: str, /) str¶
Return a Rust
ClassName::newconstructor call target.
- property format_date: Callable[[date], str]¶
Callable that formats a date as a string literal.
- property format_datetime: Callable[[datetime], str]¶
Callable that formats a datetime as a string literal.
- property format_float: Callable[[float], str]¶
Callable that formats a float value as a literal.
- property format_integer: Callable[[int], str]¶
Callable that formats an int value as a literal.
Rust’s widest built-in integer types are
i128/u128; values outside the signedi128range have no native literal form, so raiseUnrepresentableIntegerErrorrather than emit a literalrustcwill reject.
- property format_integer_widened: None¶
Default
format_integer_widened– no mixed-magnitude integer widening, so the renderer keeps the normal integer formatter.
- property format_ordered_map_entry: Callable[[str, Value, str], str]¶
Callable that formats one ordered-map entry.
- property format_sequence_entry: Callable[[Value, str], str]¶
Format a sequence entry.
- property format_set_entry: Callable[[Value, str], str]¶
Format a set entry.
- property format_string: Callable[[str], str]¶
Callable that formats a string value as a quoted literal.
- property format_time: Callable[[time], str]¶
Callable that formats a time as a string literal.
- property format_variable_assignment: Callable[[str, str, Value], str]¶
Format an assignment to an existing variable.
- property format_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]¶
Callable that formats a new variable declaration.
- has_free_function_calls = True¶
- property heterogeneous_behavior: HeterogeneousBehavior¶
Return the behavior for the chosen heterogeneous strategy.
- heterogeneous_strategies¶
alias of
HeterogeneousStrategies
- heterogeneous_strategy: HeterogeneousStrategies = _HeterogeneousStrategyConfig(build_behavior=<function _build_error_behavior>, build_preamble=<function _build_error_preamble>)¶
- heterogeneous_value_enum_name: str = 'Value'¶
- identifier_cases: ClassVar[tuple[IdentifierCase, ...]] = (IdentifierCase.SNAKE, IdentifierCase.PASCAL, IdentifierCase.UPPER_SNAKE)¶
- indent: str = ' '¶
- indent_closing_delimiter: ClassVar[bool] = False¶
- integer_format: IntegerFormats = mappingproxy({'NONE': <class 'str'>, 'UNDERSCORE': <function format_integer_underscore>})¶
- integer_formats¶
alias of
IntegerFormats
- integer_width_strategies¶
alias of
BareIntegerWidthStrategies
- integer_width_strategy: BareIntegerWidthStrategies = 1¶
- language_version: VersionFormats = 1¶
- property leading_preamble: LeadingPreamble¶
Default
leading_preamble– no preamble lines that must precedeLanguage.static_preamble.
- max_call_parameters = 9223372036854775807¶
- modifier_combinations: ClassVar[tuple[ModifierCombination, ...]] = ()¶
- modifiers¶
alias of
_RustModifiers
- property null_literal: str¶
Null literal for the active Rust representation.
- numeric_literal_suffix: NumericLiteralSuffixes = 1¶
- numeric_literal_suffixes¶
alias of
NumericLiteralSuffixes
- numeric_separator: NumericSeparators = 1¶
- numeric_separators¶
alias of
NumericSeparators
- numeric_style: NumericStyles = 1¶
- numeric_styles¶
alias of
NumericStyles
- property ordered_map_format_config: OrderedMapFormatConfig¶
Configuration for ordered-map formatting.
- pygments_name = 'rust'¶
- record_shape_names: Mapping[frozenset[str], str]¶
- record_struct_name_prefix: str = 'Record'¶
- record_unify_optional_fields: bool = False¶
- reserved_identifiers: ClassVar[frozenset[str]] = frozenset({})¶
- scalar_body_preamble: ClassVar[dict[type, tuple[str, ...]]] = {}¶
- property scalar_preamble: dict[type, tuple[str, ...]]¶
Per-instance scalar preamble computed from date/datetime format.
- sequence_binding_declarations(declarations: tuple[str, ...]) str¶
Default
sequence_binding_declarations– join the per-binding snippets with newlines.
- sequence_format: SequenceFormats = <function sequence_format_factory.<locals>._build>¶
- property sequence_format_config: SequenceFormatConfig¶
Configuration for the chosen sequence format.
- sequence_formats¶
alias of
SequenceFormats
- property sequence_open: Callable[[list[Value]], str]¶
Callable that returns the opening delimiter for a sequence.
- set_format: SetFormats = <function set_format_factory.<locals>._build>¶
- property set_format_config: SetFormatConfig¶
Configuration for the chosen set format.
- set_formats¶
alias of
SetFormats
- skip_null_dict_values: ClassVar[bool] = False¶
- special_float_preamble: ClassVar[tuple[str, ...]] = ()¶
- statement_terminator: ClassVar[str] = ';'¶
- statement_terminator_style: StatementTerminatorStyles = 1¶
- statement_terminator_styles¶
alias of
StatementTerminatorStyles
- static_body_preamble: ClassVar[Sequence[str]] = ()¶
- property static_preamble: Sequence[str]¶
Static preamble lines emitted once per file.
LAZY_STATICaddsuse std::sync::LazyLock;; other declaration styles produce no static preamble.
- string_format: StringFormats = <function _build_backslash_formatter.<locals>._format>¶
- string_formats¶
alias of
StringFormats
- supported_ref_cases: ClassVar[frozenset[IdentifierCase]] = frozenset({IdentifierCase.CAMEL, IdentifierCase.PASCAL, IdentifierCase.SNAKE, IdentifierCase.UPPER_SNAKE})¶
- supports_call_style = True¶
- supports_collection_comments: ClassVar[bool] = True¶
- supports_default_dict_key_type = True¶
- supports_default_dict_value_type = True¶
- supports_default_ordered_map_value_type = False¶
- supports_default_sequence_element_type = True¶
- supports_default_set_element_type = True¶
- supports_dict_literal_as_free_expression = True¶
- supports_dotted_call_stub = True¶
- supports_dotted_calls = True¶
- supports_empty_dict_key = False¶
- supports_inline_multiline_dict_args = True¶
- supports_module_name = False¶
- supports_multi_param_call_wrapper_stub = True¶
- supports_no_variable_wrap_in_file = False¶
- supports_non_string_dict_keys = True¶
- supports_record_shape_names = True¶
- supports_record_struct_name_prefix = True¶
- supports_scalar_before_comments: ClassVar[bool] = True¶
- supports_scalar_inline_comments: ClassVar[bool] = False¶
- supports_special_floats = True¶
- supports_standalone_comments_in_wrapped_calls = True¶
- supports_variable_names = True¶
- supports_zero_parameter_calls = True¶
- trailing_comma: TrailingCommas = TrailingCommaConfig(multiline_trailing_comma=True)¶
- property trailing_comma_config: TrailingCommaConfig¶
Configuration for trailing-comma behavior.
- trailing_commas¶
alias of
TrailingCommas
- true_literal: ClassVar[str] = 'true'¶
- property type_hint_collection_preamble_lines: Callable[[frozenset[type]], tuple[str, ...]]¶
Return preamble lines for empty-collection type hints.
- property validate_call_arg: Callable[[Value], None]¶
Return call-argument validation for this language.
- validate_spec_for_data(data: Value) None¶
Validate Rust-specific data/format combinations.
- variable_type_hints: VariableTypeHints = 1¶
- variable_type_hints_formats¶
alias of
VariableTypeHints
- version_formats¶
alias of
VersionFormats
- wrap_calls_with_declarations(declarations: tuple[str, ...], calls: str, body_preamble: tuple[str, ...]) str¶
Default
wrap_calls_with_declarations— concatenate the declarations and calls and route throughwrap_in_file()in call mode.
- wrap_combined_in_file(declaration: str, assignment: str, variable_name: str, body_preamble: tuple[str, ...]) str¶
Wrap Rust declaration + assignment in a main function.
- wrap_in_file(content: str, variable_name: str, body_preamble: tuple[str, ...]) str¶
Wrap a Rust let binding in a main function.
- class literalizer.languages.Scala(*args: object, **kwargs: object)¶
Scala language specification.
- class BoolFormats(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
Empty: this language has no alternative boolean formats.
- class BytesFormats(*values)¶
Bytes formatting options.
- BASE64 = <function format_bytes_base64>¶
- HEX = <function format_bytes_hex>¶
- class CallStyles(*values)¶
Scala call style options.
- KEYWORD = KeywordCallStyle(separator=' = ')¶
- POSITIONAL = PositionalCallStyle(arg_separator=', ', parenthesize_each_arg=False)¶
- class CommentFormats(*values)¶
Comment style options.
- BLOCK = CommentConfig(prefix='/*', suffix=' */')¶
- DOUBLE_SLASH = CommentConfig(prefix='//', suffix='')¶
- class DateFormats(*values)¶
Date format options for Scala.
- ISO = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- SCALA = DateFormatConfig(formatter=<function date_ymd_formatter.<locals>._format>, preamble_lines=('import java.time.LocalDate',), type_produced=<class 'datetime.date'>)¶
- class DatetimeFormats(*values)¶
Datetime format options for Scala.
- EPOCH = DatetimeFormatConfig(formatter=<function format_datetime_epoch>, preamble_lines=(), type_produced=<class 'int'>)¶
- ISO = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- SCALA = DatetimeFormatConfig(formatter=<function _format_datetime_scala>, preamble_lines=('import java.time.ZoneId', 'import java.time.ZonedDateTime'), type_produced=<class 'datetime.datetime'>)¶
- class DeclarationStyles(*values)¶
Declaration style options.
- VAL = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=False)¶
- VAR = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=True)¶
- class DictFormats(*values)¶
Dict/map format options.
- LIST_MAP = _ScalaDictSpec(opener_template='ListMap[String, {type_name}](', fallback='ListMap(', preamble_lines=('import scala.collection.immutable.ListMap',))¶
- MAP = _ScalaDictSpec(opener_template='Map[String, {type_name}](', fallback='Map(', preamble_lines=())¶
- class FloatFormats(*values)¶
Float format options.
- FIXED = <function format_float_fixed>¶
- REPR = <function format_float_repr>¶
- SCIENTIFIC = <function format_float_scientific>¶
- class HeterogeneousStrategies(*values)¶
Strategy for dicts whose values span more than one Scala type.
ERRORkeeps Scala’s strict-typing behavior (mixed-value dicts that cannot be represented raise).RECORDrenders each record-shaped dict (non-empty, string-keyed) as a generatedcase classdeclared in the preamble plus a matchingRecord0(field = value, ...)literal, so fields may legitimately mix scalars and containers.TUPLEcomposesRECORDand additionally renders each fixed-length heterogeneous scalar array (a record field, another dict value, or the document root) as a native tuple(e0, e1, ...)typed(T0, T1, ...). Scala 3 imposes no tuple-length limit (lengths past 22 are transparently backed byTupleXXL), so any fixed-length heterogeneous scalar array is representable.- ERROR = 1¶
- RECORD = 2¶
- TUPLE = 3¶
- class IntegerFormats(*values)¶
Integer format options.
- DECIMAL = mappingproxy({'NONE': <class 'str'>, 'UNDERSCORE': <function format_integer_underscore>})¶
- HEX = mappingproxy({'NONE': <function format_integer_hex>, 'UNDERSCORE': <function format_integer_hex>})¶
- get_formatter(numeric_separator: Enum) Callable[[int], str]¶
Return the integer formatter for the given separator.
- class JsonTypes(*values)¶
JSON value type options for Scala.
- CIRCE = 'io.circe.Json'¶
Circe’s
io.circe.Jsondynamic JSON value type.
- class Modifiers(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
C++/Java/C#-style declaration modifiers: this language has none.
- class SequenceFormats(*values)¶
Sequence type options for Scala.
- ARRAY = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=')', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence='Array.empty[Any]', preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback='Array(', uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)¶
- LIST = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=')', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)¶
- SEQ = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=')', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)¶
- class SetFormats(*values)¶
Set type options for Scala.
- SET = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close=')', empty_set=None, preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)¶
- TREE_SET = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close=')', empty_set='TreeSet.empty[Int]', preamble_lines=('import scala.collection.immutable.TreeSet',), set_opener_template='TreeSet[{type_name}](', supports_heterogeneity=False, supports_trailing_comma=True)¶
- class TrailingCommas(*values)¶
Trailing comma options.
- NO = TrailingCommaConfig(multiline_trailing_comma=False)¶
- YES = TrailingCommaConfig(multiline_trailing_comma=True)¶
- allows_empty_call_parens = True¶
- bool_formats¶
alias of
BoolFormats
- bytes_format: BytesFormats = <function format_bytes_hex>¶
- bytes_formats¶
alias of
BytesFormats
- property call_data_dependent_preamble: Callable[[Value], tuple[str, ...]]¶
Return data-dependent preamble lines for call rendering.
- call_returns_expression = True¶
- call_style: CallStyles = KeywordCallStyle(separator=' = ')¶
- property call_style_config: PositionalCallStyle | KeywordCallStyle | ObjectCallStyle | PostfixCallStyle | PrefixCallStyle | CommandCallStyle¶
Configuration for the chosen call style.
- call_styles¶
alias of
CallStyles
- property comment_config: CommentConfig¶
Configuration for the language’s comment syntax.
- comment_format: CommentFormats = CommentConfig(prefix='//', suffix='')¶
- comment_formats¶
alias of
CommentFormats
- property compute_body_preamble: Callable[[frozenset[type], Value], tuple[str, ...]]¶
Compute body-preamble lines from the scalar map, prefixed with the
RECORDstrategy’s generatedcase classdeclarations.Scala compiles every fixture in one invocation, so a file-scope
case class Record0would collide across cases. Emitting the declarations into the body preamble (whichwrap_in_file()places inside the per-fixtureobject, ahead of the value) scopes eachRecordNto its own fixture; the declarations precede the scalar body lines so a record type is in scope before its literal.
- property consumable_ref_value_inhibits_consuming_form: Callable[[Value], bool]¶
Predicate deciding whether a ref’s underlying value type inhibits the consume form.
Delegates to
never_inhibits_consuming_form. Languages whose consume operator rejects certain value types (notably the Mojo^on register-trivial scalars) override this.
- property data_dependent_preamble: Callable[[Value], tuple[str, ...]]¶
Return data-dependent preamble lines.
The
RECORDstrategy’scase classdeclarations are not emitted here (file scope): Scala compiles every fixture together, so a file-scopecase class Record0would collide across cases. They are emitted into the per-fixtureobjectbody instead; seecompute_body_preamble.
- date_format: DateFormats = DateFormatConfig(formatter=<function date_ymd_formatter.<locals>._format>, preamble_lines=('import java.time.LocalDate',), type_produced=<class 'datetime.date'>)¶
- date_formats¶
alias of
DateFormats
- datetime_format: DatetimeFormats = DatetimeFormatConfig(formatter=<function _format_datetime_scala>, preamble_lines=('import java.time.ZoneId', 'import java.time.ZonedDateTime'), type_produced=<class 'datetime.datetime'>)¶
- datetime_formats¶
alias of
DatetimeFormats
- declaration_style: DeclarationStyles = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=False)¶
- declaration_styles¶
alias of
DeclarationStyles
- dict_entry_style: DictEntryStyles = 1¶
- dict_entry_styles¶
alias of
DictEntryStyles
- dict_format: DictFormats = _ScalaDictSpec(opener_template='Map[String, {type_name}](', fallback='Map(', preamble_lines=())¶
- property dict_format_config: DictFormatConfig¶
Configuration for dict formatting.
- dict_formats¶
alias of
DictFormats
- dict_supports_heterogeneous_values = True¶
- element_separator: ClassVar[str] = ', '¶
- empty_dict_keys¶
alias of
EmptyDictKey
- extension = '.scala'¶
- false_literal: ClassVar[str] = 'false'¶
- float_format: FloatFormats = <function format_float_repr>¶
- float_formats¶
alias of
FloatFormats
- property format_bytes: Callable[[bytes], str]¶
Callable that formats a bytes value as a string literal.
- property format_call_arg: Callable[[Value, str], str]¶
Callable that rewrites a formatted direct call argument.
- property format_call_arg_ref_identifier: Callable[[str, Value | None], str]¶
Rewrite a
{"$ref": "name"}identifier in a call-argument context.Delegates to
format_call_ref_identifier. Override this to allow call-argument$refvalues that would otherwise be rejected.
- property format_call_arg_ref_identifier_consumable: Callable[[str, Value | None], str]¶
Format a
$refthe caller authorized as consumable.Delegates to
format_call_arg_ref_identifier. Override this to opt into a consuming form (e.g. C++std::move).
- format_call_binding_body_preamble() tuple[str, ...]¶
Default
format_call_binding_body_preamble– no extra body preamble lines for an inference-bound call result.
- format_call_binding_file_pragmas() tuple[str, ...]¶
Default
format_call_binding_file_pragmas– no file-level compiler-pragma line for an inference-bound call result.
- property format_call_preamble_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]¶
Return file-scope stubs for a call expression.
- property format_call_ref_identifier: Callable[[str, Value | None], str]¶
Rewrite a
{"$ref": "name"}identifier into the language’s call expression syntax.
- property format_call_statement: Callable[[str], str]¶
Return call-statement formatting for this language.
- property format_call_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]¶
Return stub declarations for a call expression.
- property format_call_target: Callable[[Sequence[str]], str]¶
Rewrite a dotted call target into the language’s call syntax.
- property format_call_variable_assignment: Callable[[str, str, Value], str]¶
Default
format_call_variable_assignment– reuse the literal-binding assignment formatter unchanged.
- property format_call_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]¶
Default
format_call_variable_declaration– reuse the literal-binding declaration formatter unchanged.
- static format_constructor_target(class_name: str, /) str¶
Return a
new ClassNameconstructor call target.
- property format_date: Callable[[date], str]¶
Callable that formats a date as a string literal.
- property format_datetime: Callable[[datetime], str]¶
Callable that formats a datetime as a string literal.
EPOCHseconds are routed throughformat_integerso a post-2038 value carries theLsuffix Scala requires for an integer literal outside 32-bit range: a bare4085195400is rejected by the compiler as “number too large” even when the target type isLong. In-range epoch seconds format identically to the plain integer, so every checked-in golden file stays byte-identical.
- property format_float: Callable[[float], str]¶
Callable that formats a float value as a literal.
- property format_integer: Callable[[int], str]¶
Callable that formats an int value as a literal.
- property format_integer_widened: None¶
Default
format_integer_widened– no mixed-magnitude integer widening, so the renderer keeps the normal integer formatter.
- property format_ordered_map_entry: Callable[[str, Value, str], str]¶
Callable that formats one ordered-map entry.
- property format_sequence_entry: Callable[[Value, str], str]¶
Format a sequence entry.
- property format_set_entry: Callable[[Value, str], str]¶
Format a set entry.
- property format_string: Callable[[str], str]¶
Format a string value as a quoted literal.
- property format_time: Callable[[time], str]¶
Callable that formats a time as a string literal.
- property format_variable_assignment: Callable[[str, str, Value], str]¶
Format an assignment to an existing variable.
- property format_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]¶
Callable that formats a new variable declaration.
- has_free_function_calls = True¶
- property heterogeneous_behavior: HeterogeneousBehavior¶
Return the behavior for the chosen heterogeneous strategy.
- heterogeneous_strategies¶
alias of
HeterogeneousStrategies
- heterogeneous_strategy: HeterogeneousStrategies = 1¶
- identifier_cases: ClassVar[tuple[IdentifierCase, ...]] = (IdentifierCase.CAMEL, IdentifierCase.PASCAL, IdentifierCase.UPPER_SNAKE)¶
- indent: str = ' '¶
- indent_closing_delimiter: ClassVar[bool] = False¶
- integer_format: IntegerFormats = mappingproxy({'NONE': <class 'str'>, 'UNDERSCORE': <function format_integer_underscore>})¶
- integer_formats¶
alias of
IntegerFormats
- integer_width_strategies¶
alias of
BareIntegerWidthStrategies
- integer_width_strategy: BareIntegerWidthStrategies = 1¶
- language_version: VersionFormats = 1¶
- property leading_preamble: LeadingPreamble¶
Default
leading_preamble– no preamble lines that must precedeLanguage.static_preamble.
- max_call_parameters = 9223372036854775807¶
- modifier_combinations: ClassVar[tuple[ModifierCombination, ...]] = ()¶
- module_name: str = 'Check'¶
- module_name_case: ClassVar[IdentifierCase] = 'pascal'¶
- null_literal: ClassVar[str] = 'null'¶
- numeric_literal_suffix: NumericLiteralSuffixes = 1¶
- numeric_literal_suffixes¶
alias of
NumericLiteralSuffixes
- numeric_separator: NumericSeparators = 1¶
- numeric_separators¶
alias of
NumericSeparators
- numeric_style: NumericStyles = 1¶
- numeric_styles¶
alias of
NumericStyles
- property ordered_map_format_config: OrderedMapFormatConfig¶
Configuration for ordered-map formatting.
- pygments_name = 'scala'¶
- record_shape_names: Mapping[frozenset[str], str]¶
- record_struct_name_prefix: str = 'Record'¶
- reserved_identifiers: ClassVar[frozenset[str]] = frozenset({})¶
- scalar_body_preamble: ClassVar[dict[type, tuple[str, ...]]] = {}¶
- property scalar_preamble: dict[type, tuple[str, ...]]¶
Per-instance scalar preamble computed from date/datetime format.
- sequence_binding_declarations(declarations: tuple[str, ...]) str¶
Default
sequence_binding_declarations– join the per-binding snippets with newlines.
- sequence_format: SequenceFormats = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=')', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)¶
- property sequence_format_config: SequenceFormatConfig¶
Configuration for the chosen sequence format.
- sequence_formats¶
alias of
SequenceFormats
- property sequence_open: Callable[[list[Value]], str]¶
Callable that returns the opening delimiter for a sequence.
Under the
RECORDstrategy (andTUPLE, which composes it) a list whose elements are record-shaped dicts is opened with the format’s plain, element-type-free opener (List() so the elements render asRecordN(...)literals and Scala infersList[RecordN]; the typed opener would otherwise infer aMap[String, ...]element type that the struct literals do not satisfy.
- set_format: SetFormats = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close=')', empty_set=None, preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)¶
- property set_format_config: SetFormatConfig¶
Configuration for the chosen set format.
- set_formats¶
alias of
SetFormats
- skip_null_dict_values: ClassVar[bool] = False¶
- special_float_preamble: ClassVar[tuple[str, ...]] = ()¶
- statement_terminator: ClassVar[str] = ''¶
- statement_terminator_style: StatementTerminatorStyles = 1¶
- statement_terminator_styles¶
alias of
StatementTerminatorStyles
- static_body_preamble: ClassVar[Sequence[str]] = ()¶
- property static_preamble: Sequence[str]¶
Static preamble lines emitted once per file.
Circe-backed Scala output needs
io.circe.Jsonin scope so theJson.obj/Json.arrfactories the rendered literal uses resolve.
- string_format: StringFormats = 1¶
- string_formats¶
alias of
StringFormats
- supported_ref_cases: ClassVar[frozenset[IdentifierCase]] = frozenset({IdentifierCase.CAMEL, IdentifierCase.PASCAL, IdentifierCase.SNAKE, IdentifierCase.UPPER_SNAKE})¶
- supports_call_style = True¶
- supports_collection_comments: ClassVar[bool] = True¶
- supports_default_dict_key_type = False¶
- supports_default_dict_value_type = False¶
- supports_default_ordered_map_value_type = False¶
- supports_default_sequence_element_type = False¶
- supports_default_set_element_type = False¶
- supports_dict_literal_as_free_expression = True¶
- supports_dotted_call_stub = True¶
- supports_dotted_calls = True¶
- supports_empty_dict_key = False¶
- supports_inline_multiline_dict_args = True¶
- supports_module_name = True¶
- supports_multi_param_call_wrapper_stub = True¶
- supports_no_variable_wrap_in_file = False¶
- supports_non_string_dict_keys = False¶
- supports_record_shape_names = True¶
- supports_record_struct_name_prefix = True¶
- supports_scalar_before_comments: ClassVar[bool] = True¶
- supports_scalar_inline_comments: ClassVar[bool] = True¶
- supports_special_floats = True¶
- supports_standalone_comments_in_wrapped_calls = True¶
- supports_variable_names = True¶
- supports_zero_parameter_calls = True¶
- trailing_comma: TrailingCommas = TrailingCommaConfig(multiline_trailing_comma=True)¶
- property trailing_comma_config: TrailingCommaConfig¶
Configuration for trailing-comma behavior.
- trailing_commas¶
alias of
TrailingCommas
- true_literal: ClassVar[str] = 'true'¶
- property type_hint_collection_preamble_lines: Callable[[frozenset[type]], tuple[str, ...]]¶
Return preamble lines for empty-collection type hints.
- property validate_call_arg: Callable[[Value], None]¶
Return call-argument validation for this language.
- validate_spec_for_data(data: Value) None¶
Validate Scala-specific data/format combinations.
- variable_type_hints: VariableTypeHints = 1¶
- variable_type_hints_formats¶
alias of
VariableTypeHints
- version_formats¶
alias of
VersionFormats
- wrap_calls_with_declarations(declarations: tuple[str, ...], calls: str, body_preamble: tuple[str, ...]) str¶
Default
wrap_calls_with_declarations— concatenate the declarations and calls and route throughwrap_in_file()in call mode.
- wrap_combined_in_file(declaration: str, assignment: str, variable_name: str, body_preamble: tuple[str, ...]) str¶
Wrap Scala declaration + assignment in an object.
- wrap_in_file(content: str, variable_name: str, body_preamble: tuple[str, ...]) str¶
Wrap a Scala declaration in an object.
- class literalizer.languages.Scheme(*args: object, **kwargs: object)¶
Scheme language specification.
- class BoolFormats(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
Empty: this language has no alternative boolean formats.
- class BytesFormats(*values)¶
Bytes formatting options.
- BASE64 = <function format_bytes_base64>¶
- HEX = <function format_bytes_hex>¶
- class CallStyles(*values)¶
Scheme call style options.
- PREFIX = PrefixCallStyle(arg_separator=' ', keyword_prefix='')¶
- class CommentFormats(*values)¶
Comment style options.
- BLOCK = CommentConfig(prefix='#|', suffix=' |#')¶
- SEMICOLON = CommentConfig(prefix=';', suffix='')¶
- class DateFormats(*values)¶
Date format options for Scheme.
- ISO = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- class DatetimeFormats(*values)¶
Datetime format options for Scheme.
- EPOCH = DatetimeFormatConfig(formatter=<function format_datetime_epoch>, preamble_lines=(), type_produced=<class 'int'>)¶
- ISO = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- class DeclarationStyles(*values)¶
Declaration style options.
- DEFINE = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=True)¶
- class FloatFormats(*values)¶
Float format options.
- FIXED = <function format_float_fixed>¶
- REPR = <function format_float_repr>¶
- SCIENTIFIC = <function format_float_scientific>¶
- class HeterogeneousStrategies(*values)¶
Heterogeneous-scalar strategy options — this language only supports raising.
- ERROR = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)¶
- class JsonTypes(*values)¶
JSON value type options for Scheme.
- GUILE_JSON = 'guile-json scm->json value shape'¶
Scheme association lists for objects, vectors for arrays,
'nullfor JSON null. The literalized output can be handed directly to(scm->json ...)without a runtime shape walker.- Type:
Guile-json’s
scm->jsonvalue shape
- class Modifiers(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
C++/Java/C#-style declaration modifiers: this language has none.
- class SequenceFormats(*values)¶
Sequence type options for Scheme.
- LIST = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=')', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=False, empty_sequence='(list)', preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)¶
- class SetFormats(*values)¶
Set type options for Scheme.
- SET = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close=')', empty_set='(list)', preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)¶
- class TrailingCommas(*values)¶
Trailing comma options.
- NO = TrailingCommaConfig(multiline_trailing_comma=False)¶
- allows_empty_call_parens = True¶
- bool_formats¶
alias of
BoolFormats
- bytes_format: BytesFormats = <function format_bytes_hex>¶
- bytes_formats¶
alias of
BytesFormats
- property call_data_dependent_preamble: Callable[[Value], tuple[str, ...]]¶
Return data-dependent preamble lines for call rendering.
- call_returns_expression = True¶
- call_style: CallStyles = PrefixCallStyle(arg_separator=' ', keyword_prefix='')¶
- property call_style_config: PositionalCallStyle | KeywordCallStyle | ObjectCallStyle | PostfixCallStyle | PrefixCallStyle | CommandCallStyle¶
Return the active call-style configuration.
- call_styles¶
alias of
CallStyles
- property comment_config: CommentConfig¶
Configuration for the language’s comment syntax.
- comment_format: CommentFormats = CommentConfig(prefix=';', suffix='')¶
- comment_formats¶
alias of
CommentFormats
- property compute_body_preamble: Callable[[frozenset[type], Value], tuple[str, ...]]¶
Compute body-preamble lines from the scalar map.
- property consumable_ref_value_inhibits_consuming_form: Callable[[Value], bool]¶
Predicate deciding whether a ref’s underlying value type inhibits the consume form.
Delegates to
never_inhibits_consuming_form. Languages whose consume operator rejects certain value types (notably the Mojo^on register-trivial scalars) override this.
- property data_dependent_preamble: Callable[[Value], tuple[str, ...]]¶
Return data-dependent preamble lines.
- date_format: DateFormats = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- date_formats¶
alias of
DateFormats
- datetime_format: DatetimeFormats = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- datetime_formats¶
alias of
DatetimeFormats
- declaration_style: DeclarationStyles = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=True)¶
- declaration_styles¶
alias of
DeclarationStyles
- dict_entry_style: DictEntryStyles = 1¶
- dict_entry_styles¶
alias of
DictEntryStyles
- dict_format: DictFormats = 1¶
- property dict_format_config: DictFormatConfig¶
Configuration for dict formatting.
Each entry is a
(cons "k" v)pair and the dict wraps them in(list ...)to form a Scheme association list – the conventional key/value mapping idiom, whatassoc/alist->hash-tableexpect, and whatscm->json’sjson-valid?accepts for JSON objects underjson_type. A list ofpair?elements is locally distinguishable from a heterogeneous sequence, unlike the legacy flat(list "k" v "k" v ...)form.
- dict_formats¶
alias of
DictFormats
- dict_supports_heterogeneous_values = True¶
- element_separator: ClassVar[str] = ' '¶
- empty_dict_keys¶
alias of
EmptyDictKey
- extension = '.scm'¶
- false_literal: ClassVar[str] = '#f'¶
- float_format: FloatFormats = <function format_float_repr>¶
- float_formats¶
alias of
FloatFormats
- property format_bytes: Callable[[bytes], str]¶
Callable that formats a bytes value as a string literal.
- static format_call_arg(_value: Value, formatted: str, /) str¶
Callable that rewrites a formatted direct call argument.
- property format_call_arg_ref_identifier: Callable[[str, Value | None], str]¶
Rewrite a
{"$ref": "name"}identifier in a call-argument context.Delegates to
format_call_ref_identifier. Override this to allow call-argument$refvalues that would otherwise be rejected.
- property format_call_arg_ref_identifier_consumable: Callable[[str, Value | None], str]¶
Format a
$refthe caller authorized as consumable.Delegates to
format_call_arg_ref_identifier. Override this to opt into a consuming form (e.g. C++std::move).
- format_call_binding_body_preamble() tuple[str, ...]¶
Default
format_call_binding_body_preamble– no extra body preamble lines for an inference-bound call result.
- format_call_binding_file_pragmas() tuple[str, ...]¶
Default
format_call_binding_file_pragmas– no file-level compiler-pragma line for an inference-bound call result.
- property format_call_preamble_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]¶
Return file-scope stubs for a call expression.
- property format_call_ref_identifier: Callable[[str, Value | None], str]¶
Raise for any
{"$ref": "name"}identifier.Scheme output is not wrapped in a function body; variable references require a surrounding
definethat cannot be injected via the call framework.
- property format_call_statement: Callable[[str], str]¶
Return call-statement formatting for this language.
- property format_call_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]¶
Return stub declarations for a call expression.
- property format_call_target: Callable[[Sequence[str]], str]¶
Rewrite a dotted call target into the language’s call syntax.
- property format_call_variable_assignment: Callable[[str, str, Value], str]¶
Default
format_call_variable_assignment– reuse the literal-binding assignment formatter unchanged.
- property format_call_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]¶
Default
format_call_variable_declaration– reuse the literal-binding declaration formatter unchanged.
- static format_constructor_target(class_name: str, /) str¶
Return class_name as a zero-argument constructor call target.
- property format_date: Callable[[date], str]¶
Callable that formats a date as a string literal.
- property format_datetime: Callable[[datetime], str]¶
Callable that formats a datetime as a string literal.
- property format_float: Callable[[float], str]¶
Callable that formats a float value as a literal.
- property format_integer: Callable[[int], str]¶
Format an int value as a literal.
- property format_integer_widened: None¶
Default
format_integer_widened– no mixed-magnitude integer widening, so the renderer keeps the normal integer formatter.
- property format_ordered_map_entry: Callable[[str, Value, str], str]¶
Callable that formats one ordered-map entry.
Each entry is a
(cons "k" v)pair matchingdict_format_config.
- property format_sequence_entry: Callable[[Value, str], str]¶
Format a sequence entry.
- property format_set_entry: Callable[[Value, str], str]¶
Format a set entry.
- property format_string: Callable[[str], str]¶
Format a string value as a quoted literal.
- property format_time: Callable[[time], str]¶
Callable that formats a time as a string literal.
- property format_variable_assignment: Callable[[str, str, Value], str]¶
Format an assignment to an existing variable.
- property format_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]¶
Callable that formats a new variable declaration.
- has_free_function_calls = True¶
- property heterogeneous_behavior: HeterogeneousBehavior¶
Return the heterogeneous-behavior config.
- heterogeneous_strategies¶
alias of
HeterogeneousStrategies
- heterogeneous_strategy: HeterogeneousStrategies = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)¶
- identifier_cases: ClassVar[tuple[IdentifierCase, ...]] = (IdentifierCase.KEBAB,)¶
- indent: str = ' '¶
- indent_closing_delimiter: ClassVar[bool] = False¶
- integer_format: IntegerFormats = 1¶
- integer_formats¶
alias of
IntegerFormats
- integer_width_strategies¶
alias of
BareIntegerWidthStrategies
- integer_width_strategy: BareIntegerWidthStrategies = 1¶
- language_version: VersionFormats = 1¶
- property leading_preamble: LeadingPreamble¶
Default
leading_preamble– no preamble lines that must precedeLanguage.static_preamble.
- max_call_parameters = 9223372036854775807¶
- modifier_combinations: ClassVar[tuple[ModifierCombination, ...]] = ()¶
- property null_literal: str¶
The literal representing null.
Under
json_typethe value must be the null sentinel that guile-json recognizes (the symbol'null, matching the default of its*null*parameter); the flat-list mode uses the empty list, which is conventional fornullin Scheme.
- numeric_literal_suffix: NumericLiteralSuffixes = 1¶
- numeric_literal_suffixes¶
alias of
NumericLiteralSuffixes
- numeric_separator: NumericSeparators = 1¶
- numeric_separators¶
alias of
NumericSeparators
- numeric_style: NumericStyles = 1¶
- numeric_styles¶
alias of
NumericStyles
- property ordered_map_format_config: OrderedMapFormatConfig¶
Configuration for ordered-map formatting.
Under
json_typean ordered map is rendered as the same association-list shape used for plain dicts soscm->jsonround-trips it as a JSON object (key order is preserved by the surrounding list’s element order).
- pygments_name = 'scheme'¶
- reserved_identifiers: ClassVar[frozenset[str]] = frozenset({})¶
- property scalar_body_preamble: dict[type, tuple[str, ...]]¶
Per-instance scalar body preamble (Scheme needs none).
- property scalar_preamble: dict[type, tuple[str, ...]]¶
Per-instance scalar preamble (Scheme needs none).
- sequence_binding_declarations(declarations: tuple[str, ...]) str¶
Default
sequence_binding_declarations– join the per-binding snippets with newlines.
- sequence_format: SequenceFormats = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=')', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=False, empty_sequence='(list)', preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)¶
- property sequence_format_config: SequenceFormatConfig¶
Configuration for the chosen sequence format.
Under
json_typearrays are emitted as(vector ...)soscm->jsonround-trips them as JSON arrays unambiguously.
- sequence_formats¶
alias of
SequenceFormats
- property sequence_open: Callable[[list[Value]], str]¶
Callable that returns the opening delimiter for a sequence.
- set_format: SetFormats = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close=')', empty_set='(list)', preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)¶
- property set_format_config: SetFormatConfig¶
Configuration for the chosen set format.
Under
json_typesets share the array form ((vector ...)); JSON has no native set type.
- set_formats¶
alias of
SetFormats
- skip_null_dict_values: ClassVar[bool] = False¶
- special_float_preamble: ClassVar[tuple[str, ...]] = ()¶
- statement_terminator: ClassVar[str] = ''¶
- statement_terminator_style: StatementTerminatorStyles = 1¶
- statement_terminator_styles¶
alias of
StatementTerminatorStyles
- static_body_preamble: ClassVar[Sequence[str]] = ()¶
- property static_preamble: Sequence[str]¶
File-scope preamble.
Under
json_typethe rendered value is a tree of Scheme association lists and vectors that(scm->json ...)accepts directly, so the(json)module must be imported.
- string_format: StringFormats = 1¶
- string_formats¶
alias of
StringFormats
- supported_ref_cases: ClassVar[frozenset[IdentifierCase]] = frozenset({IdentifierCase.CAMEL, IdentifierCase.KEBAB, IdentifierCase.PASCAL, IdentifierCase.SNAKE, IdentifierCase.UPPER_SNAKE})¶
- supports_call_style = True¶
- supports_collection_comments: ClassVar[bool] = True¶
- supports_default_dict_key_type = False¶
- supports_default_dict_value_type = False¶
- supports_default_ordered_map_value_type = False¶
- supports_default_sequence_element_type = False¶
- supports_default_set_element_type = False¶
- supports_dict_literal_as_free_expression = True¶
- supports_dotted_call_stub = True¶
- supports_dotted_calls = True¶
- supports_empty_dict_key = False¶
- supports_inline_multiline_dict_args = True¶
- supports_module_name = False¶
- supports_multi_param_call_wrapper_stub = True¶
- supports_no_variable_wrap_in_file = True¶
- supports_non_string_dict_keys = True¶
- supports_record_shape_names = False¶
- supports_record_struct_name_prefix = False¶
- supports_scalar_before_comments: ClassVar[bool] = True¶
- supports_scalar_inline_comments: ClassVar[bool] = False¶
- supports_special_floats = True¶
- supports_standalone_comments_in_wrapped_calls = True¶
- supports_variable_names = True¶
- supports_zero_parameter_calls = True¶
- trailing_comma: TrailingCommas = TrailingCommaConfig(multiline_trailing_comma=False)¶
- property trailing_comma_config: TrailingCommaConfig¶
Configuration for trailing-comma behavior.
- trailing_commas¶
alias of
TrailingCommas
- true_literal: ClassVar[str] = '#t'¶
- property type_hint_collection_preamble_lines: Callable[[frozenset[type]], tuple[str, ...]]¶
Return preamble lines for empty-collection type hints.
- property validate_call_arg: Callable[[Value], None]¶
Return call-argument validation for this language.
- validate_spec_for_data(data: Value) None¶
Reject data that
json_type=GUILE_JSONcannot represent.Walks data under
json_typeto reject non-string dict keys (JSON objects keys must be strings) and the special floatsNaN/+inf.0/-inf.0(not valid JSON).
- variable_type_hints: VariableTypeHints = 1¶
- variable_type_hints_formats¶
alias of
VariableTypeHints
- version_formats¶
alias of
VersionFormats
- wrap_calls_with_declarations(declarations: tuple[str, ...], calls: str, body_preamble: tuple[str, ...]) str¶
Default
wrap_calls_with_declarations— concatenate the declarations and calls and route throughwrap_in_file()in call mode.
- static wrap_combined_in_file(declaration: str, assignment: str, variable_name: str, body_preamble: tuple[str, ...]) str¶
Wrap declaration and assignment in a valid file (no-op).
- static wrap_in_file(content: str, variable_name: str, body_preamble: tuple[str, ...]) str¶
Wrap code in a valid file (no-op).
- class literalizer.languages.Sml(*args: object, **kwargs: object)¶
Standard ML language specification.
- Parameters:
date_format –
How to format
datetime.datevalues.date_formats.SML— tuple literal, e.g.(2024, 1, 15).date_formats.ISO— ISO 8601 quoted string, e.g."2024-01-15".
datetime_format –
How to format
datetime.datetimevalues.datetime_formats.SML— pair of tuples, e.g.((2024, 1, 15), (12, 30, 0)).datetime_formats.ISO— ISO 8601 quoted string, e.g."2024-01-15T12:30:00".
type_name – Name of the generated custom type. Defaults to
"val_t".constructor_prefix – Prefix for generated constructor names. Defaults to
"S", producing constructors likeSNull,SBool,SInt, etc.
- class BoolFormats(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
Empty: this language has no alternative boolean formats.
- class BytesFormats(*values)¶
Bytes formatting options.
- BASE64 = <function format_bytes_base64>¶
- HEX = <function format_bytes_hex>¶
- class CallStyles(*values)¶
Sml call style options.
- CURRIED = CommandCallStyle(arg_separator=' ')¶
- POSITIONAL = PositionalCallStyle(arg_separator=', ', parenthesize_each_arg=False)¶
- class CommentFormats(*values)¶
Comment style options.
- PAREN_STAR = CommentConfig(prefix='(*', suffix=' *)')¶
- class DateFormats(*values)¶
Date format options for Standard ML.
- ISO = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- SML = DateFormatConfig(formatter=<function date_ymd_formatter.<locals>._format>, preamble_lines=(), type_produced=<class 'datetime.date'>)¶
- class DatetimeFormats(*values)¶
Datetime format options for Standard ML.
- EPOCH = DatetimeFormatConfig(formatter=<function format_datetime_epoch>, preamble_lines=(), type_produced=<class 'int'>)¶
- ISO = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- SML = DatetimeFormatConfig(formatter=<function datetime_ymdhms_formatter.<locals>._format>, preamble_lines=(), type_produced=<class 'datetime.datetime'>)¶
- class DeclarationStyles(*values)¶
Declaration style options.
- VAL = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=False)¶
- class FloatFormats(*values)¶
Float format options.
- FIXED = <function _sml_negate_float.<locals>._format>¶
- REPR = <function _sml_negate_float.<locals>._format>¶
- SCIENTIFIC = <function _sml_scientific>¶
- class HeterogeneousStrategies(*values)¶
Heterogeneous-scalar strategy options — this language only supports raising.
- ERROR = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)¶
- class IntegerFormats(*values)¶
Integer format options.
- DECIMAL = mappingproxy({'NONE': <function _sml_negate_int.<locals>._format>})¶
- HEX = mappingproxy({'NONE': <function _sml_negate_int.<locals>._format>})¶
- get_formatter(numeric_separator: Enum) Callable[[int], str]¶
Return the integer formatter for the given separator.
- class JsonTypes(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
Empty: this language has no JSON value-type variants.
- class Modifiers(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
C++/Java/C#-style declaration modifiers: this language has none.
- class SequenceFormats(*values)¶
Sequence type options for Standard ML.
- LIST = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=']', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=False, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type='val_t', narrowed_empty_form=None)¶
- class SetFormats(*values)¶
Set type options for Standard ML.
- SET = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close=']', empty_set=None, preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)¶
- class TrailingCommas(*values)¶
Trailing comma options.
- NO = TrailingCommaConfig(multiline_trailing_comma=False)¶
- allows_empty_call_parens = True¶
- bool_formats¶
alias of
BoolFormats
- bytes_format: BytesFormats = <function format_bytes_hex>¶
- bytes_formats¶
alias of
BytesFormats
- property call_data_dependent_preamble: Callable[[Value], tuple[str, ...]]¶
Return data-dependent preamble lines for call rendering.
- call_returns_expression = True¶
- call_style: CallStyles = PositionalCallStyle(arg_separator=', ', parenthesize_each_arg=False)¶
- property call_style_config: PositionalCallStyle | KeywordCallStyle | ObjectCallStyle | PostfixCallStyle | PrefixCallStyle | CommandCallStyle¶
Configuration for the chosen call style.
- call_styles¶
alias of
CallStyles
- property comment_config: CommentConfig¶
Configuration for the language’s comment syntax.
- comment_format: CommentFormats = CommentConfig(prefix='(*', suffix=' *)')¶
- comment_formats¶
alias of
CommentFormats
- property compute_body_preamble: Callable[[frozenset[type], Value], tuple[str, ...]]¶
Compute body-preamble lines from the scalar map.
- constructor_prefix: str = 'S'¶
- property consumable_ref_value_inhibits_consuming_form: Callable[[Value], bool]¶
Predicate deciding whether a ref’s underlying value type inhibits the consume form.
Delegates to
never_inhibits_consuming_form. Languages whose consume operator rejects certain value types (notably the Mojo^on register-trivial scalars) override this.
- property data_dependent_preamble: Callable[[Value], tuple[str, ...]]¶
Return data-dependent preamble lines.
- date_format: DateFormats = DateFormatConfig(formatter=<function date_ymd_formatter.<locals>._format>, preamble_lines=(), type_produced=<class 'datetime.date'>)¶
- date_formats¶
alias of
DateFormats
- datetime_format: DatetimeFormats = DatetimeFormatConfig(formatter=<function datetime_ymdhms_formatter.<locals>._format>, preamble_lines=(), type_produced=<class 'datetime.datetime'>)¶
- datetime_formats¶
alias of
DatetimeFormats
- declaration_style: DeclarationStyles = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=False)¶
- declaration_styles¶
alias of
DeclarationStyles
- dict_entry_style: DictEntryStyles = 1¶
- dict_entry_styles¶
alias of
DictEntryStyles
- dict_format: DictFormats = 1¶
- property dict_format_config: DictFormatConfig¶
Configuration for dict formatting.
- dict_formats¶
alias of
DictFormats
- dict_supports_heterogeneous_values = True¶
- element_separator: ClassVar[str] = ', '¶
- empty_dict_keys¶
alias of
EmptyDictKey
- extension = '.sml'¶
- property false_literal: str¶
Literal for the false value.
- float_format: FloatFormats = <function _sml_negate_float.<locals>._format>¶
- float_formats¶
alias of
FloatFormats
- property format_bytes: Callable[[bytes], str]¶
Callable that formats a bytes value as a string literal.
- property format_call_arg: Callable[[Value, str], str]¶
Callable that rewrites a formatted direct call argument.
Curried calls parenthesize each argument so that constructor applications are not parsed as additional arguments to the outer call.
- property format_call_arg_ref_identifier: Callable[[str, Value | None], str]¶
Rewrite a
{"$ref": "name"}identifier in a call-argument context.Delegates to
format_call_ref_identifier. Override this to allow call-argument$refvalues that would otherwise be rejected.
- property format_call_arg_ref_identifier_consumable: Callable[[str, Value | None], str]¶
Format a
$refthe caller authorized as consumable.Delegates to
format_call_arg_ref_identifier. Override this to opt into a consuming form (e.g. C++std::move).
- format_call_binding_body_preamble() tuple[str, ...]¶
Default
format_call_binding_body_preamble– no extra body preamble lines for an inference-bound call result.
- format_call_binding_file_pragmas() tuple[str, ...]¶
Default
format_call_binding_file_pragmas– no file-level compiler-pragma line for an inference-bound call result.
- property format_call_preamble_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]¶
Return file-scope stubs for a call expression.
- property format_call_ref_identifier: Callable[[str, Value | None], str]¶
Rewrite a
{"$ref": "name"}identifier into the language’s call expression syntax.
- property format_call_statement: Callable[[str], str]¶
Wrap a call expression as a val binding so it is a valid SML declaration inside a structure block.
- property format_call_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]¶
Return stub declarations for a call expression.
- property format_call_target: Callable[[Sequence[str]], str]¶
Rewrite a dotted call target into the language’s call syntax.
- property format_call_variable_assignment: Callable[[str, str, Value], str]¶
Default
format_call_variable_assignment– reuse the literal-binding assignment formatter unchanged.
- property format_call_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]¶
Callable that formats a declaration binding a call expression.
The literal-binding declaration is prepended with a
: val_ttype annotation and wraps the value in adatatypeconstructor derived from the bound value’s runtime type; a call expression has no such tag, so both are omitted and SML infers the call’s return type instead.
- static format_constructor_target(class_name: str, /) str¶
Return class_name as a zero-argument constructor call target.
- property format_date: Callable[[date], str]¶
Callable that formats a date as a string literal.
- property format_datetime: Callable[[datetime], str]¶
Callable that formats a datetime as a string literal.
- property format_float: Callable[[float], str]¶
Callable that formats a float value as a literal.
- property format_integer: Callable[[int], str]¶
Callable that formats an int value as a literal.
- property format_integer_widened: None¶
Default
format_integer_widened– no mixed-magnitude integer widening, so the renderer keeps the normal integer formatter.
- property format_ordered_map_entry: Callable[[str, Value, str], str]¶
Callable that formats one ordered-map entry.
- property format_sequence_entry: Callable[[Value, str], str]¶
Callable that formats a sequence entry.
- property format_set_entry: Callable[[Value, str], str]¶
Callable that formats a set entry.
- property format_string: Callable[[str], str]¶
Format a string value as a quoted literal.
- property format_time: Callable[[time], str]¶
Callable that formats a time as a string literal.
- property format_variable_assignment: Callable[[str, str, Value], str]¶
Callable that formats an assignment to an existing variable.
- property format_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]¶
Callable that formats a new variable declaration.
- has_free_function_calls = True¶
- property heterogeneous_behavior: HeterogeneousBehavior¶
Return the heterogeneous-behavior config.
- heterogeneous_strategies¶
alias of
HeterogeneousStrategies
- heterogeneous_strategy: HeterogeneousStrategies = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)¶
- identifier_cases: ClassVar[tuple[IdentifierCase, ...]] = (IdentifierCase.SNAKE, IdentifierCase.CAMEL, IdentifierCase.PASCAL)¶
- indent: str = ' '¶
- indent_closing_delimiter: ClassVar[bool] = False¶
- integer_format: IntegerFormats = mappingproxy({'NONE': <function _sml_negate_int.<locals>._format>})¶
- integer_formats¶
alias of
IntegerFormats
- integer_width_strategies¶
alias of
BareIntegerWidthStrategies
- integer_width_strategy: BareIntegerWidthStrategies = 1¶
- language_version: VersionFormats = 1¶
- property leading_preamble: LeadingPreamble¶
Default
leading_preamble– no preamble lines that must precedeLanguage.static_preamble.
- max_call_parameters = 9223372036854775807¶
- modifier_combinations: ClassVar[tuple[ModifierCombination, ...]] = ()¶
- property null_literal: str¶
Literal for the null value.
- numeric_literal_suffix: NumericLiteralSuffixes = 1¶
- numeric_literal_suffixes¶
alias of
NumericLiteralSuffixes
- numeric_separator: NumericSeparators = 1¶
- numeric_separators¶
alias of
NumericSeparators
- numeric_style: NumericStyles = 1¶
- numeric_styles¶
alias of
NumericStyles
- property ordered_map_format_config: OrderedMapFormatConfig¶
Configuration for ordered-map formatting.
- pygments_name = 'sml'¶
- reserved_identifiers: ClassVar[frozenset[str]] = frozenset({'op'})¶
- property scalar_body_preamble: dict[type, tuple[str, ...]]¶
Per-instance scalar body preamble for SML datatype declarations.
- scalar_preamble: ClassVar[dict[type, tuple[str, ...]]] = {}¶
- sequence_binding_declarations(declarations: tuple[str, ...]) str¶
Default
sequence_binding_declarations– join the per-binding snippets with newlines.
- sequence_format: SequenceFormats = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=']', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=False, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type='val_t', narrowed_empty_form=None)¶
- property sequence_format_config: SequenceFormatConfig¶
Configuration for the chosen sequence format.
- sequence_formats¶
alias of
SequenceFormats
- property sequence_open: Callable[[list[Value]], str]¶
Callable that returns the opening delimiter for a sequence.
- set_format: SetFormats = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close=']', empty_set=None, preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)¶
- property set_format_config: SetFormatConfig¶
Configuration for the chosen set format.
- set_formats¶
alias of
SetFormats
- skip_null_dict_values: ClassVar[bool] = False¶
- special_float_preamble: ClassVar[tuple[str, ...]] = ()¶
- statement_terminator: ClassVar[str] = ''¶
- statement_terminator_style: StatementTerminatorStyles = 1¶
- statement_terminator_styles¶
alias of
StatementTerminatorStyles
- static_body_preamble: ClassVar[Sequence[str]] = ()¶
- static_preamble: ClassVar[Sequence[str]] = ()¶
- string_format: StringFormats = 1¶
- string_formats¶
alias of
StringFormats
- supported_ref_cases: ClassVar[frozenset[IdentifierCase]] = frozenset({IdentifierCase.CAMEL, IdentifierCase.PASCAL, IdentifierCase.SNAKE, IdentifierCase.UPPER_SNAKE})¶
- supports_call_style = True¶
- supports_collection_comments: ClassVar[bool] = True¶
- supports_default_dict_key_type = False¶
- supports_default_dict_value_type = False¶
- supports_default_ordered_map_value_type = False¶
- supports_default_sequence_element_type = False¶
- supports_default_set_element_type = False¶
- supports_dict_literal_as_free_expression = True¶
- supports_dotted_call_stub = True¶
- supports_dotted_calls = True¶
- supports_empty_dict_key = False¶
- supports_inline_multiline_dict_args = True¶
- supports_module_name = False¶
- supports_multi_param_call_wrapper_stub = True¶
- supports_no_variable_wrap_in_file = False¶
- supports_non_string_dict_keys = False¶
- supports_record_shape_names = False¶
- supports_record_struct_name_prefix = False¶
- supports_scalar_before_comments: ClassVar[bool] = True¶
- supports_scalar_inline_comments: ClassVar[bool] = True¶
- supports_special_floats = True¶
- supports_standalone_comments_in_wrapped_calls = True¶
- supports_variable_names = True¶
- supports_zero_parameter_calls = True¶
- trailing_comma: TrailingCommas = TrailingCommaConfig(multiline_trailing_comma=False)¶
- property trailing_comma_config: TrailingCommaConfig¶
Configuration for trailing-comma behavior.
- trailing_commas¶
alias of
TrailingCommas
- property true_literal: str¶
Literal for the true value.
- property type_hint_collection_preamble_lines: Callable[[frozenset[type]], tuple[str, ...]]¶
Return preamble lines for empty-collection type hints.
- type_name: str = 'val_t'¶
- property validate_call_arg: Callable[[Value], None]¶
Return call-argument validation for this language.
- validate_spec_for_data(data: Value) None¶
Default
validate_spec_for_data— no spec/data constraints.
- variable_type_hints: VariableTypeHints = 1¶
- variable_type_hints_formats¶
alias of
VariableTypeHints
- version_formats¶
alias of
VersionFormats
- wrap_calls_with_declarations(declarations: tuple[str, ...], calls: str, body_preamble: tuple[str, ...]) str¶
Default
wrap_calls_with_declarations— concatenate the declarations and calls and route throughwrap_in_file()in call mode.
- static wrap_combined_in_file(declaration: str, assignment: str, variable_name: str, body_preamble: tuple[str, ...]) str¶
Unsupported: literalize() rejects BothVariableForms upstream.
- static wrap_in_file(content: str, variable_name: str, body_preamble: tuple[str, ...]) str¶
Wrap an SML val declaration at top level.
- class literalizer.languages.Swift(*args: object, **kwargs: object)¶
Swift language specification.
- class BoolFormats(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
Empty: this language has no alternative boolean formats.
- class BytesFormats(*values)¶
Bytes formatting options.
- BASE64 = <function format_bytes_base64>¶
- HEX = <function format_bytes_hex>¶
- class CommentFormats(*values)¶
Comment style options.
- BLOCK = CommentConfig(prefix='/*', suffix=' */')¶
- DOUBLE_SLASH = CommentConfig(prefix='//', suffix='')¶
- class DateFormats(*values)¶
Date format options for Swift.
- ISO = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- SWIFT = DateFormatConfig(formatter=<function _format_date_swift>, preamble_lines=('import Foundation',), type_produced=<class 'datetime.date'>)¶
- class DatetimeFormats(*values)¶
Datetime format options for Swift.
- EPOCH = DatetimeFormatConfig(formatter=<function format_datetime_epoch>, preamble_lines=(), type_produced=<class 'int'>)¶
- ISO = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- SWIFT = DatetimeFormatConfig(formatter=<function _format_datetime_swift>, preamble_lines=('import Foundation',), type_produced=<class 'datetime.datetime'>)¶
- class DeclarationStyles(*values)¶
Declaration style options.
- LET = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=False)¶
- VAR = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=True)¶
- class DictFormats(*values)¶
Dict/map format options.
- DEFAULT = <function dict_format_factory.<locals>._build>¶
- class FloatFormats(*values)¶
Float format options.
- FIXED = <function format_float_fixed>¶
- REPR = <function format_float_repr>¶
- SCIENTIFIC = <function format_float_scientific>¶
- class HeterogeneousStrategies(*values)¶
Heterogeneous-scalar strategy options.
Swift represents heterogeneous collections with
Anyby default (ERROR).RECORDinstead renders each record-shaped dict (non-empty, string-keyed) as a generatedstructdeclared in the preamble plus a matchingRecord0(field: value, ...)initializer literal, so a record-shaped dict that mixes scalars with a container is representable as a typed value even thoughDictionaryrequires a homogeneous value type.- ERROR = 1¶
- RECORD = 2¶
- class IntegerFormats(*values)¶
Integer format options.
- BINARY = mappingproxy({'NONE': <function format_integer_binary>, 'UNDERSCORE': <function format_integer_binary>})¶
- DECIMAL = mappingproxy({'NONE': <class 'str'>, 'UNDERSCORE': <function format_integer_underscore>})¶
- HEX = mappingproxy({'NONE': <function format_integer_hex>, 'UNDERSCORE': <function format_integer_hex>})¶
- OCTAL = mappingproxy({'NONE': <function format_integer_octal>, 'UNDERSCORE': <function format_integer_octal>})¶
- get_formatter(numeric_separator: Enum) Callable[[int], str]¶
Return the integer formatter for the given separator.
- class JsonTypes(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
Empty: this language has no JSON value-type variants.
- class Modifiers(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
C++/Java/C#-style declaration modifiers: this language has none.
- class SequenceFormats(*values)¶
Sequence type options for Swift.
- ARRAY = <function sequence_format_factory.<locals>._build>¶
- TUPLE = <function sequence_format_factory.<locals>._build>¶
- class SetFormats(*values)¶
Set type options for Swift.
- SET = <function set_format_factory.<locals>._build>¶
- class TrailingCommas(*values)¶
Trailing comma options.
- NO = TrailingCommaConfig(multiline_trailing_comma=False)¶
- YES = TrailingCommaConfig(multiline_trailing_comma=True)¶
- class VariableTypeHints(*values)¶
Variable type hint options.
- ALWAYS = 2¶
- NEVER = 1¶
- SAFE = 3¶
- formatter(*, auto_formatter: Callable[[str, str, Value, frozenset[Enum]], str], keyword: str, date_hint: str, datetime_hint: str, default_set_element_type: str, default_sequence_element_type: str, default_dict_value_type: str, sequence_is_tuple: bool) Callable[[str, str, Value, frozenset[Enum]], str]¶
Return the variable declaration formatter.
- allows_empty_call_parens = True¶
- bool_formats¶
alias of
BoolFormats
- bytes_format: BytesFormats = <function format_bytes_hex>¶
- bytes_formats¶
alias of
BytesFormats
- property call_data_dependent_preamble: Callable[[Value], tuple[str, ...]]¶
Return data-dependent preamble lines for call rendering.
- call_returns_expression = True¶
- call_style: CallStyles = KeywordCallStyle(separator=': ')¶
- property call_style_config: PositionalCallStyle | KeywordCallStyle | ObjectCallStyle | PostfixCallStyle | PrefixCallStyle | CommandCallStyle¶
Configuration for the chosen call style.
- call_styles¶
alias of
CallStyles
- property comment_config: CommentConfig¶
Configuration for the language’s comment syntax.
- comment_format: CommentFormats = CommentConfig(prefix='//', suffix='')¶
- comment_formats¶
alias of
CommentFormats
- property compute_body_preamble: Callable[[frozenset[type], Value], tuple[str, ...]]¶
Compute body-preamble lines from the scalar map.
- property consumable_ref_value_inhibits_consuming_form: Callable[[Value], bool]¶
Predicate deciding whether a ref’s underlying value type inhibits the consume form.
Delegates to
never_inhibits_consuming_form. Languages whose consume operator rejects certain value types (notably the Mojo^on register-trivial scalars) override this.
- property data_dependent_preamble: Callable[[Value], tuple[str, ...]]¶
Return data-dependent preamble lines.
Under
HeterogeneousStrategies.RECORDthis emits onestructdeclaration per record shape present in the data; otherwise no data-dependent lines.
- date_format: DateFormats = DateFormatConfig(formatter=<function _format_date_swift>, preamble_lines=('import Foundation',), type_produced=<class 'datetime.date'>)¶
- date_formats¶
alias of
DateFormats
- datetime_format: DatetimeFormats = DatetimeFormatConfig(formatter=<function _format_datetime_swift>, preamble_lines=('import Foundation',), type_produced=<class 'datetime.datetime'>)¶
- datetime_formats¶
alias of
DatetimeFormats
- declaration_style: DeclarationStyles = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=False)¶
- declaration_styles¶
alias of
DeclarationStyles
- default_dict_key_type: str = 'String'¶
- default_dict_value_type: str = 'Any'¶
- default_sequence_element_type: str = 'Any'¶
- default_set_element_type: str = 'AnyHashable'¶
- dict_entry_style: DictEntryStyles = 1¶
- dict_entry_styles¶
alias of
DictEntryStyles
- dict_format: DictFormats = <function dict_format_factory.<locals>._build>¶
- property dict_format_config: DictFormatConfig¶
Configuration for dict formatting.
- dict_formats¶
alias of
DictFormats
- dict_supports_heterogeneous_values = True¶
- element_separator: ClassVar[str] = ', '¶
- empty_dict_keys¶
alias of
EmptyDictKey
- extension = '.swift'¶
- false_literal: ClassVar[str] = 'false'¶
- float_format: FloatFormats = <function format_float_repr>¶
- float_formats¶
alias of
FloatFormats
- property format_bytes: Callable[[bytes], str]¶
Callable that formats a bytes value as a string literal.
- static format_call_arg(_value: Value, formatted: str, /) str¶
Callable that rewrites a formatted direct call argument.
- property format_call_arg_ref_identifier: Callable[[str, Value | None], str]¶
Rewrite a
{"$ref": "name"}identifier in a call-argument context.Delegates to
format_call_ref_identifier. Override this to allow call-argument$refvalues that would otherwise be rejected.
- property format_call_arg_ref_identifier_consumable: Callable[[str, Value | None], str]¶
Format a
$refthe caller authorized as consumable.Delegates to
format_call_arg_ref_identifier. Override this to opt into a consuming form (e.g. C++std::move).
- format_call_binding_body_preamble() tuple[str, ...]¶
Default
format_call_binding_body_preamble– no extra body preamble lines for an inference-bound call result.
- format_call_binding_file_pragmas() tuple[str, ...]¶
Default
format_call_binding_file_pragmas– no file-level compiler-pragma line for an inference-bound call result.
- property format_call_preamble_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]¶
Return file-scope stubs for a call expression.
- property format_call_ref_identifier: Callable[[str, Value | None], str]¶
Rewrite a
{"$ref": "name"}identifier into the language’s call expression syntax.
- property format_call_statement: Callable[[str], str]¶
Return call-statement formatting for this language.
- property format_call_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]¶
Return stub declarations for a call expression.
- property format_call_target: Callable[[Sequence[str]], str]¶
Rewrite a dotted call target into the language’s call syntax.
- property format_call_variable_assignment: Callable[[str, str, Value], str]¶
Default
format_call_variable_assignment– reuse the literal-binding assignment formatter unchanged.
- property format_call_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]¶
Default
format_call_variable_declaration– reuse the literal-binding declaration formatter unchanged.
- static format_constructor_target(class_name: str, /) str¶
Return class_name as a zero-argument constructor call target.
- property format_date: Callable[[date], str]¶
Callable that formats a date as a string literal.
- property format_datetime: Callable[[datetime], str]¶
Callable that formats a datetime as a string literal.
- property format_float: Callable[[float], str]¶
Callable that formats a float value as a literal.
- property format_integer: Callable[[int], str]¶
Callable that formats an int value as a literal.
- property format_integer_widened: None¶
Default
format_integer_widened– no mixed-magnitude integer widening, so the renderer keeps the normal integer formatter.
- property format_ordered_map_entry: Callable[[str, Value, str], str]¶
Callable that formats one ordered-map entry.
- property format_sequence_entry: Callable[[Value, str], str]¶
Callable that formats a sequence entry.
- property format_set_entry: Callable[[Value, str], str]¶
Format a set entry.
- property format_string: Callable[[str], str]¶
Format a string value as a quoted literal.
- property format_time: Callable[[time], str]¶
Callable that formats a time as a string literal.
- property format_variable_assignment: Callable[[str, str, Value], str]¶
Format an assignment to an existing variable.
- property format_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]¶
Callable that formats a new variable declaration.
- has_free_function_calls = True¶
- property heterogeneous_behavior: HeterogeneousBehavior¶
Return the behavior for the chosen heterogeneous strategy.
- heterogeneous_strategies¶
alias of
HeterogeneousStrategies
- heterogeneous_strategy: HeterogeneousStrategies = 1¶
- identifier_cases: ClassVar[tuple[IdentifierCase, ...]] = (IdentifierCase.CAMEL, IdentifierCase.PASCAL, IdentifierCase.UPPER_SNAKE)¶
- indent: str = ' '¶
- indent_closing_delimiter: ClassVar[bool] = False¶
- integer_format: IntegerFormats = mappingproxy({'NONE': <class 'str'>, 'UNDERSCORE': <function format_integer_underscore>})¶
- integer_formats¶
alias of
IntegerFormats
- integer_width_strategies¶
alias of
BareIntegerWidthStrategies
- integer_width_strategy: BareIntegerWidthStrategies = 1¶
- language_version: VersionFormats = 1¶
- property leading_preamble: LeadingPreamble¶
Default
leading_preamble– no preamble lines that must precedeLanguage.static_preamble.
- max_call_parameters = 9223372036854775807¶
- modifier_combinations: ClassVar[tuple[ModifierCombination, ...]] = ()¶
- null_literal: ClassVar[str] = 'nil'¶
- numeric_literal_suffix: NumericLiteralSuffixes = 1¶
- numeric_literal_suffixes¶
alias of
NumericLiteralSuffixes
- numeric_separator: NumericSeparators = 1¶
- numeric_separators¶
alias of
NumericSeparators
- numeric_style: NumericStyles = 1¶
- numeric_styles¶
alias of
NumericStyles
- property ordered_map_format_config: OrderedMapFormatConfig¶
Configuration for ordered-map formatting.
- pygments_name = 'swift'¶
- record_struct_name_prefix: str = 'Record'¶
- reserved_identifiers: ClassVar[frozenset[str]] = frozenset({})¶
- scalar_body_preamble: ClassVar[dict[type, tuple[str, ...]]] = {}¶
- property scalar_preamble: dict[type, tuple[str, ...]]¶
Per-instance scalar preamble computed from date/datetime format.
- sequence_binding_declarations(declarations: tuple[str, ...]) str¶
Default
sequence_binding_declarations– join the per-binding snippets with newlines.
- sequence_format: SequenceFormats = <function sequence_format_factory.<locals>._build>¶
- property sequence_format_config: SequenceFormatConfig¶
Configuration for the chosen sequence format.
- sequence_formats¶
alias of
SequenceFormats
- property sequence_open: Callable[[list[Value]], str]¶
Callable that returns the opening delimiter for a sequence.
- set_format: SetFormats = <function set_format_factory.<locals>._build>¶
- property set_format_config: SetFormatConfig¶
Configuration for the chosen set format.
- set_formats¶
alias of
SetFormats
- skip_null_dict_values: ClassVar[bool] = False¶
- special_float_preamble: ClassVar[tuple[str, ...]] = ()¶
- statement_terminator: ClassVar[str] = ';'¶
- statement_terminator_style: StatementTerminatorStyles = 1¶
- statement_terminator_styles¶
alias of
StatementTerminatorStyles
- static_body_preamble: ClassVar[Sequence[str]] = ()¶
- static_preamble: ClassVar[Sequence[str]] = ()¶
- string_format: StringFormats = 1¶
- string_formats¶
alias of
StringFormats
- supported_ref_cases: ClassVar[frozenset[IdentifierCase]] = frozenset({IdentifierCase.CAMEL, IdentifierCase.PASCAL, IdentifierCase.SNAKE, IdentifierCase.UPPER_SNAKE})¶
- supports_call_style = True¶
- supports_collection_comments: ClassVar[bool] = True¶
- supports_default_dict_key_type = True¶
- supports_default_dict_value_type = True¶
- supports_default_ordered_map_value_type = False¶
- supports_default_sequence_element_type = True¶
- supports_default_set_element_type = True¶
- supports_dict_literal_as_free_expression = True¶
- supports_dotted_call_stub = True¶
- supports_dotted_calls = True¶
- supports_empty_dict_key = False¶
- supports_inline_multiline_dict_args = True¶
- supports_module_name = False¶
- supports_multi_param_call_wrapper_stub = True¶
- supports_no_variable_wrap_in_file = False¶
- supports_non_string_dict_keys = True¶
- supports_record_shape_names = False¶
- supports_record_struct_name_prefix = True¶
- supports_scalar_before_comments: ClassVar[bool] = False¶
- supports_scalar_inline_comments: ClassVar[bool] = True¶
- supports_special_floats = True¶
- supports_standalone_comments_in_wrapped_calls = True¶
- supports_variable_names = True¶
- supports_zero_parameter_calls = True¶
- trailing_comma: TrailingCommas = TrailingCommaConfig(multiline_trailing_comma=True)¶
- property trailing_comma_config: TrailingCommaConfig¶
Configuration for trailing-comma behavior.
- trailing_commas¶
alias of
TrailingCommas
- true_literal: ClassVar[str] = 'true'¶
- property type_hint_collection_preamble_lines: Callable[[frozenset[type]], tuple[str, ...]]¶
Return preamble lines for empty-collection type hints.
- property validate_call_arg: Callable[[Value], None]¶
Return call-argument validation for this language.
- validate_spec_for_data(data: Value) None¶
Default
validate_spec_for_data— no spec/data constraints.
- variable_type_hints: VariableTypeHints = 1¶
- variable_type_hints_formats¶
alias of
VariableTypeHints
- version_formats¶
alias of
VersionFormats
- wrap_calls_with_declarations(declarations: tuple[str, ...], calls: str, body_preamble: tuple[str, ...]) str¶
Default
wrap_calls_with_declarations— concatenate the declarations and calls and route throughwrap_in_file()in call mode.
- static wrap_combined_in_file(declaration: str, assignment: str, variable_name: str, body_preamble: tuple[str, ...]) str¶
Wrap declaration and assignment in a valid file (no-op).
- static wrap_in_file(content: str, variable_name: str, body_preamble: tuple[str, ...]) str¶
Wrap code in a valid file (no-op).
- class literalizer.languages.SystemVerilog(*args: object, **kwargs: object)¶
SystemVerilog language specification.
- class BoolFormats(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
Empty: this language has no alternative boolean formats.
- class BytesFormats(*values)¶
Bytes formatting options.
- BASE64 = <function format_bytes_base64>¶
- HEX = <function format_bytes_hex>¶
- class CallStyles(*values)¶
SystemVerilog call style options.
- POSITIONAL = PositionalCallStyle(arg_separator=', ', parenthesize_each_arg=False)¶
- class CommentFormats(*values)¶
Comment style options.
- BLOCK = CommentConfig(prefix='/*', suffix=' */')¶
- DOUBLE_SLASH = CommentConfig(prefix='//', suffix='')¶
- class DateFormats(*values)¶
Date format options for SystemVerilog.
- ISO = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- class DatetimeFormats(*values)¶
Datetime format options for SystemVerilog.
- EPOCH = DatetimeFormatConfig(formatter=<function format_datetime_epoch>, preamble_lines=(), type_produced=<class 'int'>)¶
- ISO = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- class DeclarationStyles(*values)¶
Declaration style options.
- TYPED = DeclarationStyleConfig(formatter=<function _format_variable_declaration>, supports_redefinition=True)¶
- class FloatFormats(*values)¶
Float format options.
- FIXED = <function format_float_fixed>¶
- REPR = <function format_float_repr>¶
- SCIENTIFIC = <function format_float_scientific>¶
- class HeterogeneousStrategies(*values)¶
Heterogeneous-scalar strategy options — this language only supports raising.
- ERROR = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)¶
- class IntegerFormats(*values)¶
Integer format options.
- DECIMAL = <function _format_integer_decimal_sv>¶
- HEX = <function _format_integer_hex_sv>¶
- class JsonTypes(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
Empty: this language has no JSON value-type variants.
- class Modifiers(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
C++/Java/C#-style declaration modifiers: this language has none.
- class SequenceFormats(*values)¶
Sequence type options for SystemVerilog.
- ARRAY = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close='}', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=False, empty_sequence="'{}", preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)¶
- class SetFormats(*values)¶
Set type options for SystemVerilog.
- SET = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close='}', empty_set="'{}", preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)¶
- class TrailingCommas(*values)¶
Trailing comma options.
- NO = TrailingCommaConfig(multiline_trailing_comma=False)¶
- allows_empty_call_parens = True¶
- bool_formats¶
alias of
BoolFormats
- bytes_format: BytesFormats = <function format_bytes_hex>¶
- bytes_formats¶
alias of
BytesFormats
- property call_data_dependent_preamble: Callable[[Value], tuple[str, ...]]¶
Return data-dependent preamble lines for call rendering.
- call_returns_expression = True¶
- call_style: CallStyles = PositionalCallStyle(arg_separator=', ', parenthesize_each_arg=False)¶
- property call_style_config: PositionalCallStyle | KeywordCallStyle | ObjectCallStyle | PostfixCallStyle | PrefixCallStyle | CommandCallStyle¶
Configuration for the chosen call style.
- call_styles¶
alias of
CallStyles
- property comment_config: CommentConfig¶
Configuration for the language’s comment syntax.
- comment_format: CommentFormats = CommentConfig(prefix='//', suffix='')¶
- comment_formats¶
alias of
CommentFormats
- property compute_body_preamble: Callable[[frozenset[type], Value], tuple[str, ...]]¶
Compute body-preamble lines from the scalar map.
- property consumable_ref_value_inhibits_consuming_form: Callable[[Value], bool]¶
Predicate deciding whether a ref’s underlying value type inhibits the consume form.
Delegates to
never_inhibits_consuming_form. Languages whose consume operator rejects certain value types (notably the Mojo^on register-trivial scalars) override this.
- property data_dependent_preamble: Callable[[Value], tuple[str, ...]]¶
Return data-dependent preamble lines.
- date_format: DateFormats = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- date_formats¶
alias of
DateFormats
- datetime_format: DatetimeFormats = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- datetime_formats¶
alias of
DatetimeFormats
- declaration_style: DeclarationStyles = DeclarationStyleConfig(formatter=<function _format_variable_declaration>, supports_redefinition=True)¶
- declaration_styles¶
alias of
DeclarationStyles
- dict_entry_style: DictEntryStyles = 1¶
- dict_entry_styles¶
alias of
DictEntryStyles
- dict_format: DictFormats = 1¶
- property dict_format_config: DictFormatConfig¶
Configuration for dict formatting.
- dict_formats¶
alias of
DictFormats
- dict_supports_heterogeneous_values = True¶
- element_separator: ClassVar[str] = ', '¶
- empty_dict_keys¶
alias of
EmptyDictKey
- extension = '.sv'¶
- false_literal: ClassVar[str] = '_VVal\'{tag: _VVAL_INT, i: 0, r: 0.0, s: ""}'¶
- float_format: FloatFormats = <function format_float_repr>¶
- float_formats¶
alias of
FloatFormats
- property format_bytes: Callable[[bytes], str]¶
Callable that formats a bytes value as a string literal.
- property format_call_arg: Callable[[Value, str], str]¶
Wrap each call argument in the
_VValstruct literal.
- property format_call_arg_ref_identifier: Callable[[str, Value | None], str]¶
Emit a call-argument
$refas the bare identifier.Call arguments have their type fixed by the function signature, so the scalar/dict shape mismatch that affects
format_call_ref_identifier(top-level$refinliteralize()) does not arise here.
- property format_call_arg_ref_identifier_consumable: Callable[[str, Value | None], str]¶
Format a
$refthe caller authorized as consumable.Delegates to
format_call_arg_ref_identifier. Override this to opt into a consuming form (e.g. C++std::move).
- format_call_binding_body_preamble() tuple[str, ...]¶
Default
format_call_binding_body_preamble– no extra body preamble lines for an inference-bound call result.
- format_call_binding_file_pragmas() tuple[str, ...]¶
Default
format_call_binding_file_pragmas– no file-level compiler-pragma line for an inference-bound call result.
- property format_call_preamble_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]¶
Return file-scope stubs for a call expression.
- property format_call_ref_identifier: Callable[[str, Value | None], str]¶
Rewrite a
{"$ref": "name"}identifier into the language’s call expression syntax, rejecting scalar refs.SystemVerilog’s variable declarations key the type off the marker mapping shape (
_VKV name[]), so a top-level ref pointing to a scalar produces a typed declaration that does not match the referenced_VValvariable. Refuse those cases so the renderer fails fast instead of emitting code that the SystemVerilog compiler rejects with “types are not assignment compatible”.
- property format_call_statement: Callable[[str], str]¶
Return call-statement formatting for this language.
- property format_call_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]¶
Return stub declarations for a call expression.
- property format_call_target: Callable[[Sequence[str]], str]¶
Rewrite a dotted call target into the language’s call syntax.
- property format_call_variable_assignment: Callable[[str, str, Value], str]¶
Callable that formats an assignment binding a call result.
The call-expression counterpart of
format_variable_assignment; the_VValstruct-literal wrapping is dropped since the call already yields a_VVal.
- property format_call_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]¶
Callable that formats a declaration binding a call result.
A literal binding wraps the right-hand side in a named
_VValstruct literal derived from the parsed value’s runtime type; a call’s return type is opaque to the renderer and is always the universal_VValstruct (the type every generated value-returning call stub returns), so the call result is bound directly with a plainstatic _VValdeclaration and no struct-literal wrapping.
- static format_constructor_target(class_name: str, /) str¶
Return class_name as a zero-argument constructor call target.
- property format_date: Callable[[date], str]¶
Callable that formats a date as a string literal.
- property format_datetime: Callable[[datetime], str]¶
Callable that formats a datetime as a string literal.
- property format_float: Callable[[float], str]¶
Callable that formats a float value as a literal.
- property format_integer: Callable[[int], str]¶
Callable that formats an int value as a literal.
- property format_integer_widened: None¶
Default
format_integer_widened– no mixed-magnitude integer widening, so the renderer keeps the normal integer formatter.
- property format_ordered_map_entry: Callable[[str, Value, str], str]¶
Callable that formats one ordered-map entry.
- property format_sequence_entry: Callable[[Value, str], str]¶
Format a sequence entry.
- property format_set_entry: Callable[[Value, str], str]¶
Format a set entry.
- property format_string: Callable[[str], str]¶
Format a string value as a quoted literal.
- property format_time: Callable[[time], str]¶
Callable that formats a time as a string literal.
- property format_variable_assignment: Callable[[str, str, Value], str]¶
Format an assignment to an existing variable.
- property format_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]¶
Callable that formats a new variable declaration.
- has_free_function_calls = True¶
- property heterogeneous_behavior: HeterogeneousBehavior¶
Return the heterogeneous-behavior config.
- heterogeneous_strategies¶
alias of
HeterogeneousStrategies
- heterogeneous_strategy: HeterogeneousStrategies = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)¶
- identifier_cases: ClassVar[tuple[IdentifierCase, ...]] = (IdentifierCase.SNAKE, IdentifierCase.UPPER_SNAKE)¶
- indent: str = ' '¶
- indent_closing_delimiter: ClassVar[bool] = False¶
- integer_format: IntegerFormats = <function _format_integer_decimal_sv>¶
- integer_formats¶
alias of
IntegerFormats
- integer_width_strategies¶
alias of
BareIntegerWidthStrategies
- integer_width_strategy: BareIntegerWidthStrategies = 1¶
- language_version: VersionFormats = 1¶
- property leading_preamble: LeadingPreamble¶
Default
leading_preamble– no preamble lines that must precedeLanguage.static_preamble.
- max_call_parameters = 9223372036854775807¶
- modifier_combinations: ClassVar[tuple[ModifierCombination, ...]] = ()¶
- module_name: str = 'Module'¶
- module_name_case: ClassVar[IdentifierCase] = 'snake'¶
- null_literal: ClassVar[str] = '_VVal\'{tag: _VVAL_STR, i: 0, r: 0.0, s: ""}'¶
- numeric_literal_suffix: NumericLiteralSuffixes = 1¶
- numeric_literal_suffixes¶
alias of
NumericLiteralSuffixes
- numeric_separator: NumericSeparators = 1¶
- numeric_separators¶
alias of
NumericSeparators
- numeric_style: NumericStyles = 1¶
- numeric_styles¶
alias of
NumericStyles
- property ordered_map_format_config: OrderedMapFormatConfig¶
Configuration for ordered-map formatting.
- pygments_name = 'systemverilog'¶
- reserved_identifiers: ClassVar[frozenset[str]] = frozenset({})¶
- scalar_body_preamble: ClassVar[dict[type, tuple[str, ...]]] = {}¶
- scalar_preamble: ClassVar[dict[type, tuple[str, ...]]] = {}¶
- sequence_binding_declarations(declarations: tuple[str, ...]) str¶
Default
sequence_binding_declarations– join the per-binding snippets with newlines.
- sequence_format: SequenceFormats = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close='}', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=False, empty_sequence="'{}", preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)¶
- property sequence_format_config: SequenceFormatConfig¶
Configuration for the chosen sequence format.
- sequence_formats¶
alias of
SequenceFormats
- property sequence_open: Callable[[list[Value]], str]¶
Callable that returns the opening delimiter for a sequence.
- set_format: SetFormats = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close='}', empty_set="'{}", preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)¶
- property set_format_config: SetFormatConfig¶
Configuration for the chosen set format.
- set_formats¶
alias of
SetFormats
- skip_null_dict_values: ClassVar[bool] = False¶
- special_float_preamble: ClassVar[tuple[str, ...]] = ()¶
- statement_terminator: ClassVar[str] = ';'¶
- statement_terminator_style: StatementTerminatorStyles = 1¶
- statement_terminator_styles¶
alias of
StatementTerminatorStyles
- static_body_preamble: ClassVar[Sequence[str]] = ()¶
- static_preamble: ClassVar[Sequence[str]] = ('typedef enum int {_VVAL_INT, _VVAL_REAL, _VVAL_STR} _VTag;\ntypedef struct {\n _VTag tag;\n longint i;\n real r;\n string s;\n} _VVal;\ntypedef struct {\n string k;\n _VVal v;\n} _VKV;',)¶
- string_format: StringFormats = 1¶
- string_formats¶
alias of
StringFormats
- supported_ref_cases: ClassVar[frozenset[IdentifierCase]] = frozenset({IdentifierCase.CAMEL, IdentifierCase.PASCAL, IdentifierCase.SNAKE, IdentifierCase.UPPER_SNAKE})¶
- supports_call_style = True¶
- supports_collection_comments: ClassVar[bool] = True¶
- supports_default_dict_key_type = False¶
- supports_default_dict_value_type = False¶
- supports_default_ordered_map_value_type = False¶
- supports_default_sequence_element_type = False¶
- supports_default_set_element_type = False¶
- supports_dict_literal_as_free_expression = False¶
- supports_dotted_call_stub = True¶
- supports_dotted_calls = True¶
- supports_empty_dict_key = False¶
- supports_inline_multiline_dict_args = True¶
- supports_module_name = True¶
- supports_multi_param_call_wrapper_stub = True¶
- supports_no_variable_wrap_in_file = False¶
- supports_non_string_dict_keys = False¶
- supports_record_shape_names = False¶
- supports_record_struct_name_prefix = False¶
- supports_scalar_before_comments: ClassVar[bool] = True¶
- supports_scalar_inline_comments: ClassVar[bool] = False¶
- supports_special_floats = True¶
- supports_standalone_comments_in_wrapped_calls = True¶
- supports_variable_names = True¶
- supports_zero_parameter_calls = True¶
- trailing_comma: TrailingCommas = TrailingCommaConfig(multiline_trailing_comma=False)¶
- property trailing_comma_config: TrailingCommaConfig¶
Configuration for trailing-comma behavior.
- trailing_commas¶
alias of
TrailingCommas
- true_literal: ClassVar[str] = '_VVal\'{tag: _VVAL_INT, i: 1, r: 0.0, s: ""}'¶
- property type_hint_collection_preamble_lines: Callable[[frozenset[type]], tuple[str, ...]]¶
Return preamble lines for empty-collection type hints.
- property validate_call_arg: Callable[[Value], None]¶
Return call-argument validation for this language.
- validate_spec_for_data(data: Value) None¶
Default
validate_spec_for_data— no spec/data constraints.
- variable_type_hints: VariableTypeHints = 1¶
- variable_type_hints_formats¶
alias of
VariableTypeHints
- version_formats¶
alias of
VersionFormats
- wrap_call_variable_in_file(content: str, variable_name: str, body_preamble: tuple[str, ...]) str¶
Wrap a call-result variable binding in a SystemVerilog module.
In
wrap_in_file()’svariable_namebranch, body_preamble is prepended insideinitial begin(where, for a literal binding, it is data-dependent preamble). For a call binding those lines are instead the module-scopetask/function/classstubs emitted by_sv_call_stub(), and afunctiondeclared insideinitial beginis illegal. Place the stubs at module scope (matching the call-without-binding branch ofwrap_in_file()) while keeping thestatic _VVal my_data = make_widget(...);binding insideinitial begin.
- wrap_calls_with_declarations(declarations: tuple[str, ...], calls: str, body_preamble: tuple[str, ...]) str¶
Default
wrap_calls_with_declarations— concatenate the declarations and calls and route throughwrap_in_file()in call mode.
- wrap_combined_in_file(declaration: str, assignment: str, variable_name: str, body_preamble: tuple[str, ...]) str¶
Wrap SystemVerilog declaration + assignment in a module.
- wrap_in_file(content: str, variable_name: str, body_preamble: tuple[str, ...]) str¶
Wrap a SystemVerilog declaration in a module.
In call mode (
variable_nameis empty), body_preamble holds task/function stubs that go at module scope outsideinitial begin. In declaration mode, body_preamble is prepended insideinitial beginas usual.
- class literalizer.languages.Tcl(*args: object, **kwargs: object)¶
Tcl language specification.
- class BoolFormats(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
Empty: this language has no alternative boolean formats.
- class BytesFormats(*values)¶
Bytes formatting options.
- BASE64 = <function format_bytes_base64>¶
- HEX = <function format_bytes_hex>¶
- class DateFormats(*values)¶
Date format options.
- ISO = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- class DatetimeFormats(*values)¶
Datetime format options.
- EPOCH = DatetimeFormatConfig(formatter=<function format_datetime_epoch>, preamble_lines=(), type_produced=<class 'int'>)¶
- ISO = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- class DeclarationStyles(*values)¶
Declaration style options.
- SET = DeclarationStyleConfig(formatter=<function _format_tcl_declaration>, supports_redefinition=True)¶
- class FloatFormats(*values)¶
Float format options.
- FIXED = <function format_float_fixed>¶
- REPR = <function format_float_repr>¶
- SCIENTIFIC = <function format_float_scientific>¶
- class HeterogeneousStrategies(*values)¶
Heterogeneous-scalar strategy options — this language only supports raising.
- ERROR = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)¶
- class JsonTypes(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
Empty: this language has no JSON value-type variants.
- class Modifiers(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
C++/Java/C#-style declaration modifiers: this language has none.
- class SequenceFormats(*values)¶
Sequence type options.
- LIST = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=']', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=False, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)¶
- class SetFormats(*values)¶
Set type options.
- DICT = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close=']', empty_set=None, preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)¶
- class StringFormats(*values)¶
String format options.
- DOUBLE = <function _build_backslash_formatter.<locals>._format>¶
- class TrailingCommas(*values)¶
Trailing comma options.
- NO = TrailingCommaConfig(multiline_trailing_comma=False)¶
- allows_empty_call_parens = True¶
- bool_formats¶
alias of
BoolFormats
- bytes_format: BytesFormats = <function format_bytes_hex>¶
- bytes_formats¶
alias of
BytesFormats
- property call_data_dependent_preamble: Callable[[Value], tuple[str, ...]]¶
Return data-dependent preamble lines for call rendering.
- call_returns_expression = True¶
- call_style: CallStyles = CommandCallStyle(arg_separator=' ')¶
- property call_style_config: PositionalCallStyle | KeywordCallStyle | ObjectCallStyle | PostfixCallStyle | PrefixCallStyle | CommandCallStyle¶
Configuration for the chosen call style.
- call_styles¶
alias of
CallStyles
- property comment_config: CommentConfig¶
Configuration for the language’s comment syntax.
- comment_format: CommentFormats = CommentConfig(prefix='#', suffix='')¶
- comment_formats¶
alias of
CommentFormats
- property compute_body_preamble: Callable[[frozenset[type], Value], tuple[str, ...]]¶
Compute body-preamble lines from the scalar map.
- property consumable_ref_value_inhibits_consuming_form: Callable[[Value], bool]¶
Predicate deciding whether a ref’s underlying value type inhibits the consume form.
Delegates to
never_inhibits_consuming_form. Languages whose consume operator rejects certain value types (notably the Mojo^on register-trivial scalars) override this.
- property data_dependent_preamble: Callable[[Value], tuple[str, ...]]¶
Return data-dependent preamble lines.
- date_format: DateFormats = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- date_formats¶
alias of
DateFormats
- datetime_format: DatetimeFormats = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- datetime_formats¶
alias of
DatetimeFormats
- declaration_style: DeclarationStyles = DeclarationStyleConfig(formatter=<function _format_tcl_declaration>, supports_redefinition=True)¶
- declaration_styles¶
alias of
DeclarationStyles
- dict_entry_style: DictEntryStyles = 1¶
- dict_entry_styles¶
alias of
DictEntryStyles
- dict_format: DictFormats = 1¶
- property dict_format_config: DictFormatConfig¶
Configuration for dict formatting.
- dict_formats¶
alias of
DictFormats
- dict_supports_heterogeneous_values = True¶
- element_separator: ClassVar[str] = ' '¶
- empty_dict_keys¶
alias of
EmptyDictKey
- extension = '.tcl'¶
- false_literal: ClassVar[str] = '0'¶
- float_format: FloatFormats = <function format_float_repr>¶
- float_formats¶
alias of
FloatFormats
- property format_bytes: Callable[[bytes], str]¶
Callable that formats a bytes value as a string literal.
- static format_call_arg(_value: Value, formatted: str, /) str¶
Callable that rewrites a formatted direct call argument.
- property format_call_arg_ref_identifier: Callable[[str, Value | None], str]¶
Rewrite a
{"$ref": "name"}identifier in a call-argument context.Delegates to
format_call_ref_identifier. Override this to allow call-argument$refvalues that would otherwise be rejected.
- property format_call_arg_ref_identifier_consumable: Callable[[str, Value | None], str]¶
Format a
$refthe caller authorized as consumable.Delegates to
format_call_arg_ref_identifier. Override this to opt into a consuming form (e.g. C++std::move).
- format_call_binding_body_preamble() tuple[str, ...]¶
Default
format_call_binding_body_preamble– no extra body preamble lines for an inference-bound call result.
- format_call_binding_file_pragmas() tuple[str, ...]¶
Default
format_call_binding_file_pragmas– no file-level compiler-pragma line for an inference-bound call result.
- property format_call_preamble_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]¶
Return file-scope stubs for a call expression.
- property format_call_ref_identifier: Callable[[str, Value | None], str]¶
Rewrite a
{"$ref": "name"}identifier into the language’s call expression syntax.
- property format_call_statement: Callable[[str], str]¶
Return call-statement formatting for this language.
- property format_call_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]¶
Return stub declarations for a call expression.
- property format_call_target: Callable[[Sequence[str]], str]¶
Rewrite a dotted call target into the language’s call syntax.
- property format_call_variable_assignment: Callable[[str, str, Value], str]¶
Callable that formats an assignment binding a call expression.
setis the only binding form in this language, so an existing-variable assignment shares the command-substitution template withformat_call_variable_declaration.
- property format_call_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]¶
Callable that formats a declaration binding a call expression.
The literal-binding template emits the right-hand side as a value word; a call result must be command-substituted with
[...]so Tcl runs the command instead of treating its name and arguments as a literal list.
- static format_constructor_target(class_name: str, /) str¶
Return class_name as a zero-argument constructor call target.
- property format_date: Callable[[date], str]¶
Callable that formats a date as a string literal.
- property format_datetime: Callable[[datetime], str]¶
Callable that formats a datetime as a string literal.
- property format_float: Callable[[float], str]¶
Callable that formats a float value as a literal.
- property format_integer: Callable[[int], str]¶
Format an int value as a literal.
- property format_integer_widened: None¶
Default
format_integer_widened– no mixed-magnitude integer widening, so the renderer keeps the normal integer formatter.
- property format_ordered_map_entry: Callable[[str, Value, str], str]¶
Format one ordered-map entry.
- property format_sequence_entry: Callable[[Value, str], str]¶
Format a sequence entry.
- property format_set_entry: Callable[[Value, str], str]¶
Format a set entry.
- property format_string: Callable[[str], str]¶
Callable that formats a string value as a quoted literal.
- property format_time: Callable[[time], str]¶
Callable that formats a time as a string literal.
- property format_variable_assignment: Callable[[str, str, Value], str]¶
Callable that formats an assignment to an existing variable.
- property format_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]¶
Callable that formats a new variable declaration.
- has_free_function_calls = True¶
- property heterogeneous_behavior: HeterogeneousBehavior¶
Return the heterogeneous-behavior config.
- heterogeneous_strategies¶
alias of
HeterogeneousStrategies
- heterogeneous_strategy: HeterogeneousStrategies = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)¶
- identifier_cases: ClassVar[tuple[IdentifierCase, ...]] = (IdentifierCase.SNAKE, IdentifierCase.CAMEL)¶
- indent: str = ' '¶
- indent_closing_delimiter: ClassVar[bool] = False¶
- integer_format: IntegerFormats = 1¶
- integer_formats¶
alias of
IntegerFormats
- integer_width_strategies¶
alias of
BareIntegerWidthStrategies
- integer_width_strategy: BareIntegerWidthStrategies = 1¶
- language_version: VersionFormats = 1¶
- property leading_preamble: LeadingPreamble¶
Default
leading_preamble– no preamble lines that must precedeLanguage.static_preamble.
- max_call_parameters = 9223372036854775807¶
- modifier_combinations: ClassVar[tuple[ModifierCombination, ...]] = ()¶
- null_literal: ClassVar[str] = '""'¶
- numeric_literal_suffix: NumericLiteralSuffixes = 1¶
- numeric_literal_suffixes¶
alias of
NumericLiteralSuffixes
- numeric_separator: NumericSeparators = 1¶
- numeric_separators¶
alias of
NumericSeparators
- numeric_style: NumericStyles = 1¶
- numeric_styles¶
alias of
NumericStyles
- property ordered_map_format_config: OrderedMapFormatConfig¶
Configuration for ordered-map formatting.
- pygments_name = 'tcl'¶
- reserved_identifiers: ClassVar[frozenset[str]] = frozenset({})¶
- property scalar_body_preamble: dict[type, tuple[str, ...]]¶
Per-instance scalar body preamble (Tcl needs none).
- property scalar_preamble: dict[type, tuple[str, ...]]¶
Per-instance scalar preamble (Tcl needs none).
- sequence_binding_declarations(declarations: tuple[str, ...]) str¶
Default
sequence_binding_declarations– join the per-binding snippets with newlines.
- sequence_format: SequenceFormats = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=']', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=False, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)¶
- property sequence_format_config: SequenceFormatConfig¶
Configuration for the chosen sequence format.
- sequence_formats¶
alias of
SequenceFormats
- property sequence_open: Callable[[list[Value]], str]¶
Callable that returns the opening delimiter for a sequence.
- set_format: SetFormats = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close=']', empty_set=None, preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)¶
- property set_format_config: SetFormatConfig¶
Configuration for the chosen set format.
- set_formats¶
alias of
SetFormats
- skip_null_dict_values: ClassVar[bool] = False¶
- special_float_preamble: ClassVar[tuple[str, ...]] = ()¶
- statement_terminator: ClassVar[str] = ''¶
- statement_terminator_style: StatementTerminatorStyles = 1¶
- statement_terminator_styles¶
alias of
StatementTerminatorStyles
- static_body_preamble: ClassVar[Sequence[str]] = ()¶
- static_preamble: ClassVar[Sequence[str]] = ()¶
- string_format: StringFormats = <function _build_backslash_formatter.<locals>._format>¶
- string_formats¶
alias of
StringFormats
- supported_ref_cases: ClassVar[frozenset[IdentifierCase]] = frozenset({IdentifierCase.CAMEL, IdentifierCase.PASCAL, IdentifierCase.SNAKE, IdentifierCase.UPPER_SNAKE})¶
- supports_call_style = True¶
- supports_collection_comments: ClassVar[bool] = False¶
- supports_default_dict_key_type = False¶
- supports_default_dict_value_type = False¶
- supports_default_ordered_map_value_type = False¶
- supports_default_sequence_element_type = False¶
- supports_default_set_element_type = False¶
- supports_dict_literal_as_free_expression = True¶
- supports_dotted_call_stub = True¶
- supports_dotted_calls = True¶
- supports_empty_dict_key = False¶
- supports_inline_multiline_dict_args = True¶
- supports_module_name = False¶
- supports_multi_param_call_wrapper_stub = True¶
- supports_no_variable_wrap_in_file = False¶
- supports_non_string_dict_keys = True¶
- supports_record_shape_names = False¶
- supports_record_struct_name_prefix = False¶
- supports_scalar_before_comments: ClassVar[bool] = False¶
- supports_scalar_inline_comments: ClassVar[bool] = False¶
- supports_special_floats = True¶
- supports_standalone_comments_in_wrapped_calls = True¶
- supports_variable_names = True¶
- supports_zero_parameter_calls = True¶
- trailing_comma: TrailingCommas = TrailingCommaConfig(multiline_trailing_comma=False)¶
- property trailing_comma_config: TrailingCommaConfig¶
Configuration for trailing-comma behavior.
- trailing_commas¶
alias of
TrailingCommas
- true_literal: ClassVar[str] = '1'¶
- property type_hint_collection_preamble_lines: Callable[[frozenset[type]], tuple[str, ...]]¶
Return preamble lines for empty-collection type hints.
- property validate_call_arg: Callable[[Value], None]¶
Return call-argument validation for this language.
- validate_spec_for_data(data: Value) None¶
Default
validate_spec_for_data— no spec/data constraints.
- variable_type_hints: VariableTypeHints = 1¶
- variable_type_hints_formats¶
alias of
VariableTypeHints
- version_formats¶
alias of
VersionFormats
- wrap_calls_with_declarations(declarations: tuple[str, ...], calls: str, body_preamble: tuple[str, ...]) str¶
Default
wrap_calls_with_declarations— concatenate the declarations and calls and route throughwrap_in_file()in call mode.
- static wrap_combined_in_file(declaration: str, assignment: str, variable_name: str, body_preamble: tuple[str, ...]) str¶
Wrap declaration and assignment in a valid file (no-op).
- static wrap_in_file(content: str, variable_name: str, body_preamble: tuple[str, ...]) str¶
Wrap code in a valid file (no-op).
- class literalizer.languages.Toml(*args: object, **kwargs: object)¶
TOML language specification.
Produces TOML inline values — inline tables for mappings, and arrays for sequences and sets — using TOML v1.1 multiline inline table syntax, which permits newlines and comments within braces.
nullis not a TOML type; dict entries whose value isnullare omitted (skip_null_dict_values = True), andnullvalues in sequences are rendered as the empty string"".Dates and datetimes are rendered as unquoted TOML native date / datetime literals, which are a distinct TOML type.
- class BoolFormats(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
Empty: this language has no alternative boolean formats.
- class BytesFormats(*values)¶
Bytes formatting options.
- BASE64 = <function format_bytes_base64>¶
- HEX = <function format_bytes_hex>¶
- class CallStyles(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
Toml call style options.
- class DateFormats(*values)¶
Date format options for Toml.
- ISO = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- TOML = DateFormatConfig(formatter=<function date_iso_formatter.<locals>._format>, preamble_lines=(), type_produced=<class 'datetime.date'>)¶
- class DatetimeFormats(*values)¶
Datetime format options for Toml.
- EPOCH = DatetimeFormatConfig(formatter=<function format_datetime_epoch>, preamble_lines=(), type_produced=<class 'int'>)¶
- ISO = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- TOML = DatetimeFormatConfig(formatter=<function datetime_iso_formatter.<locals>._format>, preamble_lines=(), type_produced=<class 'datetime.datetime'>)¶
- class DeclarationStyles(*values)¶
Declaration style options.
- ASSIGN = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=False)¶
- class FloatFormats(*values)¶
Float format options.
- FIXED = <function format_float_fixed>¶
- REPR = <function format_float_repr>¶
- SCIENTIFIC = <function format_float_scientific>¶
- class HeterogeneousStrategies(*values)¶
Heterogeneous-scalar strategy options — this language only supports raising.
- ERROR = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)¶
- class JsonTypes(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
Empty: this language has no JSON value-type variants.
- class Modifiers(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
C++/Java/C#-style declaration modifiers: this language has none.
- class SequenceFormats(*values)¶
Sequence type options for TOML.
- ARRAY = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=']', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)¶
- class SetFormats(*values)¶
Set type options for TOML.
- SET = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close=']', empty_set=None, preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)¶
- class TrailingCommas(*values)¶
Trailing comma options.
- NO = TrailingCommaConfig(multiline_trailing_comma=False)¶
- allows_empty_call_parens = True¶
- bool_formats¶
alias of
BoolFormats
- bytes_format: BytesFormats = <function format_bytes_hex>¶
- bytes_formats¶
alias of
BytesFormats
- property call_data_dependent_preamble: Callable[[Value], tuple[str, ...]]¶
Return data-dependent preamble lines for call rendering.
- call_returns_expression = True¶
- call_style_config: ClassVar[PositionalCallStyle | KeywordCallStyle | ObjectCallStyle | PostfixCallStyle | PrefixCallStyle | CommandCallStyle | CallSupport] = 'not_in_language'¶
- call_styles¶
alias of
CallStyles
- property comment_config: CommentConfig¶
Configuration for the language’s comment syntax.
- comment_format: CommentFormats = CommentConfig(prefix='#', suffix='')¶
- comment_formats¶
alias of
CommentFormats
- property compute_body_preamble: Callable[[frozenset[type], Value], tuple[str, ...]]¶
Compute body-preamble lines from the scalar map.
- property consumable_ref_value_inhibits_consuming_form: Callable[[Value], bool]¶
Predicate deciding whether a ref’s underlying value type inhibits the consume form.
Delegates to
never_inhibits_consuming_form. Languages whose consume operator rejects certain value types (notably the Mojo^on register-trivial scalars) override this.
- property data_dependent_preamble: Callable[[Value], tuple[str, ...]]¶
Return data-dependent preamble lines.
- date_format: DateFormats = DateFormatConfig(formatter=<function date_iso_formatter.<locals>._format>, preamble_lines=(), type_produced=<class 'datetime.date'>)¶
- date_formats¶
alias of
DateFormats
- datetime_format: DatetimeFormats = DatetimeFormatConfig(formatter=<function datetime_iso_formatter.<locals>._format>, preamble_lines=(), type_produced=<class 'datetime.datetime'>)¶
- datetime_formats¶
alias of
DatetimeFormats
- declaration_style: DeclarationStyles = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=False)¶
- declaration_styles¶
alias of
DeclarationStyles
- dict_entry_style: DictEntryStyles = 1¶
- dict_entry_styles¶
alias of
DictEntryStyles
- dict_format: DictFormats = 1¶
- property dict_format_config: DictFormatConfig¶
Configuration for dict formatting.
- dict_formats¶
alias of
DictFormats
- dict_supports_heterogeneous_values = True¶
- element_separator: ClassVar[str] = ', '¶
- empty_dict_keys¶
alias of
EmptyDictKey
- extension = '.toml'¶
- false_literal: ClassVar[str] = 'false'¶
- float_format: FloatFormats = <function format_float_repr>¶
- float_formats¶
alias of
FloatFormats
- property format_bytes: Callable[[bytes], str]¶
Callable that formats a bytes value as a string literal.
- static format_call_arg(_value: Value, formatted: str, /) str¶
Callable that rewrites a formatted direct call argument.
- property format_call_arg_ref_identifier: Callable[[str, Value | None], str]¶
Rewrite a
{"$ref": "name"}identifier in a call-argument context.Delegates to
format_call_ref_identifier. Override this to allow call-argument$refvalues that would otherwise be rejected.
- property format_call_arg_ref_identifier_consumable: Callable[[str, Value | None], str]¶
Format a
$refthe caller authorized as consumable.Delegates to
format_call_arg_ref_identifier. Override this to opt into a consuming form (e.g. C++std::move).
- format_call_binding_body_preamble() tuple[str, ...]¶
Default
format_call_binding_body_preamble– no extra body preamble lines for an inference-bound call result.
- format_call_binding_file_pragmas() tuple[str, ...]¶
Default
format_call_binding_file_pragmas– no file-level compiler-pragma line for an inference-bound call result.
- property format_call_preamble_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]¶
Return file-scope stubs for a call expression.
- property format_call_ref_identifier: Callable[[str, Value | None], str]¶
Raise for any
{"$ref": "name"}identifier.TOML is a data format; values must be literals, not variable references, so refs are not supported.
- property format_call_statement: Callable[[str], str]¶
Return call-statement formatting for this language.
- property format_call_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]¶
Return stub declarations for a call expression.
- property format_call_target: Callable[[Sequence[str]], str]¶
Rewrite a dotted call target into the language’s call syntax.
- property format_call_variable_assignment: Callable[[str, str, Value], str]¶
Default
format_call_variable_assignment– reuse the literal-binding assignment formatter unchanged.
- property format_call_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]¶
Default
format_call_variable_declaration– reuse the literal-binding declaration formatter unchanged.
- static format_constructor_target(class_name: str, /) str¶
Return class_name as a zero-argument constructor call target.
- property format_date: Callable[[date], str]¶
Callable that formats a date as a string literal.
- property format_datetime: Callable[[datetime], str]¶
Callable that formats a datetime as a string literal.
- property format_float: Callable[[float], str]¶
Callable that formats a float value as a literal.
- property format_integer: Callable[[int], str]¶
Format an int value as a literal.
- property format_integer_widened: None¶
Default
format_integer_widened– no mixed-magnitude integer widening, so the renderer keeps the normal integer formatter.
- property format_ordered_map_entry: Callable[[str, Value, str], str]¶
Format one ordered-map entry.
- property format_sequence_entry: Callable[[Value, str], str]¶
Format a sequence entry.
- property format_set_entry: Callable[[Value, str], str]¶
Format a set entry.
- property format_string: Callable[[str], str]¶
Callable that formats a string value as a quoted literal.
- property format_time: Callable[[time], str]¶
Callable that formats a time as a string literal.
- property format_variable_assignment: Callable[[str, str, Value], str]¶
Format an assignment to an existing variable.
- property format_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]¶
Callable that formats a new variable declaration.
- has_free_function_calls = True¶
- property heterogeneous_behavior: HeterogeneousBehavior¶
Return the heterogeneous-behavior config.
- heterogeneous_strategies¶
alias of
HeterogeneousStrategies
- heterogeneous_strategy: HeterogeneousStrategies = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)¶
- identifier_cases: ClassVar[tuple[IdentifierCase, ...]] = (IdentifierCase.SNAKE,)¶
- indent: str = ' '¶
- indent_closing_delimiter: ClassVar[bool] = False¶
- integer_format: IntegerFormats = 1¶
- integer_formats¶
alias of
IntegerFormats
- integer_width_strategies¶
alias of
BareIntegerWidthStrategies
- integer_width_strategy: BareIntegerWidthStrategies = 1¶
- language_version: VersionFormats = 1¶
- property leading_preamble: LeadingPreamble¶
Default
leading_preamble– no preamble lines that must precedeLanguage.static_preamble.
- max_call_parameters = 9223372036854775807¶
- modifier_combinations: ClassVar[tuple[ModifierCombination, ...]] = ()¶
- null_literal: ClassVar[str] = '""'¶
- numeric_literal_suffix: NumericLiteralSuffixes = 1¶
- numeric_literal_suffixes¶
alias of
NumericLiteralSuffixes
- numeric_separator: NumericSeparators = 1¶
- numeric_separators¶
alias of
NumericSeparators
- numeric_style: NumericStyles = 1¶
- numeric_styles¶
alias of
NumericStyles
- property ordered_map_format_config: OrderedMapFormatConfig¶
Configuration for ordered-map formatting.
- pygments_name = 'toml'¶
- reserved_identifiers: ClassVar[frozenset[str]] = frozenset({})¶
- property scalar_body_preamble: dict[type, tuple[str, ...]]¶
Per-instance scalar body preamble (TOML needs none).
- property scalar_preamble: dict[type, tuple[str, ...]]¶
Per-instance scalar preamble (TOML needs none).
- sequence_binding_declarations(declarations: tuple[str, ...]) str¶
Default
sequence_binding_declarations– join the per-binding snippets with newlines.
- sequence_format: SequenceFormats = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=']', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)¶
- property sequence_format_config: SequenceFormatConfig¶
Configuration for the chosen sequence format.
- sequence_formats¶
alias of
SequenceFormats
- property sequence_open: Callable[[list[Value]], str]¶
Callable that returns the opening delimiter for a sequence.
- set_format: SetFormats = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close=']', empty_set=None, preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)¶
- property set_format_config: SetFormatConfig¶
Configuration for the chosen set format.
- set_formats¶
alias of
SetFormats
- skip_null_dict_values: ClassVar[bool] = True¶
- special_float_preamble: ClassVar[tuple[str, ...]] = ()¶
- statement_terminator: ClassVar[str] = ''¶
- statement_terminator_style: StatementTerminatorStyles = 1¶
- statement_terminator_styles¶
alias of
StatementTerminatorStyles
- static_body_preamble: ClassVar[Sequence[str]] = ()¶
- static_preamble: ClassVar[Sequence[str]] = ()¶
- string_format: StringFormats = 1¶
- string_formats¶
alias of
StringFormats
- supported_ref_cases: ClassVar[frozenset[IdentifierCase]] = frozenset({IdentifierCase.CAMEL, IdentifierCase.PASCAL, IdentifierCase.SNAKE, IdentifierCase.UPPER_SNAKE})¶
- supports_call_style = False¶
- supports_collection_comments: ClassVar[bool] = True¶
- supports_default_dict_key_type = False¶
- supports_default_dict_value_type = False¶
- supports_default_ordered_map_value_type = False¶
- supports_default_sequence_element_type = False¶
- supports_default_set_element_type = False¶
- supports_dict_literal_as_free_expression = True¶
- supports_dotted_call_stub = True¶
- supports_dotted_calls = True¶
- supports_empty_dict_key = False¶
- supports_inline_multiline_dict_args = True¶
- supports_module_name = False¶
- supports_multi_param_call_wrapper_stub = True¶
- supports_no_variable_wrap_in_file = False¶
- supports_non_string_dict_keys = False¶
- supports_record_shape_names = False¶
- supports_record_struct_name_prefix = False¶
- supports_scalar_before_comments: ClassVar[bool] = False¶
- supports_scalar_inline_comments: ClassVar[bool] = True¶
- supports_special_floats = True¶
- supports_standalone_comments_in_wrapped_calls = True¶
- supports_variable_names = True¶
- supports_zero_parameter_calls = True¶
- trailing_comma: TrailingCommas = TrailingCommaConfig(multiline_trailing_comma=False)¶
- property trailing_comma_config: TrailingCommaConfig¶
Configuration for trailing-comma behavior.
- trailing_commas¶
alias of
TrailingCommas
- true_literal: ClassVar[str] = 'true'¶
- property type_hint_collection_preamble_lines: Callable[[frozenset[type]], tuple[str, ...]]¶
Return preamble lines for empty-collection type hints.
- property validate_call_arg: Callable[[Value], None]¶
Return call-argument validation for this language.
- validate_spec_for_data(data: Value) None¶
Default
validate_spec_for_data— no spec/data constraints.
- variable_type_hints: VariableTypeHints = 1¶
- variable_type_hints_formats¶
alias of
VariableTypeHints
- version_formats¶
alias of
VersionFormats
- wrap_calls_with_declarations(declarations: tuple[str, ...], calls: str, body_preamble: tuple[str, ...]) str¶
Default
wrap_calls_with_declarations— concatenate the declarations and calls and route throughwrap_in_file()in call mode.
- static wrap_combined_in_file(declaration: str, assignment: str, variable_name: str, body_preamble: tuple[str, ...]) str¶
Unsupported: literalize() rejects BothVariableForms upstream.
- static wrap_in_file(content: str, variable_name: str, body_preamble: tuple[str, ...]) str¶
Wrap code in a valid file (no-op).
- class literalizer.languages.TypeScript(*args: object, **kwargs: object)¶
TypeScript language specification.
- Parameters:
date_format –
How to format
datetime.datevalues.date_formats.JS—new Date(...)call, e.g.new Date("2024-01-15").date_formats.ISO— ISO 8601 quoted string, e.g."2024-01-15".
datetime_format –
How to format
datetime.datetimevalues.datetime_formats.JS—new Date(...)call, e.g.new Date("2024-01-15T12:30:00").datetime_formats.ISO— ISO 8601 quoted string, e.g."2024-01-15T12:30:00".
sequence_format –
Which TypeScript sequence type to use.
sequence_formats.ARRAY— array literal, e.g.[1, 2, 3].sequence_formats.TUPLE—as consttuple literal, e.g.[1, 2, 3] as const. TypeScript infers per-element types instead of a union array type.
- class BoolFormats(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
Empty: this language has no alternative boolean formats.
- class BytesFormats(*values)¶
Bytes formatting options.
- BASE64 = <function format_bytes_base64>¶
- HEX = <function format_bytes_hex>¶
- class CallStyles(*values)¶
TypeScript call style options.
- OBJECT = ObjectCallStyle(separator=': ')¶
- POSITIONAL = PositionalCallStyle(arg_separator=', ', parenthesize_each_arg=False)¶
- class CommentFormats(*values)¶
Comment style options.
- BLOCK = CommentConfig(prefix='/*', suffix=' */')¶
- DOUBLE_SLASH = CommentConfig(prefix='//', suffix='')¶
- class DateFormats(*values)¶
Date formatting options for TypeScript.
- ISO = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- JS = DateFormatConfig(formatter=<function date_iso_formatter.<locals>._format>, preamble_lines=(), type_produced=<class 'datetime.date'>)¶
- class DatetimeFormats(*values)¶
Datetime formatting options for TypeScript.
- EPOCH = DatetimeFormatConfig(formatter=<function format_datetime_epoch>, preamble_lines=(), type_produced=<class 'int'>)¶
- ISO = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- JS = DatetimeFormatConfig(formatter=<function datetime_iso_formatter.<locals>._format>, preamble_lines=(), type_produced=<class 'datetime.datetime'>)¶
- class DeclarationStyles(*values)¶
Declaration style options.
- CONST = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=False)¶
- LET = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=True)¶
- VAR = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=True)¶
- class DictFormats(*values)¶
Dict/map format options.
- MAP = DictFormatConfig(dict_open=<function fixed_open.<locals>._open>, close='])', format_entry=<function dict_entry_with_template.<locals>._format>, empty_dict='new Map()', preamble_lines=(), narrowed_open=None, supports_trailing_comma=True)¶
- OBJECT = DictFormatConfig(dict_open=<function fixed_open.<locals>._open>, close='}', format_entry=<function dict_entry_with_separator.<locals>._format>, empty_dict=None, preamble_lines=(), narrowed_open=None, supports_trailing_comma=True)¶
- class FloatFormats(*values)¶
Float format options.
- FIXED = <function format_float_fixed>¶
- REPR = <function format_float_repr>¶
- SCIENTIFIC = <function format_float_scientific>¶
- class HeterogeneousStrategies(*values)¶
Heterogeneous-scalar strategy options.
TypeScript represents heterogeneous scalar collections with union element / value types by default (
ERROR);TUPLEadditionally renders a fixed-length heterogeneous scalar array (a dict value or the document root, all elements scalar, spanning at least two scalar buckets) as an[e0, e1, ...] as consttuple literal, which TypeScript infers as areadonly [T0, T1, ...]tuple type.- ERROR = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)¶
- TUPLE = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=<function _render_ts_tuple>, compute_tuple_list_ids=<function _ts_tuple_list_ids>)¶
- class IntegerFormats(*values)¶
Integer format options.
- BINARY = mappingproxy({'NONE': <function format_integer_binary>, 'UNDERSCORE': <function format_integer_binary>})¶
- DECIMAL = mappingproxy({'NONE': <class 'str'>, 'UNDERSCORE': <function format_integer_underscore>})¶
- HEX = mappingproxy({'NONE': <function format_integer_hex>, 'UNDERSCORE': <function format_integer_hex>})¶
- OCTAL = mappingproxy({'NONE': <function format_integer_octal>, 'UNDERSCORE': <function format_integer_octal>})¶
- get_formatter(numeric_separator: Enum) Callable[[int], str]¶
Return the integer formatter for the given separator.
- class JsonTypes(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
Empty: this language has no JSON value-type variants.
- class Modifiers(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
C++/Java/C#-style declaration modifiers: this language has none.
- class SequenceFormats(*values)¶
Sequence type options for TypeScript.
- ARRAY = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=']', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)¶
- TUPLE = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close='] as const', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence='[] as const', preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)¶
- class SetFormats(*values)¶
Set type options for TypeScript.
- SET = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close='])', empty_set='new Set()', preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)¶
- class StatementTerminatorStyles(*values)¶
Statement terminator options.
- NONE = 'none'¶
- SEMICOLON = 1¶
- wrap_formatter(formatter: Callable[[str, str, Value, frozenset[Enum]], str]) Callable[[str, str, Value, frozenset[Enum]], str]¶
Wrap a formatter to match this statement terminator style.
- class StringFormats(*values)¶
String format options.
- DOUBLE = <function _build_backslash_formatter.<locals>._format>¶
- SINGLE = <function _build_backslash_formatter.<locals>._format>¶
- class TrailingCommas(*values)¶
Trailing comma options.
- NO = TrailingCommaConfig(multiline_trailing_comma=False)¶
- YES = TrailingCommaConfig(multiline_trailing_comma=True)¶
- class VariableTypeHints(*values)¶
Variable type hint options.
- ALWAYS = 2¶
- NEVER = 1¶
- SAFE = 3¶
- formatter(*, auto_formatter: Callable[[str, str, Value, frozenset[Enum]], str], keyword: str, date_hint: str, datetime_hint: str, dict_hint_template: str, sequence_is_tuple: bool) Callable[[str, str, Value, frozenset[Enum]], str]¶
Return the variable declaration formatter.
- allows_empty_call_parens = True¶
- bool_formats¶
alias of
BoolFormats
- bytes_format: BytesFormats = <function format_bytes_hex>¶
- bytes_formats¶
alias of
BytesFormats
- property call_data_dependent_preamble: Callable[[Value], tuple[str, ...]]¶
Return data-dependent preamble lines for call rendering.
- call_returns_expression = True¶
- call_style: CallStyles = ObjectCallStyle(separator=': ')¶
- property call_style_config: PositionalCallStyle | KeywordCallStyle | ObjectCallStyle | PostfixCallStyle | PrefixCallStyle | CommandCallStyle¶
Configuration for the chosen call style.
- call_styles¶
alias of
CallStyles
- property comment_config: CommentConfig¶
Configuration for the language’s comment syntax.
- comment_format: CommentFormats = CommentConfig(prefix='//', suffix='')¶
- comment_formats¶
alias of
CommentFormats
- property compute_body_preamble: Callable[[frozenset[type], Value], tuple[str, ...]]¶
Compute body-preamble lines from the scalar map.
- property consumable_ref_value_inhibits_consuming_form: Callable[[Value], bool]¶
Predicate deciding whether a ref’s underlying value type inhibits the consume form.
Delegates to
never_inhibits_consuming_form. Languages whose consume operator rejects certain value types (notably the Mojo^on register-trivial scalars) override this.
- property data_dependent_preamble: Callable[[Value], tuple[str, ...]]¶
Return data-dependent preamble lines.
- date_format: DateFormats = DateFormatConfig(formatter=<function date_iso_formatter.<locals>._format>, preamble_lines=(), type_produced=<class 'datetime.date'>)¶
- date_formats¶
alias of
DateFormats
- datetime_format: DatetimeFormats = DatetimeFormatConfig(formatter=<function datetime_iso_formatter.<locals>._format>, preamble_lines=(), type_produced=<class 'datetime.datetime'>)¶
- datetime_formats¶
alias of
DatetimeFormats
- declaration_style: DeclarationStyles = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=False)¶
- declaration_styles¶
alias of
DeclarationStyles
- dict_entry_style: DictEntryStyles = 1¶
- dict_entry_styles¶
alias of
DictEntryStyles
- dict_format: DictFormats = DictFormatConfig(dict_open=<function fixed_open.<locals>._open>, close='}', format_entry=<function dict_entry_with_separator.<locals>._format>, empty_dict=None, preamble_lines=(), narrowed_open=None, supports_trailing_comma=True)¶
- property dict_format_config: DictFormatConfig¶
Configuration for dict formatting.
- dict_formats¶
alias of
DictFormats
- dict_supports_heterogeneous_values = True¶
- element_separator: ClassVar[str] = ', '¶
- empty_dict_keys¶
alias of
EmptyDictKey
- extension = '.ts'¶
- false_literal: ClassVar[str] = 'false'¶
- float_format: FloatFormats = <function format_float_repr>¶
- float_formats¶
alias of
FloatFormats
- property format_bytes: Callable[[bytes], str]¶
Callable that formats a bytes value as a string literal.
- static format_call_arg(_value: Value, formatted: str, /) str¶
Callable that rewrites a formatted direct call argument.
- property format_call_arg_ref_identifier: Callable[[str, Value | None], str]¶
Rewrite a
{"$ref": "name"}identifier in a call-argument context.Delegates to
format_call_ref_identifier. Override this to allow call-argument$refvalues that would otherwise be rejected.
- property format_call_arg_ref_identifier_consumable: Callable[[str, Value | None], str]¶
Format a
$refthe caller authorized as consumable.Delegates to
format_call_arg_ref_identifier. Override this to opt into a consuming form (e.g. C++std::move).
- format_call_binding_body_preamble() tuple[str, ...]¶
Default
format_call_binding_body_preamble– no extra body preamble lines for an inference-bound call result.
- format_call_binding_file_pragmas() tuple[str, ...]¶
Default
format_call_binding_file_pragmas– no file-level compiler-pragma line for an inference-bound call result.
- property format_call_preamble_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]¶
Return file-scope stubs for a call expression.
- property format_call_ref_identifier: Callable[[str, Value | None], str]¶
Rewrite a
{"$ref": "name"}identifier into the language’s call expression syntax.
- property format_call_statement: Callable[[str], str]¶
Return call-statement formatting for this language.
- property format_call_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]¶
Return stub declarations for a call expression.
- property format_call_target: Callable[[Sequence[str]], str]¶
Rewrite a dotted call target into the language’s call syntax.
- property format_call_variable_assignment: Callable[[str, str, Value], str]¶
Default
format_call_variable_assignment– reuse the literal-binding assignment formatter unchanged.
- property format_call_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]¶
Callable that formats a declaration binding a call result.
The input row describes call arguments, not the call’s return type, so TypeScript call-result bindings intentionally rely on inference instead of reusing literal-derived annotations.
- static format_constructor_target(class_name: str, /) str¶
Return a
new ClassNameconstructor call target.
- property format_date: Callable[[date], str]¶
Callable that formats a date as a string literal.
- property format_datetime: Callable[[datetime], str]¶
Callable that formats a datetime as a string literal.
- property format_float: Callable[[float], str]¶
Callable that formats a float value as a literal.
- property format_integer: Callable[[int], str]¶
Callable that formats an int value as a literal.
JavaScript’s
numberis an IEEE 754 double whose integer precision tops out atNumber.MAX_SAFE_INTEGER(2**53 - 1). Above that, a bare numeric literal silently loses precision on parse, so reject the value at literalize time withUnrepresentableIntegerErrorrather than emit a literal that no longer round-trips. Wrapping such values in aBigIntliteral (99n) is a separate strategy not yet offered for TypeScript.
- property format_integer_widened: None¶
Default
format_integer_widened– no mixed-magnitude integer widening, so the renderer keeps the normal integer formatter.
- property format_ordered_map_entry: Callable[[str, Value, str], str]¶
Callable that formats one ordered-map entry.
- property format_sequence_entry: Callable[[Value, str], str]¶
Format a sequence entry.
- property format_set_entry: Callable[[Value, str], str]¶
Format a set entry.
- property format_string: Callable[[str], str]¶
Callable that formats a string value as a quoted literal.
- property format_time: Callable[[time], str]¶
Callable that formats a time as a string literal.
- property format_variable_assignment: Callable[[str, str, Value], str]¶
Callable that formats an assignment to an existing variable.
- property format_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]¶
Callable that formats a new variable declaration.
- has_free_function_calls = True¶
- property heterogeneous_behavior: HeterogeneousBehavior¶
Return the heterogeneous-behavior config.
- heterogeneous_strategies¶
alias of
HeterogeneousStrategies
- heterogeneous_strategy: HeterogeneousStrategies = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)¶
- identifier_cases: ClassVar[tuple[IdentifierCase, ...]] = (IdentifierCase.CAMEL, IdentifierCase.PASCAL, IdentifierCase.UPPER_SNAKE)¶
- indent: str = ' '¶
- indent_closing_delimiter: ClassVar[bool] = False¶
- integer_format: IntegerFormats = mappingproxy({'NONE': <class 'str'>, 'UNDERSCORE': <function format_integer_underscore>})¶
- integer_formats¶
alias of
IntegerFormats
- integer_width_strategies¶
alias of
BareIntegerWidthStrategies
- integer_width_strategy: BareIntegerWidthStrategies = 1¶
- language_version: VersionFormats = 1¶
- property leading_preamble: LeadingPreamble¶
Default
leading_preamble– no preamble lines that must precedeLanguage.static_preamble.
- max_call_parameters = 9223372036854775807¶
- modifier_combinations: ClassVar[tuple[ModifierCombination, ...]] = ()¶
- null_literal: ClassVar[str] = 'null'¶
- numeric_literal_suffix: NumericLiteralSuffixes = 1¶
- numeric_literal_suffixes¶
alias of
NumericLiteralSuffixes
- numeric_separator: NumericSeparators = 1¶
- numeric_separators¶
alias of
NumericSeparators
- numeric_style: NumericStyles = 1¶
- numeric_styles¶
alias of
NumericStyles
- property ordered_map_format_config: OrderedMapFormatConfig¶
Configuration for ordered-map formatting.
- pygments_name = 'typescript'¶
- reserved_identifiers: ClassVar[frozenset[str]] = frozenset({})¶
- property scalar_body_preamble: dict[type, tuple[str, ...]]¶
Per-instance scalar body preamble (TypeScript needs none).
- property scalar_preamble: dict[type, tuple[str, ...]]¶
Per-instance scalar preamble (TypeScript needs none).
- sequence_binding_declarations(declarations: tuple[str, ...]) str¶
Default
sequence_binding_declarations– join the per-binding snippets with newlines.
- sequence_format: SequenceFormats = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=']', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)¶
- property sequence_format_config: SequenceFormatConfig¶
Configuration for the chosen sequence format.
- sequence_formats¶
alias of
SequenceFormats
- property sequence_open: Callable[[list[Value]], str]¶
Callable that returns the opening delimiter for a sequence.
- set_format: SetFormats = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close='])', empty_set='new Set()', preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)¶
- property set_format_config: SetFormatConfig¶
Configuration for the chosen set format.
- set_formats¶
alias of
SetFormats
- skip_null_dict_values: ClassVar[bool] = False¶
- special_float_preamble: ClassVar[tuple[str, ...]] = ()¶
- statement_terminator: ClassVar[str] = ';'¶
- statement_terminator_style: StatementTerminatorStyles = 1¶
- statement_terminator_styles¶
alias of
StatementTerminatorStyles
- static_body_preamble: ClassVar[Sequence[str]] = ()¶
- static_preamble: ClassVar[Sequence[str]] = ()¶
- string_format: StringFormats = <function _build_backslash_formatter.<locals>._format>¶
- string_formats¶
alias of
StringFormats
- supported_ref_cases: ClassVar[frozenset[IdentifierCase]] = frozenset({IdentifierCase.CAMEL, IdentifierCase.PASCAL, IdentifierCase.SNAKE, IdentifierCase.UPPER_SNAKE})¶
- supports_call_style = True¶
- supports_collection_comments: ClassVar[bool] = True¶
- supports_default_dict_key_type = False¶
- supports_default_dict_value_type = False¶
- supports_default_ordered_map_value_type = False¶
- supports_default_sequence_element_type = False¶
- supports_default_set_element_type = False¶
- supports_dict_literal_as_free_expression = True¶
- supports_dotted_call_stub = True¶
- supports_dotted_calls = True¶
- supports_empty_dict_key = False¶
- supports_inline_multiline_dict_args = True¶
- supports_module_name = False¶
- supports_multi_param_call_wrapper_stub = True¶
- supports_no_variable_wrap_in_file = True¶
- supports_non_string_dict_keys = False¶
- supports_record_shape_names = False¶
- supports_record_struct_name_prefix = False¶
- supports_scalar_before_comments: ClassVar[bool] = True¶
- supports_scalar_inline_comments: ClassVar[bool] = True¶
- supports_special_floats = True¶
- supports_standalone_comments_in_wrapped_calls = True¶
- supports_variable_names = True¶
- supports_zero_parameter_calls = True¶
- trailing_comma: TrailingCommas = TrailingCommaConfig(multiline_trailing_comma=True)¶
- property trailing_comma_config: TrailingCommaConfig¶
Configuration for trailing-comma behavior.
- trailing_commas¶
alias of
TrailingCommas
- true_literal: ClassVar[str] = 'true'¶
- property type_hint_collection_preamble_lines: Callable[[frozenset[type]], tuple[str, ...]]¶
Return preamble lines for empty-collection type hints.
- property validate_call_arg: Callable[[Value], None]¶
Return call-argument validation for this language.
- validate_spec_for_data(data: Value) None¶
Default
validate_spec_for_data— no spec/data constraints.
- variable_type_hints: VariableTypeHints = 1¶
- variable_type_hints_formats¶
alias of
VariableTypeHints
- version_formats¶
alias of
VersionFormats
- wrap_calls_with_declarations(declarations: tuple[str, ...], calls: str, body_preamble: tuple[str, ...]) str¶
Default
wrap_calls_with_declarations— concatenate the declarations and calls and route throughwrap_in_file()in call mode.
- static wrap_combined_in_file(declaration: str, assignment: str, variable_name: str, body_preamble: tuple[str, ...]) str¶
Wrap TypeScript declaration + assignment as a module.
- static wrap_in_file(content: str, variable_name: str, body_preamble: tuple[str, ...]) str¶
Wrap a TypeScript declaration as a module.
- class literalizer.languages.V(*args: object, **kwargs: object)¶
V language specification.
- Parameters:
declaration_style –
How to declare variables.
declaration_styles.ASSIGN— immutable short declaration, e.g.x := value.declaration_styles.MUT— mutable short declaration, e.g.mut x := value.
- class BoolFormats(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
Empty: this language has no alternative boolean formats.
- class BytesFormats(*values)¶
Bytes formatting options.
- BASE64 = <function format_bytes_base64>¶
- HEX = <function format_bytes_hex>¶
- class CallStyles(*values)¶
V call style options.
- POSITIONAL = PositionalCallStyle(arg_separator=', ', parenthesize_each_arg=False)¶
- class CommentFormats(*values)¶
Comment style options.
- BLOCK = CommentConfig(prefix='/*', suffix=' */')¶
- DOUBLE_SLASH = CommentConfig(prefix='//', suffix='')¶
- class DateFormats(*values)¶
Date format options for V.
- ISO = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- class DatetimeFormats(*values)¶
Datetime format options for V.
- EPOCH = DatetimeFormatConfig(formatter=<function format_datetime_epoch>, preamble_lines=(), type_produced=<class 'int'>)¶
- ISO = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- class DeclarationStyles(*values)¶
Declaration style options.
- ASSIGN = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=False)¶
- MUT = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=True)¶
- class FloatFormats(*values)¶
Float format options.
- FIXED = <function format_float_fixed>¶
- REPR = <function format_float_repr>¶
- SCIENTIFIC = <function format_float_scientific>¶
- class HeterogeneousStrategies(*values)¶
Heterogeneous-scalar strategy options for V.
- ERROR = 1¶
Raise on heterogeneous scalar collections (default).
V is statically typed and rejects unwrapped heterogeneous collections, so the default refuses to render them rather than emit code the V compiler will not accept. Callers that want to materialize such data must opt in to
INTERFACEorRECORD.Still emits
interface IVal {}when the data contains an empty list, dict, or set, because the empty-literal rendering ([]IVal{}/map[string]IVal{}) references it regardless of strategy.
- INTERFACE = 2¶
Wrap heterogeneous scalars and null values with
IVal(...)and emitinterface IVal {}in the file preamble.
- RECORD = 3¶
Render each record-shaped dict (non-empty, string-keyed) as a generated file-scope
structplus a matchingRecord0{ field: value, ... }literal, so a dict may mix scalars and containers that a homogeneousmap[string]Vcannot.The behavior and preamble are resolved per instance from
_record_strategy(the shared record behavior needs the per-instance renderer, so it cannot be stored on the enum member).
- class IntegerFormats(*values)¶
Integer format options.
- BINARY = mappingproxy({'NONE': <function format_integer_binary>, 'UNDERSCORE': <function format_integer_binary>})¶
- DECIMAL = mappingproxy({'NONE': <class 'str'>, 'UNDERSCORE': <function format_integer_underscore>})¶
- HEX = mappingproxy({'NONE': <function format_integer_hex>, 'UNDERSCORE': <function format_integer_hex>})¶
- OCTAL = mappingproxy({'NONE': <function format_integer_octal>, 'UNDERSCORE': <function format_integer_octal>})¶
- get_formatter(numeric_separator: Enum) Callable[[int], str]¶
Return the integer formatter for the given separator.
- class JsonTypes(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
Empty: this language has no JSON value-type variants.
- class Modifiers(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
C++/Java/C#-style declaration modifiers: this language has none.
- class SequenceFormats(*values)¶
Sequence type options for V.
- ARRAY = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=']', supports_heterogeneity=False, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence='[]IVal{}', preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=<function make_narrowed_empty_form.<locals>._narrowed_empty_form>)¶
- class SetFormats(*values)¶
Set type options for V.
- ARRAY = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close=']', empty_set='[]IVal{}', preamble_lines=(), set_opener_template='', supports_heterogeneity=False, supports_trailing_comma=True)¶
- class TrailingCommas(*values)¶
Trailing comma options.
- NO = TrailingCommaConfig(multiline_trailing_comma=False)¶
- YES = TrailingCommaConfig(multiline_trailing_comma=True)¶
- allows_empty_call_parens = True¶
- bool_formats¶
alias of
BoolFormats
- bytes_format: BytesFormats = <function format_bytes_hex>¶
- bytes_formats¶
alias of
BytesFormats
- property call_data_dependent_preamble: Callable[[Value], tuple[str, ...]]¶
Return data-dependent preamble lines for call rendering.
- call_returns_expression = True¶
- call_style: CallStyles = PositionalCallStyle(arg_separator=', ', parenthesize_each_arg=False)¶
- property call_style_config: PositionalCallStyle | KeywordCallStyle | ObjectCallStyle | PostfixCallStyle | PrefixCallStyle | CommandCallStyle¶
Return the active call-style configuration.
- call_styles¶
alias of
CallStyles
- property comment_config: CommentConfig¶
Configuration for the language’s comment syntax.
- comment_format: CommentFormats = CommentConfig(prefix='//', suffix='')¶
- comment_formats¶
alias of
CommentFormats
- property compute_body_preamble: Callable[[frozenset[type], Value], tuple[str, ...]]¶
Compute body-preamble lines from the scalar map.
- property consumable_ref_value_inhibits_consuming_form: Callable[[Value], bool]¶
Predicate deciding whether a ref’s underlying value type inhibits the consume form.
Delegates to
never_inhibits_consuming_form. Languages whose consume operator rejects certain value types (notably the Mojo^on register-trivial scalars) override this.
- property data_dependent_preamble: Callable[[Value], tuple[str, ...]]¶
Return data-dependent preamble lines for the chosen strategy.
RECORDemits theinterface IVal {}line (when an empty container references it) followed by onestructdeclaration per record shape;INTERFACEemits the interface when any container needs wrapping;ERRORemits the interface only for an empty-collection literal.
- date_format: DateFormats = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- date_formats¶
alias of
DateFormats
- datetime_format: DatetimeFormats = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- datetime_formats¶
alias of
DatetimeFormats
- declaration_style: DeclarationStyles = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=False)¶
- declaration_styles¶
alias of
DeclarationStyles
- dict_entry_style: DictEntryStyles = 1¶
- dict_entry_styles¶
alias of
DictEntryStyles
- dict_format: DictFormats = 1¶
- property dict_format_config: DictFormatConfig¶
Configuration for dict formatting.
- dict_formats¶
alias of
DictFormats
- dict_supports_heterogeneous_values = False¶
- element_separator: ClassVar[str] = ', '¶
- empty_dict_keys¶
alias of
EmptyDictKey
- extension = '.v'¶
- false_literal: ClassVar[str] = 'false'¶
- float_format: FloatFormats = <function format_float_repr>¶
- float_formats¶
alias of
FloatFormats
- property format_bytes: Callable[[bytes], str]¶
Callable that formats a bytes value as a string literal.
- static format_call_arg(_value: Value, formatted: str, /) str¶
Callable that rewrites a formatted direct call argument.
- property format_call_arg_ref_identifier: Callable[[str, Value | None], str]¶
Return the ref identifier unchanged in a call-argument context.
When a
$refis passed as a function argument (directly or nested inside a container argument vialiteralize_call()), V does not require.clone(); V passes the value automatically without copying.
- property format_call_arg_ref_identifier_consumable: Callable[[str, Value | None], str]¶
Format a
$refthe caller authorized as consumable.Delegates to
format_call_arg_ref_identifier. Override this to opt into a consuming form (e.g. C++std::move).
- format_call_binding_body_preamble() tuple[str, ...]¶
Default
format_call_binding_body_preamble– no extra body preamble lines for an inference-bound call result.
- format_call_binding_file_pragmas() tuple[str, ...]¶
Default
format_call_binding_file_pragmas– no file-level compiler-pragma line for an inference-bound call result.
- property format_call_preamble_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]¶
Return file-scope stubs for a call expression.
- property format_call_ref_identifier: Callable[[str, Value | None], str]¶
Append
.clone()to the ref identifier, except for scalars.V’s container types (arrays, maps) are not copied by direct assignment, so a
$refmarker appearing on the right-hand side of an emitted assignment must be cloned to satisfy the V compiler. V’s primitive scalars (int,bool,f64, …) have no.clone()method -int.clone()is a hard error - so we emit the bare identifier and let V’s automatic primitive copy do the right thing. When the caller did not supplyref_valueswe cannot tell which case applies and fall back to.clone(), which is correct for V’s original use case (map/array refs).
- property format_call_statement: Callable[[str], str]¶
Return call-statement formatting for this language.
- property format_call_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]¶
Return stub declarations for a call expression.
- property format_call_target: Callable[[Sequence[str]], str]¶
Rewrite a dotted call target into the language’s call syntax.
- property format_call_variable_assignment: Callable[[str, str, Value], str]¶
Default
format_call_variable_assignment– reuse the literal-binding assignment formatter unchanged.
- property format_call_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]¶
Default
format_call_variable_declaration– reuse the literal-binding declaration formatter unchanged.
- static format_constructor_target(class_name: str, /) str¶
Return class_name as a zero-argument constructor call target.
- property format_date: Callable[[date], str]¶
Callable that formats a date as a string literal.
- property format_datetime: Callable[[datetime], str]¶
Callable that formats a datetime as a string literal.
EPOCHseconds are routed throughformat_integerso a post-2038 value carries thei64(...)cast V requires for an integer literal outside signed 32-bit range (a bare4085195400is otherwise an out-of-rangeintliteral), matching thei64field type theRECORDstrategy derives for it. In-range epoch seconds format identically to the plain integer, so every checked-in golden file stays byte-identical.
- property format_float: Callable[[float], str]¶
Callable that formats a float value as a literal.
- property format_integer: Callable[[int], str]¶
Callable that formats an int value as a literal.
Values in 32-bit signed range are formatted with the chosen integer format. Values outside that range but within 64-bit signed range use
i64(...). Values outside 64-bit signed range useu64(...)(or raise for negative overflow).
- property format_integer_widened: Callable[[int], str]¶
Always-
i64(...)-cast integer formatter for widened collections (mixed-magnitude int sets/lists).
- property format_ordered_map_entry: Callable[[str, Value, str], str]¶
Callable that formats one ordered-map entry.
- property format_sequence_entry: Callable[[Value, str], str]¶
Format a sequence entry.
- property format_set_entry: Callable[[Value, str], str]¶
Format a set entry.
- property format_string: Callable[[str], str]¶
Format a string value as a quoted literal.
- property format_time: Callable[[time], str]¶
Callable that formats a time as a string literal.
- property format_variable_assignment: Callable[[str, str, Value], str]¶
Format an assignment to an existing variable.
- property format_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]¶
Callable that formats a new variable declaration.
- has_free_function_calls = True¶
- property heterogeneous_behavior: HeterogeneousBehavior¶
Return the heterogeneous-behavior config for the chosen strategy.
RECORDresolves to the shared record behavior (its value needs the per-instance renderer, so it cannot be stored on the enum member);INTERFACEwraps scalars inIVal(...);ERRORraises on unwrapped heterogeneous collections.
- heterogeneous_strategies¶
alias of
HeterogeneousStrategies
- heterogeneous_strategy: HeterogeneousStrategies = 1¶
- identifier_cases: ClassVar[tuple[IdentifierCase, ...]] = (IdentifierCase.SNAKE,)¶
- indent: str = '\t'¶
- indent_closing_delimiter: ClassVar[bool] = False¶
- integer_format: IntegerFormats = mappingproxy({'NONE': <class 'str'>, 'UNDERSCORE': <function format_integer_underscore>})¶
- integer_formats¶
alias of
IntegerFormats
- integer_width_strategies¶
alias of
BareIntegerWidthStrategies
- integer_width_strategy: BareIntegerWidthStrategies = 1¶
- language_version: VersionFormats = 1¶
- property leading_preamble: LeadingPreamble¶
Default
leading_preamble– no preamble lines that must precedeLanguage.static_preamble.
- max_call_parameters = 9223372036854775807¶
- modifier_combinations: ClassVar[tuple[ModifierCombination, ...]] = ()¶
- null_literal: ClassVar[str] = 'unsafe { nil }'¶
- numeric_literal_suffix: NumericLiteralSuffixes = 1¶
- numeric_literal_suffixes¶
alias of
NumericLiteralSuffixes
- numeric_separator: NumericSeparators = 1¶
- numeric_separators¶
alias of
NumericSeparators
- numeric_style: NumericStyles = 1¶
- numeric_styles¶
alias of
NumericStyles
- property ordered_map_format_config: OrderedMapFormatConfig¶
Configuration for ordered-map formatting.
- pygments_name = 'v'¶
- record_struct_name_prefix: str = 'Record'¶
- reserved_identifiers: ClassVar[frozenset[str]] = frozenset({})¶
- property scalar_body_preamble: dict[type, tuple[str, ...]]¶
Per-instance scalar body preamble (V needs none).
- property scalar_preamble: dict[type, tuple[str, ...]]¶
Per-instance scalar preamble (V needs none).
- sequence_binding_declarations(declarations: tuple[str, ...]) str¶
Default
sequence_binding_declarations– join the per-binding snippets with newlines.
- sequence_format: SequenceFormats = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=']', supports_heterogeneity=False, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence='[]IVal{}', preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=<function make_narrowed_empty_form.<locals>._narrowed_empty_form>)¶
- property sequence_format_config: SequenceFormatConfig¶
Configuration for the chosen sequence format.
- sequence_formats¶
alias of
SequenceFormats
- property sequence_open: Callable[[list[Value]], str]¶
Callable that returns the opening delimiter for a sequence.
- set_format: SetFormats = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close=']', empty_set='[]IVal{}', preamble_lines=(), set_opener_template='', supports_heterogeneity=False, supports_trailing_comma=True)¶
- property set_format_config: SetFormatConfig¶
Configuration for the chosen set format.
- set_formats¶
alias of
SetFormats
- skip_null_dict_values: ClassVar[bool] = False¶
- special_float_preamble: ClassVar[tuple[str, ...]] = ('import math',)¶
- statement_terminator: ClassVar[str] = ';'¶
- statement_terminator_style: StatementTerminatorStyles = 1¶
- statement_terminator_styles¶
alias of
StatementTerminatorStyles
- static_body_preamble: ClassVar[Sequence[str]] = ()¶
- static_preamble: ClassVar[Sequence[str]] = ()¶
- string_format: StringFormats = 1¶
- string_formats¶
alias of
StringFormats
- supported_ref_cases: ClassVar[frozenset[IdentifierCase]] = frozenset({IdentifierCase.SNAKE})¶
- supports_call_style = True¶
- supports_collection_comments: ClassVar[bool] = True¶
- supports_default_dict_key_type = False¶
- supports_default_dict_value_type = False¶
- supports_default_ordered_map_value_type = False¶
- supports_default_sequence_element_type = False¶
- supports_default_set_element_type = False¶
- supports_dict_literal_as_free_expression = True¶
- supports_dotted_call_stub = True¶
- supports_dotted_calls = True¶
- supports_empty_dict_key = False¶
- supports_inline_multiline_dict_args = True¶
- supports_module_name = False¶
- supports_multi_param_call_wrapper_stub = True¶
- supports_no_variable_wrap_in_file = False¶
- supports_non_string_dict_keys = False¶
- supports_record_shape_names = False¶
- supports_record_struct_name_prefix = True¶
- supports_scalar_before_comments: ClassVar[bool] = False¶
- supports_scalar_inline_comments: ClassVar[bool] = True¶
- supports_special_floats = True¶
- supports_standalone_comments_in_wrapped_calls = True¶
- supports_variable_names = True¶
- supports_zero_parameter_calls = True¶
- trailing_comma: TrailingCommas = TrailingCommaConfig(multiline_trailing_comma=True)¶
- property trailing_comma_config: TrailingCommaConfig¶
Configuration for trailing-comma behavior.
- trailing_commas¶
alias of
TrailingCommas
- true_literal: ClassVar[str] = 'true'¶
- property type_hint_collection_preamble_lines: Callable[[frozenset[type]], tuple[str, ...]]¶
Return preamble lines for empty-collection type hints.
- property validate_call_arg: Callable[[Value], None]¶
Return call-argument validation for this language.
- validate_spec_for_data(data: Value) None¶
Default
validate_spec_for_data— no spec/data constraints.
- variable_type_hints: VariableTypeHints = 1¶
- variable_type_hints_formats¶
alias of
VariableTypeHints
- version_formats¶
alias of
VersionFormats
- wrap_calls_with_declarations(declarations: tuple[str, ...], calls: str, body_preamble: tuple[str, ...]) str¶
Default
wrap_calls_with_declarations— concatenate the declarations and calls and route throughwrap_in_file()in call mode.
- wrap_combined_in_file(declaration: str, assignment: str, variable_name: str, body_preamble: tuple[str, ...]) str¶
Wrap V declaration + assignment in
fn main().
- wrap_in_file(content: str, variable_name: str, body_preamble: tuple[str, ...]) str¶
Wrap a V declaration in
fn main().
- class literalizer.languages.VisualBasic(*args: object, **kwargs: object)¶
Visual Basic (.NET) language specification.
VB.NET collection initializers (
New T() { ... },New HashSet(Of T) From { ... }, etc.) do not support comments inside the{ ... }block. YAML comments associated with collection elements are therefore emitted as standalone comment lines before the collection — or before the variable declaration when a variable name is supplied.- class BoolFormats(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
Empty: this language has no alternative boolean formats.
- class BytesFormats(*values)¶
Bytes formatting options.
- BASE64 = <function format_bytes_base64>¶
- HEX = <function format_bytes_hex>¶
- class CallStyles(*values)¶
VisualBasic call style options.
- NAMED = KeywordCallStyle(separator=':=')¶
- POSITIONAL = PositionalCallStyle(arg_separator=', ', parenthesize_each_arg=False)¶
- class CommentFormats(*values)¶
Comment style options.
- APOSTROPHE = CommentConfig(prefix="'", suffix='')¶
- class DateFormats(*values)¶
Date format options for VisualBasic.
- ISO = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- class DatetimeFormats(*values)¶
Datetime format options for VisualBasic.
- EPOCH = DatetimeFormatConfig(formatter=<function format_datetime_epoch>, preamble_lines=(), type_produced=<class 'int'>)¶
- ISO = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- class DeclarationStyles(*values)¶
Declaration style options.
- DIM = DeclarationStyleConfig(formatter=<function _format_variable_declaration>, supports_redefinition=True)¶
- class DictFormats(*values)¶
Dict/map format options.
- DEFAULT = <function dict_format_factory.<locals>._build>¶
- class FloatFormats(*values)¶
Float format options.
- FIXED = <function format_float_fixed>¶
- REPR = <function format_float_repr>¶
- SCIENTIFIC = <function format_float_scientific>¶
- class HeterogeneousStrategies(*values)¶
Heterogeneous-scalar strategy options — this language only supports raising.
- ERROR = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)¶
- class JsonTypes(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
Empty: this language has no JSON value-type variants.
- class Modifiers(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
C++/Java/C#-style declaration modifiers: this language has none.
- class SetFormats(*values)¶
Set type options for Visual Basic.
- HASH_SET = <function set_format_factory.<locals>._build>¶
- class TrailingCommas(*values)¶
Trailing comma options.
- NO = TrailingCommaConfig(multiline_trailing_comma=False)¶
- allows_empty_call_parens = True¶
- bool_formats¶
alias of
BoolFormats
- bytes_format: BytesFormats = <function format_bytes_hex>¶
- bytes_formats¶
alias of
BytesFormats
- property call_data_dependent_preamble: Callable[[Value], tuple[str, ...]]¶
Return data-dependent preamble lines for call rendering.
- call_returns_expression = True¶
- call_style: CallStyles = PositionalCallStyle(arg_separator=', ', parenthesize_each_arg=False)¶
- property call_style_config: PositionalCallStyle | KeywordCallStyle | ObjectCallStyle | PostfixCallStyle | PrefixCallStyle | CommandCallStyle¶
Configuration for the chosen call style.
- call_styles¶
alias of
CallStyles
- property comment_config: CommentConfig¶
Configuration for the language’s comment syntax.
- comment_format: CommentFormats = CommentConfig(prefix="'", suffix='')¶
- comment_formats¶
alias of
CommentFormats
- property compute_body_preamble: Callable[[frozenset[type], Value], tuple[str, ...]]¶
Compute body-preamble lines from the scalar map.
- property consumable_ref_value_inhibits_consuming_form: Callable[[Value], bool]¶
Predicate deciding whether a ref’s underlying value type inhibits the consume form.
Delegates to
never_inhibits_consuming_form. Languages whose consume operator rejects certain value types (notably the Mojo^on register-trivial scalars) override this.
- property data_dependent_preamble: Callable[[Value], tuple[str, ...]]¶
Return data-dependent preamble lines.
- date_format: DateFormats = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- date_formats¶
alias of
DateFormats
- datetime_format: DatetimeFormats = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- datetime_formats¶
alias of
DatetimeFormats
- declaration_style: DeclarationStyles = DeclarationStyleConfig(formatter=<function _format_variable_declaration>, supports_redefinition=True)¶
- declaration_styles¶
alias of
DeclarationStyles
- default_dict_key_type: str = 'String'¶
- default_dict_value_type: str = 'Object'¶
- default_sequence_element_type: str = 'Object'¶
- default_set_element_type: str = 'Object'¶
- dict_entry_style: DictEntryStyles = 1¶
- dict_entry_styles¶
alias of
DictEntryStyles
- dict_format: DictFormats = <function dict_format_factory.<locals>._build>¶
- property dict_format_config: DictFormatConfig¶
Configuration for dict formatting.
- dict_formats¶
alias of
DictFormats
- dict_supports_heterogeneous_values = True¶
- element_separator: ClassVar[str] = ', '¶
- empty_dict_keys¶
alias of
EmptyDictKey
- extension = '.vb'¶
- false_literal: ClassVar[str] = 'False'¶
- float_format: FloatFormats = <function format_float_repr>¶
- float_formats¶
alias of
FloatFormats
- property format_bytes: Callable[[bytes], str]¶
Callable that formats a bytes value as a string literal.
- static format_call_arg(_value: Value, formatted: str, /) str¶
Callable that rewrites a formatted direct call argument.
- property format_call_arg_ref_identifier: Callable[[str, Value | None], str]¶
Rewrite a
{"$ref": "name"}identifier in a call-argument context.Delegates to
format_call_ref_identifier. Override this to allow call-argument$refvalues that would otherwise be rejected.
- property format_call_arg_ref_identifier_consumable: Callable[[str, Value | None], str]¶
Format a
$refthe caller authorized as consumable.Delegates to
format_call_arg_ref_identifier. Override this to opt into a consuming form (e.g. C++std::move).
- format_call_binding_body_preamble() tuple[str, ...]¶
Default
format_call_binding_body_preamble– no extra body preamble lines for an inference-bound call result.
- format_call_binding_file_pragmas() tuple[str, ...]¶
Default
format_call_binding_file_pragmas– no file-level compiler-pragma line for an inference-bound call result.
- property format_call_preamble_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]¶
Return file-scope stubs for a call expression.
- property format_call_ref_identifier: Callable[[str, Value | None], str]¶
Rewrite a
{"$ref": "name"}identifier into the language’s call expression syntax.
- property format_call_statement: Callable[[str], str]¶
Return call-statement formatting for this language.
- property format_call_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]¶
Return stub declarations for a call expression.
- property format_call_target: Callable[[Sequence[str]], str]¶
Rewrite a dotted call target into the language’s call syntax.
- property format_call_variable_assignment: Callable[[str, str, Value], str]¶
Default
format_call_variable_assignment– reuse the literal-binding assignment formatter unchanged.
- property format_call_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]¶
Default
format_call_variable_declaration– reuse the literal-binding declaration formatter unchanged.
- static format_constructor_target(class_name: str, /) str¶
Format a VB.NET constructor call target.
- property format_date: Callable[[date], str]¶
Callable that formats a date as a string literal.
- property format_datetime: Callable[[datetime], str]¶
Callable that formats a datetime as a string literal.
- property format_float: Callable[[float], str]¶
Callable that formats a float value as a literal.
- property format_integer: Callable[[int], str]¶
Format an int value as a literal.
- property format_integer_widened: Callable[[int], str]¶
Always-
L-suffixed integer formatter for widened collections (mixed-magnitude int sets/lists).
- property format_ordered_map_entry: Callable[[str, Value, str], str]¶
Callable that formats one ordered-map entry.
- property format_sequence_entry: Callable[[Value, str], str]¶
Format a sequence entry.
- property format_set_entry: Callable[[Value, str], str]¶
Format a set entry.
- property format_string: Callable[[str], str]¶
Format a string value as a quoted literal.
- property format_time: Callable[[time], str]¶
Callable that formats a time as a string literal.
- property format_variable_assignment: Callable[[str, str, Value], str]¶
Format an assignment to an existing variable.
- property format_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]¶
Callable that formats a new variable declaration.
- has_free_function_calls = True¶
- property heterogeneous_behavior: HeterogeneousBehavior¶
Return the heterogeneous-behavior config.
- heterogeneous_strategies¶
alias of
HeterogeneousStrategies
- heterogeneous_strategy: HeterogeneousStrategies = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)¶
- identifier_cases: ClassVar[tuple[IdentifierCase, ...]] = (IdentifierCase.PASCAL, IdentifierCase.CAMEL)¶
- indent: str = ' '¶
- indent_closing_delimiter: ClassVar[bool] = False¶
- integer_format: IntegerFormats = 1¶
- integer_formats¶
alias of
IntegerFormats
- integer_width_strategies¶
alias of
BareIntegerWidthStrategies
- integer_width_strategy: BareIntegerWidthStrategies = 1¶
- language_version: VersionFormats = 1¶
- property leading_preamble: LeadingPreamble¶
Default
leading_preamble– no preamble lines that must precedeLanguage.static_preamble.
- max_call_parameters = 9223372036854775807¶
- modifier_combinations: ClassVar[tuple[ModifierCombination, ...]] = ()¶
- null_literal: ClassVar[str] = 'Nothing'¶
- numeric_literal_suffix: NumericLiteralSuffixes = 1¶
- numeric_literal_suffixes¶
alias of
NumericLiteralSuffixes
- numeric_separator: NumericSeparators = 1¶
- numeric_separators¶
alias of
NumericSeparators
- numeric_style: NumericStyles = 1¶
- numeric_styles¶
alias of
NumericStyles
- property ordered_map_format_config: OrderedMapFormatConfig¶
Configuration for ordered-map formatting.
- pygments_name = 'vb.net'¶
- reserved_identifiers: ClassVar[frozenset[str]] = frozenset({})¶
- property scalar_body_preamble: dict[type, tuple[str, ...]]¶
Per-instance scalar body preamble (VisualBasic needs none).
- property scalar_preamble: dict[type, tuple[str, ...]]¶
Per-instance scalar preamble.
- sequence_binding_declarations(declarations: tuple[str, ...]) str¶
Default
sequence_binding_declarations– join the per-binding snippets with newlines.
- sequence_format: SequenceFormats = 1¶
- property sequence_format_config: SequenceFormatConfig¶
Configuration for the chosen sequence format.
- sequence_formats¶
alias of
SequenceFormats
- property sequence_open: Callable[[list[Value]], str]¶
Callable that returns the opening delimiter for a sequence.
- set_format: SetFormats = <function set_format_factory.<locals>._build>¶
- property set_format_config: SetFormatConfig¶
Configuration for the chosen set format.
- set_formats¶
alias of
SetFormats
- skip_null_dict_values: ClassVar[bool] = False¶
- special_float_preamble: ClassVar[tuple[str, ...]] = ()¶
- statement_terminator: ClassVar[str] = ''¶
- statement_terminator_style: StatementTerminatorStyles = 1¶
- statement_terminator_styles¶
alias of
StatementTerminatorStyles
- static_body_preamble: ClassVar[Sequence[str]] = ()¶
- static_preamble: ClassVar[Sequence[str]] = ()¶
- string_format: StringFormats = 1¶
- string_formats¶
alias of
StringFormats
- supported_ref_cases: ClassVar[frozenset[IdentifierCase]] = frozenset({IdentifierCase.CAMEL, IdentifierCase.PASCAL, IdentifierCase.SNAKE, IdentifierCase.UPPER_SNAKE})¶
- supports_call_style = True¶
- supports_collection_comments: ClassVar[bool] = False¶
- supports_default_dict_key_type = True¶
- supports_default_dict_value_type = True¶
- supports_default_ordered_map_value_type = False¶
- supports_default_sequence_element_type = True¶
- supports_default_set_element_type = True¶
- supports_dict_literal_as_free_expression = True¶
- supports_dotted_call_stub = True¶
- supports_dotted_calls = True¶
- supports_empty_dict_key = False¶
- supports_inline_multiline_dict_args = True¶
- supports_module_name = False¶
- supports_multi_param_call_wrapper_stub = True¶
- supports_no_variable_wrap_in_file = False¶
- supports_non_string_dict_keys = False¶
- supports_record_shape_names = False¶
- supports_record_struct_name_prefix = False¶
- supports_scalar_before_comments: ClassVar[bool] = True¶
- supports_scalar_inline_comments: ClassVar[bool] = True¶
- supports_special_floats = True¶
- supports_standalone_comments_in_wrapped_calls = True¶
- supports_variable_names = True¶
- supports_zero_parameter_calls = True¶
- trailing_comma: TrailingCommas = TrailingCommaConfig(multiline_trailing_comma=False)¶
- property trailing_comma_config: TrailingCommaConfig¶
Configuration for trailing-comma behavior.
- trailing_commas¶
alias of
TrailingCommas
- true_literal: ClassVar[str] = 'True'¶
- property type_hint_collection_preamble_lines: Callable[[frozenset[type]], tuple[str, ...]]¶
Return preamble lines for empty-collection type hints.
- property validate_call_arg: Callable[[Value], None]¶
Return call-argument validation for this language.
- validate_spec_for_data(data: Value) None¶
Default
validate_spec_for_data— no spec/data constraints.
- variable_type_hints: VariableTypeHints = 1¶
- variable_type_hints_formats¶
alias of
VariableTypeHints
- version_formats¶
alias of
VersionFormats
- wrap_calls_with_declarations(declarations: tuple[str, ...], calls: str, body_preamble: tuple[str, ...]) str¶
Default
wrap_calls_with_declarations— concatenate the declarations and calls and route throughwrap_in_file()in call mode.
- wrap_combined_in_file(declaration: str, assignment: str, variable_name: str, body_preamble: tuple[str, ...]) str¶
Wrap VB.NET declaration + assignment in separate Subs.
- wrap_in_file(content: str, variable_name: str, body_preamble: tuple[str, ...]) str¶
Wrap a VB.NET Dim declaration inside a Module.
When body_preamble carries call-stub declarations (
ClassandFunctionblocks plus theirDim ... As New ...instances) the stubs sit at module scope and content is placed insideSub _calls(): VB rejects bare expression statements at module level, but shared subs taking no arguments are invoked by the fixture linter so the calls still execute.
- class literalizer.languages.Wren(*args: object, **kwargs: object)¶
Wren language specification.
- class BoolFormats(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
Empty: this language has no alternative boolean formats.
- class BytesFormats(*values)¶
Bytes formatting options.
- BASE64 = <function format_bytes_base64>¶
- HEX = <function format_bytes_hex>¶
- class CallStyles(*values)¶
Wren call style options.
- POSITIONAL = PositionalCallStyle(arg_separator=', ', parenthesize_each_arg=False)¶
- class CommentFormats(*values)¶
Comment style options.
- BLOCK = CommentConfig(prefix='/*', suffix=' */')¶
- SLASH = CommentConfig(prefix='//', suffix='')¶
- class DateFormats(*values)¶
Date format options for Wren.
- ISO = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- class DatetimeFormats(*values)¶
Datetime format options for Wren.
- EPOCH = DatetimeFormatConfig(formatter=<function format_datetime_epoch>, preamble_lines=(), type_produced=<class 'int'>)¶
- ISO = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- class DeclarationStyles(*values)¶
Declaration style options.
- VAR = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=True)¶
- class FloatFormats(*values)¶
Float format options.
- FIXED = <function format_float_fixed>¶
- REPR = <function format_float_repr>¶
- SCIENTIFIC = <function format_float_scientific>¶
- class HeterogeneousStrategies(*values)¶
Heterogeneous-scalar strategy options — this language only supports raising.
- ERROR = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)¶
- class IntegerFormats(*values)¶
Integer format options.
- DECIMAL = <class 'str'>¶
- HEX = <function format_integer_hex>¶
- class JsonTypes(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
Empty: this language has no JSON value-type variants.
- class Modifiers(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
C++/Java/C#-style declaration modifiers: this language has none.
- class SequenceFormats(*values)¶
Sequence type options for Wren.
- LIST = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=']', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)¶
- class SetFormats(*values)¶
Set type options for Wren.
- SET = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close='}', empty_set=None, preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)¶
- class StringFormats(*values)¶
String format options.
- DOUBLE = <function _build_backslash_formatter.<locals>._format>¶
- class TrailingCommas(*values)¶
Trailing comma options.
- NO = TrailingCommaConfig(multiline_trailing_comma=False)¶
- YES = TrailingCommaConfig(multiline_trailing_comma=True)¶
- allows_empty_call_parens = True¶
- bool_formats¶
alias of
BoolFormats
- bytes_format: BytesFormats = <function format_bytes_hex>¶
- bytes_formats¶
alias of
BytesFormats
- property call_data_dependent_preamble: Callable[[Value], tuple[str, ...]]¶
Return data-dependent preamble lines for call rendering.
- call_returns_expression = True¶
- call_style: CallStyles = PositionalCallStyle(arg_separator=', ', parenthesize_each_arg=False)¶
- property call_style_config: PositionalCallStyle | KeywordCallStyle | ObjectCallStyle | PostfixCallStyle | PrefixCallStyle | CommandCallStyle¶
Return the active call-style configuration.
- call_styles¶
alias of
CallStyles
- property comment_config: CommentConfig¶
Configuration for the language’s comment syntax.
- comment_format: CommentFormats = CommentConfig(prefix='//', suffix='')¶
- comment_formats¶
alias of
CommentFormats
- property compute_body_preamble: Callable[[frozenset[type], Value], tuple[str, ...]]¶
Compute body-preamble lines from the scalar map.
- property consumable_ref_value_inhibits_consuming_form: Callable[[Value], bool]¶
Predicate deciding whether a ref’s underlying value type inhibits the consume form.
Delegates to
never_inhibits_consuming_form. Languages whose consume operator rejects certain value types (notably the Mojo^on register-trivial scalars) override this.
- property data_dependent_preamble: Callable[[Value], tuple[str, ...]]¶
Return data-dependent preamble lines.
- date_format: DateFormats = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- date_formats¶
alias of
DateFormats
- datetime_format: DatetimeFormats = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- datetime_formats¶
alias of
DatetimeFormats
- declaration_style: DeclarationStyles = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=True)¶
- declaration_styles¶
alias of
DeclarationStyles
- dict_entry_style: DictEntryStyles = 1¶
- dict_entry_styles¶
alias of
DictEntryStyles
- dict_format: DictFormats = 1¶
- property dict_format_config: DictFormatConfig¶
Configuration for dict formatting.
- dict_formats¶
alias of
DictFormats
- dict_supports_heterogeneous_values = True¶
- element_separator: ClassVar[str] = ', '¶
- empty_dict_keys¶
alias of
EmptyDictKey
- extension = '.wren'¶
- false_literal: ClassVar[str] = 'false'¶
- float_format: FloatFormats = <function format_float_repr>¶
- float_formats¶
alias of
FloatFormats
- property format_bytes: Callable[[bytes], str]¶
Callable that formats a bytes value as a string literal.
- static format_call_arg(_value: Value, formatted: str, /) str¶
Callable that rewrites a formatted direct call argument.
- property format_call_arg_ref_identifier: Callable[[str, Value | None], str]¶
Rewrite a
{"$ref": "name"}identifier in a call-argument context.Delegates to
format_call_ref_identifier. Override this to allow call-argument$refvalues that would otherwise be rejected.
- property format_call_arg_ref_identifier_consumable: Callable[[str, Value | None], str]¶
Format a
$refthe caller authorized as consumable.Delegates to
format_call_arg_ref_identifier. Override this to opt into a consuming form (e.g. C++std::move).
- format_call_binding_body_preamble() tuple[str, ...]¶
Default
format_call_binding_body_preamble– no extra body preamble lines for an inference-bound call result.
- format_call_binding_file_pragmas() tuple[str, ...]¶
Default
format_call_binding_file_pragmas– no file-level compiler-pragma line for an inference-bound call result.
- property format_call_preamble_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]¶
Return file-scope stubs for a call expression.
- property format_call_ref_identifier: Callable[[str, Value | None], str]¶
Rewrite a
{"$ref": "name"}identifier into the language’s call expression syntax.
- property format_call_statement: Callable[[str], str]¶
Return call-statement formatting for this language.
- property format_call_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]¶
Return stub declarations for a call expression.
- property format_call_target: Callable[[Sequence[str]], str]¶
Rewrite a dotted call target into the language’s call syntax.
- property format_call_variable_assignment: Callable[[str, str, Value], str]¶
Default
format_call_variable_assignment– reuse the literal-binding assignment formatter unchanged.
- property format_call_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]¶
Default
format_call_variable_declaration– reuse the literal-binding declaration formatter unchanged.
- static format_constructor_target(class_name: str, /) str¶
Return a Wren
ClassName.newconstructor call target.
- property format_date: Callable[[date], str]¶
Callable that formats a date as a string literal.
- property format_datetime: Callable[[datetime], str]¶
Callable that formats a datetime as a string literal.
- property format_float: Callable[[float], str]¶
Callable that formats a float value as a literal.
- property format_integer: Callable[[int], str]¶
Callable that formats an int value as a literal.
- property format_integer_widened: None¶
Default
format_integer_widened– no mixed-magnitude integer widening, so the renderer keeps the normal integer formatter.
- property format_ordered_map_entry: Callable[[str, Value, str], str]¶
Callable that formats one ordered-map entry.
- property format_sequence_entry: Callable[[Value, str], str]¶
Format a sequence entry.
- property format_set_entry: Callable[[Value, str], str]¶
Format a set entry.
- property format_string: Callable[[str], str]¶
Callable that formats a string value as a quoted literal.
- property format_time: Callable[[time], str]¶
Callable that formats a time as a string literal.
- property format_variable_assignment: Callable[[str, str, Value], str]¶
Format an assignment to an existing variable.
- property format_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]¶
Callable that formats a new variable declaration.
- has_free_function_calls = False¶
- property heterogeneous_behavior: HeterogeneousBehavior¶
Return the heterogeneous-behavior config.
- heterogeneous_strategies¶
alias of
HeterogeneousStrategies
- heterogeneous_strategy: HeterogeneousStrategies = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)¶
- identifier_cases: ClassVar[tuple[IdentifierCase, ...]] = (IdentifierCase.SNAKE, IdentifierCase.PASCAL, IdentifierCase.UPPER_SNAKE)¶
- indent: str = ' '¶
- indent_closing_delimiter: ClassVar[bool] = False¶
- integer_format: IntegerFormats = <class 'str'>¶
- integer_formats¶
alias of
IntegerFormats
- integer_width_strategies¶
alias of
BareIntegerWidthStrategies
- integer_width_strategy: BareIntegerWidthStrategies = 1¶
- language_version: VersionFormats = 1¶
- property leading_preamble: LeadingPreamble¶
Default
leading_preamble– no preamble lines that must precedeLanguage.static_preamble.
- max_call_parameters = 16¶
- modifier_combinations: ClassVar[tuple[ModifierCombination, ...]] = ()¶
- null_literal: ClassVar[str] = 'null'¶
- numeric_literal_suffix: NumericLiteralSuffixes = 1¶
- numeric_literal_suffixes¶
alias of
NumericLiteralSuffixes
- numeric_separator: NumericSeparators = 1¶
- numeric_separators¶
alias of
NumericSeparators
- numeric_style: NumericStyles = 1¶
- numeric_styles¶
alias of
NumericStyles
- property ordered_map_format_config: OrderedMapFormatConfig¶
Configuration for ordered-map formatting.
- pygments_name = 'wren'¶
- reserved_identifiers: ClassVar[frozenset[str]] = frozenset({})¶
- property scalar_body_preamble: dict[type, tuple[str, ...]]¶
Per-instance scalar body preamble (Wren needs none).
- property scalar_preamble: dict[type, tuple[str, ...]]¶
Per-instance scalar preamble (Wren needs none).
- sequence_binding_declarations(declarations: tuple[str, ...]) str¶
Default
sequence_binding_declarations– join the per-binding snippets with newlines.
- sequence_format: SequenceFormats = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=']', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)¶
- property sequence_format_config: SequenceFormatConfig¶
Configuration for the chosen sequence format.
- sequence_formats¶
alias of
SequenceFormats
- property sequence_open: Callable[[list[Value]], str]¶
Callable that returns the opening delimiter for a sequence.
- set_format: SetFormats = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close='}', empty_set=None, preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)¶
- property set_format_config: SetFormatConfig¶
Configuration for the chosen set format.
- set_formats¶
alias of
SetFormats
- skip_null_dict_values: ClassVar[bool] = True¶
- special_float_preamble: ClassVar[tuple[str, ...]] = ()¶
- statement_terminator: ClassVar[str] = ''¶
- statement_terminator_style: StatementTerminatorStyles = 1¶
- statement_terminator_styles¶
alias of
StatementTerminatorStyles
- static_body_preamble: ClassVar[Sequence[str]] = ()¶
- static_preamble: ClassVar[Sequence[str]] = ()¶
- string_format: StringFormats = <function _build_backslash_formatter.<locals>._format>¶
- string_formats¶
alias of
StringFormats
- supported_ref_cases: ClassVar[frozenset[IdentifierCase]] = frozenset({IdentifierCase.CAMEL, IdentifierCase.PASCAL, IdentifierCase.SNAKE, IdentifierCase.UPPER_SNAKE})¶
- supports_call_style = True¶
- supports_collection_comments: ClassVar[bool] = True¶
- supports_default_dict_key_type = False¶
- supports_default_dict_value_type = False¶
- supports_default_ordered_map_value_type = False¶
- supports_default_sequence_element_type = False¶
- supports_default_set_element_type = False¶
- supports_dict_literal_as_free_expression = True¶
- supports_dotted_call_stub = True¶
- supports_dotted_calls = True¶
- supports_empty_dict_key = False¶
- supports_inline_multiline_dict_args = True¶
- supports_module_name = False¶
- supports_multi_param_call_wrapper_stub = True¶
- supports_no_variable_wrap_in_file = True¶
- supports_non_string_dict_keys = True¶
- supports_record_shape_names = False¶
- supports_record_struct_name_prefix = False¶
- supports_scalar_before_comments: ClassVar[bool] = False¶
- supports_scalar_inline_comments: ClassVar[bool] = True¶
- supports_special_floats = True¶
- supports_standalone_comments_in_wrapped_calls = True¶
- supports_variable_names = True¶
- supports_zero_parameter_calls = True¶
- trailing_comma: TrailingCommas = TrailingCommaConfig(multiline_trailing_comma=True)¶
- property trailing_comma_config: TrailingCommaConfig¶
Configuration for trailing-comma behavior.
- trailing_commas¶
alias of
TrailingCommas
- true_literal: ClassVar[str] = 'true'¶
- property type_hint_collection_preamble_lines: Callable[[frozenset[type]], tuple[str, ...]]¶
Return preamble lines for empty-collection type hints.
- property validate_call_arg: Callable[[Value], None]¶
Return call-argument validation for this language.
- validate_spec_for_data(data: Value) None¶
Default
validate_spec_for_data— no spec/data constraints.
- variable_type_hints: VariableTypeHints = 1¶
- variable_type_hints_formats¶
alias of
VariableTypeHints
- version_formats¶
alias of
VersionFormats
- wrap_calls_with_declarations(declarations: tuple[str, ...], calls: str, body_preamble: tuple[str, ...]) str¶
Default
wrap_calls_with_declarations— concatenate the declarations and calls and route throughwrap_in_file()in call mode.
- static wrap_combined_in_file(declaration: str, assignment: str, variable_name: str, body_preamble: tuple[str, ...]) str¶
Wrap declaration and assignment in a valid file (no-op).
- static wrap_in_file(content: str, variable_name: str, body_preamble: tuple[str, ...]) str¶
Wrap code in a valid file (no-op).
- class literalizer.languages.Yaml(*args: object, **kwargs: object)¶
YAML language specification.
Produces YAML flow-style values — flow mappings for dicts, and flow sequences for sequences and sets — so that the output is valid inline YAML that can be embedded in any YAML document.
Dates and datetimes are rendered as unquoted YAML native date / datetime literals, which YAML parsers interpret as typed values.
- class BoolFormats(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
Empty: this language has no alternative boolean formats.
- class BytesFormats(*values)¶
Bytes formatting options.
- BASE64 = <function format_bytes_base64>¶
- HEX = <function format_bytes_hex>¶
- class CallStyles(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
Yaml call style options.
- class DateFormats(*values)¶
Date format options for Yaml.
- ISO = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- YAML = DateFormatConfig(formatter=<function date_iso_formatter.<locals>._format>, preamble_lines=(), type_produced=<class 'datetime.date'>)¶
- class DatetimeFormats(*values)¶
Datetime format options for Yaml.
- EPOCH = DatetimeFormatConfig(formatter=<function format_datetime_epoch>, preamble_lines=(), type_produced=<class 'int'>)¶
- ISO = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- YAML = DatetimeFormatConfig(formatter=<function datetime_iso_formatter.<locals>._format>, preamble_lines=(), type_produced=<class 'datetime.datetime'>)¶
- class DeclarationStyles(*values)¶
Declaration style options.
- ASSIGN = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=False)¶
- class FloatFormats(*values)¶
Float format options.
- FIXED = <function format_float_fixed>¶
- REPR = <function format_float_repr>¶
- SCIENTIFIC = <function format_float_scientific>¶
- class HeterogeneousStrategies(*values)¶
Heterogeneous-scalar strategy options — this language only supports raising.
- ERROR = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)¶
- class JsonTypes(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
Empty: this language has no JSON value-type variants.
- class Modifiers(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
C++/Java/C#-style declaration modifiers: this language has none.
- class SequenceFormats(*values)¶
Sequence type options for YAML.
- SEQUENCE = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=']', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)¶
- class SetFormats(*values)¶
Set type options for YAML.
- SET = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close=']', empty_set=None, preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)¶
- class TrailingCommas(*values)¶
Trailing comma options.
- NO = TrailingCommaConfig(multiline_trailing_comma=False)¶
- allows_empty_call_parens = True¶
- bool_formats¶
alias of
BoolFormats
- bytes_format: BytesFormats = <function format_bytes_hex>¶
- bytes_formats¶
alias of
BytesFormats
- property call_data_dependent_preamble: Callable[[Value], tuple[str, ...]]¶
Return data-dependent preamble lines for call rendering.
- call_returns_expression = True¶
- call_style_config: ClassVar[PositionalCallStyle | KeywordCallStyle | ObjectCallStyle | PostfixCallStyle | PrefixCallStyle | CommandCallStyle | CallSupport] = 'not_in_language'¶
- call_styles¶
alias of
CallStyles
- property comment_config: CommentConfig¶
Configuration for the language’s comment syntax.
- comment_format: CommentFormats = CommentConfig(prefix='#', suffix='')¶
- comment_formats¶
alias of
CommentFormats
- property compute_body_preamble: Callable[[frozenset[type], Value], tuple[str, ...]]¶
Compute body-preamble lines from the scalar map.
- property consumable_ref_value_inhibits_consuming_form: Callable[[Value], bool]¶
Predicate deciding whether a ref’s underlying value type inhibits the consume form.
Delegates to
never_inhibits_consuming_form. Languages whose consume operator rejects certain value types (notably the Mojo^on register-trivial scalars) override this.
- property data_dependent_preamble: Callable[[Value], tuple[str, ...]]¶
Return data-dependent preamble lines.
- date_format: DateFormats = DateFormatConfig(formatter=<function date_iso_formatter.<locals>._format>, preamble_lines=(), type_produced=<class 'datetime.date'>)¶
- date_formats¶
alias of
DateFormats
- datetime_format: DatetimeFormats = DatetimeFormatConfig(formatter=<function datetime_iso_formatter.<locals>._format>, preamble_lines=(), type_produced=<class 'datetime.datetime'>)¶
- datetime_formats¶
alias of
DatetimeFormats
- declaration_style: DeclarationStyles = DeclarationStyleConfig(formatter=<function variable_declaration_formatter.<locals>._format>, supports_redefinition=False)¶
- declaration_styles¶
alias of
DeclarationStyles
- dict_entry_style: DictEntryStyles = 1¶
- dict_entry_styles¶
alias of
DictEntryStyles
- dict_format: DictFormats = 1¶
- property dict_format_config: DictFormatConfig¶
Configuration for dict formatting.
- dict_formats¶
alias of
DictFormats
- dict_supports_heterogeneous_values = True¶
- element_separator: ClassVar[str] = ', '¶
- empty_dict_keys¶
alias of
EmptyDictKey
- extension = '.yaml'¶
- false_literal: ClassVar[str] = 'false'¶
- float_format: FloatFormats = <function format_float_repr>¶
- float_formats¶
alias of
FloatFormats
- property format_bytes: Callable[[bytes], str]¶
Callable that formats a bytes value as a string literal.
- static format_call_arg(_value: Value, formatted: str, /) str¶
Callable that rewrites a formatted direct call argument.
- property format_call_arg_ref_identifier: Callable[[str, Value | None], str]¶
Rewrite a
{"$ref": "name"}identifier in a call-argument context.Delegates to
format_call_ref_identifier. Override this to allow call-argument$refvalues that would otherwise be rejected.
- property format_call_arg_ref_identifier_consumable: Callable[[str, Value | None], str]¶
Format a
$refthe caller authorized as consumable.Delegates to
format_call_arg_ref_identifier. Override this to opt into a consuming form (e.g. C++std::move).
- format_call_binding_body_preamble() tuple[str, ...]¶
Default
format_call_binding_body_preamble– no extra body preamble lines for an inference-bound call result.
- format_call_binding_file_pragmas() tuple[str, ...]¶
Default
format_call_binding_file_pragmas– no file-level compiler-pragma line for an inference-bound call result.
- property format_call_preamble_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]¶
Return file-scope stubs for a call expression.
- property format_call_ref_identifier: Callable[[str, Value | None], str]¶
Rewrite a
{"$ref": "name"}identifier into the language’s call expression syntax.
- property format_call_statement: Callable[[str], str]¶
Return call-statement formatting for this language.
- property format_call_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]¶
Return stub declarations for a call expression.
- property format_call_target: Callable[[Sequence[str]], str]¶
Rewrite a dotted call target into the language’s call syntax.
- property format_call_variable_assignment: Callable[[str, str, Value], str]¶
Default
format_call_variable_assignment– reuse the literal-binding assignment formatter unchanged.
- property format_call_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]¶
Default
format_call_variable_declaration– reuse the literal-binding declaration formatter unchanged.
- static format_constructor_target(class_name: str, /) str¶
Return class_name as a zero-argument constructor call target.
- property format_date: Callable[[date], str]¶
Callable that formats a date as a string literal.
- property format_datetime: Callable[[datetime], str]¶
Callable that formats a datetime as a string literal.
- property format_float: Callable[[float], str]¶
Callable that formats a float value as a literal.
- property format_integer: Callable[[int], str]¶
Format an int value as a literal.
- property format_integer_widened: None¶
Default
format_integer_widened– no mixed-magnitude integer widening, so the renderer keeps the normal integer formatter.
- property format_ordered_map_entry: Callable[[str, Value, str], str]¶
Callable that formats one ordered-map entry.
- property format_sequence_entry: Callable[[Value, str], str]¶
Format a sequence entry.
- property format_set_entry: Callable[[Value, str], str]¶
Format a set entry.
- property format_string: Callable[[str], str]¶
Callable that formats a string value as a quoted literal.
- property format_time: Callable[[time], str]¶
Callable that formats a time as a string literal.
- property format_variable_assignment: Callable[[str, str, Value], str]¶
Format an assignment to an existing variable.
- property format_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]¶
Callable that formats a new variable declaration.
- has_free_function_calls = True¶
- property heterogeneous_behavior: HeterogeneousBehavior¶
Return the heterogeneous-behavior config.
- heterogeneous_strategies¶
alias of
HeterogeneousStrategies
- heterogeneous_strategy: HeterogeneousStrategies = HeterogeneousBehavior(skip_scalar_checks=False, compute_wrap_ids=<function no_compute_wrap_ids>, wrap_scalar=None, wrap_non_scalar=None, compute_call_slot_wrap_ids=<function _no_compute_call_slot_wrap_ids>, render_record_literal=None, compute_record_shapes=None, render_tuple_literal=None, compute_tuple_list_ids=None)¶
- identifier_cases: ClassVar[tuple[IdentifierCase, ...]] = (IdentifierCase.SNAKE,)¶
- indent: str = ' '¶
- indent_closing_delimiter: ClassVar[bool] = False¶
- integer_format: IntegerFormats = 1¶
- integer_formats¶
alias of
IntegerFormats
- integer_width_strategies¶
alias of
BareIntegerWidthStrategies
- integer_width_strategy: BareIntegerWidthStrategies = 1¶
- language_version: VersionFormats = 1¶
- property leading_preamble: LeadingPreamble¶
Default
leading_preamble– no preamble lines that must precedeLanguage.static_preamble.
- max_call_parameters = 9223372036854775807¶
- modifier_combinations: ClassVar[tuple[ModifierCombination, ...]] = ()¶
- null_literal: ClassVar[str] = 'null'¶
- numeric_literal_suffix: NumericLiteralSuffixes = 1¶
- numeric_literal_suffixes¶
alias of
NumericLiteralSuffixes
- numeric_separator: NumericSeparators = 1¶
- numeric_separators¶
alias of
NumericSeparators
- numeric_style: NumericStyles = 1¶
- numeric_styles¶
alias of
NumericStyles
- property ordered_map_format_config: OrderedMapFormatConfig¶
Configuration for ordered-map formatting.
- pygments_name = 'yaml'¶
- reserved_identifiers: ClassVar[frozenset[str]] = frozenset({})¶
- property scalar_body_preamble: dict[type, tuple[str, ...]]¶
Per-instance scalar body preamble (YAML needs none).
- property scalar_preamble: dict[type, tuple[str, ...]]¶
Per-instance scalar preamble (YAML needs none).
- sequence_binding_declarations(declarations: tuple[str, ...]) str¶
Default
sequence_binding_declarations– join the per-binding snippets with newlines.
- sequence_format: SequenceFormats = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close=']', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)¶
- property sequence_format_config: SequenceFormatConfig¶
Configuration for the chosen sequence format.
- sequence_formats¶
alias of
SequenceFormats
- property sequence_open: Callable[[list[Value]], str]¶
Callable that returns the opening delimiter for a sequence.
- set_format: SetFormats = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close=']', empty_set=None, preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)¶
- property set_format_config: SetFormatConfig¶
Configuration for the chosen set format.
- set_formats¶
alias of
SetFormats
- skip_null_dict_values: ClassVar[bool] = False¶
- special_float_preamble: ClassVar[tuple[str, ...]] = ()¶
- statement_terminator: ClassVar[str] = ''¶
- statement_terminator_style: StatementTerminatorStyles = 1¶
- statement_terminator_styles¶
alias of
StatementTerminatorStyles
- static_body_preamble: ClassVar[Sequence[str]] = ()¶
- static_preamble: ClassVar[Sequence[str]] = ()¶
- string_format: StringFormats = 1¶
- string_formats¶
alias of
StringFormats
- supported_ref_cases: ClassVar[frozenset[IdentifierCase]] = frozenset({IdentifierCase.CAMEL, IdentifierCase.PASCAL, IdentifierCase.SNAKE, IdentifierCase.UPPER_SNAKE})¶
- supports_call_style = False¶
- supports_collection_comments: ClassVar[bool] = True¶
- supports_default_dict_key_type = False¶
- supports_default_dict_value_type = False¶
- supports_default_ordered_map_value_type = False¶
- supports_default_sequence_element_type = False¶
- supports_default_set_element_type = False¶
- supports_dict_literal_as_free_expression = True¶
- supports_dotted_call_stub = True¶
- supports_dotted_calls = True¶
- supports_empty_dict_key = False¶
- supports_inline_multiline_dict_args = True¶
- supports_module_name = False¶
- supports_multi_param_call_wrapper_stub = True¶
- supports_no_variable_wrap_in_file = True¶
- supports_non_string_dict_keys = True¶
- supports_record_shape_names = False¶
- supports_record_struct_name_prefix = False¶
- supports_scalar_before_comments: ClassVar[bool] = True¶
- supports_scalar_inline_comments: ClassVar[bool] = True¶
- supports_special_floats = True¶
- supports_standalone_comments_in_wrapped_calls = True¶
- supports_variable_names = False¶
- supports_zero_parameter_calls = True¶
- trailing_comma: TrailingCommas = TrailingCommaConfig(multiline_trailing_comma=False)¶
- property trailing_comma_config: TrailingCommaConfig¶
Configuration for trailing-comma behavior.
- trailing_commas¶
alias of
TrailingCommas
- true_literal: ClassVar[str] = 'true'¶
- property type_hint_collection_preamble_lines: Callable[[frozenset[type]], tuple[str, ...]]¶
Return preamble lines for empty-collection type hints.
- property validate_call_arg: Callable[[Value], None]¶
Return call-argument validation for this language.
- validate_spec_for_data(data: Value) None¶
Default
validate_spec_for_data— no spec/data constraints.
- variable_type_hints: VariableTypeHints = 1¶
- variable_type_hints_formats¶
alias of
VariableTypeHints
- version_formats¶
alias of
VersionFormats
- wrap_calls_with_declarations(declarations: tuple[str, ...], calls: str, body_preamble: tuple[str, ...]) str¶
Default
wrap_calls_with_declarations— concatenate the declarations and calls and route throughwrap_in_file()in call mode.
- static wrap_combined_in_file(declaration: str, assignment: str, variable_name: str, body_preamble: tuple[str, ...]) str¶
Unsupported: literalize() rejects BothVariableForms upstream.
- static wrap_in_file(content: str, variable_name: str, body_preamble: tuple[str, ...]) str¶
Wrap code in a valid file (no-op).
- class literalizer.languages.Zig(*args: object, **kwargs: object)¶
Zig language specification.
- class BoolFormats(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
Empty: this language has no alternative boolean formats.
- class BytesFormats(*values)¶
Bytes formatting options.
- BASE64 = <function format_bytes_base64>¶
- HEX = <function format_bytes_hex>¶
- class CallStyles(*values)¶
Zig call style options.
- POSITIONAL = PositionalCallStyle(arg_separator=', ', parenthesize_each_arg=False)¶
- class CommentFormats(*values)¶
Comment style options.
- DOUBLE_SLASH = CommentConfig(prefix='//', suffix='')¶
- class DateFormats(*values)¶
Date format options for Zig.
- ISO = DateFormatConfig(formatter=<function format_date_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- ZIG = DateFormatConfig(formatter=<function _format_date_zig>, preamble_lines=(), type_produced=<class 'int'>)¶
- class DatetimeFormats(*values)¶
Datetime format options for Zig.
- EPOCH = DatetimeFormatConfig(formatter=<function format_datetime_epoch>, preamble_lines=(), type_produced=<class 'int'>)¶
- ISO = DatetimeFormatConfig(formatter=<function format_datetime_iso>, preamble_lines=(), type_produced=<class 'str'>)¶
- ZIG = DatetimeFormatConfig(formatter=<function _format_datetime_zig>, preamble_lines=(), type_produced=<class 'int'>)¶
- class DeclarationStyles(*values)¶
Declaration style options.
- CONST = _ZigDeclarationStyleConfig(keyword='const', supports_redefinition=False)¶
- VAR = _ZigDeclarationStyleConfig(keyword='var', supports_redefinition=True)¶
- class FloatFormats(*values)¶
Float format options.
- FIXED = <function format_float_fixed>¶
- REPR = <function format_float_repr>¶
- SCIENTIFIC = <function format_float_scientific>¶
- class HeterogeneousStrategies(*values)¶
Heterogeneous-scalar strategy options.
ERRORkeeps the defaultZValunion model (a record-shaped dict that mixes scalars with a container is rendered as a homogeneous-typed.{ .map = &.{ ... } }).RECORDinstead renders each record-shaped dict (non-empty, string-keyed) as a generatedconst Record0 = struct { ... };declared in the preamble plus a matchingRecord0{ .field = value, ... }literal whose fields are raw Zig values, so a field may mix scalars and containers that the homogeneousZValmap cannot.- ERROR = 1¶
- RECORD = 2¶
- class IntegerFormats(*values)¶
Integer format options.
- BINARY = mappingproxy({'NONE': <function format_integer_binary>, 'UNDERSCORE': <function format_integer_binary>})¶
- DECIMAL = mappingproxy({'NONE': <class 'str'>, 'UNDERSCORE': <function format_integer_underscore>})¶
- HEX = mappingproxy({'NONE': <function format_integer_hex>, 'UNDERSCORE': <function format_integer_hex>})¶
- OCTAL = mappingproxy({'NONE': <function format_integer_octal>, 'UNDERSCORE': <function format_integer_octal>})¶
- get_formatter(numeric_separator: Enum) Callable[[int], str]¶
Return the integer formatter for the given separator.
- class JsonTypes(*values)¶
JSON value type options for Zig.
- STD_JSON_VALUE = 'std.json.Value'¶
Zig’s standard library dynamic JSON value type.
- class Modifiers(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
C++/Java/C#-style declaration modifiers: this language has none.
- class SequenceFormats(*values)¶
Sequence type options for Zig.
- ARRAY = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close='}}', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)¶
- class SetFormats(*values)¶
Set type options for Zig.
- SET = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close='}}', empty_set=None, preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)¶
- class TrailingCommas(*values)¶
Trailing comma options.
- NO = TrailingCommaConfig(multiline_trailing_comma=False)¶
- YES = TrailingCommaConfig(multiline_trailing_comma=True)¶
- allows_empty_call_parens = True¶
- bool_formats¶
alias of
BoolFormats
- bytes_format: BytesFormats = <function format_bytes_hex>¶
- bytes_formats¶
alias of
BytesFormats
- property call_data_dependent_preamble: Callable[[Value], tuple[str, ...]]¶
Return data-dependent preamble lines for call rendering.
- call_returns_expression = True¶
- call_style: CallStyles = PositionalCallStyle(arg_separator=', ', parenthesize_each_arg=False)¶
- property call_style_config: PositionalCallStyle | KeywordCallStyle | ObjectCallStyle | PostfixCallStyle | PrefixCallStyle | CommandCallStyle¶
Configuration for the chosen call style.
- call_styles¶
alias of
CallStyles
- property comment_config: CommentConfig¶
Configuration for the language’s comment syntax.
- comment_format: CommentFormats = CommentConfig(prefix='//', suffix='')¶
- comment_formats¶
alias of
CommentFormats
- property compute_body_preamble: Callable[[frozenset[type], Value], tuple[str, ...]]¶
Compute body-preamble lines from the scalar map.
- property consumable_ref_value_inhibits_consuming_form: Callable[[Value], bool]¶
Predicate deciding whether a ref’s underlying value type inhibits the consume form.
Delegates to
never_inhibits_consuming_form. Languages whose consume operator rejects certain value types (notably the Mojo^on register-trivial scalars) override this.
- property data_dependent_preamble: Callable[[Value], tuple[str, ...]]¶
Return data-dependent preamble lines.
Under
json_typethe data rides inside a single JSON string, so no per-data preamble applies. UnderRECORDthis is the generatedconst Record0 = struct { ... };block, emitted in dependency order so a nested record is declared before its parent.
- date_format: DateFormats = DateFormatConfig(formatter=<function _format_date_zig>, preamble_lines=(), type_produced=<class 'int'>)¶
- date_formats¶
alias of
DateFormats
- datetime_format: DatetimeFormats = DatetimeFormatConfig(formatter=<function _format_datetime_zig>, preamble_lines=(), type_produced=<class 'int'>)¶
- datetime_formats¶
alias of
DatetimeFormats
- declaration_style: DeclarationStyles = _ZigDeclarationStyleConfig(keyword='const', supports_redefinition=False)¶
- declaration_styles¶
alias of
DeclarationStyles
- dict_entry_style: DictEntryStyles = 1¶
- dict_entry_styles¶
alias of
DictEntryStyles
- dict_format: DictFormats = 1¶
- property dict_format_config: DictFormatConfig¶
Configuration for dict formatting.
Under
json_typedicts are rendered into the JSON text and the framework’s formatted output is discarded. UnderRECORDevery non-empty string-keyed dict is a record (rendered as a generatedstruct); the only plain dict that still reaches the dict formatter is the empty dict, emitted as the raw empty struct.{}instead of theZVal.{ .map = &.{}}form.
- dict_formats¶
alias of
DictFormats
- dict_supports_heterogeneous_values = True¶
- element_separator: ClassVar[str] = ', '¶
- empty_dict_keys¶
alias of
EmptyDictKey
- extension = '.zig'¶
- property false_literal: str¶
The literal representing false.
Raw Zig
falseunderRECORD(aboolfield), theZValunion literal otherwise.
- float_format: FloatFormats = <function format_float_repr>¶
- float_formats¶
alias of
FloatFormats
- property format_bytes: Callable[[bytes], str]¶
Callable that formats a bytes value as a string literal.
- property format_call_arg: Callable[[Value, str], str]¶
Wrap each call argument in the
ZValunion so call sites match the parameter shape emitted by_zig_call_preamble_stub().Under
json_typethe argument is rendered as astd.json.Valueproduced byparseFromSliceinstead.
- property format_call_arg_ref_identifier: Callable[[str, Value | None], str]¶
Rewrite a
{"$ref": "name"}identifier in a call-argument context.Delegates to
format_call_ref_identifier. Override this to allow call-argument$refvalues that would otherwise be rejected.
- property format_call_arg_ref_identifier_consumable: Callable[[str, Value | None], str]¶
Format a
$refthe caller authorized as consumable.Delegates to
format_call_arg_ref_identifier. Override this to opt into a consuming form (e.g. C++std::move).
- format_call_binding_body_preamble() tuple[str, ...]¶
Default
format_call_binding_body_preamble– no extra body preamble lines for an inference-bound call result.
- format_call_binding_file_pragmas() tuple[str, ...]¶
Default
format_call_binding_file_pragmas– no file-level compiler-pragma line for an inference-bound call result.
- property format_call_preamble_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]¶
Return file-scope stubs for a call expression.
Under
json_typecall arguments arestd.json.Valueexpressions rather thanZValunion literals, so the stub acceptsanytypeparameters just as theRECORDstrategy does.
- property format_call_ref_identifier: Callable[[str, Value | None], str]¶
Rewrite a
{"$ref": "name"}identifier into the language’s call expression syntax.
- property format_call_statement: Callable[[str], str]¶
Return call-statement formatting for this language.
- property format_call_stub: Callable[[Sequence[str], Sequence[str], StubReturn, Sequence[Value]], tuple[str, ...]]¶
Return stub declarations for a call expression.
Zig disallows nested function declarations inside
main, so every stub is emitted at file scope viaformat_call_preamble_stubinstead.
- property format_call_target: Callable[[Sequence[str]], str]¶
Rewrite a dotted call target into the language’s call syntax.
- property format_call_variable_assignment: Callable[[str, str, Value], str]¶
Callable that formats an assignment binding a call result.
The call-expression counterpart of
format_call_variable_declaration; theZValtagging a literal-binding assignment applies is dropped since a call result is not aZValunion literal.
- property format_call_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]¶
Callable that formats a declaration binding a call result.
A Zig literal binding wraps the right-hand side in a designated-initializer
ZValprojection (.{ .int = 42 }), or a generatedRecord0{ .field = value, ... }struct literal under theRECORDstrategy, and declares an explicit value type (: ZVal). A call’s return type is opaque to the renderer and is neither, so the call result is bound with a plain inferred declaration (const my_data = make_widget(...);/var my_data = make_widget(...);): the Zigconst/vartype inference means no caller-supplied return-type hint is needed, and the value-wrapping and: ZValannotation are dropped.
- static format_constructor_target(class_name: str, /) str¶
Return class_name as a zero-argument constructor call target.
- property format_date: Callable[[date], str]¶
Callable that formats a date as a string literal.
- property format_datetime: Callable[[datetime], str]¶
Callable that formats a datetime as a string literal.
- property format_float: Callable[[float], str]¶
Callable that formats a float value as a literal.
- property format_integer: Callable[[int], str]¶
Callable that formats an int value as a literal.
- property format_integer_widened: None¶
Default
format_integer_widened– no mixed-magnitude integer widening, so the renderer keeps the normal integer formatter.
- property format_ordered_map_entry: Callable[[str, Value, str], str]¶
Callable that formats one ordered-map entry.
- property format_sequence_entry: Callable[[Value, str], str]¶
Format a sequence entry.
- property format_set_entry: Callable[[Value, str], str]¶
Format a set entry.
- property format_string: Callable[[str], str]¶
Callable that formats a string value as a quoted literal.
- property format_time: Callable[[time], str]¶
Callable that formats a time as a string literal.
- property format_variable_assignment: Callable[[str, str, Value], str]¶
Format an assignment to an existing variable.
- property format_variable_declaration: Callable[[str, str, Value, frozenset[Enum]], str]¶
Callable that formats a new variable declaration.
Under
json_typethe declaration is aparseFromSlicecall. Aconstbinding is emitted with an inferred type; avarbinding gets an explicit: std.json.Valueannotation so a subsequent assignment can compile against the same static type.Otherwise this closes over the chosen date/datetime
type_producedso theZValtag selection can be driven by the parsedValuerather than the rendered text.
- has_free_function_calls = True¶
- property heterogeneous_behavior: HeterogeneousBehavior¶
Return the heterogeneous-behavior config.
Under
json_typeheterogeneous scalars all flow through the JSON text, so scalar-uniformity checks are skipped.RECORDresolves to the shared record behavior (its value needs the per-instance renderer, so it cannot be stored on the enum member);ERRORkeeps the defaultZValmodel.
- heterogeneous_strategies¶
alias of
HeterogeneousStrategies
- heterogeneous_strategy: HeterogeneousStrategies = 1¶
- identifier_cases: ClassVar[tuple[IdentifierCase, ...]] = (IdentifierCase.SNAKE, IdentifierCase.PASCAL, IdentifierCase.CAMEL)¶
- indent: str = ' '¶
- indent_closing_delimiter: ClassVar[bool] = False¶
- integer_format: IntegerFormats = mappingproxy({'NONE': <class 'str'>, 'UNDERSCORE': <function format_integer_underscore>})¶
- integer_formats¶
alias of
IntegerFormats
- integer_width_strategies¶
alias of
BareIntegerWidthStrategies
- integer_width_strategy: BareIntegerWidthStrategies = 1¶
- language_version: VersionFormats = 1¶
- property leading_preamble: LeadingPreamble¶
Default
leading_preamble– no preamble lines that must precedeLanguage.static_preamble.
- max_call_parameters = 9223372036854775807¶
- modifier_combinations: ClassVar[tuple[ModifierCombination, ...]] = ()¶
- property null_literal: str¶
The literal representing null.
The default
ZValmodel uses the union tag.nil; underRECORDa null record field is a raw Zignull(its field type is the optional?i64).
- numeric_literal_suffix: NumericLiteralSuffixes = 1¶
- numeric_literal_suffixes¶
alias of
NumericLiteralSuffixes
- numeric_separator: NumericSeparators = 1¶
- numeric_separators¶
alias of
NumericSeparators
- numeric_style: NumericStyles = 1¶
- numeric_styles¶
alias of
NumericStyles
- property ordered_map_format_config: OrderedMapFormatConfig¶
Configuration for ordered-map formatting.
Under
json_typeordered maps are folded into the JSON text. An ordered map is never record-eligible, so underRECORDit stays a map but as a raw&.{ .{ .key = ..., .val = ... }, ... }slice ofkey/valstructvalues rather than theZVal.{ .map = &.{ ... }}form.
- pygments_name = 'zig'¶
- record_struct_name_prefix: str = 'Record'¶
- reserved_identifiers: ClassVar[frozenset[str]] = frozenset({})¶
- property scalar_body_preamble: dict[type, tuple[str, ...]]¶
Per-instance scalar body preamble (Zig needs none).
- property scalar_preamble: dict[type, tuple[str, ...]]¶
Per-instance scalar preamble (Zig needs none).
- sequence_binding_declarations(declarations: tuple[str, ...]) str¶
Default
sequence_binding_declarations– join the per-binding snippets with newlines.
- sequence_format: SequenceFormats = SequenceFormatConfig(sequence_open=<function fixed_open.<locals>._open>, close='}}', supports_heterogeneity=True, single_element_trailing_comma=False, supports_trailing_comma=True, empty_sequence=None, preamble_lines=(), format_entry=<function passthrough_sequence_entry>, typed_opener_fallback=None, uses_typed_literal_for_scalars=False, requires_uniform_record_shapes=False, declared_type=None, narrowed_empty_form=None)¶
- property sequence_format_config: SequenceFormatConfig¶
Configuration for the chosen sequence format.
Under
json_typelists are rendered into the JSON text and the framework’s formatted output is discarded. UnderRECORDa list is a raw Zig literal – a&.{ ... }slice (homogeneous / empty) or a.{ ... }tuple (heterogeneous), both closed by a single}rather than theZVal.{ .arr = &.{ ... }}form. Only the closer changes here; the opener is chosen per list bysequence_open.
- sequence_formats¶
alias of
SequenceFormats
- property sequence_open: Callable[[list[Value]], str]¶
Callable that returns the opening delimiter for a sequence.
Under
RECORDa homogeneous or empty list opens&.{so the literal coerces to a[]const Tslice; a heterogeneous list opens.{so it is a Zig tuple (matching thestruct { T0, ... }field type_zig_value_type()derives). Every other strategy keeps theZValarray opener.
- set_format: SetFormats = SetFormatConfig(set_open=<function fixed_open.<locals>._open>, close='}}', empty_set=None, preamble_lines=(), set_opener_template='', supports_heterogeneity=True, supports_trailing_comma=True)¶
- property set_format_config: SetFormatConfig¶
Configuration for the chosen set format.
- set_formats¶
alias of
SetFormats
- skip_null_dict_values: ClassVar[bool] = False¶
- special_float_preamble: ClassVar[tuple[str, ...]] = ('const std = @import("std");',)¶
- statement_terminator: ClassVar[str] = ';'¶
- statement_terminator_style: StatementTerminatorStyles = 1¶
- statement_terminator_styles¶
alias of
StatementTerminatorStyles
- static_body_preamble: ClassVar[Sequence[str]] = ()¶
- property static_preamble: Sequence[str]¶
File-scope preamble.
Under
json_typeonlyconst std = @import("std");is emitted (the data flows throughstd.json.parseFromSlice). The defaultZValmodel needs its tagged-union declaration; theRECORDstrategy emits raw Zig values and generatedstructdeclarations instead, so it needs no static preamble.
- string_format: StringFormats = 1¶
- string_formats¶
alias of
StringFormats
- supported_ref_cases: ClassVar[frozenset[IdentifierCase]] = frozenset({IdentifierCase.CAMEL, IdentifierCase.PASCAL, IdentifierCase.SNAKE, IdentifierCase.UPPER_SNAKE})¶
- supports_call_style = True¶
- supports_collection_comments: ClassVar[bool] = True¶
- supports_default_dict_key_type = False¶
- supports_default_dict_value_type = False¶
- supports_default_ordered_map_value_type = False¶
- supports_default_sequence_element_type = False¶
- supports_default_set_element_type = False¶
- supports_dict_literal_as_free_expression = True¶
- supports_dotted_call_stub = True¶
- supports_dotted_calls = True¶
- supports_empty_dict_key = False¶
- supports_inline_multiline_dict_args = True¶
- supports_module_name = False¶
- supports_multi_param_call_wrapper_stub = False¶
- supports_no_variable_wrap_in_file = False¶
- supports_non_string_dict_keys = False¶
- supports_record_shape_names = False¶
- supports_record_struct_name_prefix = True¶
- supports_scalar_before_comments: ClassVar[bool] = True¶
- supports_scalar_inline_comments: ClassVar[bool] = False¶
- supports_special_floats = True¶
- supports_standalone_comments_in_wrapped_calls = True¶
- supports_variable_names = True¶
- supports_zero_parameter_calls = True¶
- trailing_comma: TrailingCommas = TrailingCommaConfig(multiline_trailing_comma=True)¶
- property trailing_comma_config: TrailingCommaConfig¶
Configuration for trailing-comma behavior.
- trailing_commas¶
alias of
TrailingCommas
- property true_literal: str¶
The literal representing true.
Raw Zig
trueunderRECORD(aboolfield), theZValunion literal otherwise.
- property type_hint_collection_preamble_lines: Callable[[frozenset[type]], tuple[str, ...]]¶
Return preamble lines for empty-collection type hints.
- property validate_call_arg: Callable[[Value], None]¶
Return call-argument validation for this language.
- validate_spec_for_data(data: Value) None¶
Raise if the spec cannot produce valid code for data.
When
json_typeis active, walk data to reject non-string dict keys, which JSON objects cannot represent.
- variable_type_hints: VariableTypeHints = 1¶
- variable_type_hints_formats¶
alias of
VariableTypeHints
- version_formats¶
alias of
VersionFormats
- wrap_calls_with_declarations(declarations: tuple[str, ...], calls: str, body_preamble: tuple[str, ...]) str¶
Default
wrap_calls_with_declarations— concatenate the declarations and calls and route throughwrap_in_file()in call mode.
- wrap_combined_in_file(declaration: str, assignment: str, variable_name: str, body_preamble: tuple[str, ...]) str¶
Wrap Zig declaration + assignment in a main function.
- wrap_in_file(content: str, variable_name: str, body_preamble: tuple[str, ...]) str¶
Wrap a Zig declaration in a main function.