diff options
author | Ryo Nihei <nihei.dev@gmail.com> | 2021-08-01 17:17:53 +0900 |
---|---|---|
committer | Ryo Nihei <nihei.dev@gmail.com> | 2021-08-01 21:18:34 +0900 |
commit | 2433c27f26bc1be2d9b33f6550482abc48fa31ef (patch) | |
tree | c7cbc22929045e2d5dccdc37cc978138b59c1bdb /compiler/parser_test.go | |
parent | Add unique kind IDs to tokens (diff) | |
download | tre-2433c27f26bc1be2d9b33f6550482abc48fa31ef.tar.gz tre-2433c27f26bc1be2d9b33f6550482abc48fa31ef.tar.xz |
Change APIs
Change fields of tokens, results of lexical analysis, as follows:
- Rename: mode -> mode_id
- Rename: kind_id -> mode_kind_id
- Add: kind_id
The kind ID is unique across all modes, but the mode kind ID is unique only within a mode.
Change fields of a transition table as follows:
- Rename: initial_mode -> initial_mode_id
- Rename: modes -> mode_names
- Rename: kinds -> kind_names
- Rename: specs[].kinds -> specs[].kind_names
- Rename: specs[].dfa.initial_state -> specs[].dfa.initial_state_id
Change public types defined in the spec package as follows:
- Rename: LexModeNum -> LexModeID
- Rename: LexKind -> LexKindName
- Add: LexKindID
- Add: StateID
Diffstat (limited to 'compiler/parser_test.go')
-rw-r--r-- | compiler/parser_test.go | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/compiler/parser_test.go b/compiler/parser_test.go index 3394845..30e6130 100644 --- a/compiler/parser_test.go +++ b/compiler/parser_test.go @@ -4,6 +4,8 @@ import ( "fmt" "reflect" "testing" + + "github.com/nihei9/maleeni/spec" ) func symPos(n uint16) symbolPosition { @@ -1197,7 +1199,7 @@ func TestParse(t *testing.T) { for kind, pattern := range tt.fragments { fragments[kind] = []byte(pattern) } - ast, _, err := parse(map[int][]byte{ + ast, _, err := parse(map[spec.LexModeKindID][]byte{ 1: []byte(tt.pattern), }, fragments) if tt.syntaxError != nil { @@ -1237,7 +1239,7 @@ func TestParse(t *testing.T) { } func TestParse_FollowAndSymbolTable(t *testing.T) { - root, symTab, err := parse(map[int][]byte{ + root, symTab, err := parse(map[spec.LexModeKindID][]byte{ 1: []byte("(a|b)*abb"), }, nil) if err != nil { @@ -1295,7 +1297,7 @@ func TestParse_FollowAndSymbolTable(t *testing.T) { symPos(4): entry(byte('b')), symPos(5): entry(byte('b')), }, - endPos2ID: map[symbolPosition]int{ + endPos2ID: map[symbolPosition]spec.LexModeKindID{ endPos(6): 1, }, } |