<- Back to shtanton's homepage
aboutsummaryrefslogtreecommitdiff
path: root/subex
diff options
context:
space:
mode:
authorCharlie Stanton <charlie@shtanton.xyz>2023-04-21 10:26:12 +0100
committerCharlie Stanton <charlie@shtanton.xyz>2023-04-21 10:26:12 +0100
commita55375e36b159448723807198cd2b2bbd4371c1f (patch)
tree491b708bc8a39aba4a189a057a454a53ce654fa7 /subex
parent40276dc66bffda2692096fb1facbc7cf44e18fde (diff)
downloadstred-go-a55375e36b159448723807198cd2b2bbd4371c1f.tar
Radically changes precedences so concatenation is now the strongest
We'll see if this sticks
Diffstat (limited to 'subex')
-rw-r--r--subex/parse.go26
1 files changed, 13 insertions, 13 deletions
diff --git a/subex/parse.go b/subex/parse.go
index b403adc..52488a7 100644
--- a/subex/parse.go
+++ b/subex/parse.go
@@ -329,8 +329,8 @@ func parseSubex(l RuneReader, minPower int) SubexAST {
lhs = SubexASTCopyAtom{Atom: walk.StringAtom(r)}
}
loop: for {
- if minPower <= 0 {
- next := parseSubex(l, 1)
+ if minPower <= 20 {
+ next := parseSubex(l, 21)
if next != nil {
lhs = SubexASTConcat{lhs, next}
continue loop
@@ -338,22 +338,22 @@ func parseSubex(l RuneReader, minPower int) SubexAST {
}
r := l.Next()
switch {
- case r == '{' && minPower <= 8:
+ case r == '{' && minPower <= 4:
lhs = SubexASTRepeat {
Content: lhs,
Acceptable: parseRepeatRange(l),
}
- case r == '+' && minPower <= 8:
+ case r == '+' && minPower <= 4:
lhs = SubexASTSum {lhs}
- case r == '*' && minPower <= 8:
+ case r == '*' && minPower <= 4:
lhs = SubexASTProduct {lhs}
- case r == '-' && minPower <= 8:
+ case r == '-' && minPower <= 4:
lhs = SubexASTNegate {lhs}
- case r == '/' && minPower <= 8:
+ case r == '/' && minPower <= 4:
lhs = SubexASTReciprocal {lhs}
- case r == '!' && minPower <= 8:
+ case r == '!' && minPower <= 4:
lhs = SubexASTNot {lhs}
- case r == '$' && minPower <= 8:
+ case r == '$' && minPower <= 4:
slot := l.Next()
if slot == eof {
panic("Missing slot character")
@@ -362,14 +362,14 @@ func parseSubex(l RuneReader, minPower int) SubexAST {
Match: lhs,
Slot: slot,
}
- case r == '|' && minPower <= 4:
- rhs := parseSubex(l, 5)
+ case r == '|' && minPower <= 8:
+ rhs := parseSubex(l, 9)
if rhs == nil {
panic("Missing subex after |")
}
lhs = SubexASTOr{lhs, rhs}
- case r == ';' && minPower <= 2:
- rhs := parseSubex(l, 3)
+ case r == ';' && minPower <= 10:
+ rhs := parseSubex(l, 11)
if rhs == nil {
panic("Missing subex after ;")
}