diff options
author | Ryo Nihei <nihei.dev@gmail.com> | 2021-09-18 21:25:48 +0900 |
---|---|---|
committer | Ryo Nihei <nihei.dev@gmail.com> | 2021-09-18 23:48:51 +0900 |
commit | 7be1d273429765907af0abad182666d77eb557e4 (patch) | |
tree | 1dcb0d68d8d65e4a8f847a6790eed5c7c0854401 /spec/spec.go | |
parent | Generate constant values representing mode IDs, mode names, kind IDs, and kin... (diff) | |
download | tre-7be1d273429765907af0abad182666d77eb557e4.tar.gz tre-7be1d273429765907af0abad182666d77eb557e4.tar.xz |
Add name field to the lexical specification
Diffstat (limited to 'spec/spec.go')
-rw-r--r-- | spec/spec.go | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/spec/spec.go b/spec/spec.go index 62acfc4..2360201 100644 --- a/spec/spec.go +++ b/spec/spec.go @@ -157,10 +157,16 @@ func (e *LexEntry) validate() error { } type LexSpec struct { + Name string `json:"name"` Entries []*LexEntry `json:"entries"` } func (s *LexSpec) Validate() error { + err := validateIdentifier(s.Name) + if err != nil { + return fmt.Errorf("invalid specification name: %v", err) + } + if len(s.Entries) <= 0 { return fmt.Errorf("the lexical specification must have at least one entry") } @@ -364,6 +370,7 @@ type CompiledLexModeSpec struct { } type CompiledLexSpec struct { + Name string `json:"name"` InitialModeID LexModeID `json:"initial_mode_id"` ModeNames []LexModeName `json:"mode_names"` KindNames []LexKindName `json:"kind_names"` |