diff options
| author | Charlie Stanton <charlie@shtanton.xyz> | 2023-04-19 12:22:57 +0100 | 
|---|---|---|
| committer | Charlie Stanton <charlie@shtanton.xyz> | 2023-04-19 12:22:57 +0100 | 
| commit | 1c2d7a4e9258ed72f5c8ebecc3d575d065f25c5d (patch) | |
| tree | 32fb8aa93aeff149d41419b7b02913c204749d2f | |
| parent | 184368ae155fcdd50dde5c2e4b0c87e0d69acdd7 (diff) | |
| download | stred-go-1c2d7a4e9258ed72f5c8ebecc3d575d065f25c5d.tar | |
Changes parser so the storing operator is postfix instead of prefix
| -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 { | 
