diff options
author | Charlie Stanton <charlie@shtanton.xyz> | 2023-04-21 10:26:12 +0100 |
---|---|---|
committer | Charlie Stanton <charlie@shtanton.xyz> | 2023-04-21 10:26:12 +0100 |
commit | a55375e36b159448723807198cd2b2bbd4371c1f (patch) | |
tree | 491b708bc8a39aba4a189a057a454a53ce654fa7 /subex/parse.go | |
parent | 40276dc66bffda2692096fb1facbc7cf44e18fde (diff) | |
download | stred-go-a55375e36b159448723807198cd2b2bbd4371c1f.tar |
Radically changes precedences so concatenation is now the strongest
We'll see if this sticks
Diffstat (limited to 'subex/parse.go')
-rw-r--r-- | subex/parse.go | 26 |
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 ;") } |