Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
37 changes: 33 additions & 4 deletions src/v4/extdeps/languages/cpp.dag
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,16 @@
module v4.extdeps.languages.cpp

import v4.std.grammar {
FormalGrammarSymbol,
FormalNonterminal,
FormalProduction,
FormalTerminal,
FormalTerminalOccurrence,
GrammarExpr,
GrammarProduction,
Sequence,
Terminal,
grammar_production_to_node
formal_production_to_node
}
import v4.std.lexing {
LexRule,
Expand Down Expand Up @@ -194,7 +199,7 @@ type CppConcreteSyntaxToken
| CppBoundToken { token_class: Symbol, binding: Symbol }

type CppGrammarRelationRow {
production: GrammarProduction
production: FormalProduction
emitted: Node
tokens: List<CppConcreteSyntaxToken>
}
Expand Down Expand Up @@ -1127,6 +1132,30 @@ fn cpp_grammar_terminal(token_class: Symbol) -> GrammarExpr {
Terminal { token_class: token_class }
}

fn cpp_formal_terminal_symbol(token_class: Symbol) -> FormalGrammarSymbol {
FormalTerminalOccurrence { terminal: FormalTerminal { identity: token_class } }
}

fn cpp_formal_rhs_from_token_classes() -> List<FormalGrammarSymbol> {
fold_list(
xs: cpp_mvp1_concrete_tokens(),
empty: Empty,
cons: fn(acc, token) {
list_snoc_item(
xs: acc,
item: cpp_formal_terminal_symbol(token_class: cpp_concrete_token_class(token: token))
)
}
)
}

fn cpp_formal_production_mvp1_fn_add() -> FormalProduction {
FormalProduction {
lhs: FormalNonterminal { identity: cpp_production_mvp1_fn_add },
rhs: cpp_formal_rhs_from_token_classes()
}
}

type CppGramBuild1State
= CppGramBuild1StateInit
| CppGramBuild1StateReady { expr: GrammarExpr }
Expand Down Expand Up @@ -1167,7 +1196,7 @@ fn cpp_grammar_production_mvp1_fn_add(target_profile: Node) -> GrammarProduction

fn cpp_mvp1_grammar_relation_row(target_profile: Node) -> CppGrammarRelationRow {
CppGrammarRelationRow {
production: cpp_grammar_production_mvp1_fn_add(target_profile: target_profile),
production: cpp_formal_production_mvp1_fn_add(),
emitted: cpp_mvp1_emitted_add_fn_node(target_profile: target_profile),
tokens: cpp_mvp1_concrete_tokens()
}
Expand All @@ -1187,7 +1216,7 @@ fn cpp_grammar_relation_row_node(row: CppGrammarRelationRow) -> Node {
Node {
kind: TypeNode { connective: Conj },
children: [
cpp_named_edge(name: grammar_relation_field_production, target: grammar_production_to_node(production: row.production)),
cpp_named_edge(name: grammar_relation_field_production, target: formal_production_to_node(production: row.production)),
cpp_named_edge(name: grammar_relation_field_emitted, target: row.emitted),
cpp_named_edge(
name: grammar_relation_field_tokens,
Expand Down
12 changes: 6 additions & 6 deletions src/v4/extdeps/languages/go.dag
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ import v4.std.grammar {
ParseGrammar,
Sequence,
Terminal,
formal_production_to_node,
grammar_carries_symbol,
grammar_empty_sync_tokens,
grammar_production_to_node
grammar_empty_sync_tokens
}
import v4.std.lexing {
CharClassPattern,
Expand Down Expand Up @@ -164,7 +164,7 @@ type GoConcreteSyntaxToken
| GoBoundToken { token_class: Symbol, binding: Symbol }

type GoGrammarRelationRow {
production: GrammarProduction
production: FormalProduction
tokens: List<GoConcreteSyntaxToken>
}

Expand Down Expand Up @@ -1368,7 +1368,7 @@ fn go_grammar_production_mvp1_fn_add() -> GrammarProduction {

fn go_mvp1_grammar_relation_row() -> GoGrammarRelationRow {
GoGrammarRelationRow {
production: go_grammar_production_mvp1_fn_add(),
production: go_formal_production_mvp1_fn_add(),
tokens: go_mvp1_concrete_tokens()
}
}
Expand All @@ -1387,8 +1387,8 @@ fn go_grammar_relation_row_node(row: GoGrammarRelationRow) -> Node {
Node {
kind: TypeNode { connective: Conj },
children: [
go_named_edge(name: grammar_relation_field_production, target: grammar_production_to_node(production: row.production)),
go_named_edge(name: grammar_relation_field_emitted, target: row.production.emitted),
go_named_edge(name: grammar_relation_field_production, target: formal_production_to_node(production: row.production)),
go_named_edge(name: grammar_relation_field_emitted, target: go_mvp1_emitted_add_fn_node()),

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BLOCKING: The relation-row projection now fabricates the MVP1 emitted node instead of reading an emitted fact from the row, so replacing GrammarProduction with FormalProduction silently drops emission authority and violates INVARIANTS.md P2 facts-flow-forward.

go_named_edge(
name: grammar_relation_field_tokens,
target: Node { kind: TypeNode { connective: Conj }, children: go_relation_token_edges(tokens: row.tokens) }
Expand Down
39 changes: 34 additions & 5 deletions src/v4/extdeps/languages/java.dag
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ module v4.extdeps.languages.java

import v4.std.grammar {
Choice,
FormalGrammarSymbol,
FormalNonterminal,
FormalProduction,
FormalTerminal,
FormalTerminalOccurrence,
ParseGrammar,
GrammarExpr,
GrammarProduction,
Expand All @@ -17,9 +22,9 @@ import v4.std.grammar {
Repeat,
Sequence,
Terminal,
formal_production_to_node,
grammar_carries_symbol,
grammar_empty_sync_tokens,
grammar_production_to_node
grammar_empty_sync_tokens
}
import v4.std.lexing {
CharClassPattern,
Expand Down Expand Up @@ -158,7 +163,7 @@ type JavaConcreteSyntaxToken
| JavaBoundToken { token_class: Symbol, binding: Symbol }

type JavaGrammarRelationRow {
production: GrammarProduction
production: FormalProduction
emitted: Node
tokens: List<JavaConcreteSyntaxToken>
}
Expand Down Expand Up @@ -808,6 +813,30 @@ fn java_grammar_terminal(token_class: Symbol) -> GrammarExpr {
Terminal { token_class: token_class }
}

fn java_formal_terminal_symbol(token_class: Symbol) -> FormalGrammarSymbol {
FormalTerminalOccurrence { terminal: FormalTerminal { identity: token_class } }
}

fn java_formal_rhs_from_token_classes() -> List<FormalGrammarSymbol> {
fold_list(
xs: java_mvp1_concrete_tokens(),
empty: Empty,
cons: fn(acc, token) {
list_snoc_item(
xs: acc,
item: java_formal_terminal_symbol(token_class: java_concrete_token_class(token: token))
)
}
)
}

fn java_formal_production_mvp1_method_add() -> FormalProduction {
FormalProduction {
lhs: FormalNonterminal { identity: java_production_mvp1_method_add },
rhs: java_formal_rhs_from_token_classes()
}
}

fn java_grammar_nonterminal(production: Symbol) -> GrammarExpr {
Nonterminal { production: production }
}
Expand Down Expand Up @@ -872,7 +901,7 @@ fn java_grammar_sequence_from_token_classes() -> GrammarExpr {

fn java_mvp1_grammar_relation_row() -> JavaGrammarRelationRow {
JavaGrammarRelationRow {
production: java_grammar_production_mvp1_method_add(),
production: java_formal_production_mvp1_method_add(),
emitted: java_mvp1_emitted_add_method_node(),
tokens: java_mvp1_concrete_tokens()
}
Expand All @@ -897,7 +926,7 @@ fn java_grammar_relation_row_node(row: JavaGrammarRelationRow) -> Node {
children: [
java_named_edge(
name: grammar_relation_field_production,
target: grammar_production_to_node(production: row.production)
target: formal_production_to_node(production: row.production)
),
java_named_edge(name: grammar_relation_field_emitted, target: row.emitted),
java_named_edge(
Expand Down
39 changes: 33 additions & 6 deletions src/v4/extdeps/languages/kotlin.dag
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,13 @@
module v4.extdeps.languages.kotlin

import v4.std.grammar {
ParseGrammar,
Choice,
FormalGrammarSymbol,
FormalNonterminal,
FormalProduction,
FormalTerminal,
FormalTerminalOccurrence,
ParseGrammar,
GrammarExpr,
GrammarProduction,
GrammarRoot,
Expand All @@ -17,9 +22,9 @@ import v4.std.grammar {
Repeat,
Sequence,
Terminal,
formal_production_to_node,
grammar_carries_symbol,
grammar_empty_sync_tokens,
grammar_production_to_node
grammar_empty_sync_tokens
}
import v4.std.lexing {
CharClassPattern,
Expand Down Expand Up @@ -1125,6 +1130,28 @@ fn kotlin_grammar_sequence_from_nonempty(
)
}

fn kotlin_formal_production_from_nonempty(
head: KotlinConcreteSyntaxToken,
tail: List<KotlinConcreteSyntaxToken>
) -> FormalProduction {
let tokens = kotlin_concrete_tokens_list(head: head, tail: tail)
FormalProduction {
lhs: FormalNonterminal { identity: kotlin_production_mvp1_fn_add },
rhs: fold_list(
xs: tokens,
empty: Empty,
cons: fn(acc, token) {
list_snoc_item(
xs: acc,
item: FormalTerminalOccurrence {
terminal: FormalTerminal { identity: kotlin_concrete_token_class(token: token) }
}
)
}
)
}
}

fn kotlin_grammar_production_from_nonempty(
head: KotlinConcreteSyntaxToken,
tail: List<KotlinConcreteSyntaxToken>
Expand Down Expand Up @@ -1308,18 +1335,18 @@ fn kotlin_relation_token_edges(tokens: List<KotlinConcreteSyntaxToken>) -> List<
}

fn kotlin_grammar_relation_row_node(row: KotlinGrammarRelationRow) -> Node {
let production = kotlin_grammar_production_from_nonempty(head: row.head, tail: row.tail)
let production = kotlin_formal_production_from_nonempty(head: row.head, tail: row.tail)
let tokens = kotlin_concrete_tokens_list(head: row.head, tail: row.tail)
Node {
kind: TypeNode { connective: Conj },
children: [
kotlin_named_edge(
name: grammar_relation_field_production,
target: grammar_production_to_node(production: production)
target: formal_production_to_node(production: production)
),
kotlin_named_edge(
name: grammar_relation_field_emitted,
target: production.emitted
target: kotlin_mvp1_emitted_add_fn_node()

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BLOCKING: The relation-row projection hardcodes kotlin_mvp1_emitted_add_fn_node after switching to FormalProduction, leaving emitted output outside the row’s typed authority and violating INVARIANTS.md P2 single-authority/facts-flow-forward.

),
kotlin_named_edge(
name: grammar_relation_field_tokens,
Expand Down
10 changes: 5 additions & 5 deletions src/v4/extdeps/languages/rust.dag
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ import v4.std.grammar {
Repeat,
Sequence,
Terminal,
formal_production_to_node,
grammar_carries_symbol,
grammar_empty_sync_tokens,
grammar_production_to_node
grammar_empty_sync_tokens
}
import v4.std.lexing {
CharClassPattern,
Expand Down Expand Up @@ -253,7 +253,7 @@ type RustConcreteSyntaxToken
| RustBoundToken { token_class: Symbol, binding: Symbol }

type RustGrammarRelationRow {
production: GrammarProduction
production: FormalProduction
emitted: Node
tokens: List<RustConcreteSyntaxToken>
}
Expand Down Expand Up @@ -1327,7 +1327,7 @@ fn rust_grammar_sequence_from_token_classes() -> GrammarExpr {

fn rust_mvp1_grammar_relation_row() -> RustGrammarRelationRow {
RustGrammarRelationRow {
production: rust_grammar_production_mvp1_fn_add(),
production: rust_formal_production_mvp1_fn_add(),
emitted: rust_mvp1_emitted_add_fn_node(),
tokens: rust_mvp1_concrete_tokens()
}
Expand All @@ -1352,7 +1352,7 @@ fn rust_grammar_relation_row_node(row: RustGrammarRelationRow) -> Node {
children: [
rust_named_edge(
name: grammar_relation_field_production,
target: grammar_production_to_node(production: row.production)
target: formal_production_to_node(production: row.production)
),
rust_named_edge(name: grammar_relation_field_emitted, target: row.emitted),
rust_named_edge(
Expand Down
39 changes: 34 additions & 5 deletions src/v4/extdeps/languages/swift.dag
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ module v4.extdeps.languages.swift

import v4.std.grammar {
Choice,
FormalGrammarSymbol,
FormalNonterminal,
FormalProduction,
FormalTerminal,
FormalTerminalOccurrence,
ParseGrammar,
GrammarExpr,
GrammarProduction,
Expand All @@ -20,9 +25,9 @@ import v4.std.grammar {
Repeat,
Sequence,
Terminal,
formal_production_to_node,
grammar_carries_symbol,
grammar_empty_sync_tokens,
grammar_production_to_node
grammar_empty_sync_tokens
}
import v4.std.lexing {
CharClassPattern,
Expand Down Expand Up @@ -193,7 +198,7 @@ type SwiftConcreteSyntaxToken

// 🟢 grounded.
type SwiftGrammarRelationRow {
production: GrammarProduction
production: FormalProduction
emitted: Node
tokens: List<SwiftConcreteSyntaxToken>
}
Expand Down Expand Up @@ -790,6 +795,30 @@ fn swift_grammar_terminal(token_class: Symbol) -> GrammarExpr {
Terminal { token_class: token_class }
}

fn swift_formal_terminal_symbol(token_class: Symbol) -> FormalGrammarSymbol {
FormalTerminalOccurrence { terminal: FormalTerminal { identity: token_class } }
}

fn swift_formal_rhs_from_token_classes() -> List<FormalGrammarSymbol> {
fold_list(
xs: swift_mvp1_concrete_tokens(),
empty: Empty,
cons: fn(acc, token) {
list_snoc_item(
xs: acc,
item: swift_formal_terminal_symbol(token_class: swift_concrete_token_class(token: token))
)
}
)
}

fn swift_formal_production_mvp1_fn_add() -> FormalProduction {
FormalProduction {
lhs: FormalNonterminal { identity: swift_production_mvp1_fn_add },
rhs: swift_formal_rhs_from_token_classes()
}
}

fn swift_grammar_sequence_fold_step(acc: GrammarExpr, token: SwiftConcreteSyntaxToken) -> GrammarExpr {
let token_class = swift_concrete_token_class(token: token)
if token_class == swift_token_kw_func {
Expand All @@ -814,7 +843,7 @@ fn swift_grammar_sequence_from_token_classes() -> GrammarExpr {

fn swift_mvp1_grammar_relation_row() -> SwiftGrammarRelationRow {
SwiftGrammarRelationRow {
production: swift_grammar_production_mvp1_fn_add(),
production: swift_formal_production_mvp1_fn_add(),
emitted: swift_mvp1_emitted_add_fn_node(),
tokens: swift_mvp1_concrete_tokens()
}
Expand All @@ -839,7 +868,7 @@ fn swift_grammar_relation_row_node(row: SwiftGrammarRelationRow) -> Node {
children: [
swift_named_edge(
name: grammar_relation_field_production,
target: grammar_production_to_node(production: row.production)
target: formal_production_to_node(production: row.production)
),
swift_named_edge(name: grammar_relation_field_emitted, target: row.emitted),
swift_named_edge(
Expand Down
Loading
Loading