From a7c5525133a381c982d5a184b5ca52e4b54f8a4b Mon Sep 17 00:00:00 2001 From: Ryo Nihei Date: Sun, 2 May 2021 15:29:33 +0900 Subject: Fix parser to recognize property expressions in bracket expressions --- compiler/parser.go | 3 +++ compiler/parser_test.go | 11 +++++++++++ 2 files changed, 14 insertions(+) (limited to 'compiler') diff --git a/compiler/parser.go b/compiler/parser.go index 7b50459..5b8c912 100644 --- a/compiler/parser.go +++ b/compiler/parser.go @@ -329,6 +329,9 @@ func (p *parser) parseBExpElem() astNode { if p.consume(tokenKindCodePointLeader) { return p.parseCodePoint() } + if p.consume(tokenKindCharPropLeader) { + return p.parseCharProp() + } left := p.parseNormalChar() if left == nil { return nil diff --git a/compiler/parser_test.go b/compiler/parser_test.go index 79f89ff..aca08ec 100644 --- a/compiler/parser_test.go +++ b/compiler/parser_test.go @@ -487,6 +487,17 @@ func TestParser_parse(t *testing.T) { newEndMarkerNodeWithPos(1, endPos(3)), ), }, + { + pattern: "[\\u{004E}]", + ast: newConcatNode( + newSymbolNodeWithPos(byte('N'), symPos(1)), + newEndMarkerNodeWithPos(1, endPos(2)), + ), + }, + { + pattern: "[\\p{Lu}]", + skipTestAST: true, + }, { pattern: "a[]", syntaxError: synErrBExpNoElem, -- cgit v1.2.3