aboutsummaryrefslogtreecommitdiff
path: root/spec/description.go
diff options
context:
space:
mode:
authorRyo Nihei <nihei.dev@gmail.com>2021-08-29 21:10:42 +0900
committerRyo Nihei <nihei.dev@gmail.com>2021-08-29 21:10:42 +0900
commitb70f41840819a59f82a37c0da7eddae40fc52aa0 (patch)
treef830f25438d089465ce70bec272f1ac2e6f3d03b /spec/description.go
parentUse a pattern string defined by a string literal as its alias (diff)
downloadurubu-b70f41840819a59f82a37c0da7eddae40fc52aa0.tar.gz
urubu-b70f41840819a59f82a37c0da7eddae40fc52aa0.tar.xz
Add describe command to print a description file
Diffstat (limited to 'spec/description.go')
-rw-r--r--spec/description.go67
1 files changed, 67 insertions, 0 deletions
diff --git a/spec/description.go b/spec/description.go
new file mode 100644
index 0000000..d2b6d3b
--- /dev/null
+++ b/spec/description.go
@@ -0,0 +1,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"`
+}