From a55375e36b159448723807198cd2b2bbd4371c1f Mon Sep 17 00:00:00 2001 From: Charlie Stanton Date: Fri, 21 Apr 2023 10:26:12 +0100 Subject: Radically changes precedences so concatenation is now the strongest We'll see if this sticks --- subex/parse.go | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'subex/parse.go') 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 ;") } -- cgit v1.2.3