diff --git a/buildinfo.go b/buildinfo.go index 0373629..3857def 100644 --- a/buildinfo.go +++ b/buildinfo.go @@ -3,11 +3,11 @@ package main const ( // VERSION is the version of peg - VERSION = "unknown" + VERSION = "" // BUILDTIME is the build time of peg - BUILDTIME = "2024-02-26T12:28:35" + BUILDTIME = "2024-11-27T19:39:27" // COMMIT is the commit hash of peg - COMMIT = "a4f5c509ba3254cae4204db9c02d36ca2f733d53" + COMMIT = "f02924709a94d2f169ee1dd5f9cee0277aed4edd" // IS_TAGGED is there a version IS_TAGGED = false ) diff --git a/peg.peg.go b/peg.peg.go index d741b22..a26aa3b 100644 --- a/peg.peg.go +++ b/peg.peg.go @@ -1,4 +1,4 @@ -// Code generated by ./peg -inline -switch peg.peg. DO NOT EDIT. +// Code generated by peg -inline -switch peg.peg. DO NOT EDIT. package main diff --git a/peg_test.go b/peg_test.go index 19cbc3b..ec8c004 100644 --- a/peg_test.go +++ b/peg_test.go @@ -134,6 +134,23 @@ Begin <- Begin 'x' } } +func TestCJKCharacter(t *testing.T) { + buffer := ` +package main + +type DiceExprParser Peg { +} + +Expr <- 'CJK' / '汉字' / 'test' +` + p := &Peg{Tree: tree.New(false, true, false), Buffer: buffer} + p.Init(Size(1 << 15)) + err := p.Parse() + if err != nil { + t.Fatal("cjk character test failed") + } +} + var files = [...]string{ "peg.peg", "grammars/c/c.peg", diff --git a/tree/peg.go b/tree/peg.go index b861be5..e9605de 100644 --- a/tree/peg.go +++ b/tree/peg.go @@ -17,6 +17,7 @@ import ( "strconv" "strings" "text/template" + "unicode" "github.com/pointlander/peg/set" ) @@ -1124,7 +1125,7 @@ func (t *Tree) Compile(file string, args []string, out io.Writer) (err error) { ordered.PushBack(element.Copy()) } else { class := &node{Type: TypeUnorderedAlternate} - for d := 0; d < 256; d++ { + for d := 0; d < unicode.MaxRune; d++ { if properties[c].s.Has(rune(d)) { class.PushBack(&node{Type: TypeCharacter, string: string(rune(d))}) }