Added support for dashes in identities
This commit is contained in:
parent
a65e6b2627
commit
acdd8b3f72
|
@ -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),
|
||||
|
|
|
@ -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"},
|
||||
|
|
Loading…
Reference in a new issue