aboutsummaryrefslogtreecommitdiff
path: root/spec/grammar.go
diff options
context:
space:
mode:
authorRyo Nihei <nihei.dev@gmail.com>2021-06-19 00:38:27 +0900
committerRyo Nihei <nihei.dev@gmail.com>2021-06-19 00:38:27 +0900
commit52379a9e26578eb1105e73839db8157e24ba2d4c (patch)
tree1b03f2da6d9a67bd69823d01a050c2a95f1e9e55 /spec/grammar.go
parentAdd SLR parsing table generator (diff)
downloadcotia-52379a9e26578eb1105e73839db8157e24ba2d4c.tar.gz
cotia-52379a9e26578eb1105e73839db8157e24ba2d4c.tar.xz
Add driver
Diffstat (limited to 'spec/grammar.go')
-rw-r--r--spec/grammar.go33
1 files changed, 33 insertions, 0 deletions
diff --git a/spec/grammar.go b/spec/grammar.go
new file mode 100644
index 0000000..653b50d
--- /dev/null
+++ b/spec/grammar.go
@@ -0,0 +1,33 @@
+package spec
+
+import mlspec "github.com/nihei9/maleeni/spec"
+
+type CompiledGrammar struct {
+ LexicalSpecification *LexicalSpecification `json:"lexical_specification"`
+ ParsingTable *ParsingTable `json:"parsing_table"`
+}
+
+type LexicalSpecification struct {
+ Lexer string `json:"lexer"`
+ Maleeni *Maleeni `json:"maleeni"`
+}
+
+type Maleeni struct {
+ Spec *mlspec.CompiledLexSpec `json:"spec"`
+ KindToTerminal [][]int `json:"kind_to_terminal"`
+}
+
+type ParsingTable struct {
+ Action []int `json:"action"`
+ GoTo []int `json:"goto"`
+ StateCount int `json:"state_count"`
+ InitialState int `json:"initial_state"`
+ StartProduction int `json:"start_production"`
+ LHSSymbols []int `json:"lhs_symbols"`
+ AlternativeSymbolCounts []int `json:"alternative_symbol_counts"`
+ Terminals []string `json:"terminals"`
+ TerminalCount int `json:"terminal_count"`
+ NonTerminals []string `json:"non_terminals"`
+ NonTerminalCount int `json:"non_terminal_count"`
+ EOFSymbol int `json:"eof_symbol"`
+}