diff options
author | Andreas Rumpf <rumpf_a@web.de> | 2015-04-09 09:44:16 +0200 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2015-04-09 09:44:16 +0200 |
commit | a2d3dff6909eb1a0a7f4639b6f8d09e19342c4bf (patch) | |
tree | 843e4e037bf27943ba8e480109369cd57230e886 /compiler | |
parent | 4d0ee66f29cf487cc848a3f4f0f672e2cb0aa3c7 (diff) | |
parent | 5bbebe4a8913b3f304701aa3b4eaf082bd4fe8ca (diff) | |
download | Nim-a2d3dff6909eb1a0a7f4639b6f8d09e19342c4bf.tar.gz |
Merge pull request #2491 from ReneSac/strongSpacesFix
Apply strongSpaces to keyword operators too. Fix #1894.
Diffstat (limited to 'compiler')
-rw-r--r-- | compiler/parser.nim | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/compiler/parser.nim b/compiler/parser.nim index dcd5401e8..f135c540c 100644 --- a/compiler/parser.nim +++ b/compiler/parser.nim @@ -215,24 +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 = 9 of tkIn, tkNotin, tkIs, tkIsnot, tkNot, tkOf, tkAs: result = 5 - of tkDotDot: result = considerStrongSpaces(6) + of tkDotDot: result = 6 of tkAnd: result = 4 of tkOr, tkXor, tkPtr, tkRef: result = 3 - else: result = -10 + else: return -10 + result = considerStrongSpaces(result) proc isOperator(tok: TToken): bool = ## Determines if the given token is an operator type token. |