From be5fd8bc59f4cdf933df7ea692003899dbbc56d9 Mon Sep 17 00:00:00 2001 From: Maximilian Eschenbacher Date: Wed, 14 Feb 2024 14:35:51 +0100 Subject: [PATCH] Idents may consist of underscores --- scanner.go | 2 +- scanner_test.go | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/scanner.go b/scanner.go index aff29a6..f88c54f 100644 --- a/scanner.go +++ b/scanner.go @@ -192,4 +192,4 @@ func isLetter(ch rune) bool { return (ch >= 'a' && ch <= 'z') || (ch >= 'A' && c // isDigit returns true if the rune is a digit. func isDigit(ch rune) bool { return (ch >= '0' && ch <= '9') } -func isMisc(ch rune) bool { return (ch == '.' || ch == '/' || ch == '-') } +func isMisc(ch rune) bool { return (ch == '.' || ch == '/' || ch == '-' || ch == '_') } diff --git a/scanner_test.go b/scanner_test.go index c5d1dfb..bbcd03c 100644 --- a/scanner_test.go +++ b/scanner_test.go @@ -28,6 +28,7 @@ func TestScanner_Scan(t *testing.T) { {s: "hello friend", tok: IDENT, lit: "hello"}, {s: "192.168.178.2/24", tok: IDENT, lit: "192.168.178.2/24"}, {s: "# 192.168.178.2/24", tok: COMMENTLINE, lit: " 192.168.178.2/24"}, + {s: "I_test_rule-something", tok: IDENT, lit: "I_test_rule-something"}, } { s := newScanner(strings.NewReader(tc.s)) tok, lit := s.scan()