refactor strongSpaceB with an enum (#20809)

refactor strongSpaceB
This commit is contained in:
ringabout 2022-11-10 23:21:52 +08:00 • committed by GitHub
commit a15872ba9e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 26 additions and 23 deletions

View file

@ -300,14 +300,14 @@ proc isRightAssociative(tok: Token): bool {.inline.} =
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.strongSpaceB == tsNone and
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 not p.tok.strongSpaceA:
if p.tok.strongSpaceB == tsTrailing and not p.tok.strongSpaceA:
parMessage(p, warnInconsistentSpacing, prettyTok(p.tok))
#| module = stmt ^* (';' / IND{=})