diff options
author | Andreas Rumpf <rumpf_a@web.de> | 2018-06-19 09:42:33 +0200 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2018-06-19 09:42:33 +0200 |
commit | dd81d9d5b711a9a78d5b4a26a62d02da2e495b21 (patch) | |
tree | 1af67518fe1442a145209a917733b6e39b167f94 /compiler/lexer.nim | |
parent | 98f3daea651b5e2f9ef620f6b9bb5a55e3530358 (diff) | |
download | Nim-dd81d9d5b711a9a78d5b4a26a62d02da2e495b21.tar.gz |
nimpretty improvements
Diffstat (limited to 'compiler/lexer.nim')
-rw-r--r-- | compiler/lexer.nim | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/compiler/lexer.nim b/compiler/lexer.nim index 13460f7c1..c5afa6e97 100644 --- a/compiler/lexer.nim +++ b/compiler/lexer.nim @@ -867,7 +867,7 @@ proc getOperator(L: var TLexer, tok: var TToken) = if buf[pos] in {CR, LF, nimlexbase.EndOfFile}: tok.strongSpaceB = -1 -proc newlineFollows*(L: var TLexer): bool = +proc newlineFollows*(L: TLexer): bool = var pos = L.bufpos var buf = L.buf while true: @@ -1220,3 +1220,15 @@ proc rawGetTok*(L: var TLexer, tok: var TToken) = lexMessage(L, errGenerated, "invalid token: " & c & " (\\" & $(ord(c)) & ')') inc(L.bufpos) atTokenEnd() + +proc getIndentWidth*(fileIdx: FileIndex, inputstream: PLLStream; + cache: IdentCache; config: ConfigRef): int = + var lex: TLexer + var tok: TToken + initToken(tok) + openLexer(lex, fileIdx, inputstream, cache, config) + while true: + rawGetTok(lex, tok) + result = tok.indent + if result > 0 or tok.tokType == tkEof: break + closeLexer(lex) |