summaryrefslogtreecommitdiff
path: root/lang/spec.go
diff options
context:
space:
mode:
authorMarc Vertes <mvertes@free.fr>2024-04-02 11:27:13 +0200
committerGitHub <noreply@github.com>2024-04-02 11:27:13 +0200
commit1bff92c52b27b9a516599e172fe9852c3d99be38 (patch)
tree26b30b5ec1a5537dcafd806d23e03a062475705d /lang/spec.go
parent362f7c9c45598b429c92e67756f41b690043e0c4 (diff)
chore: add linters and some lint fixes (#8)
* chore: add linters and some lint fixes Configure some golangci-lint linters to get the code quality right. Apply the first fixes. Next step will be to add github actions to run lint and tests in github CI. * chore: more lint, fixed comments and variable names. no semantic change. * chore: add Makefile This makefile is intended to be used as a local substitute to github actions.
Diffstat (limited to 'lang/spec.go')
-rw-r--r--lang/spec.go15
1 files changed, 10 insertions, 5 deletions
diff --git a/lang/spec.go b/lang/spec.go
index a910f70..92d90f7 100644
--- a/lang/spec.go
+++ b/lang/spec.go
@@ -1,5 +1,7 @@
+// Package lang provides tokens for possibly multiple languages.
package lang
+// Lexical properties of tokens to allow scanning.
const (
CharIllegal = 1 << iota
CharOp
@@ -16,26 +18,29 @@ const (
EosValidEnd // end of input string terminates block or string token
)
+// ASCIILen is the length of the ASCII characters set.
const ASCIILen = 1 << 7 // 128
+// TokenProp represent token properties for parsing.
type TokenProp struct {
- TokenId
+ Token
SkipSemi bool // automatic semicolon insertion after newline
Precedence int // operator precedence
}
+// Spec represents the token specification for scanning.
type Spec struct {
CharProp [ASCIILen]uint // special Character properties
End map[string]string // end delimiters, indexed by start
BlockProp map[string]uint // block properties
TokenProps map[string]TokenProp // token properties
DotNum bool // true if a number can start with '.'
- IdAscii bool // true if an identifier can be in ASCII only
- Num_ bool // true if a number can contain _ character
+ IdentASCII bool // true if an identifier can be in ASCII only
+ NumUnder bool // true if a number can contain _ character
}
-// HasInit stores if a statement may contain a simple init statement
-var HasInit = map[TokenId]bool{
+// HasInit stores if a statement may contain a simple init statement.
+var HasInit = map[Token]bool{
Case: true,
For: true,
If: true,