diff options
author | ringabout <43030857+ringabout@users.noreply.github.com> | 2022-11-03 16:18:09 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-03 09:18:09 +0100 |
commit | 0b1d1b7886396d943a54843c63e4dc0604db0cdb (patch) | |
tree | f354c418781ab48ac0f94c616f470f0be8aabc7a /compiler/parser.nim | |
parent | c4e5dab4197ce57af03c5eaa6117b738279fa537 (diff) | |
download | Nim-0b1d1b7886396d943a54843c63e4dc0604db0cdb.tar.gz |
fixes #15688; handle `strongSpace` overflow issues (#20724)
* fixes #15688; handle `strongSpace` overflow issues * stop at 1 * change the type of strongSpaceA to bool
Diffstat (limited to 'compiler/parser.nim')
-rw-r--r-- | compiler/parser.nim | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/compiler/parser.nim b/compiler/parser.nim index 990f7dfef..19600f686 100644 --- a/compiler/parser.nim +++ b/compiler/parser.nim @@ -301,13 +301,13 @@ proc isUnary(tok: Token): bool = ## Check if the given token is a unary operator tok.tokType in {tkOpr, tkDotDot} and tok.strongSpaceB == 0 and - tok.strongSpaceA > 0 + tok.strongSpaceA proc checkBinary(p: Parser) {.inline.} = ## Check if the current parser token is a binary operator. # we don't check '..' here as that's too annoying if p.tok.tokType == tkOpr: - if p.tok.strongSpaceB > 0 and p.tok.strongSpaceA == 0: + if p.tok.strongSpaceB > 0 and not p.tok.strongSpaceA: parMessage(p, warnInconsistentSpacing, prettyTok(p.tok)) #| module = stmt ^* (';' / IND{=}) @@ -477,7 +477,7 @@ proc dotExpr(p: var Parser, a: PNode): PNode = optInd(p, result) result.add(a) result.add(parseSymbol(p, smAfterDot)) - if p.tok.tokType == tkBracketLeColon and p.tok.strongSpaceA <= 0: + if p.tok.tokType == tkBracketLeColon and not p.tok.strongSpaceA: var x = newNodeI(nkBracketExpr, p.parLineInfo) # rewrite 'x.y[:z]()' to 'y[z](x)' x.add result[1] @@ -486,7 +486,7 @@ proc dotExpr(p: var Parser, a: PNode): PNode = var y = newNodeI(nkCall, p.parLineInfo) y.add x y.add result[0] - if p.tok.tokType == tkParLe and p.tok.strongSpaceA <= 0: + if p.tok.tokType == tkParLe and not p.tok.strongSpaceA: exprColonEqExprListAux(p, tkParRi, y) result = y @@ -842,7 +842,7 @@ proc primarySuffix(p: var Parser, r: PNode, case p.tok.tokType of tkParLe: # progress guaranteed - if p.tok.strongSpaceA > 0: + if p.tok.strongSpaceA: result = commandExpr(p, result, mode) # type sections allow full command syntax if mode == pmTypeDef: @@ -861,13 +861,13 @@ proc primarySuffix(p: var Parser, r: PNode, result = parseGStrLit(p, result) of tkBracketLe: # progress guaranteed - if p.tok.strongSpaceA > 0: + if p.tok.strongSpaceA: result = commandExpr(p, result, mode) break result = namedParams(p, result, nkBracketExpr, tkBracketRi) of tkCurlyLe: # progress guaranteed - if p.tok.strongSpaceA > 0: + if p.tok.strongSpaceA: result = commandExpr(p, result, mode) break result = namedParams(p, result, nkCurlyExpr, tkCurlyRi) @@ -2386,7 +2386,7 @@ proc parseAll(p: var Parser): PNode = parMessage(p, errInvalidIndentation) proc checkFirstLineIndentation*(p: var Parser) = - if p.tok.indent != 0 and p.tok.strongSpaceA > 0: + if p.tok.indent != 0 and p.tok.strongSpaceA: parMessage(p, errInvalidIndentation) proc parseTopLevelStmt(p: var Parser): PNode = |