diff options
Diffstat (limited to 'lib/pure/lexbase.nim')
-rw-r--r-- | lib/pure/lexbase.nim | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/lib/pure/lexbase.nim b/lib/pure/lexbase.nim index 8bc96c82c..1efd97b24 100644 --- a/lib/pure/lexbase.nim +++ b/lib/pure/lexbase.nim @@ -1,6 +1,6 @@ # # -# The Nim Compiler +# Nim's Runtime Library # (c) Copyright 2009 Andreas Rumpf # # See the file "copying.txt", included in this @@ -12,7 +12,10 @@ ## needs refilling. import - strutils, streams + std/[strutils, streams] + +when defined(nimPreviewSlimSystem): + import std/assertions const EndOfFile* = '\0' ## end of file marker @@ -33,7 +36,7 @@ type lineNumber*: int ## the current line number sentinel: int lineStart: int # index of last line start in buffer - offsetBase*: int # use ``offsetBase + bufpos`` to get the offset + offsetBase*: int # use `offsetBase + bufpos` to get the offset refillChars: set[char] proc close*(L: var BaseLexer) = @@ -52,7 +55,8 @@ proc fillBuffer(L: var BaseLexer) = toCopy = L.buf.len - (L.sentinel + 1) assert(toCopy >= 0) if toCopy > 0: - when defined(js): + when defined(js) or defined(nimscript): + # nimscript has to be here to avoid compiling other branch (moveMem) for i in 0 ..< toCopy: L.buf[i] = L.buf[L.sentinel + 1 + i] else: @@ -100,9 +104,9 @@ proc fillBaseLexer(L: var BaseLexer, pos: int): int = result = 0 proc handleCR*(L: var BaseLexer, pos: int): int = - ## Call this if you scanned over '\c' in the buffer; it returns the + ## Call this if you scanned over `'\c'` in the buffer; it returns the ## position to continue the scanning from. `pos` must be the position - ## of the '\c'. + ## of the `'\c'`. assert(L.buf[pos] == '\c') inc(L.lineNumber) result = fillBaseLexer(L, pos) @@ -111,9 +115,9 @@ proc handleCR*(L: var BaseLexer, pos: int): int = L.lineStart = result proc handleLF*(L: var BaseLexer, pos: int): int = - ## Call this if you scanned over '\L' in the buffer; it returns the + ## Call this if you scanned over `'\L'` in the buffer; it returns the ## position to continue the scanning from. `pos` must be the position - ## of the '\L'. + ## of the `'\L'`. assert(L.buf[pos] == '\L') inc(L.lineNumber) result = fillBaseLexer(L, pos) #L.lastNL := result-1; // BUGFIX: was: result; |