diff options
author | Ryo Nihei <nihei.dev@gmail.com> | 2022-05-27 02:11:39 +0900 |
---|---|---|
committer | Ryo Nihei <nihei.dev@gmail.com> | 2022-05-27 02:25:50 +0900 |
commit | 4c0f7eb15db566a19eb753e6ffc3a2354078f5fc (patch) | |
tree | f3956aa60561ede7d6ccfb288eabfd47de60ffe4 /spec/grammar/grammar.go | |
parent | Allows a directory to be specified as the --output option for the vartan-comp... (diff) | |
download | urubu-4c0f7eb15db566a19eb753e6ffc3a2354078f5fc.tar.gz urubu-4c0f7eb15db566a19eb753e6ffc3a2354078f5fc.tar.xz |
Rename spec package to spec/grammar package
Diffstat (limited to 'spec/grammar/grammar.go')
-rw-r--r-- | spec/grammar/grammar.go | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/spec/grammar/grammar.go b/spec/grammar/grammar.go new file mode 100644 index 0000000..25266e5 --- /dev/null +++ b/spec/grammar/grammar.go @@ -0,0 +1,45 @@ +package grammar + +import mlspec "github.com/nihei9/maleeni/spec" + +type CompiledGrammar struct { + Name string `json:"name"` + LexicalSpecification *LexicalSpecification `json:"lexical_specification"` + ParsingTable *ParsingTable `json:"parsing_table"` + ASTAction *ASTAction `json:"ast_action"` +} + +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"` + TerminalToKind []int `json:"terminal_to_kind"` + Skip []int `json:"skip"` + KindAliases []string `json:"kind_aliases"` +} + +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"` + ErrorSymbol int `json:"error_symbol"` + ErrorTrapperStates []int `json:"error_trapper_states"` + RecoverProductions []int `json:"recover_productions"` +} + +type ASTAction struct { + Entries [][]int `json:"entries"` +} |