aboutsummaryrefslogtreecommitdiff
path: root/src/urubu/spec/grammar/description.go
blob: 0d2a0b7af42ac0edf522303f516175533098d9f2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
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"`
}