diff --git a/compiler/layouter.nim b/compiler/layouter.nim index c603c16ffc075..ee45d357f4bfb 100644 --- a/compiler/layouter.nim +++ b/compiler/layouter.nim @@ -494,7 +494,7 @@ proc emitTok*(em: var Emitter; L: Lexer; tok: Token) = wrSpace em if not em.inquote: - wr(em, $tok.tokType, ltKeyword) + wr(em, TokTypeToStr[tok.tokType], ltKeyword) if tok.tokType in {tkAnd, tkOr, tkIn, tkNotin}: rememberSplit(splitIn) wrSpace em @@ -503,28 +503,28 @@ proc emitTok*(em: var Emitter; L: Lexer; tok: Token) = wr(em, tok.ident.s, ltIdent) of tkColon: - wr(em, $tok.tokType, ltOther) + wr(em, TokTypeToStr[tok.tokType], ltOther) wrSpace em of tkSemiColon, tkComma: - wr(em, $tok.tokType, ltOther) + wr(em, TokTypeToStr[tok.tokType], ltOther) rememberSplit(splitComma) wrSpace em of openPars: if tok.strongSpaceA > 0 and not em.endsInWhite and (not em.wasExportMarker or tok.tokType == tkCurlyDotLe): wrSpace em - wr(em, $tok.tokType, ltSomeParLe) + wr(em, TokTypeToStr[tok.tokType], ltSomeParLe) rememberSplit(splitParLe) of closedPars: - wr(em, $tok.tokType, ltSomeParRi) + wr(em, TokTypeToStr[tok.tokType], ltSomeParRi) of tkColonColon: - wr(em, $tok.tokType, ltOther) + wr(em, TokTypeToStr[tok.tokType], ltOther) of tkDot: lastTokWasTerse = true - wr(em, $tok.tokType, ltOther) + wr(em, TokTypeToStr[tok.tokType], ltOther) of tkEquals: if not em.inquote and not em.endsInWhite: wrSpace(em) - wr(em, $tok.tokType, ltOther) + wr(em, TokTypeToStr[tok.tokType], ltOther) if not em.inquote: wrSpace(em) of tkOpr, tkDotDot: if em.inquote or ((tok.strongSpaceA == 0 and tok.strongSpaceB == 0) and @@ -544,7 +544,7 @@ proc emitTok*(em: var Emitter; L: Lexer; tok: Token) = wrSpace(em) of tkAccent: if not em.inquote and endsInAlpha(em): wrSpace(em) - wr(em, $tok.tokType, ltOther) + wr(em, TokTypeToStr[tok.tokType], ltOther) em.inquote = not em.inquote of tkComment: if not preventComment: diff --git a/compiler/lexer.nim b/compiler/lexer.nim index e068d3651bff8..ff433928c9fab 100644 --- a/compiler/lexer.nim +++ b/compiler/lexer.nim @@ -170,7 +170,7 @@ proc `$`*(tok: Token): string = of tkIntLit..tkInt64Lit: $tok.iNumber of tkFloatLit..tkFloat64Lit: $tok.fNumber of tkInvalid, tkStrLit..tkCharLit, tkComment: tok.literal - of tkParLe..tkColon, tkEof, tkAccent: $tok.tokType + of tkParLe..tkColon, tkEof, tkAccent: TokTypeToStr[tok.tokType] else: if tok.ident != nil: tok.ident.s @@ -183,7 +183,7 @@ proc prettyTok*(tok: Token): string = proc printTok*(conf: ConfigRef; tok: Token) = msgWriteln(conf, $tok.line & ":" & $tok.col & "\t" & - $tok.tokType & " " & $tok) + TokTypeToStr[tok.tokType] & " " & $tok) proc initToken*(L: var Token) = L.tokType = tkInvalid diff --git a/compiler/parser.nim b/compiler/parser.nim index 28fdeaa851e64..e7db8d8b195e6 100644 --- a/compiler/parser.nim +++ b/compiler/parser.nim @@ -219,7 +219,7 @@ proc eat(p: var Parser, tokType: TokType) = getTok(p) else: lexMessage(p.lex, errGenerated, - "expected: '" & $tokType & "', but got: '" & prettyTok(p.tok) & "'") + "expected: '" & TokTypeToStr[tokType] & "', but got: '" & prettyTok(p.tok) & "'") proc parLineInfo(p: Parser): TLineInfo = ## Retrieve the line information associated with the parser's current state. diff --git a/compiler/renderer.nim b/compiler/renderer.nim index eba16b8b0eb23..bf4aab063d019 100644 --- a/compiler/renderer.nim +++ b/compiler/renderer.nim @@ -588,7 +588,7 @@ proc gcommaAux(g: var TSrcGen, n: PNode, ind: int, start: int = 0, gsub(g, n[i]) if c: if g.tokens.len > oldLen: - putWithSpace(g, separator, $separator) + putWithSpace(g, separator, TokTypeToStr[separator]) if hasCom(n[i]): gcoms(g) optNL(g, ind)