320 lines
17 KiB
Markdown
320 lines
17 KiB
Markdown
# Slovo Formatter Fixtures
|
|
|
|
Formatter fixtures define canonical layout for the current strict supported
|
|
syntax. They are not additional compiler-supported programs unless mirrored
|
|
under `examples/supported/`.
|
|
|
|
The formatter fixture set now includes the final exp-125 unsigned fixtures
|
|
absorbed into `1.0.0-beta`.
|
|
|
|
Promoted formatter fixtures may use only:
|
|
|
|
- `(module name)`
|
|
- top-level `(fn ...)`
|
|
- explicit `i32` parameters and `i32` returns, plus promoted `string`
|
|
parameters and returns
|
|
- direct `(option i32)`, `(option i64)`, and `(result i32 i32)` returns only
|
|
for first-pass option/result constructor fixtures
|
|
- integer literals
|
|
- parameter references
|
|
- binary `+`
|
|
- user-defined function calls
|
|
- legacy compiler/runtime compatibility alias `(print_i32 value)`
|
|
- local `i32` bindings with `(let name i32 value)` and `(var name i32 value)`
|
|
- immutable array locals with `(let name (array T N) array-expression)` when
|
|
`T` is `i32`, `i64`, `f64`, or `bool` and the initializer has the exact
|
|
declared fixed array type
|
|
- assignment to mutable local `i32` bindings with `(set name value)`
|
|
- value-producing `(if condition then-expression else-expression)`
|
|
- first-pass `(while condition body...)` as a non-final sequential body form
|
|
- top-level `(struct Name (field i32)...)`
|
|
- first-pass struct construction and immediate field access
|
|
- first v1 struct value flow through immutable locals, parameters, returns,
|
|
calls returning structs, and stored field access
|
|
- fixed direct scalar array constructors and literal `(index array index)`
|
|
- fixed direct scalar array value flow through immutable array locals
|
|
initialized from matching array-valued expressions, fixed array parameters,
|
|
returns, calls returning arrays, and dynamic `(index array index)` with `i32`
|
|
index expressions
|
|
- first-pass `(some i32 value)`, `(none i32)`, `(some i64 value)`,
|
|
`(none i64)`, `(ok i32 i32 value)`, and `(err i32 i32 value)` constructors
|
|
as direct function returns
|
|
- first v1 option/result value flow through immutable locals, parameters, calls
|
|
returning option/result values, and `is_some` / `is_none` / `is_ok` /
|
|
`is_err` tag observation
|
|
- first v1 option/result payload access with `unwrap_some`, `unwrap_ok`, and
|
|
`unwrap_err`
|
|
- v1.4 source-level `match` for `(option i32)`, `(option i64)`, and
|
|
`(result i32 i32)` values, with exhaustive arms, immutable arm-scoped
|
|
payload bindings, one-or-more expression arm bodies, and common arm result
|
|
types
|
|
- source string literals used directly as `print_string` or
|
|
`std.io.print_string` arguments
|
|
- legacy compiler/runtime compatibility alias `(print_string value)`
|
|
- immutable string locals with `(let name string value)`
|
|
- string parameters and string returns
|
|
- calls returning strings
|
|
- string equality with `=`
|
|
- string byte length with `(string_len value)`
|
|
- legacy compiler/runtime compatibility alias `(print_bool value)`
|
|
- compiler-known standard-runtime calls `(std.io.print_i32 value)`,
|
|
`(std.io.print_string value)`, `(std.io.print_bool value)`, and
|
|
`(std.string.len value)`
|
|
- exp-112 direct immutable `bool` locals with `(let name bool value)` over the
|
|
already promoted bool-expression surface
|
|
- exp-20 direct `f64` parameters, returns, immutable locals, decimal literals,
|
|
same-type `f64` arithmetic/comparison, and `(std.io.print_f64 value)`
|
|
- exp-21 direct `i64` parameters, returns, immutable locals, explicit signed
|
|
decimal `i64` literal atoms, same-type `i64` arithmetic/comparison, and
|
|
`(std.io.print_i64 value)`
|
|
- exp-22 explicit numeric widening calls
|
|
`std.num.i32_to_i64 : (i32) -> i64`,
|
|
`std.num.i32_to_f64 : (i32) -> f64`, and
|
|
`std.num.i64_to_f64 : (i64) -> f64`
|
|
- exp-23 checked numeric narrowing call
|
|
`std.num.i64_to_i32_result : (i64) -> (result i32 i32)`
|
|
- exp-24 integer to string calls
|
|
`std.num.i32_to_string : (i32) -> string` and
|
|
`std.num.i64_to_string : (i64) -> string`
|
|
- exp-25 string parse i64 result call
|
|
`std.string.parse_i64_result : (string) -> (result i64 i32)`
|
|
- exp-26 f64 to string call `std.num.f64_to_string : (f64) -> string`
|
|
- exp-27 checked f64 to i32 result call
|
|
`std.num.f64_to_i32_result : (f64) -> (result i32 i32)`
|
|
- exp-28 string parse f64 result call
|
|
`std.string.parse_f64_result : (string) -> (result f64 i32)`
|
|
- exp-29 direct immutable `i64` and finite `f64` struct fields, using
|
|
existing struct construction, immutable struct flow, field access,
|
|
same-type numeric arithmetic/comparison, and numeric print/format helpers
|
|
- exp-30 conservative source-layout helper shape in
|
|
`std-source-layout-alpha.slo`, without repo-root `std` import/search
|
|
support or source replacement of compiler-known `std.*` calls
|
|
- exp-31 checked f64 to i64 result call
|
|
`std.num.f64_to_i64_result : (f64) -> (result i64 i32)`
|
|
- exp-1 compiler-known call `(std.string.concat left right)`
|
|
- exp-2 `(vec i32)` type forms and compiler-known calls
|
|
`(std.vec.i32.empty)`, `(std.vec.i32.append values value)`,
|
|
`(std.vec.i32.len values)`, and `(std.vec.i32.index values index)`
|
|
- exp-3 compiler-known calls `(std.io.eprint value)`,
|
|
`(std.process.argc)`, `(std.process.arg index)`, `(std.env.get name)`,
|
|
`(std.fs.read_text path)`, and `(std.fs.write_text path text)`
|
|
- exp-4 payloadless enum declarations `(enum Name VariantA VariantB)`,
|
|
zero-argument qualified constructors `(Name.VariantA)`, enum locals,
|
|
parameters, returns, calls, equality, and exhaustive enum `match`
|
|
- exp-16 unary `i32` enum payload variants such as `(Value i32)`,
|
|
qualified unary constructors such as `(Reading.Value value)`, immutable
|
|
arm-local payload bindings in enum `match`, and same-enum tag-plus-payload
|
|
equality
|
|
- exp-18 direct enum struct fields and exp-19 direct `bool` and immutable
|
|
`string` struct fields, using existing struct construction, immutable
|
|
struct flow, field access, equality, enum `match`, bool predicate, and
|
|
`std.string.len` forms
|
|
- exp-8 compiler-known calls `(std.time.monotonic_ms)` and
|
|
`(std.time.sleep_ms 0)` for structural/non-negative conformance checks only
|
|
- exp-11 compiler-known call `(std.random.i32)` and non-negative
|
|
structural checks using existing `<` and `if` forms
|
|
- exp-12 compiler-known call `(std.io.read_stdin_result)` using
|
|
existing `(result string i32)` observers, unwrap, and `match`
|
|
- exp-13 compiler-known call `(std.string.parse_i32_result text)` using
|
|
existing `(result i32 i32)` observers, unwrap, and `match`
|
|
- exp-15 compiler-known result helper calls `(std.result.is_ok value)`,
|
|
`(std.result.is_err value)`, `(std.result.unwrap_ok value)`, and
|
|
`(std.result.unwrap_err value)` for only `(result i32 i32)`,
|
|
`(result i64 i32)`, and `(result string i32)`
|
|
- lexical `(unsafe body... final-expression)` expression blocks containing only
|
|
otherwise supported safe v0 forms
|
|
- final-expression returns
|
|
- top-level `(test "name" body... final-expression)`
|
|
- equality comparison `=` when used as a bool-producing test expression
|
|
- ordering comparison `<` when used as a bool-producing condition
|
|
- line comments
|
|
|
|
Promoted formatter fixtures are canonical output.
|
|
Formatting one of these fixtures must reproduce the same source bytes,
|
|
including accepted full-line comments and final newline, and formatting
|
|
formatter output must be idempotent. The v1 formatter is not a width-based
|
|
pretty printer and does not promise column reflow for long inline calls or
|
|
forms.
|
|
|
|
Line comments are stable only as full-line comments before top-level forms,
|
|
inside function/test bodies before body expressions, after the final
|
|
function/test body expression before the closing paren, and after the last
|
|
top-level form. Comments inside module forms, struct forms, function/test
|
|
headers, type forms, or inline expression forms are unsupported formatter
|
|
positions and must produce structured diagnostics instead of being silently
|
|
dropped.
|
|
|
|
Nested `if`, `while`, `unsafe`, and `match` forms keep their canonical
|
|
multiline shapes. Calls, field access, arrays, struct constructors,
|
|
option/result constructors, option/result observers, option/result unwraps,
|
|
legacy print aliases, `std.io.print_*` calls, exp-1 `std.string.concat` calls,
|
|
exp-2 `std.vec.i32.*` calls, exp-3 host calls, exp-4 qualified enum
|
|
constructors, exp-16 unary enum payload constructors, exp-8 `std.time.*`
|
|
calls, and exp-13
|
|
`std.string.parse_i32_result` calls, and exp-15 `std.result.*` helper calls
|
|
and exp-20 `std.io.print_f64` calls remain inline when used as expressions.
|
|
exp-21 `std.io.print_i64`, exp-22 `std.num.*` conversion calls, exp-23
|
|
`std.num.i64_to_i32_result`, exp-24 integer-to-string calls, and exp-25
|
|
`std.string.parse_i64_result` calls, and exp-26 `std.num.f64_to_string` calls
|
|
and exp-27 `std.num.f64_to_i32_result` calls remain inline when used as
|
|
expressions. exp-28 `std.string.parse_f64_result` calls and exp-31
|
|
`std.num.f64_to_i64_result` calls remain inline when used as expressions.
|
|
`string_len` and `std.string.len` remain inline when used as expressions.
|
|
|
|
Current Slovo-side target formatter fixtures:
|
|
|
|
- `u32-numeric-primitive.slo`
|
|
- `u64-numeric-primitive.slo`
|
|
- `unsigned-integer-to-string.slo`
|
|
- `string-parse-u32-result.slo`
|
|
- `string-parse-u64-result.slo`
|
|
|
|
These formatter fixtures describe the final exp-125 unsigned contract shape
|
|
now absorbed into `1.0.0-beta`. Execution claims still come from the paired
|
|
supported/project fixtures and Glagol gates, not from formatter fixtures
|
|
alone.
|
|
|
|
Design-target forms such as mutable string locals, string assignment, string
|
|
ordering, strings inside arrays, options, or results, string containers beyond
|
|
exp-19 direct struct fields, string slices, concatenation beyond exp-1
|
|
`std.string.concat`, indexing, ownership
|
|
annotations, user-defined string runtime bindings,
|
|
`print_unit`, `std.io.print_unit`, host IO beyond the exp-3 slice and exp-12
|
|
stdin-result slice, networking, async IO, binary file APIs, directory
|
|
traversal, terminal control, platform abstraction, general host error ADTs
|
|
beyond exp-10,
|
|
`result string Error`, package interaction, stdin APIs beyond the exp-12
|
|
result slice, parsing beyond exp-13 `std.string.parse_i32_result`, exp-25
|
|
`std.string.parse_i64_result`, and exp-28
|
|
`std.string.parse_f64_result`,
|
|
result helper payload families beyond the explicitly listed `(result i32 i32)`,
|
|
`(result i64 i32)`, `(result string i32)`, and exp-28 returned
|
|
`(result f64 i32)` families,
|
|
tokenizer/scanner APIs, parsing bools/strings/bytes, numeric casts or
|
|
conversions beyond exp-22 explicit widening calls and the exp-23 checked
|
|
`i64 -> i32` result call, exp-27 checked `f64 -> i32` result call, and exp-31
|
|
checked `f64 -> i64` result call, f64
|
|
formatting beyond exp-26 finite decimal text,
|
|
locale/base/radix/grouping/padding formatting controls, generic format/display
|
|
traits, stable integer-formatting ABI/layout/ownership, implicit promotion,
|
|
mixed numeric arithmetic, `f32`,
|
|
unsigned integers, narrower integer widths beyond the existing `i32`,
|
|
char/bytes/decimal,
|
|
whitespace/locale/base-prefix/underscore/plus-sign parsing beyond the exact
|
|
exp-13, exp-25, and exp-28 parse calls, Unicode digit parsing, parse error
|
|
messages or richer codes, randomness beyond the exp-11
|
|
slice, time beyond the exp-8 host time/sleep slice, generic vectors,
|
|
vector element types other than `i32`,
|
|
vector mutation, vector `var` or `set`, vector literals beyond empty/append
|
|
construction, `push`, nested vectors, vectors in arrays, structs, options, or
|
|
results, iterators, slices, maps, sets, user-visible vector deallocation,
|
|
stable vector ABI/layout/helper symbols, allocation, user-defined standard
|
|
modules, imports/packages, overloading, generic APIs, Unicode length
|
|
semantics, general slices, pointer types, raw memory operations, array
|
|
mutation, array element types beyond direct scalar `i32`, `i64`, `f64`,
|
|
`bool`, and `string`, zero-length arrays, nested arrays, array equality,
|
|
printing arrays, option/result mapping, equality, printing,
|
|
non-`i32` payload extraction, nested option/result values, arrays or structs
|
|
containing option/results, generic payloads, enum payloads beyond exp-16 unary
|
|
`i32` variants, generic enums, generic functions, type aliases,
|
|
traits/interfaces/protocols, methods, derives, wildcard/rest enum patterns,
|
|
enum guards, nested enum patterns, enum values in
|
|
arrays/structs/options/results/vectors, enum mutation,
|
|
enum printing/ordering/hash, enum reflection, explicit enum discriminants,
|
|
enum constructors with multiple arguments, unqualified variant constructors,
|
|
stable enum ABI/layout, moving option/result to ordinary standard-library
|
|
types, user-catchable exceptions, struct mutation, unsafe abstractions, and
|
|
user-declared `unit` returns must stay out of this directory until they meet
|
|
the strict support rule.
|
|
|
|
`canonical.slo` is the canonical formatted shape for the current supported
|
|
function fixture surface. `top-level-test.slo` is the canonical formatted shape
|
|
for the promoted top-level test fixture surface. `local-variables.slo` is the
|
|
canonical formatted shape for promoted local `let` / `var` / `set` forms,
|
|
including the later exp-112 immutable bool-local broadening.
|
|
`if.slo` is the canonical formatted shape for promoted value-producing
|
|
conditionals. `while.slo` is the canonical formatted shape for promoted
|
|
first-pass loops. `struct.slo` is the canonical formatted shape for promoted
|
|
first-pass structs. `struct-value-flow.slo` is the canonical formatted shape
|
|
for the first v1 struct value-flow slice. `array.slo` is the canonical
|
|
formatted shape for promoted first-pass array constructors, immutable array
|
|
locals, and literal indexing. `array-direct-scalars.slo` is the canonical
|
|
formatted shape for the widened direct scalar fixed-array constructor and
|
|
literal-indexing slice. `array-value-flow.slo` is the canonical formatted
|
|
shape for the first v1 array value-flow and dynamic-indexing slice.
|
|
`array-direct-scalars-value-flow.slo` is the canonical formatted shape for the
|
|
widened direct scalar fixed-array value-flow and dynamic-indexing slice.
|
|
`array-string.slo` is the canonical formatted shape for the widened fixed
|
|
string-array constructor and literal-indexing slice.
|
|
`array-string-value-flow.slo` is the canonical formatted shape for the widened
|
|
fixed string-array value-flow and dynamic-indexing slice.
|
|
`option-result.slo` is the canonical formatted shape for promoted first-pass
|
|
option/result constructors.
|
|
`option-result-flow.slo` is the canonical formatted shape for the first v1
|
|
option/result value-flow slice. `option-result-payload.slo` is the canonical
|
|
formatted shape for the first v1 option/result payload-access slice.
|
|
`option-result-match.slo` is the canonical formatted shape for the v1.4
|
|
option/result match slice.
|
|
`string-print.slo` is the canonical formatted shape for the first runtime
|
|
string-printing slice.
|
|
`string-value-flow.slo` is the canonical formatted shape for the v1.2
|
|
immutable string value-flow, equality, and length slice.
|
|
`print-bool.slo` is the canonical formatted shape for the v1.2 bool-printing
|
|
slice.
|
|
`standard-runtime.slo` is the canonical formatted shape for the v1.5
|
|
standard-runtime alpha names.
|
|
`owned-string-concat.slo` is the canonical formatted shape for the exp-1
|
|
owned-runtime-string concat fixture.
|
|
`vec-i32.slo` is the canonical formatted shape for the exp-2 `(vec i32)`
|
|
fixture.
|
|
`vec-i64.slo` is the canonical formatted shape for the exp-94 `(vec i64)`
|
|
fixture.
|
|
`host-io.slo` is the canonical formatted shape for the exp-3 standard IO and
|
|
host environment fixture.
|
|
`time-sleep.slo` is the canonical formatted shape for the exp-8 host time and
|
|
sleep fixture aligned by the exp-14 release.
|
|
`random.slo` is the canonical formatted shape for the exp-11 basic randomness
|
|
alpha release fixture.
|
|
`stdin-result.slo` is the canonical formatted shape for the exp-12 standard
|
|
input result alpha release fixture.
|
|
`string-parse-i32-result.slo` is the canonical formatted shape for the exp-13
|
|
string parse i32 result alpha fixture.
|
|
`result-helpers.slo` is the canonical formatted shape for the exp-15 result
|
|
helper standard names alpha fixture.
|
|
`enum-basic.slo` is the canonical formatted shape for the exp-4 payloadless
|
|
user enum fixture.
|
|
`enum-payload-i32.slo` is the canonical formatted shape for the exp-16 unary
|
|
`i32` enum payload fixture.
|
|
`primitive-struct-fields.slo` is the canonical formatted shape for the exp-19
|
|
primitive struct field fixture.
|
|
`local-variables.slo` is the canonical formatted shape for the exp-112
|
|
immutable bool locals fixture.
|
|
`f64-numeric-primitive.slo` is the canonical formatted shape for the exp-20
|
|
f64 numeric primitive fixture.
|
|
`i64-numeric-primitive.slo` is the canonical formatted shape for the exp-21
|
|
i64 numeric primitive fixture.
|
|
`numeric-widening-conversions.slo` is the canonical formatted shape for the
|
|
exp-22 numeric widening conversions fixture.
|
|
`checked-i64-to-i32-conversion.slo` is the canonical formatted shape for the
|
|
exp-23 checked i64-to-i32 conversion fixture.
|
|
`integer-to-string.slo` is the canonical formatted shape for the exp-24
|
|
integer to string fixture.
|
|
`string-parse-i64-result.slo` is the canonical formatted shape for the exp-25
|
|
string parse i64 result fixture.
|
|
`f64-to-string.slo` is the canonical formatted shape for the exp-26 f64 to
|
|
string fixture.
|
|
`f64-to-i32-result.slo` is the canonical formatted shape for the exp-27
|
|
checked f64-to-i32 result fixture.
|
|
`string-parse-f64-result.slo` is the canonical formatted shape for the exp-28
|
|
string parse f64 result fixture.
|
|
`numeric-struct-fields.slo` is the canonical formatted shape for the exp-29
|
|
numeric struct fields fixture.
|
|
`std-source-layout-alpha.slo` is the canonical formatted shape for the exp-30
|
|
standard library source layout alpha fixture.
|
|
`f64-to-i64-result.slo` is the canonical formatted shape for the exp-31
|
|
checked f64-to-i64 result fixture.
|
|
`unsafe.slo` is the canonical formatted shape for promoted lexical unsafe
|
|
blocks.
|
|
`comments.slo` is the canonical formatted shape for the promoted v1 full-line
|
|
comment stability positions.
|