aboutsummaryrefslogtreecommitdiff
path: root/spec/grammar.go
blob: 002fac911767c21738fcd291eba883735c2676bf (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
package spec

import mlspec "github.com/nihei9/maleeni/spec"

type CompiledGrammar struct {
	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"`
}

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"`
	ExpectedTerminals       [][]int  `json:"expected_terminals"`
}

type ASTAction struct {
	Entries [][]int `json:"entries"`
}