Skip to content

Commit

Permalink
Finish revert
Browse files Browse the repository at this point in the history
  • Loading branch information
Clyybber committed Aug 27, 2020
1 parent 0b941d3 commit 0b86029
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
18 changes: 9 additions & 9 deletions compiler/layouter.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions compiler/lexer.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion compiler/parser.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion compiler/renderer.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 0b86029

Please sign in to comment.