aboutsummaryrefslogtreecommitdiff
path: root/spec/description.go
blob: d2b6d3b9328459839cf5437c3d1c21f9c63b2e36 (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
package spec

type Terminal struct {
	Number    int    `json:"number"`
	Name      string `json:"name"`
	Anonymous bool   `json:"anonymous"`
	Alias     string `json:"alias"`
	Pattern   string `json:"pattern"`
}

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"`
}

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"`
}

type RRConflict struct {
	Symbol            int `json:"symbol"`
	Production1       int `json:"production_1"`
	Production2       int `json:"production_2"`
	AdoptedProduction int `json:"adopted_production"`
}

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 Description struct {
	Terminals    []*Terminal    `json:"terminals"`
	NonTerminals []*NonTerminal `json:"non_terminals"`
	Productions  []*Production  `json:"productions"`
	States       []*State       `json:"states"`
}