diff options
author | ReneSac <reneduani@yahoo.com.br> | 2015-04-08 01:00:14 -0300 |
---|---|---|
committer | ReneSac <reneduani@yahoo.com.br> | 2015-04-08 01:00:14 -0300 |
commit | 6a528bc7e9eb81c745161bbcf0eaeec9e5384df8 (patch) | |
tree | a6b1337721e9638f59e2491e07ca6e75baac430c /compiler | |
parent | d170a51f544536522625bf9ca2b6e0a7f80427f7 (diff) | |
download | Nim-6a528bc7e9eb81c745161bbcf0eaeec9e5384df8.tar.gz |
Consider #!strongSpaces for keyword operators too.
When #!strongSpaces is on, every operator affected by it gains priority higher than any operator not affected by it. This includes comparison operators, addition, etc. It seems that counting spaces for keywords operators don't break anything in the parser. Of course, they can't have 0 spaces between their operands, but at least their precedence will work accordingly to their 1+ spaces.
Diffstat (limited to 'compiler')
-rw-r--r-- | compiler/parser.nim | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/compiler/parser.nim b/compiler/parser.nim index dcd5401e8..0f97cb757 100644 --- a/compiler/parser.nim +++ b/compiler/parser.nim @@ -227,11 +227,12 @@ proc getPrecedence(tok: TToken, strongSpaces: bool): int = of '.': considerAsgn(6) of '?': result = considerStrongSpaces(2) else: considerAsgn(2) - of tkDiv, tkMod, tkShl, tkShr: result = 9 - of tkIn, tkNotin, tkIs, tkIsnot, tkNot, tkOf, tkAs: result = 5 + 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 = 4 - of tkOr, tkXor, tkPtr, tkRef: result = 3 + of tkAnd: result = considerStrongSpaces(4) + of tkOr, tkXor, tkPtr, tkRef: result = considerStrongSpaces(3) else: result = -10 proc isOperator(tok: TToken): bool = |