aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRyo Nihei <nihei.dev@gmail.com>2021-05-02 15:29:33 +0900
committerRyo Nihei <nihei.dev@gmail.com>2021-05-02 15:29:33 +0900
commita7c5525133a381c982d5a184b5ca52e4b54f8a4b (patch)
tree6cc8a6b5ec2d47b30d5c7d8bd86c7b143fb3587b
parentImprove compilation time a little (diff)
downloadtre-a7c5525133a381c982d5a184b5ca52e4b54f8a4b.tar.gz
tre-a7c5525133a381c982d5a184b5ca52e4b54f8a4b.tar.xz
Fix parser to recognize property expressions in bracket expressions
-rw-r--r--compiler/parser.go3
-rw-r--r--compiler/parser_test.go11
2 files changed, 14 insertions, 0 deletions
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
@@ -488,6 +488,17 @@ func TestParser_parse(t *testing.T) {
),
},
{
+ pattern: "[\\u{004E}]",
+ ast: newConcatNode(
+ newSymbolNodeWithPos(byte('N'), symPos(1)),
+ newEndMarkerNodeWithPos(1, endPos(2)),
+ ),
+ },
+ {
+ pattern: "[\\p{Lu}]",
+ skipTestAST: true,
+ },
+ {
pattern: "a[]",
syntaxError: synErrBExpNoElem,
},