Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
86d8140
WIP: Author std/lexing.dag + std/grammar.dag: move LexRule/Grammar/Pr…
briansrls May 28, 2026
149b50b
WIP: Author std/lexing.dag + std/grammar.dag: move LexRule/Grammar/Pr…
briansrls May 28, 2026
337200b
WIP: Author std/lexing.dag + std/grammar.dag: move LexRule/Grammar/Pr…
briansrls May 28, 2026
5744381
WIP: Author std/lexing.dag + std/grammar.dag: move LexRule/Grammar/Pr…
briansrls May 28, 2026
3d9362b
WIP: Author std/lexing.dag + std/grammar.dag: move LexRule/Grammar/Pr…
briansrls May 28, 2026
c470fb0
WIP: Author std/lexing.dag + std/grammar.dag: move LexRule/Grammar/Pr…
briansrls May 28, 2026
4266c0a
WIP: Author std/lexing.dag + std/grammar.dag: move LexRule/Grammar/Pr…
briansrls May 28, 2026
341df4e
WIP: Author std/lexing.dag + std/grammar.dag: move LexRule/Grammar/Pr…
briansrls May 28, 2026
c5eb824
WIP: Author std/lexing.dag + std/grammar.dag: move LexRule/Grammar/Pr…
briansrls May 28, 2026
8a4dc2f
WIP: Author std/lexing.dag + std/grammar.dag: move LexRule/Grammar/Pr…
briansrls May 28, 2026
be8ba7c
WIP: Author std/lexing.dag + std/grammar.dag: move LexRule/Grammar/Pr…
briansrls May 28, 2026
b7f569d
WIP: Author std/lexing.dag + std/grammar.dag: move LexRule/Grammar/Pr…
briansrls May 28, 2026
8f64f3e
WIP: Author std/lexing.dag + std/grammar.dag: move LexRule/Grammar/Pr…
briansrls May 28, 2026
77a19f3
WIP: Author std/lexing.dag + std/grammar.dag: move LexRule/Grammar/Pr…
briansrls May 28, 2026
bdf1c09
WIP: Author std/lexing.dag + std/grammar.dag: move LexRule/Grammar/Pr…
briansrls May 28, 2026
de2edcb
WIP: Author std/lexing.dag + std/grammar.dag: move LexRule/Grammar/Pr…
briansrls May 28, 2026
ec4e7d4
WIP: Author std/lexing.dag + std/grammar.dag: move LexRule/Grammar/Pr…
briansrls May 28, 2026
d85a22c
WIP: Author std/lexing.dag + std/grammar.dag: move LexRule/Grammar/Pr…
briansrls May 28, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions scripts/strict_deprose_dag.py
Original file line number Diff line number Diff line change
Expand Up @@ -652,23 +652,23 @@ def main() -> None:
"src/v4/extdeps/languages/typescript.dag",
"// Scope: TypeScript 5.9 + ECMA-262 ES2025 numeric primitive fact-bundles and ModelCore wave-1.",
"// Anchor: https://www.typescriptlang.org/docs/handbook/2/everyday-types.html — ECMA-262 https://tc39.es/ecma262/2025/multipage/",
"// Consumes: v4.compiler.parse, v4.compiler.tokenize, v4.std.collection, v4.std.node, v4.std.logic, v4.std.algebra, v4.std.model_core, v4.std.target_model, v4.std.text.",
"// Consumes: v4.std.grammar, v4.std.lexing, v4.std.collection, v4.std.node, v4.std.logic, v4.std.algebra, v4.std.model_core, v4.std.target_model, v4.std.text.",
"// Status: T-4 typescript slice — ECMA `number` (IEEE-754 binary64) + `bigint` (exact unbounded ℤ) fact-bundles; `core: ModelCore` primitives from `ts_numeric_facts_catalog` via fold; canonical_symbols = catalog surface spellings + wave-1 lex/grammar/MVP; target_model edge keys from std/target_model.dag; MVP-1 grammar/token substrate for T-11; bool canonical-B decl-ref — 🟡 E-6(b) staging.",
"// 🟡",
),
(
"src/v4/extdeps/languages/swift.dag",
"// Scope: Swift language/standard-library scalar fact-bundles and ModelCore wave-1.",
"// Anchor: https://docs.swift.org/swift-book/documentation/the-swift-programming-language/thebasics/",
"// Consumes: v4.compiler.parse, v4.compiler.tokenize, v4.std.collection, v4.std.model_core, v4.std.target_model, v4.std.node, v4.std.logic, v4.std.algebra, v4.std.text.",
"// Consumes: v4.std.grammar, v4.std.lexing, v4.std.collection, v4.std.model_core, v4.std.target_model, v4.std.node, v4.std.logic, v4.std.algebra, v4.std.text.",
"// Status: T-4 Swift wave-1; fixed-width integer spellings are explicit, Int/UInt stay platform-word-width facts, Float/Double carry IEEE-754 precision; canonical_symbols = catalog surface spellings + wave-1 lex/grammar/MVP; target_model edge keys from std/target_model.dag; MVP-1 grammar/token substrate for T-11; bool canonical-B decl-ref is E-6(b) staging.",
"// 🟡",
),
(
"src/v4/extdeps/languages/wasm.dag",
"// Scope: WebAssembly Core numeric value types — LanguageModel fact-bundles (Shape A).",
"// Anchor: https://webassembly.github.io/spec/core/types.html#number-types",
"// Consumes: v4.compiler.parse, v4.compiler.tokenize, v4.std.collection, v4.std.model_core, v4.std.target_model, v4.std.node, v4.std.logic, v4.std.algebra, v4.std.text.",
"// Consumes: v4.std.grammar, v4.std.lexing, v4.std.collection, v4.std.model_core, v4.std.target_model, v4.std.node, v4.std.logic, v4.std.algebra, v4.std.text.",
"// Status: T-4 wasm slice — Core §2.3.1 number types (i32/i64/f32/f64 wave-1); `core: ModelCore` (#3474); canonical_symbols = catalog surface spellings + wave-1 lex/grammar/MVP; target_model edge keys from std/target_model.dag; MVP-1 WAT grammar/token substrate for T-11; v128/funcref/externref 🟡 wave-2; integer sign-agnostic per spec (width + modular wrap, not signed/unsigned partition).",
"// 🟡",
),
Expand Down
33 changes: 33 additions & 0 deletions src/v4/TASKS.md
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,22 @@ conceptual `(Source, LanguageModel)` spelling.
- merged: `src/v4/compiler/01_tokenize.dag` (B2-OMNI, E0 contract)
- v3 L2.5 design: `docs/r3-path-b-tokenize-parse-brief-set.md` PB-2

#### T-6.1: LexRule token-class query dissolution

**Owner/lane:** T-6 std lexing substrate follow-up.

**Missing primitive:** substrate-derived `LexRule` token-class projection plus
`TokenRule` discriminant query in `src/v4/std/lexing.dag`.

**Interim surface:** `lex_rule_token_class_member` / `lex_rule_set_token_class_member`
are allowed only as the shared std query while language slices need canonical symbol
membership and no derived `LexRule` projection exists.

**Dissolve-on-arrival:** the first PR that lands the projection/query primitive
must delete the hand-written `LexRule` arm match in `lex_rule_token_class_member`
and make `lex_rule_set_token_class_member` consume the substrate query in the same
commit train. No extdeps/compiler-local duplicate predicate may be added meanwhile.

---

### T-7: compiler/02_parse.dag
Expand All @@ -515,6 +531,23 @@ syntax-side projection of the landed `LanguageModel = Node` authority in
- merged: `src/v4/compiler/02_parse.dag` (B2-OMNI, G0 contract)
- v3 L2.5 design: `docs/r3-path-b-tokenize-parse-brief-set.md` PB-3

#### T-7.1: GrammarExpr node projection dissolution

**Owner/lane:** T-7 std grammar substrate follow-up.

**Missing primitive:** substrate-derived `GrammarExpr` fold/projection to canonical
`Node` edges in `src/v4/std/grammar.dag`.

**Interim surface:** `grammar_expr_to_node` is allowed only as the shared std
projection used by `grammar_to_node` and symbol-membership checks while no
substrate fold exists for `GrammarExpr`.

**Dissolve-on-arrival:** the first PR that lands the `GrammarExpr` fold/projection
primitive must delete the recursive hand-written coproduct walker in
`grammar_expr_to_node` and route `grammar_to_node` through the substrate projection
in the same commit train. No compiler/extdeps-local `GrammarExpr` re-encoder may
be added meanwhile.

---

### T-8: compiler/03_normalize.dag + 03_resolve.dag
Expand Down
3 changes: 2 additions & 1 deletion src/v4/compiler/00_compile.dag
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ import v4.compiler.normalize { normalize }
import v4.compiler.parse { parse }
import v4.compiler.resolve { resolve }
import v4.compiler.tokenize { tokenize }
import v4.compiler.target_carriers { TargetModel, TargetSource }
import v4.compiler.target_carriers { TargetSource }
import v4.std.target_model { TargetModel }
import v4.extdeps.languages.dag { dag_language_model_wave1, qualified_name_from_module_node }
import v4.lens.fact_density { fact_density_hollow_alias_gate }
import v4.std.algebra { Cons, Empty, FreeMonoid, list_append, list_snoc_item }
Expand Down
106 changes: 31 additions & 75 deletions src/v4/compiler/01_tokenize.dag
Original file line number Diff line number Diff line change
Expand Up @@ -16,62 +16,37 @@ import v4.std.algebra { Cons, Empty, ListTailResult, TailAbsent, TailFound, fold
import v4.std.text { Char, CharAbsent, CharFound, String, string_head, string_is_empty, string_tail }
import v4.std.nat { Nat, nat_lte, nat_gte }
import v4.std.logic { Bool }

// 🟡 coproduct dissolution — CP-1b item 13a; lexical data is modeled, per-arm lexer morphism witness remains gated.
type LexCharClass
= WhitespaceChar
| DigitChar
| HexDigitChar
| IdentStartChar
| IdentContinueChar
| StringTextChar
| LineCommentTextChar
| BlockCommentTextChar


// 🟡 coproduct dissolution — CP-1b item 13b; declarative parse/emit pattern data is modeled, bidirectional grammar carrier convergence remains gated.
type LexPattern
= EmptyPattern
| LiteralPattern { text: String }
| KeywordPattern { text: String }
| CharPattern { char: Char }
| CharClassPattern { class: LexCharClass }
| SequencePattern { left: LexPattern, right: LexPattern }
| ChoicePattern { left: LexPattern, right: LexPattern }
| OptionalPattern { element: LexPattern }
| RepeatPattern { element: LexPattern }
| OneOrMorePattern { element: LexPattern }
| DelimitedPattern { open: LexPattern, body: LexPattern, close: LexPattern }


// 🟡 coproduct dissolution — CP-1b item 13c; token/trivia rule data is modeled, per-arm lexer morphism witness remains gated.
type LexRule
= TokenRule { token_class: Symbol, pattern: LexPattern }
| TriviaRule { pattern: LexPattern }


// Maximal munch: lex_try_rules selects the accepting rule with the longest lexeme;
// equal-length ties prefer the later rule (specific literals/keywords after ident).
type LexRuleSet {
rules: List<LexRule>
}


// 🟡 coproduct dissolution — CP-1b item 13d; modeled rule data is present, generic lexical walk realized.
type LexRules
= VoidLexRules
| ModeledLexRules { root: LexRuleSet }


type Token {
class: Symbol
lexeme: String
file: Symbol
start: Int
end: Int
}
type TokenStream {
tokens: List<Token>
import v4.std.lexing {
BlockCommentTextChar,
CharClassPattern,
CharPattern,
ChoicePattern,
DelimitedPattern,
DigitChar,
EmptyPattern,
HexDigitChar,
IdentContinueChar,
IdentStartChar,
KeywordPattern,
LexCharClass,
LexPattern,
LexRule,
LexRuleSet,
LexRules,
LineCommentTextChar,
LiteralPattern,
ModeledLexRules,
OneOrMorePattern,
OptionalPattern,
RepeatPattern,
SequencePattern,
StringTextChar,
Token,
TokenRule,
TokenStream,
TriviaRule,
VoidLexRules,
WhitespaceChar
}

// 🟡 coproduct dissolution — CP-1b item 13e; per-pattern match result; dissolves when LexPattern converges with GrammarExpr on single bidirectional grammar carrier.
Expand All @@ -89,25 +64,6 @@ data tokenize_lex_e0_source_not_exhausted: Symbol = tokenize_lex_e0_source_not_e
data tokenize_lex_e1_unrecognized_char: Symbol = tokenize_lex_e1_unrecognized_char


fn lex_rule_token_class_member(rule: LexRule, token_class: Symbol) -> Bool {
match rule {
TokenRule { token_class: c, pattern: _ } => c == token_class
TriviaRule { pattern: _ } => false
}
}


fn lex_rule_set_token_class_member(rules: LexRuleSet, token_class: Symbol) -> Bool {
fold_list(
xs: rules.rules,
empty: false,
cons: fn(acc, rule) {
acc || lex_rule_token_class_member(rule: rule, token_class: token_class)
}
)
}


fn tokenize_lex_e0_source_not_exhausted_diagnostic(at: Locus) -> Diagnostic {
Diagnostic {
reason: tokenize_lex_e0_source_not_exhausted,
Expand Down
Loading
Loading