diff options
author | ReneSac <reneduani@yahoo.com.br> | 2015-04-08 02:06:18 -0300 |
---|---|---|
committer | ReneSac <reneduani@yahoo.com.br> | 2015-04-08 02:06:18 -0300 |
commit | 80050a09a07af06b888ac4ab41f8e1e83c6ce392 (patch) | |
tree | 7eca096a31a696980bea61d6d368fedef1fe4129 /compiler | |
parent | 6a528bc7e9eb81c745161bbcf0eaeec9e5384df8 (diff) | |
download | Nim-80050a09a07af06b888ac4ab41f8e1e83c6ce392.tar.gz |
Refactored getPrecedence() after last change
The considerStrongSpaces() is now applied to almost all results, so it is better to do it at the end.
Diffstat (limited to 'compiler')
-rw-r--r-- | compiler/parser.nim | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/compiler/parser.nim b/compiler/parser.nim index 0f97cb757..f135c540c 100644 --- a/compiler/parser.nim +++ b/compiler/parser.nim @@ -215,25 +215,25 @@ proc getPrecedence(tok: TToken, strongSpaces: bool): int = if L > 1 and tok.ident.s[L-1] == '>': return considerStrongSpaces(1) template considerAsgn(value: expr) = - result = if tok.ident.s[L-1] == '=': 1 else: considerStrongSpaces(value) + result = if tok.ident.s[L-1] == '=': 1 else: value case relevantChar of '$', '^': considerAsgn(10) of '*', '%', '/', '\\': considerAsgn(9) - of '~': result = considerStrongSpaces(8) + of '~': result = 8 of '+', '-', '|': considerAsgn(8) of '&': considerAsgn(7) - of '=', '<', '>', '!': result = considerStrongSpaces(5) + of '=', '<', '>', '!': result = 5 of '.': considerAsgn(6) - of '?': result = considerStrongSpaces(2) + of '?': result = 2 else: considerAsgn(2) - of tkDiv, tkMod, tkShl, tkShr: result = considerStrongSpaces(9) - of tkIn, tkNotin, tkIs, tkIsnot, tkNot, tkOf, tkAs: - result = considerStrongSpaces(5) - of tkDotDot: result = considerStrongSpaces(6) - of tkAnd: result = considerStrongSpaces(4) - of tkOr, tkXor, tkPtr, tkRef: result = considerStrongSpaces(3) - else: result = -10 + of tkDiv, tkMod, tkShl, tkShr: result = 9 + of tkIn, tkNotin, tkIs, tkIsnot, tkNot, tkOf, tkAs: result = 5 + of tkDotDot: result = 6 + of tkAnd: result = 4 + of tkOr, tkXor, tkPtr, tkRef: result = 3 + else: return -10 + result = considerStrongSpaces(result) proc isOperator(tok: TToken): bool = ## Determines if the given token is an operator type token. |