<- Back to shtanton's homepage
aboutsummaryrefslogtreecommitdiff
path: root/subex/parse.go
diff options
context:
space:
mode:
Diffstat (limited to 'subex/parse.go')
-rw-r--r--subex/parse.go13
1 files changed, 4 insertions, 9 deletions
diff --git a/subex/parse.go b/subex/parse.go
index 6e1493b..0208142 100644
--- a/subex/parse.go
+++ b/subex/parse.go
@@ -206,7 +206,7 @@ func parseSubex(l *RuneReader, minPower int) SubexAST {
case '[':
rangeParts := parseRangeSubex(l)
lhs = SubexASTRange {rangeParts}
- case ')', '|', ';', '{':
+ case ')', '|', ';', '{', '+':
l.rewind()
return nil
case '$':
@@ -243,10 +243,12 @@ func parseSubex(l *RuneReader, minPower int) SubexAST {
r := l.next()
switch {
case r == '{' && minPower <= 8:
- lhs = SubexASTRepeat{
+ lhs = SubexASTRepeat {
content: lhs,
acceptable: parseRepeatRange(l),
}
+ case r == '+' && minPower <= 8:
+ lhs = SubexASTSum {lhs}
case r == '|' && minPower <= 4:
rhs := parseSubex(l, 5)
if rhs == nil {
@@ -262,13 +264,6 @@ func parseSubex(l *RuneReader, minPower int) SubexAST {
content: lhs,
delimiter: rhs,
}
- //case r == '+' && minPower <= 6:
- // rhs := parseSubex(l, 7)
- // if rhs == nil {
- // panic("Missing subex after +")
- // }
- // // TODO: Implement this. Runs subex on the left, then subex on the right, then sums the outputs of each and outputs that
- // lhs = SubexASTAdd{lhs, rhs}
default:
l.rewind()
break loop