diff --git a/cmdlang/ast.go b/cmdlang/ast.go index d5984aa..0a29001 100644 --- a/cmdlang/ast.go +++ b/cmdlang/ast.go @@ -1,9 +1,10 @@ package cmdlang import ( + "io" + "github.com/alecthomas/participle/v2" "github.com/alecthomas/participle/v2/lexer" - "io" ) type astLiteral struct { @@ -52,7 +53,7 @@ var scanner = lexer.MustStateful(lexer.Rules{ {"RC", `\}`, nil}, {"NL", `[;\n][; \n\t]*`, nil}, {"PIPE", `\|`, nil}, - {"Ident", `\w+`, nil}, + {"Ident", `[\w-]+`, nil}, }, }) var parser = participle.MustBuild[astScript](participle.Lexer(scanner), diff --git a/cmdlang/inst_test.go b/cmdlang/inst_test.go index 2ca544a..beec7a8 100644 --- a/cmdlang/inst_test.go +++ b/cmdlang/inst_test.go @@ -3,9 +3,10 @@ package cmdlang_test import ( "bytes" "context" + "testing" + "github.com/lmika/cmdlang-proto/cmdlang" "github.com/stretchr/testify/assert" - "testing" ) func TestInst_Eval(t *testing.T) { @@ -15,6 +16,7 @@ func TestInst_Eval(t *testing.T) { want string }{ {desc: "simple string", expr: `firstarg "hello"`, want: "hello"}, + {desc: "simple ident", expr: `firstarg a-test`, want: "a-test"}, // Sub-expressions {desc: "sub expression 1", expr: `firstarg (sjoin "hello")`, want: "hello"},