summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc Vertes <mvertes@free.fr>2025-11-10 14:01:16 +0100
committerMarc Vertes <mvertes@free.fr>2025-11-10 14:01:16 +0100
commit0035f65d697e165c4f2ba2d445bfa938ab4159ee (patch)
treea2b9779d2cf0ac7c1a36ec381b0ed0b1be2a1bba
parentc6ff109198546a8adb340a7be84a7fc03762081b (diff)
chore: fix lint
-rw-r--r--.gitignore1
-rw-r--r--.golangci.yaml22
-rw-r--r--main.go2
-rw-r--r--parser/compiler.go10
-rw-r--r--parser/expr.go2
-rw-r--r--scanner/scan.go9
6 files changed, 35 insertions, 11 deletions
diff --git a/.gitignore b/.gitignore
index e2bf6fd..9d0511e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,4 @@
*.out
*.test
parscan
+tags
diff --git a/.golangci.yaml b/.golangci.yaml
index f2191fb..a185bb8 100644
--- a/.golangci.yaml
+++ b/.golangci.yaml
@@ -1,8 +1,8 @@
+version: "2"
linters:
enable:
- gocritic
- godot
- - gofumpt
- gosec
- misspell
- perfsprint
@@ -11,3 +11,23 @@ linters:
- reassign
- revive
- unconvert
+ exclusions:
+ generated: lax
+ presets:
+ - comments
+ - common-false-positives
+ - legacy
+ - std-error-handling
+ paths:
+ - third_party$
+ - builtin$
+ - examples$
+formatters:
+ enable:
+ - gofumpt
+ exclusions:
+ generated: lax
+ paths:
+ - third_party$
+ - builtin$
+ - examples$
diff --git a/main.go b/main.go
index 276f732..232e122 100644
--- a/main.go
+++ b/main.go
@@ -58,7 +58,7 @@ func repl(interp Interpreter, in io.Reader) (err error) {
}
fmt.Print(prompt)
}
- return
+ return err
}
func run(arg []string) (err error) {
diff --git a/parser/compiler.go b/parser/compiler.go
index 634409e..06bc87a 100644
--- a/parser/compiler.go
+++ b/parser/compiler.go
@@ -385,11 +385,11 @@ func (e entry) String() string {
if e.symbol != nil {
return fmt.Sprintf("name: %s,local: %t, i: %d, k: %d, t: %s, v: %v",
e.name,
- e.symbol.local,
- e.symbol.index,
- e.symbol.kind,
- e.symbol.typ,
- e.symbol.value,
+ e.local,
+ e.index,
+ e.kind,
+ e.typ,
+ e.value,
)
}
diff --git a/parser/expr.go b/parser/expr.go
index 1efb45e..23534e5 100644
--- a/parser/expr.go
+++ b/parser/expr.go
@@ -172,7 +172,7 @@ func (p *Parser) parseExpr(in Tokens) (out Tokens, err error) {
func (p *Parser) parseExprStr(s string) (tokens Tokens, err error) {
if tokens, err = p.Scan(s, false); err != nil {
- return
+ return tokens, err
}
var result Tokens
for _, sub := range tokens.Split(lang.Comma) {
diff --git a/scanner/scan.go b/scanner/scan.go
index 2782788..ea8b3a2 100644
--- a/scanner/scan.go
+++ b/scanner/scan.go
@@ -134,17 +134,20 @@ func (sc *Scanner) Scan(src string, semiEOF bool) (tokens []Token, err error) {
tokens = append(tokens, t)
}
}
+
// Optional insertion of semi-colon at the end of the token stream.
if semiEOF && len(tokens) > 0 {
last := tokens[len(tokens)-1]
if last.Str == ";" {
return tokens, nil
}
- if !(last.Tok == lang.Ident && sc.TokenProps[last.Str].SkipSemi ||
- last.Tok.IsOperator() && !sc.TokenProps[last.Str].SkipSemi) {
- tokens = append(tokens, Token{Tok: lang.Semicolon, Str: ";"})
+ if last.Tok == lang.Ident && sc.TokenProps[last.Str].SkipSemi ||
+ last.Tok.IsOperator() && !sc.TokenProps[last.Str].SkipSemi {
+ return tokens, nil
}
+ tokens = append(tokens, Token{Tok: lang.Semicolon, Str: ";"})
}
+
return tokens, nil
}