From 8359c047aaebe274a2d811d61922b571ca7d10df Mon Sep 17 00:00:00 2001 From: EuAndreh Date: Tue, 10 Dec 2024 12:29:03 -0300 Subject: Namespace packages with "urubu/" --- src/urubu/spec/grammar/description.go | 71 +++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 src/urubu/spec/grammar/description.go (limited to 'src/urubu/spec/grammar/description.go') diff --git a/src/urubu/spec/grammar/description.go b/src/urubu/spec/grammar/description.go new file mode 100644 index 0000000..0d2a0b7 --- /dev/null +++ b/src/urubu/spec/grammar/description.go @@ -0,0 +1,71 @@ +package grammar + +type Terminal struct { + Number int `json:"number"` + Name string `json:"name"` + Pattern string `json:"pattern"` + Precedence int `json:"prec"` + Associativity string `json:"assoc"` +} + +type NonTerminal struct { + Number int `json:"number"` + Name string `json:"name"` +} + +type Production struct { + Number int `json:"number"` + LHS int `json:"lhs"` + RHS []int `json:"rhs"` + Precedence int `json:"prec"` + Associativity string `json:"assoc"` +} + +type Item struct { + Production int `json:"production"` + Dot int `json:"dot"` +} + +type Transition struct { + Symbol int `json:"symbol"` + State int `json:"state"` +} + +type Reduce struct { + LookAhead []int `json:"look_ahead"` + Production int `json:"production"` +} + +type SRConflict struct { + Symbol int `json:"symbol"` + State int `json:"state"` + Production int `json:"production"` + AdoptedState *int `json:"adopted_state"` + AdoptedProduction *int `json:"adopted_production"` + ResolvedBy int `json:"resolved_by"` +} + +type RRConflict struct { + Symbol int `json:"symbol"` + Production1 int `json:"production_1"` + Production2 int `json:"production_2"` + AdoptedProduction int `json:"adopted_production"` + ResolvedBy int `json:"resolved_by"` +} + +type State struct { + Number int `json:"number"` + Kernel []*Item `json:"kernel"` + Shift []*Transition `json:"shift"` + Reduce []*Reduce `json:"reduce"` + GoTo []*Transition `json:"goto"` + SRConflict []*SRConflict `json:"sr_conflict"` + RRConflict []*RRConflict `json:"rr_conflict"` +} + +type Report struct { + Terminals []*Terminal `json:"terminals"` + NonTerminals []*NonTerminal `json:"non_terminals"` + Productions []*Production `json:"productions"` + States []*State `json:"states"` +} -- cgit v1.2.3