aboutsummaryrefslogtreecommitdiff
path: root/compiler/parser/parser.go
diff options
context:
space:
mode:
authorRyo Nihei <nihei.dev@gmail.com>2021-12-11 19:42:32 +0900
committerRyo Nihei <nihei.dev@gmail.com>2021-12-11 19:42:32 +0900
commit3ec662c34841bb5bcf05166d1b9efd800b1e9ea3 (patch)
treea7acd4fa535819a941da862905a14bfffa8493b5 /compiler/parser/parser.go
parentMake character properties unavailable in bracket expressions (diff)
downloadtre-3ec662c34841bb5bcf05166d1b9efd800b1e9ea3.tar.gz
tre-3ec662c34841bb5bcf05166d1b9efd800b1e9ea3.tar.xz
Add tests of compiler/parser package
Diffstat (limited to '')
-rw-r--r--compiler/parser/parser.go8
1 files changed, 4 insertions, 4 deletions
diff --git a/compiler/parser/parser.go b/compiler/parser/parser.go
index 70d1ce6..fd85fab 100644
--- a/compiler/parser/parser.go
+++ b/compiler/parser/parser.go
@@ -205,7 +205,7 @@ func (p *parser) parseSingleChar() CPTree {
}
inverse := exclude(elem, genAnyCharAST())
if inverse == nil {
- panic(fmt.Errorf("a pattern that isn't matching any symbols"))
+ p.raiseParseError(synErrUnmatchablePattern, "")
}
for {
elem := p.parseBExpElem()
@@ -214,7 +214,7 @@ func (p *parser) parseSingleChar() CPTree {
}
inverse = exclude(elem, inverse)
if inverse == nil {
- panic(fmt.Errorf("a pattern that isn't matching any symbols"))
+ p.raiseParseError(synErrUnmatchablePattern, "")
}
}
if p.consume(tokenKindEOF) {
@@ -355,12 +355,12 @@ func (p *parser) parseCharProp() CPTree {
r := cpRanges[0]
alt = exclude(newRangeSymbolNode(r.From, r.To), genAnyCharAST())
if alt == nil {
- panic(fmt.Errorf("a pattern that isn't matching any symbols"))
+ p.raiseParseError(synErrUnmatchablePattern, "")
}
for _, r := range cpRanges[1:] {
alt = exclude(newRangeSymbolNode(r.From, r.To), alt)
if alt == nil {
- panic(fmt.Errorf("a pattern that isn't matching any symbols"))
+ p.raiseParseError(synErrUnmatchablePattern, "")
}
}
} else {