diff options
-rw-r--r-- | subex/parse.go | 24 |
1 files changed, 10 insertions, 14 deletions
diff --git a/subex/parse.go b/subex/parse.go index 0208142..2389c3b 100644 --- a/subex/parse.go +++ b/subex/parse.go @@ -206,22 +206,9 @@ func parseSubex(l *RuneReader, minPower int) SubexAST { case '[': rangeParts := parseRangeSubex(l) lhs = SubexASTRange {rangeParts} - case ')', '|', ';', '{', '+': + case ')', '|', ';', '{', '+', '$': l.rewind() return nil - case '$': - slot := l.next() - if slot == eof { - panic("Missing slot character") - } - match := parseSubex(l, 100) - if match == nil { - panic("Missing regex for store") - } - lhs = SubexASTStore{ - match: match, - slot: slot, - } case '"': replacement := parseReplacement(l) lhs = SubexASTOutput{replacement} @@ -249,6 +236,15 @@ func parseSubex(l *RuneReader, minPower int) SubexAST { } case r == '+' && minPower <= 8: lhs = SubexASTSum {lhs} + case r == '$' && minPower <= 8: + slot := l.next() + if slot == eof { + panic("Missing slot character") + } + lhs = SubexASTStore{ + match: lhs, + slot: slot, + } case r == '|' && minPower <= 4: rhs := parseSubex(l, 5) if rhs == nil { |