From 2433c27f26bc1be2d9b33f6550482abc48fa31ef Mon Sep 17 00:00:00 2001 From: Ryo Nihei Date: Sun, 1 Aug 2021 17:17:53 +0900 Subject: 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 --- compiler/dfa_test.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'compiler/dfa_test.go') diff --git a/compiler/dfa_test.go b/compiler/dfa_test.go index a797313..2683815 100644 --- a/compiler/dfa_test.go +++ b/compiler/dfa_test.go @@ -2,10 +2,12 @@ package compiler import ( "testing" + + "github.com/nihei9/maleeni/spec" ) func TestGenDFA(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 { @@ -94,7 +96,7 @@ func TestGenDFA(t *testing.T) { t.Errorf("initial state is mismatched; want: %v, got: %v", s0.hash(), dfa.InitialState) } - accTab := map[string]int{ + accTab := map[string]spec.LexModeKindID{ s3.hash(): 1, } if len(dfa.AcceptingStatesTable) != len(accTab) { -- cgit v1.2.3