Merge pull request #2961 from Perelandric/rename_writeLn
Renamed writeln to writeLine. Issue #2958
This commit is contained in:
commit
e74012b396
71 changed files with 815 additions and 801 deletions
|
|
@ -452,7 +452,7 @@ proc debug(n: PSym) =
|
||||||
elif n.kind == skUnknown:
|
elif n.kind == skUnknown:
|
||||||
msgWriteln("skUnknown")
|
msgWriteln("skUnknown")
|
||||||
else:
|
else:
|
||||||
#writeln(stdout, $symToYaml(n, 0, 1))
|
#writeLine(stdout, $symToYaml(n, 0, 1))
|
||||||
msgWriteln("$1_$2: $3, $4, $5, $6" % [
|
msgWriteln("$1_$2: $3, $4, $5, $6" % [
|
||||||
n.name.s, $n.id, $flagsToStr(n.flags), $flagsToStr(n.loc.flags),
|
n.name.s, $n.id, $flagsToStr(n.flags), $flagsToStr(n.loc.flags),
|
||||||
$lineInfoToStr(n.info), $n.kind])
|
$lineInfoToStr(n.info), $n.kind])
|
||||||
|
|
|
||||||
|
|
@ -596,7 +596,7 @@ proc externalFileChanged(filename: string): bool =
|
||||||
result = true
|
result = true
|
||||||
if result:
|
if result:
|
||||||
if open(f, crcFile, fmWrite):
|
if open(f, crcFile, fmWrite):
|
||||||
f.writeln($currentCrc)
|
f.writeLine($currentCrc)
|
||||||
close(f)
|
close(f)
|
||||||
|
|
||||||
proc addExternalFileToCompile*(filename: string) =
|
proc addExternalFileToCompile*(filename: string) =
|
||||||
|
|
|
||||||
|
|
@ -48,8 +48,8 @@ proc toGid(f: string): string =
|
||||||
|
|
||||||
proc saveMaxIds*(project: string) =
|
proc saveMaxIds*(project: string) =
|
||||||
var f = open(project.toGid, fmWrite)
|
var f = open(project.toGid, fmWrite)
|
||||||
f.writeln($gFrontEndId)
|
f.writeLine($gFrontEndId)
|
||||||
f.writeln($gBackendId)
|
f.writeLine($gBackendId)
|
||||||
f.close()
|
f.close()
|
||||||
|
|
||||||
proc loadMaxIds*(project: string) =
|
proc loadMaxIds*(project: string) =
|
||||||
|
|
|
||||||
|
|
@ -593,7 +593,7 @@ var
|
||||||
|
|
||||||
proc suggestWriteln*(s: string) =
|
proc suggestWriteln*(s: string) =
|
||||||
if eStdOut in errorOutputs:
|
if eStdOut in errorOutputs:
|
||||||
if isNil(writelnHook): writeln(stdout, s)
|
if isNil(writelnHook): writeLine(stdout, s)
|
||||||
else: writelnHook(s)
|
else: writelnHook(s)
|
||||||
|
|
||||||
proc msgQuit*(x: int8) = quit x
|
proc msgQuit*(x: int8) = quit x
|
||||||
|
|
@ -688,7 +688,7 @@ var gTrackPos*: TLineInfo
|
||||||
|
|
||||||
proc outWriteln*(s: string) =
|
proc outWriteln*(s: string) =
|
||||||
## Writes to stdout. Always.
|
## Writes to stdout. Always.
|
||||||
if eStdOut in errorOutputs: writeln(stdout, s)
|
if eStdOut in errorOutputs: writeLine(stdout, s)
|
||||||
|
|
||||||
proc msgWriteln*(s: string) =
|
proc msgWriteln*(s: string) =
|
||||||
## Writes to stdout. If --stdout option is given, writes to stderr instead.
|
## Writes to stdout. If --stdout option is given, writes to stderr instead.
|
||||||
|
|
@ -698,9 +698,9 @@ proc msgWriteln*(s: string) =
|
||||||
if not isNil(writelnHook):
|
if not isNil(writelnHook):
|
||||||
writelnHook(s)
|
writelnHook(s)
|
||||||
elif optStdout in gGlobalOptions:
|
elif optStdout in gGlobalOptions:
|
||||||
if eStdErr in errorOutputs: writeln(stderr, s)
|
if eStdErr in errorOutputs: writeLine(stderr, s)
|
||||||
else:
|
else:
|
||||||
if eStdOut in errorOutputs: writeln(stdout, s)
|
if eStdOut in errorOutputs: writeLine(stdout, s)
|
||||||
|
|
||||||
macro callIgnoringStyle(theProc: typed, first: typed,
|
macro callIgnoringStyle(theProc: typed, first: typed,
|
||||||
args: varargs[expr]): stmt =
|
args: varargs[expr]): stmt =
|
||||||
|
|
@ -735,13 +735,13 @@ template styledMsgWriteln*(args: varargs[expr]) =
|
||||||
if not isNil(writelnHook):
|
if not isNil(writelnHook):
|
||||||
callIgnoringStyle(callWritelnHook, nil, args)
|
callIgnoringStyle(callWritelnHook, nil, args)
|
||||||
elif optStdout in gGlobalOptions:
|
elif optStdout in gGlobalOptions:
|
||||||
if eStdErr in errorOutputs: callIgnoringStyle(writeln, stderr, args)
|
if eStdErr in errorOutputs: callIgnoringStyle(writeLine, stderr, args)
|
||||||
else:
|
else:
|
||||||
if eStdOut in errorOutputs:
|
if eStdOut in errorOutputs:
|
||||||
if optUseColors in gGlobalOptions:
|
if optUseColors in gGlobalOptions:
|
||||||
callStyledEcho(args)
|
callStyledEcho(args)
|
||||||
else:
|
else:
|
||||||
callIgnoringStyle(writeln, stdout, args)
|
callIgnoringStyle(writeLine, stdout, args)
|
||||||
|
|
||||||
proc coordToStr(coord: int): string =
|
proc coordToStr(coord: int): string =
|
||||||
if coord == -1: result = "???"
|
if coord == -1: result = "???"
|
||||||
|
|
|
||||||
|
|
@ -82,7 +82,7 @@ proc processCmdLine*(pass: TCmdLinePass, cmd: string) =
|
||||||
|
|
||||||
proc handleCmdLine() =
|
proc handleCmdLine() =
|
||||||
if paramCount() == 0:
|
if paramCount() == 0:
|
||||||
stdout.writeln(Usage)
|
stdout.writeLine(Usage)
|
||||||
else:
|
else:
|
||||||
processCmdLine(passCmd1, "")
|
processCmdLine(passCmd1, "")
|
||||||
if gProjectName != "":
|
if gProjectName != "":
|
||||||
|
|
|
||||||
|
|
@ -304,7 +304,7 @@ proc completeGeneratedFilePath*(f: string, createSubDir: bool = true): string =
|
||||||
when noTimeMachine:
|
when noTimeMachine:
|
||||||
excludeDirFromTimeMachine(subdir)
|
excludeDirFromTimeMachine(subdir)
|
||||||
except OSError:
|
except OSError:
|
||||||
writeln(stdout, "cannot create directory: " & subdir)
|
writeLine(stdout, "cannot create directory: " & subdir)
|
||||||
quit(1)
|
quit(1)
|
||||||
result = joinPath(subdir, tail)
|
result = joinPath(subdir, tail)
|
||||||
#echo "completeGeneratedFilePath(", f, ") = ", result
|
#echo "completeGeneratedFilePath(", f, ") = ", result
|
||||||
|
|
|
||||||
|
|
@ -1031,28 +1031,28 @@ proc viewFile(rodfile: string) =
|
||||||
case section
|
case section
|
||||||
of "CRC":
|
of "CRC":
|
||||||
inc(r.pos) # skip ':'
|
inc(r.pos) # skip ':'
|
||||||
outf.writeln("CRC:", $decodeVInt(r.s, r.pos))
|
outf.writeLine("CRC:", $decodeVInt(r.s, r.pos))
|
||||||
of "ID":
|
of "ID":
|
||||||
inc(r.pos) # skip ':'
|
inc(r.pos) # skip ':'
|
||||||
r.moduleID = decodeVInt(r.s, r.pos)
|
r.moduleID = decodeVInt(r.s, r.pos)
|
||||||
setId(r.moduleID)
|
setId(r.moduleID)
|
||||||
outf.writeln("ID:", $r.moduleID)
|
outf.writeLine("ID:", $r.moduleID)
|
||||||
of "ORIGFILE":
|
of "ORIGFILE":
|
||||||
inc(r.pos)
|
inc(r.pos)
|
||||||
r.origFile = decodeStr(r.s, r.pos)
|
r.origFile = decodeStr(r.s, r.pos)
|
||||||
outf.writeln("ORIGFILE:", r.origFile)
|
outf.writeLine("ORIGFILE:", r.origFile)
|
||||||
of "OPTIONS":
|
of "OPTIONS":
|
||||||
inc(r.pos) # skip ':'
|
inc(r.pos) # skip ':'
|
||||||
r.options = cast[TOptions](int32(decodeVInt(r.s, r.pos)))
|
r.options = cast[TOptions](int32(decodeVInt(r.s, r.pos)))
|
||||||
outf.writeln("OPTIONS:", $r.options)
|
outf.writeLine("OPTIONS:", $r.options)
|
||||||
of "GOPTIONS":
|
of "GOPTIONS":
|
||||||
inc(r.pos) # skip ':'
|
inc(r.pos) # skip ':'
|
||||||
let dep = cast[TGlobalOptions](int32(decodeVInt(r.s, r.pos)))
|
let dep = cast[TGlobalOptions](int32(decodeVInt(r.s, r.pos)))
|
||||||
outf.writeln("GOPTIONS:", $dep)
|
outf.writeLine("GOPTIONS:", $dep)
|
||||||
of "CMD":
|
of "CMD":
|
||||||
inc(r.pos) # skip ':'
|
inc(r.pos) # skip ':'
|
||||||
let dep = cast[TCommands](int32(decodeVInt(r.s, r.pos)))
|
let dep = cast[TCommands](int32(decodeVInt(r.s, r.pos)))
|
||||||
outf.writeln("CMD:", $dep)
|
outf.writeLine("CMD:", $dep)
|
||||||
of "DEFINES":
|
of "DEFINES":
|
||||||
inc(r.pos) # skip ':'
|
inc(r.pos) # skip ':'
|
||||||
var d = 0
|
var d = 0
|
||||||
|
|
@ -1074,7 +1074,7 @@ proc viewFile(rodfile: string) =
|
||||||
r.files.add(finalPath.fileInfoIdx)
|
r.files.add(finalPath.fileInfoIdx)
|
||||||
inc(r.pos) # skip #10
|
inc(r.pos) # skip #10
|
||||||
inc(r.line)
|
inc(r.line)
|
||||||
outf.writeln finalPath
|
outf.writeLine finalPath
|
||||||
if r.s[r.pos] == ')': inc(r.pos)
|
if r.s[r.pos] == ')': inc(r.pos)
|
||||||
outf.write(")\n")
|
outf.write(")\n")
|
||||||
of "INCLUDES":
|
of "INCLUDES":
|
||||||
|
|
|
||||||
|
|
@ -218,12 +218,12 @@ proc cmpCandidates*(a, b: TCandidate): int =
|
||||||
result = complexDisambiguation(a.callee, b.callee)
|
result = complexDisambiguation(a.callee, b.callee)
|
||||||
|
|
||||||
proc writeMatches*(c: TCandidate) =
|
proc writeMatches*(c: TCandidate) =
|
||||||
writeln(stdout, "exact matches: " & $c.exactMatches)
|
writeLine(stdout, "exact matches: " & $c.exactMatches)
|
||||||
writeln(stdout, "generic matches: " & $c.genericMatches)
|
writeLine(stdout, "generic matches: " & $c.genericMatches)
|
||||||
writeln(stdout, "subtype matches: " & $c.subtypeMatches)
|
writeLine(stdout, "subtype matches: " & $c.subtypeMatches)
|
||||||
writeln(stdout, "intconv matches: " & $c.intConvMatches)
|
writeLine(stdout, "intconv matches: " & $c.intConvMatches)
|
||||||
writeln(stdout, "conv matches: " & $c.convMatches)
|
writeLine(stdout, "conv matches: " & $c.convMatches)
|
||||||
writeln(stdout, "inheritance: " & $c.inheritancePenalty)
|
writeLine(stdout, "inheritance: " & $c.inheritancePenalty)
|
||||||
|
|
||||||
proc argTypeToString(arg: PNode; prefer: TPreferedDesc): string =
|
proc argTypeToString(arg: PNode; prefer: TPreferedDesc): string =
|
||||||
if arg.kind in nkSymChoices:
|
if arg.kind in nkSymChoices:
|
||||||
|
|
|
||||||
|
|
@ -222,13 +222,13 @@ Call with named arguments
|
||||||
Concrete syntax:
|
Concrete syntax:
|
||||||
|
|
||||||
.. code-block:: nim
|
.. code-block:: nim
|
||||||
writeln(file=stdout, "hallo")
|
writeLine(file=stdout, "hallo")
|
||||||
|
|
||||||
AST:
|
AST:
|
||||||
|
|
||||||
.. code-block:: nim
|
.. code-block:: nim
|
||||||
nnkCall(
|
nnkCall(
|
||||||
nnkIdent(!"writeln"),
|
nnkIdent(!"writeLine"),
|
||||||
nnkExprEqExpr(
|
nnkExprEqExpr(
|
||||||
nnkIdent(!"file"),
|
nnkIdent(!"file"),
|
||||||
nnkIdent(!"stdout")
|
nnkIdent(!"stdout")
|
||||||
|
|
|
||||||
|
|
@ -53,7 +53,7 @@ The following example shows a generic binary tree can be modelled:
|
||||||
add(root, newNode("hallo")) # instantiates generic procs ``newNode`` and
|
add(root, newNode("hallo")) # instantiates generic procs ``newNode`` and
|
||||||
add(root, newNode("world")) # ``add``
|
add(root, newNode("world")) # ``add``
|
||||||
for str in inorder(root):
|
for str in inorder(root):
|
||||||
writeln(stdout, str)
|
writeLine(stdout, str)
|
||||||
|
|
||||||
|
|
||||||
Is operator
|
Is operator
|
||||||
|
|
|
||||||
|
|
@ -132,7 +132,7 @@ to supply any type of first argument for procedures:
|
||||||
echo("abc".len) # is the same as echo(len("abc"))
|
echo("abc".len) # is the same as echo(len("abc"))
|
||||||
echo("abc".toUpper())
|
echo("abc".toUpper())
|
||||||
echo({'a', 'b', 'c'}.card)
|
echo({'a', 'b', 'c'}.card)
|
||||||
stdout.writeln("Hallo") # the same as writeln(stdout, "Hallo")
|
stdout.writeLine("Hallo") # the same as writeLine(stdout, "Hallo")
|
||||||
|
|
||||||
Another way to look at the method call syntax is that it provides the missing
|
Another way to look at the method call syntax is that it provides the missing
|
||||||
postfix notation.
|
postfix notation.
|
||||||
|
|
|
||||||
|
|
@ -77,10 +77,10 @@ special ``:`` syntax:
|
||||||
quit("cannot open: " & fn)
|
quit("cannot open: " & fn)
|
||||||
|
|
||||||
withFile(txt, "ttempl3.txt", fmWrite):
|
withFile(txt, "ttempl3.txt", fmWrite):
|
||||||
txt.writeln("line 1")
|
txt.writeLine("line 1")
|
||||||
txt.writeln("line 2")
|
txt.writeLine("line 2")
|
||||||
|
|
||||||
In the example the two ``writeln`` statements are bound to the ``actions``
|
In the example the two ``writeLine`` statements are bound to the ``actions``
|
||||||
parameter.
|
parameter.
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -206,8 +206,8 @@ template parameter, it is an inject'ed symbol:
|
||||||
...
|
...
|
||||||
|
|
||||||
withFile(txt, "ttempl3.txt", fmWrite):
|
withFile(txt, "ttempl3.txt", fmWrite):
|
||||||
txt.writeln("line 1")
|
txt.writeLine("line 1")
|
||||||
txt.writeln("line 2")
|
txt.writeLine("line 2")
|
||||||
|
|
||||||
|
|
||||||
The ``inject`` and ``gensym`` pragmas are second class annotations; they have
|
The ``inject`` and ``gensym`` pragmas are second class annotations; they have
|
||||||
|
|
@ -299,7 +299,7 @@ variable number of arguments:
|
||||||
# add a call to the statement list that writes ": "
|
# add a call to the statement list that writes ": "
|
||||||
add(result, newCall("write", newIdentNode("stdout"), newStrLitNode(": ")))
|
add(result, newCall("write", newIdentNode("stdout"), newStrLitNode(": ")))
|
||||||
# add a call to the statement list that writes the expressions value:
|
# add a call to the statement list that writes the expressions value:
|
||||||
add(result, newCall("writeln", newIdentNode("stdout"), n[i]))
|
add(result, newCall("writeLine", newIdentNode("stdout"), n[i]))
|
||||||
|
|
||||||
var
|
var
|
||||||
a: array [0..10, int]
|
a: array [0..10, int]
|
||||||
|
|
@ -314,15 +314,15 @@ The macro call expands to:
|
||||||
.. code-block:: nim
|
.. code-block:: nim
|
||||||
write(stdout, "a[0]")
|
write(stdout, "a[0]")
|
||||||
write(stdout, ": ")
|
write(stdout, ": ")
|
||||||
writeln(stdout, a[0])
|
writeLine(stdout, a[0])
|
||||||
|
|
||||||
write(stdout, "a[1]")
|
write(stdout, "a[1]")
|
||||||
write(stdout, ": ")
|
write(stdout, ": ")
|
||||||
writeln(stdout, a[1])
|
writeLine(stdout, a[1])
|
||||||
|
|
||||||
write(stdout, "x")
|
write(stdout, "x")
|
||||||
write(stdout, ": ")
|
write(stdout, ": ")
|
||||||
writeln(stdout, x)
|
writeLine(stdout, x)
|
||||||
|
|
||||||
|
|
||||||
Arguments that are passed to a ``varargs`` parameter are wrapped in an array
|
Arguments that are passed to a ``varargs`` parameter are wrapped in an array
|
||||||
|
|
@ -333,7 +333,7 @@ children.
|
||||||
BindSym
|
BindSym
|
||||||
-------
|
-------
|
||||||
|
|
||||||
The above ``debug`` macro relies on the fact that ``write``, ``writeln`` and
|
The above ``debug`` macro relies on the fact that ``write``, ``writeLine`` and
|
||||||
``stdout`` are declared in the system module and thus visible in the
|
``stdout`` are declared in the system module and thus visible in the
|
||||||
instantiating context. There is a way to use bound identifiers
|
instantiating context. There is a way to use bound identifiers
|
||||||
(aka `symbols`:idx:) instead of using unbound identifiers. The ``bindSym``
|
(aka `symbols`:idx:) instead of using unbound identifiers. The ``bindSym``
|
||||||
|
|
@ -348,7 +348,7 @@ builtin can be used for that:
|
||||||
# we can bind symbols in scope via 'bindSym':
|
# we can bind symbols in scope via 'bindSym':
|
||||||
add(result, newCall(bindSym"write", bindSym"stdout", toStrLit(n[i])))
|
add(result, newCall(bindSym"write", bindSym"stdout", toStrLit(n[i])))
|
||||||
add(result, newCall(bindSym"write", bindSym"stdout", newStrLitNode(": ")))
|
add(result, newCall(bindSym"write", bindSym"stdout", newStrLitNode(": ")))
|
||||||
add(result, newCall(bindSym"writeln", bindSym"stdout", n[i]))
|
add(result, newCall(bindSym"writeLine", bindSym"stdout", n[i]))
|
||||||
|
|
||||||
var
|
var
|
||||||
a: array [0..10, int]
|
a: array [0..10, int]
|
||||||
|
|
@ -363,17 +363,17 @@ The macro call expands to:
|
||||||
.. code-block:: nim
|
.. code-block:: nim
|
||||||
write(stdout, "a[0]")
|
write(stdout, "a[0]")
|
||||||
write(stdout, ": ")
|
write(stdout, ": ")
|
||||||
writeln(stdout, a[0])
|
writeLine(stdout, a[0])
|
||||||
|
|
||||||
write(stdout, "a[1]")
|
write(stdout, "a[1]")
|
||||||
write(stdout, ": ")
|
write(stdout, ": ")
|
||||||
writeln(stdout, a[1])
|
writeLine(stdout, a[1])
|
||||||
|
|
||||||
write(stdout, "x")
|
write(stdout, "x")
|
||||||
write(stdout, ": ")
|
write(stdout, ": ")
|
||||||
writeln(stdout, x)
|
writeLine(stdout, x)
|
||||||
|
|
||||||
However, the symbols ``write``, ``writeln`` and ``stdout`` are already bound
|
However, the symbols ``write``, ``writeLine`` and ``stdout`` are already bound
|
||||||
and are not looked up again. As the example shows, ``bindSym`` does work with
|
and are not looked up again. As the example shows, ``bindSym`` does work with
|
||||||
overloaded symbols implicitly.
|
overloaded symbols implicitly.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -272,7 +272,7 @@ parameter is of the type ``varargs`` it is treated specially and it can match
|
||||||
.. code-block:: nim
|
.. code-block:: nim
|
||||||
template optWrite{
|
template optWrite{
|
||||||
write(f, x)
|
write(f, x)
|
||||||
((write|writeln){w})(f, y)
|
((write|writeLine){w})(f, y)
|
||||||
}(x, y: varargs[expr], f: File, w: expr) =
|
}(x, y: varargs[expr], f: File, w: expr) =
|
||||||
w(f, x, y)
|
w(f, x, y)
|
||||||
|
|
||||||
|
|
|
||||||
26
doc/tut2.txt
26
doc/tut2.txt
|
|
@ -207,7 +207,7 @@ for any type:
|
||||||
echo("abc".len) # is the same as echo(len("abc"))
|
echo("abc".len) # is the same as echo(len("abc"))
|
||||||
echo("abc".toUpper())
|
echo("abc".toUpper())
|
||||||
echo({'a', 'b', 'c'}.card)
|
echo({'a', 'b', 'c'}.card)
|
||||||
stdout.writeln("Hallo") # the same as writeln(stdout, "Hallo")
|
stdout.writeLine("Hallo") # the same as writeLine(stdout, "Hallo")
|
||||||
|
|
||||||
(Another way to look at the method call syntax is that it provides the missing
|
(Another way to look at the method call syntax is that it provides the missing
|
||||||
postfix notation.)
|
postfix notation.)
|
||||||
|
|
@ -217,9 +217,9 @@ So "pure object oriented" code is easy to write:
|
||||||
.. code-block:: nim
|
.. code-block:: nim
|
||||||
import strutils
|
import strutils
|
||||||
|
|
||||||
stdout.writeln("Give a list of numbers (separated by spaces): ")
|
stdout.writeLine("Give a list of numbers (separated by spaces): ")
|
||||||
stdout.write(stdin.readLine.split.map(parseInt).max.`$`)
|
stdout.write(stdin.readLine.split.map(parseInt).max.`$`)
|
||||||
stdout.writeln(" is the maximum!")
|
stdout.writeLine(" is the maximum!")
|
||||||
|
|
||||||
|
|
||||||
Properties
|
Properties
|
||||||
|
|
@ -535,7 +535,7 @@ containers:
|
||||||
add(root, newNode("hello")) # instantiates ``newNode`` and ``add``
|
add(root, newNode("hello")) # instantiates ``newNode`` and ``add``
|
||||||
add(root, "world") # instantiates the second ``add`` proc
|
add(root, "world") # instantiates the second ``add`` proc
|
||||||
for str in preorder(root):
|
for str in preorder(root):
|
||||||
stdout.writeln(str)
|
stdout.writeLine(str)
|
||||||
|
|
||||||
The example shows a generic binary tree. Depending on context, the brackets are
|
The example shows a generic binary tree. Depending on context, the brackets are
|
||||||
used either to introduce type parameters or to instantiate a generic proc,
|
used either to introduce type parameters or to instantiate a generic proc,
|
||||||
|
|
@ -580,7 +580,7 @@ simple proc for logging:
|
||||||
debug = true
|
debug = true
|
||||||
|
|
||||||
proc log(msg: string) {.inline.} =
|
proc log(msg: string) {.inline.} =
|
||||||
if debug: stdout.writeln(msg)
|
if debug: stdout.writeLine(msg)
|
||||||
|
|
||||||
var
|
var
|
||||||
x = 4
|
x = 4
|
||||||
|
|
@ -597,7 +597,7 @@ Turning the ``log`` proc into a template solves this problem:
|
||||||
debug = true
|
debug = true
|
||||||
|
|
||||||
template log(msg: string) =
|
template log(msg: string) =
|
||||||
if debug: stdout.writeln(msg)
|
if debug: stdout.writeLine(msg)
|
||||||
|
|
||||||
var
|
var
|
||||||
x = 4
|
x = 4
|
||||||
|
|
@ -627,10 +627,10 @@ via a special ``:`` syntax:
|
||||||
quit("cannot open: " & fn)
|
quit("cannot open: " & fn)
|
||||||
|
|
||||||
withFile(txt, "ttempl3.txt", fmWrite):
|
withFile(txt, "ttempl3.txt", fmWrite):
|
||||||
txt.writeln("line 1")
|
txt.writeLine("line 1")
|
||||||
txt.writeln("line 2")
|
txt.writeLine("line 2")
|
||||||
|
|
||||||
In the example the two ``writeln`` statements are bound to the ``body``
|
In the example the two ``writeLine`` statements are bound to the ``body``
|
||||||
parameter. The ``withFile`` template contains boilerplate code and helps to
|
parameter. The ``withFile`` template contains boilerplate code and helps to
|
||||||
avoid a common bug: to forget to close the file. Note how the
|
avoid a common bug: to forget to close the file. Note how the
|
||||||
``let fn = filename`` statement ensures that ``filename`` is evaluated only
|
``let fn = filename`` statement ensures that ``filename`` is evaluated only
|
||||||
|
|
@ -684,7 +684,7 @@ variable number of arguments:
|
||||||
# add a call to the statement list that writes ": "
|
# add a call to the statement list that writes ": "
|
||||||
result.add(newCall("write", newIdentNode("stdout"), newStrLitNode(": ")))
|
result.add(newCall("write", newIdentNode("stdout"), newStrLitNode(": ")))
|
||||||
# add a call to the statement list that writes the expressions value:
|
# add a call to the statement list that writes the expressions value:
|
||||||
result.add(newCall("writeln", newIdentNode("stdout"), n[i]))
|
result.add(newCall("writeLine", newIdentNode("stdout"), n[i]))
|
||||||
|
|
||||||
var
|
var
|
||||||
a: array[0..10, int]
|
a: array[0..10, int]
|
||||||
|
|
@ -699,15 +699,15 @@ The macro call expands to:
|
||||||
.. code-block:: nim
|
.. code-block:: nim
|
||||||
write(stdout, "a[0]")
|
write(stdout, "a[0]")
|
||||||
write(stdout, ": ")
|
write(stdout, ": ")
|
||||||
writeln(stdout, a[0])
|
writeLine(stdout, a[0])
|
||||||
|
|
||||||
write(stdout, "a[1]")
|
write(stdout, "a[1]")
|
||||||
write(stdout, ": ")
|
write(stdout, ": ")
|
||||||
writeln(stdout, a[1])
|
writeLine(stdout, a[1])
|
||||||
|
|
||||||
write(stdout, "x")
|
write(stdout, "x")
|
||||||
write(stdout, ": ")
|
write(stdout, ": ")
|
||||||
writeln(stdout, x)
|
writeLine(stdout, x)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,4 +4,4 @@ write(stdout, "Content-type: text/html\n\n")
|
||||||
write(stdout, "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\">\n")
|
write(stdout, "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\">\n")
|
||||||
write(stdout, "<html><head><title>Test</title></head><body>\n")
|
write(stdout, "<html><head><title>Test</title></head><body>\n")
|
||||||
write(stdout, "Hello!")
|
write(stdout, "Hello!")
|
||||||
writeln(stdout, "</body></html>")
|
writeLine(stdout, "</body></html>")
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,6 @@ writeContentType()
|
||||||
|
|
||||||
write(stdout, "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\">\n")
|
write(stdout, "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\">\n")
|
||||||
write(stdout, "<html><head><title>Test</title></head><body>\n")
|
write(stdout, "<html><head><title>Test</title></head><body>\n")
|
||||||
writeln(stdout, "name: " & myData["name"])
|
writeLine(stdout, "name: " & myData["name"])
|
||||||
writeln(stdout, "password: " & myData["password"])
|
writeLine(stdout, "password: " & myData["password"])
|
||||||
writeln(stdout, "</body></html>")
|
writeLine(stdout, "</body></html>")
|
||||||
|
|
|
||||||
|
|
@ -369,7 +369,7 @@ iterator split*(s: string, sep: Regex): string =
|
||||||
##
|
##
|
||||||
## .. code-block:: nim
|
## .. code-block:: nim
|
||||||
## for word in split("00232this02939is39an22example111", re"\d+"):
|
## for word in split("00232this02939is39an22example111", re"\d+"):
|
||||||
## writeln(stdout, word)
|
## writeLine(stdout, word)
|
||||||
##
|
##
|
||||||
## Results in:
|
## Results in:
|
||||||
##
|
##
|
||||||
|
|
|
||||||
|
|
@ -307,7 +307,7 @@ proc defaultMsgHandler*(filename: string, line, col: int, msgkind: MsgKind,
|
||||||
let a = messages[msgkind] % arg
|
let a = messages[msgkind] % arg
|
||||||
let message = "$1($2, $3) $4: $5" % [filename, $line, $col, $mc, a]
|
let message = "$1($2, $3) $4: $5" % [filename, $line, $col, $mc, a]
|
||||||
if mc == mcError: raise newException(EParseError, message)
|
if mc == mcError: raise newException(EParseError, message)
|
||||||
else: writeln(stdout, message)
|
else: writeLine(stdout, message)
|
||||||
|
|
||||||
proc defaultFindFile*(filename: string): string {.procvar.} =
|
proc defaultFindFile*(filename: string): string {.procvar.} =
|
||||||
if existsFile(filename): result = filename
|
if existsFile(filename): result = filename
|
||||||
|
|
|
||||||
|
|
@ -25,9 +25,9 @@
|
||||||
## # generate content:
|
## # generate content:
|
||||||
## write(stdout, "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\">\n")
|
## write(stdout, "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\">\n")
|
||||||
## write(stdout, "<html><head><title>Test</title></head><body>\n")
|
## write(stdout, "<html><head><title>Test</title></head><body>\n")
|
||||||
## writeln(stdout, "your name: " & myData["name"])
|
## writeLine(stdout, "your name: " & myData["name"])
|
||||||
## writeln(stdout, "your password: " & myData["password"])
|
## writeLine(stdout, "your password: " & myData["password"])
|
||||||
## writeln(stdout, "</body></html>")
|
## writeLine(stdout, "</body></html>")
|
||||||
|
|
||||||
import strutils, os, strtabs, cookies
|
import strutils, os, strtabs, cookies
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -132,12 +132,12 @@ method log*(logger: Logger, level: Level, args: varargs[string, `$`]) {.
|
||||||
method log*(logger: ConsoleLogger, level: Level, args: varargs[string, `$`]) =
|
method log*(logger: ConsoleLogger, level: Level, args: varargs[string, `$`]) =
|
||||||
## Logs to the console using ``logger`` only.
|
## Logs to the console using ``logger`` only.
|
||||||
if level >= logger.levelThreshold:
|
if level >= logger.levelThreshold:
|
||||||
writeln(stdout, substituteLog(logger.fmtStr, level, args))
|
writeLine(stdout, substituteLog(logger.fmtStr, level, args))
|
||||||
|
|
||||||
method log*(logger: FileLogger, level: Level, args: varargs[string, `$`]) =
|
method log*(logger: FileLogger, level: Level, args: varargs[string, `$`]) =
|
||||||
## Logs to a file using ``logger`` only.
|
## Logs to a file using ``logger`` only.
|
||||||
if level >= logger.levelThreshold:
|
if level >= logger.levelThreshold:
|
||||||
writeln(logger.f, substituteLog(logger.fmtStr, level, args))
|
writeLine(logger.f, substituteLog(logger.fmtStr, level, args))
|
||||||
|
|
||||||
proc defaultFilename*(): string =
|
proc defaultFilename*(): string =
|
||||||
## Returns the default filename for a logger.
|
## Returns the default filename for a logger.
|
||||||
|
|
@ -228,7 +228,7 @@ method log*(logger: RollingFileLogger, level: Level, args: varargs[string, `$`])
|
||||||
logger.curLine = 0
|
logger.curLine = 0
|
||||||
logger.f = open(logger.baseName, logger.baseMode, bufSize = logger.bufSize)
|
logger.f = open(logger.baseName, logger.baseMode, bufSize = logger.bufSize)
|
||||||
|
|
||||||
writeln(logger.f, substituteLog(logger.fmtStr, level, args))
|
writeLine(logger.f, substituteLog(logger.fmtStr, level, args))
|
||||||
logger.curLine.inc
|
logger.curLine.inc
|
||||||
|
|
||||||
# --------
|
# --------
|
||||||
|
|
|
||||||
|
|
@ -155,7 +155,7 @@ proc writeProfile() {.noconv.} =
|
||||||
var f: File
|
var f: File
|
||||||
if open(f, filename, fmWrite):
|
if open(f, filename, fmWrite):
|
||||||
sort(profileData, cmpEntries)
|
sort(profileData, cmpEntries)
|
||||||
writeln(f, "total executions of each stack trace:")
|
writeLine(f, "total executions of each stack trace:")
|
||||||
var entries = 0
|
var entries = 0
|
||||||
for i in 0..high(profileData):
|
for i in 0..high(profileData):
|
||||||
if profileData[i] != nil: inc entries
|
if profileData[i] != nil: inc entries
|
||||||
|
|
@ -175,13 +175,13 @@ proc writeProfile() {.noconv.} =
|
||||||
for i in 0..min(100, entries-1):
|
for i in 0..min(100, entries-1):
|
||||||
if profileData[i].total > 1:
|
if profileData[i].total > 1:
|
||||||
inc sum, profileData[i].total
|
inc sum, profileData[i].total
|
||||||
writeln(f, "Entry: ", i+1, "/", entries, " Calls: ",
|
writeLine(f, "Entry: ", i+1, "/", entries, " Calls: ",
|
||||||
profileData[i].total // totalCalls, " [sum: ", sum, "; ",
|
profileData[i].total // totalCalls, " [sum: ", sum, "; ",
|
||||||
sum // totalCalls, "]")
|
sum // totalCalls, "]")
|
||||||
for ii in 0..high(StackTrace):
|
for ii in 0..high(StackTrace):
|
||||||
let procname = profileData[i].st[ii]
|
let procname = profileData[i].st[ii]
|
||||||
if isNil(procname): break
|
if isNil(procname): break
|
||||||
writeln(f, " ", procname, " ", perProc[$procname] // totalCalls)
|
writeLine(f, " ", procname, " ", perProc[$procname] // totalCalls)
|
||||||
close(f)
|
close(f)
|
||||||
echo "... done"
|
echo "... done"
|
||||||
else:
|
else:
|
||||||
|
|
|
||||||
|
|
@ -1323,7 +1323,7 @@ proc ra(n: SqlNode, s: var string, indent: int) =
|
||||||
# where: x.name == y.name
|
# where: x.name == y.name
|
||||||
#db.select(fromm = [t1, t2], where = t1.name == t2.name):
|
#db.select(fromm = [t1, t2], where = t1.name == t2.name):
|
||||||
#for x, y, z in db.select(fromm = a, b where = a.name == b.name):
|
#for x, y, z in db.select(fromm = a, b where = a.name == b.name):
|
||||||
# writeln x, y, z
|
# writeLine x, y, z
|
||||||
|
|
||||||
proc renderSQL*(n: SqlNode): string =
|
proc renderSQL*(n: SqlNode): string =
|
||||||
## Converts an SQL abstract syntax tree to its string representation.
|
## Converts an SQL abstract syntax tree to its string representation.
|
||||||
|
|
|
||||||
|
|
@ -979,7 +979,7 @@ iterator split*(s: string, sep: Peg): string =
|
||||||
##
|
##
|
||||||
## .. code-block:: nim
|
## .. code-block:: nim
|
||||||
## for word in split("00232this02939is39an22example111", peg"\d+"):
|
## for word in split("00232this02939is39an22example111", peg"\d+"):
|
||||||
## writeln(stdout, word)
|
## writeLine(stdout, word)
|
||||||
##
|
##
|
||||||
## Results in:
|
## Results in:
|
||||||
##
|
##
|
||||||
|
|
|
||||||
|
|
@ -117,7 +117,12 @@ proc write*(s: Stream, x: string) =
|
||||||
## terminating zero is written.
|
## terminating zero is written.
|
||||||
writeData(s, cstring(x), x.len)
|
writeData(s, cstring(x), x.len)
|
||||||
|
|
||||||
proc writeln*(s: Stream, args: varargs[string, `$`]) =
|
proc writeLn*(s: Stream, args: varargs[string, `$`]) {.deprecated.} =
|
||||||
|
## **Deprecated since version 0.11.4:** Use **writeLine** instead.
|
||||||
|
for str in args: write(s, str)
|
||||||
|
write(s, "\n")
|
||||||
|
|
||||||
|
proc writeLine*(s: Stream, args: varargs[string, `$`]) =
|
||||||
## writes one or more strings to the the stream `s` followed
|
## writes one or more strings to the the stream `s` followed
|
||||||
## by a new line. No length field or terminating zero is written.
|
## by a new line. No length field or terminating zero is written.
|
||||||
for str in args: write(s, str)
|
for str in args: write(s, str)
|
||||||
|
|
|
||||||
|
|
@ -206,7 +206,7 @@ iterator split*(s: string, seps: set[char] = Whitespace): string =
|
||||||
##
|
##
|
||||||
## .. code-block:: nim
|
## .. code-block:: nim
|
||||||
## for word in split(" this is an example "):
|
## for word in split(" this is an example "):
|
||||||
## writeln(stdout, word)
|
## writeLine(stdout, word)
|
||||||
##
|
##
|
||||||
## ...generates this output:
|
## ...generates this output:
|
||||||
##
|
##
|
||||||
|
|
@ -220,7 +220,7 @@ iterator split*(s: string, seps: set[char] = Whitespace): string =
|
||||||
##
|
##
|
||||||
## .. code-block:: nim
|
## .. code-block:: nim
|
||||||
## for word in split(";;this;is;an;;example;;;", {';'}):
|
## for word in split(";;this;is;an;;example;;;", {';'}):
|
||||||
## writeln(stdout, word)
|
## writeLine(stdout, word)
|
||||||
##
|
##
|
||||||
## ...produces the same output as the first example. The code:
|
## ...produces the same output as the first example. The code:
|
||||||
##
|
##
|
||||||
|
|
@ -228,7 +228,7 @@ iterator split*(s: string, seps: set[char] = Whitespace): string =
|
||||||
## let date = "2012-11-20T22:08:08.398990"
|
## let date = "2012-11-20T22:08:08.398990"
|
||||||
## let separators = {' ', '-', ':', 'T'}
|
## let separators = {' ', '-', ':', 'T'}
|
||||||
## for number in split(date, separators):
|
## for number in split(date, separators):
|
||||||
## writeln(stdout, number)
|
## writeLine(stdout, number)
|
||||||
##
|
##
|
||||||
## ...results in:
|
## ...results in:
|
||||||
##
|
##
|
||||||
|
|
@ -259,7 +259,7 @@ iterator split*(s: string, sep: char): string =
|
||||||
##
|
##
|
||||||
## .. code-block:: nim
|
## .. code-block:: nim
|
||||||
## for word in split(";;this;is;an;;example;;;", ';'):
|
## for word in split(";;this;is;an;;example;;;", ';'):
|
||||||
## writeln(stdout, word)
|
## writeLine(stdout, word)
|
||||||
##
|
##
|
||||||
## Results in:
|
## Results in:
|
||||||
##
|
##
|
||||||
|
|
@ -309,7 +309,7 @@ iterator splitLines*(s: string): string =
|
||||||
##
|
##
|
||||||
## .. code-block:: nim
|
## .. code-block:: nim
|
||||||
## for line in splitLines("\nthis\nis\nan\n\nexample\n"):
|
## for line in splitLines("\nthis\nis\nan\n\nexample\n"):
|
||||||
## writeln(stdout, line)
|
## writeLine(stdout, line)
|
||||||
##
|
##
|
||||||
## Results in:
|
## Results in:
|
||||||
##
|
##
|
||||||
|
|
@ -571,7 +571,7 @@ iterator tokenize*(s: string, seps: set[char] = Whitespace): tuple[
|
||||||
##
|
##
|
||||||
## .. code-block:: nim
|
## .. code-block:: nim
|
||||||
## for word in tokenize(" this is an example "):
|
## for word in tokenize(" this is an example "):
|
||||||
## writeln(stdout, word)
|
## writeLine(stdout, word)
|
||||||
##
|
##
|
||||||
## Results in:
|
## Results in:
|
||||||
##
|
##
|
||||||
|
|
|
||||||
|
|
@ -430,8 +430,8 @@ macro styledEcho*(m: varargs[expr]): stmt =
|
||||||
case item.kind
|
case item.kind
|
||||||
of nnkStrLit..nnkTripleStrLit:
|
of nnkStrLit..nnkTripleStrLit:
|
||||||
if i == m.len - 1:
|
if i == m.len - 1:
|
||||||
# optimize if string literal is last, just call writeln
|
# optimize if string literal is last, just call writeLine
|
||||||
result.add(newCall(bindSym"writeln", bindSym"stdout", item))
|
result.add(newCall(bindSym"writeLine", bindSym"stdout", item))
|
||||||
if reset: result.add(newCall(bindSym"resetAttributes"))
|
if reset: result.add(newCall(bindSym"resetAttributes"))
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
|
|
@ -470,7 +470,7 @@ when not defined(testing) and isMainModule:
|
||||||
writeStyled("styled text ", {styleBright, styleBlink, styleUnderscore})
|
writeStyled("styled text ", {styleBright, styleBlink, styleUnderscore})
|
||||||
setBackGroundColor(bgCyan, true)
|
setBackGroundColor(bgCyan, true)
|
||||||
setForeGroundColor(fgBlue)
|
setForeGroundColor(fgBlue)
|
||||||
writeln(stdout, "ordinary text")
|
writeLine(stdout, "ordinary text")
|
||||||
|
|
||||||
styledEcho("styled text ", {styleBright, styleBlink, styleUnderscore})
|
styledEcho("styled text ", {styleBright, styleBlink, styleUnderscore})
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -898,7 +898,7 @@ proc contains*[T](x: set[T], y: T): bool {.magic: "InSet", noSideEffect.}
|
||||||
##
|
##
|
||||||
## .. code-block:: Nim
|
## .. code-block:: Nim
|
||||||
## var s: set[range['a'..'z']] = {'a'..'c'}
|
## var s: set[range['a'..'z']] = {'a'..'c'}
|
||||||
## writeln(stdout, 'b' in s)
|
## writeLine(stdout, 'b' in s)
|
||||||
##
|
##
|
||||||
## If ``in`` had been declared as ``[T](elem: T, s: set[T])`` then ``T`` would
|
## If ``in`` had been declared as ``[T](elem: T, s: set[T])`` then ``T`` would
|
||||||
## have been bound to ``char``. But ``s`` is not compatible to type
|
## have been bound to ``char``. But ``s`` is not compatible to type
|
||||||
|
|
@ -2269,7 +2269,7 @@ proc echo*(x: varargs[expr, `$`]) {.magic: "Echo", tags: [WriteIOEffect],
|
||||||
## Special built-in that takes a variable number of arguments. Each argument
|
## Special built-in that takes a variable number of arguments. Each argument
|
||||||
## is converted to a string via ``$``, so it works for user-defined
|
## is converted to a string via ``$``, so it works for user-defined
|
||||||
## types that have an overloaded ``$`` operator.
|
## types that have an overloaded ``$`` operator.
|
||||||
## It is roughly equivalent to ``writeln(stdout, x); flushFile(stdout)``, but
|
## It is roughly equivalent to ``writeLine(stdout, x); flushFile(stdout)``, but
|
||||||
## available for the JavaScript target too.
|
## available for the JavaScript target too.
|
||||||
##
|
##
|
||||||
## Unlike other IO operations this is guaranteed to be thread-safe as
|
## Unlike other IO operations this is guaranteed to be thread-safe as
|
||||||
|
|
@ -2526,7 +2526,11 @@ when not defined(JS): #and not defined(NimrodVM):
|
||||||
## Returns ``false`` if the end of the file has been reached, ``true``
|
## Returns ``false`` if the end of the file has been reached, ``true``
|
||||||
## otherwise. If ``false`` is returned `line` contains no new data.
|
## otherwise. If ``false`` is returned `line` contains no new data.
|
||||||
|
|
||||||
proc writeln*[Ty](f: File, x: varargs[Ty, `$`]) {.inline,
|
proc writeLn*[Ty](f: File, x: varargs[Ty, `$`]) {.inline,
|
||||||
|
tags: [WriteIOEffect], benign, deprecated.}
|
||||||
|
## **Deprecated since version 0.11.4:** Use **writeLine** instead.
|
||||||
|
|
||||||
|
proc writeLine*[Ty](f: File, x: varargs[Ty, `$`]) {.inline,
|
||||||
tags: [WriteIOEffect], benign.}
|
tags: [WriteIOEffect], benign.}
|
||||||
## writes the values `x` to `f` and then writes "\n".
|
## writes the values `x` to `f` and then writes "\n".
|
||||||
## May throw an IO exception.
|
## May throw an IO exception.
|
||||||
|
|
|
||||||
|
|
@ -117,7 +117,7 @@ proc dbgRepr(p: pointer, typ: PNimType): string =
|
||||||
proc writeVariable(stream: File, slot: VarSlot) =
|
proc writeVariable(stream: File, slot: VarSlot) =
|
||||||
write(stream, slot.name)
|
write(stream, slot.name)
|
||||||
write(stream, " = ")
|
write(stream, " = ")
|
||||||
writeln(stream, dbgRepr(slot.address, slot.typ))
|
writeLine(stream, dbgRepr(slot.address, slot.typ))
|
||||||
|
|
||||||
proc listFrame(stream: File, f: PFrame) =
|
proc listFrame(stream: File, f: PFrame) =
|
||||||
write(stream, EndbBeg)
|
write(stream, EndbBeg)
|
||||||
|
|
@ -125,7 +125,7 @@ proc listFrame(stream: File, f: PFrame) =
|
||||||
write(stream, f.len)
|
write(stream, f.len)
|
||||||
write(stream, " slots):\n")
|
write(stream, " slots):\n")
|
||||||
for i in 0 .. f.len-1:
|
for i in 0 .. f.len-1:
|
||||||
writeln(stream, getLocal(f, i).name)
|
writeLine(stream, getLocal(f, i).name)
|
||||||
write(stream, EndbEnd)
|
write(stream, EndbEnd)
|
||||||
|
|
||||||
proc listLocals(stream: File, f: PFrame) =
|
proc listLocals(stream: File, f: PFrame) =
|
||||||
|
|
@ -141,7 +141,7 @@ proc listGlobals(stream: File) =
|
||||||
write(stream, EndbBeg)
|
write(stream, EndbBeg)
|
||||||
write(stream, "| Globals:\n")
|
write(stream, "| Globals:\n")
|
||||||
for i in 0 .. getGlobalLen()-1:
|
for i in 0 .. getGlobalLen()-1:
|
||||||
writeln(stream, getGlobal(i).name)
|
writeLine(stream, getGlobal(i).name)
|
||||||
write(stream, EndbEnd)
|
write(stream, EndbEnd)
|
||||||
|
|
||||||
proc debugOut(msg: cstring) =
|
proc debugOut(msg: cstring) =
|
||||||
|
|
|
||||||
|
|
@ -208,10 +208,15 @@ proc endOfFile(f: File): bool =
|
||||||
ungetc(c, f)
|
ungetc(c, f)
|
||||||
return c < 0'i32
|
return c < 0'i32
|
||||||
|
|
||||||
proc writeln[Ty](f: File, x: varargs[Ty, `$`]) =
|
proc writeLn[Ty](f: File, x: varargs[Ty, `$`]) =
|
||||||
for i in items(x): write(f, i)
|
for i in items(x): write(f, i)
|
||||||
write(f, "\n")
|
write(f, "\n")
|
||||||
|
|
||||||
|
proc writeLine[Ty](f: File, x: varargs[Ty, `$`]) =
|
||||||
|
for i in items(x): write(f, i)
|
||||||
|
write(f, "\n")
|
||||||
|
|
||||||
|
|
||||||
proc rawEcho(x: string) {.inline, compilerproc.} = write(stdout, x)
|
proc rawEcho(x: string) {.inline, compilerproc.} = write(stdout, x)
|
||||||
proc rawEchoNL() {.inline, compilerproc.} = write(stdout, "\n")
|
proc rawEchoNL() {.inline, compilerproc.} = write(stdout, "\n")
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ type
|
||||||
proc len(x: TMyType): int {.inline.} = return x.len
|
proc len(x: TMyType): int {.inline.} = return x.len
|
||||||
|
|
||||||
proc x(s: TMyType, len: int) =
|
proc x(s: TMyType, len: int) =
|
||||||
writeln(stdout, len(s))
|
writeLine(stdout, len(s))
|
||||||
|
|
||||||
var
|
var
|
||||||
m: TMyType
|
m: TMyType
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,6 @@ import mambsym1, times
|
||||||
var
|
var
|
||||||
v = mDec #ERROR_MSG ambiguous identifier
|
v = mDec #ERROR_MSG ambiguous identifier
|
||||||
|
|
||||||
writeln(stdout, ord(v))
|
writeLine(stdout, ord(v))
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -22,10 +22,10 @@ proc test() =
|
||||||
|
|
||||||
b = a # perform a deep copy here!
|
b = a # perform a deep copy here!
|
||||||
b.seq = @["xyz", "huch", "was", "soll"]
|
b.seq = @["xyz", "huch", "was", "soll"]
|
||||||
writeln(stdout, len(a.seq))
|
writeLine(stdout, len(a.seq))
|
||||||
writeln(stdout, a.seq[3])
|
writeLine(stdout, a.seq[3])
|
||||||
writeln(stdout, len(b.seq))
|
writeLine(stdout, len(b.seq))
|
||||||
writeln(stdout, b.seq[3])
|
writeLine(stdout, b.seq[3])
|
||||||
writeln(stdout, b.y)
|
writeLine(stdout, b.y)
|
||||||
|
|
||||||
test()
|
test()
|
||||||
|
|
|
||||||
|
|
@ -16,8 +16,8 @@ proc main() =
|
||||||
p = find(example, "=")
|
p = find(example, "=")
|
||||||
a = substr(example, 0, p-1)
|
a = substr(example, 0, p-1)
|
||||||
b = substr(example, p+1)
|
b = substr(example, p+1)
|
||||||
writeln(stdout, a & '=' & b)
|
writeLine(stdout, a & '=' & b)
|
||||||
#writeln(stdout, b)
|
#writeLine(stdout, b)
|
||||||
|
|
||||||
main()
|
main()
|
||||||
#OUT TEMP=C:\Programs\xyz\bin
|
#OUT TEMP=C:\Programs\xyz\bin
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ type
|
||||||
proc forw: int {. .}
|
proc forw: int {. .}
|
||||||
|
|
||||||
proc lier(): int {.raises: [IO2Error].} =
|
proc lier(): int {.raises: [IO2Error].} =
|
||||||
writeln stdout, "arg"
|
writeLine stdout, "arg"
|
||||||
|
|
||||||
proc forw: int =
|
proc forw: int =
|
||||||
raise newException(IOError, "arg")
|
raise newException(IOError, "arg")
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ type
|
||||||
proc forw: int {.raises: [].}
|
proc forw: int {.raises: [].}
|
||||||
|
|
||||||
proc lier(): int {.raises: [IOError].} =
|
proc lier(): int {.raises: [IOError].} =
|
||||||
writeln stdout, "arg"
|
writeLine stdout, "arg"
|
||||||
|
|
||||||
proc forw: int =
|
proc forw: int =
|
||||||
raise newException(IOError, "arg")
|
raise newException(IOError, "arg")
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ type
|
||||||
EIO2 = ref object of EIO
|
EIO2 = ref object of EIO
|
||||||
|
|
||||||
proc raiser(): int {.tags: [TObj, FWriteIO].} =
|
proc raiser(): int {.tags: [TObj, FWriteIO].} =
|
||||||
writeln stdout, "arg"
|
writeLine stdout, "arg"
|
||||||
|
|
||||||
var o: TObjB
|
var o: TObjB
|
||||||
o.fn = raiser
|
o.fn = raiser
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ proc q() {.tags: [FIO].} =
|
||||||
nil
|
nil
|
||||||
|
|
||||||
proc raiser(): int =
|
proc raiser(): int =
|
||||||
writeln stdout, "arg"
|
writeLine stdout, "arg"
|
||||||
if true:
|
if true:
|
||||||
q()
|
q()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -63,12 +63,12 @@ proc caseTree(lvl: int = 0): PCaseNode =
|
||||||
if lvl == 3: result = newCaseNode("data item")
|
if lvl == 3: result = newCaseNode("data item")
|
||||||
else: result = newCaseNode(caseTree(lvl+1), caseTree(lvl+1))
|
else: result = newCaseNode(caseTree(lvl+1), caseTree(lvl+1))
|
||||||
|
|
||||||
proc finalizeBNode(n: TBNode) = writeln(stdout, n.data)
|
proc finalizeBNode(n: TBNode) = writeLine(stdout, n.data)
|
||||||
proc finalizeNode(n: PNode) =
|
proc finalizeNode(n: PNode) =
|
||||||
assert(n != nil)
|
assert(n != nil)
|
||||||
write(stdout, "finalizing: ")
|
write(stdout, "finalizing: ")
|
||||||
if isNil(n.data): writeln(stdout, "nil!")
|
if isNil(n.data): writeLine(stdout, "nil!")
|
||||||
else: writeln(stdout, n.data)
|
else: writeLine(stdout, n.data)
|
||||||
|
|
||||||
var
|
var
|
||||||
id: int = 1
|
id: int = 1
|
||||||
|
|
@ -82,7 +82,7 @@ proc buildTree(depth = 1): PNode =
|
||||||
inc(id)
|
inc(id)
|
||||||
|
|
||||||
proc returnTree(): PNode =
|
proc returnTree(): PNode =
|
||||||
writeln(stdout, "creating id: " & $id)
|
writeLine(stdout, "creating id: " & $id)
|
||||||
new(result, finalizeNode)
|
new(result, finalizeNode)
|
||||||
result.data = $id
|
result.data = $id
|
||||||
new(result.le, finalizeNode)
|
new(result.le, finalizeNode)
|
||||||
|
|
@ -92,26 +92,26 @@ proc returnTree(): PNode =
|
||||||
inc(id)
|
inc(id)
|
||||||
|
|
||||||
# now create a cycle:
|
# now create a cycle:
|
||||||
writeln(stdout, "creating id (cyclic): " & $id)
|
writeLine(stdout, "creating id (cyclic): " & $id)
|
||||||
var cycle: PNode
|
var cycle: PNode
|
||||||
new(cycle, finalizeNode)
|
new(cycle, finalizeNode)
|
||||||
cycle.data = $id
|
cycle.data = $id
|
||||||
cycle.le = cycle
|
cycle.le = cycle
|
||||||
cycle.ri = cycle
|
cycle.ri = cycle
|
||||||
inc(id)
|
inc(id)
|
||||||
#writeln(stdout, "refcount: " & $refcount(cycle))
|
#writeLine(stdout, "refcount: " & $refcount(cycle))
|
||||||
#writeln(stdout, "refcount le: " & $refcount(cycle.le))
|
#writeLine(stdout, "refcount le: " & $refcount(cycle.le))
|
||||||
#writeln(stdout, "refcount ri: " & $refcount(cycle.ri))
|
#writeLine(stdout, "refcount ri: " & $refcount(cycle.ri))
|
||||||
|
|
||||||
proc printTree(t: PNode) =
|
proc printTree(t: PNode) =
|
||||||
if t == nil: return
|
if t == nil: return
|
||||||
writeln(stdout, "printing")
|
writeLine(stdout, "printing")
|
||||||
writeln(stdout, t.data)
|
writeLine(stdout, t.data)
|
||||||
printTree(t.le)
|
printTree(t.le)
|
||||||
printTree(t.ri)
|
printTree(t.ri)
|
||||||
|
|
||||||
proc unsureNew(result: var PNode) =
|
proc unsureNew(result: var PNode) =
|
||||||
writeln(stdout, "creating unsure id: " & $id)
|
writeLine(stdout, "creating unsure id: " & $id)
|
||||||
new(result, finalizeNode)
|
new(result, finalizeNode)
|
||||||
result.data = $id
|
result.data = $id
|
||||||
new(result.le, finalizeNode)
|
new(result.le, finalizeNode)
|
||||||
|
|
@ -176,7 +176,7 @@ proc main() =
|
||||||
var s: seq[string] = @[]
|
var s: seq[string] = @[]
|
||||||
for i in 1..100:
|
for i in 1..100:
|
||||||
add s, "hohoho" # test reallocation
|
add s, "hohoho" # test reallocation
|
||||||
writeln(stdout, s[89])
|
writeLine(stdout, s[89])
|
||||||
write(stdout, "done!\n")
|
write(stdout, "done!\n")
|
||||||
|
|
||||||
var
|
var
|
||||||
|
|
@ -184,7 +184,7 @@ var
|
||||||
s: string
|
s: string
|
||||||
s = ""
|
s = ""
|
||||||
s = ""
|
s = ""
|
||||||
writeln(stdout, repr(caseTree()))
|
writeLine(stdout, repr(caseTree()))
|
||||||
father.t.data = @["ha", "lets", "stress", "it"]
|
father.t.data = @["ha", "lets", "stress", "it"]
|
||||||
father.t.data = @["ha", "lets", "stress", "it"]
|
father.t.data = @["ha", "lets", "stress", "it"]
|
||||||
var t = buildTree()
|
var t = buildTree()
|
||||||
|
|
@ -199,5 +199,5 @@ GC_fullCollect()
|
||||||
# the M&S GC fails with this call and it's unclear why. Definitely something
|
# the M&S GC fails with this call and it's unclear why. Definitely something
|
||||||
# we need to fix!
|
# we need to fix!
|
||||||
GC_fullCollect()
|
GC_fullCollect()
|
||||||
writeln(stdout, GC_getStatistics())
|
writeLine(stdout, GC_getStatistics())
|
||||||
write(stdout, "finished\n")
|
write(stdout, "finished\n")
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ if find(root, "world"):
|
||||||
for str in items(root):
|
for str in items(root):
|
||||||
stdout.write(str)
|
stdout.write(str)
|
||||||
else:
|
else:
|
||||||
stdout.writeln("BUG")
|
stdout.writeLine("BUG")
|
||||||
|
|
||||||
var
|
var
|
||||||
r2: PBinaryTree[int]
|
r2: PBinaryTree[int]
|
||||||
|
|
|
||||||
|
|
@ -92,7 +92,7 @@ when isMainModule:
|
||||||
for str in items(root):
|
for str in items(root):
|
||||||
stdout.write(str)
|
stdout.write(str)
|
||||||
else:
|
else:
|
||||||
stdout.writeln("BUG")
|
stdout.writeLine("BUG")
|
||||||
|
|
||||||
var
|
var
|
||||||
r2: PBinaryTree[int]
|
r2: PBinaryTree[int]
|
||||||
|
|
|
||||||
|
|
@ -184,7 +184,7 @@ proc traceTree[T,D](root: PNode[T,D]) =
|
||||||
|
|
||||||
|
|
||||||
proc traceln(space: string) =
|
proc traceln(space: string) =
|
||||||
writeln stdout, ""
|
writeLine stdout, ""
|
||||||
write stdout, space
|
write stdout, space
|
||||||
|
|
||||||
proc doTrace(n: PNode[T,D], level: int) =
|
proc doTrace(n: PNode[T,D], level: int) =
|
||||||
|
|
@ -192,7 +192,7 @@ proc traceTree[T,D](root: PNode[T,D]) =
|
||||||
traceln(space)
|
traceln(space)
|
||||||
write stdout, "node: "
|
write stdout, "node: "
|
||||||
if n == nil:
|
if n == nil:
|
||||||
writeln stdout, "is empty"
|
writeLine stdout, "is empty"
|
||||||
return
|
return
|
||||||
write stdout, n.count
|
write stdout, n.count
|
||||||
write stdout, " elements: "
|
write stdout, " elements: "
|
||||||
|
|
@ -219,7 +219,7 @@ proc traceTree[T,D](root: PNode[T,D]) =
|
||||||
else : write stdout, el.key
|
else : write stdout, el.key
|
||||||
if el.node != nil: doTrace(el.node, level +1)
|
if el.node != nil: doTrace(el.node, level +1)
|
||||||
else : write stdout, " empty "
|
else : write stdout, " empty "
|
||||||
writeln stdout,""
|
writeLine stdout,""
|
||||||
|
|
||||||
doTrace(root, 0)
|
doTrace(root, 0)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -50,8 +50,8 @@ proc main*(infile: string, a, b: int, someverylongnamewithtype = 0,
|
||||||
# this should be an error!
|
# this should be an error!
|
||||||
if initBaseLexer(L, infile, 30): nil
|
if initBaseLexer(L, infile, 30): nil
|
||||||
else:
|
else:
|
||||||
writeln(stdout, "could not open: " & infile)
|
writeLine(stdout, "could not open: " & infile)
|
||||||
writeln(stdout, "Success!")
|
writeLine(stdout, "Success!")
|
||||||
call(3, # we use 3
|
call(3, # we use 3
|
||||||
12, # we use 12
|
12, # we use 12
|
||||||
43) # we use 43
|
43) # we use 43
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ macro debug(n: varargs[expr]): stmt =
|
||||||
# add a call to the statement list that writes ": "
|
# add a call to the statement list that writes ": "
|
||||||
add(result, newCall("write", newIdentNode("stdout"), newStrLitNode(": ")))
|
add(result, newCall("write", newIdentNode("stdout"), newStrLitNode(": ")))
|
||||||
# add a call to the statement list that writes the expressions value:
|
# add a call to the statement list that writes the expressions value:
|
||||||
add(result, newCall("writeln", newIdentNode("stdout"), n[i]))
|
add(result, newCall("writeLine", newIdentNode("stdout"), n[i]))
|
||||||
|
|
||||||
var
|
var
|
||||||
a: array [0..10, int]
|
a: array [0..10, int]
|
||||||
|
|
|
||||||
|
|
@ -7,8 +7,8 @@ var
|
||||||
i: int
|
i: int
|
||||||
params = paramCount()
|
params = paramCount()
|
||||||
i = 0
|
i = 0
|
||||||
writeln(stdout, "This exe: " & getAppFilename())
|
writeLine(stdout, "This exe: " & getAppFilename())
|
||||||
writeln(stdout, "Number of parameters: " & $params)
|
writeLine(stdout, "Number of parameters: " & $params)
|
||||||
while i <= params:
|
while i <= params:
|
||||||
writeln(stdout, paramStr(i))
|
writeLine(stdout, paramStr(i))
|
||||||
i = i + 1
|
i = i + 1
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,3 @@
|
||||||
# test the new endian magic
|
# test the new endian magic
|
||||||
|
|
||||||
writeln(stdout, repr(system.cpuEndian))
|
writeLine(stdout, repr(system.cpuEndian))
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ macro macrotest(n: expr): stmt {.immediate.} =
|
||||||
result = newNimNode(nnkStmtList, n)
|
result = newNimNode(nnkStmtList, n)
|
||||||
for i in 2..n.len-1:
|
for i in 2..n.len-1:
|
||||||
result.add(newCall("write", n[1], n[i]))
|
result.add(newCall("write", n[1], n[i]))
|
||||||
result.add(newCall("writeln", n[1], newStrLitNode("")))
|
result.add(newCall("writeLine", n[1], newStrLitNode("")))
|
||||||
|
|
||||||
macro debug(n: expr): stmt {.immediate.} =
|
macro debug(n: expr): stmt {.immediate.} =
|
||||||
let n = callsite()
|
let n = callsite()
|
||||||
|
|
@ -30,7 +30,7 @@ macro debug(n: expr): stmt {.immediate.} =
|
||||||
for i in 1..n.len-1:
|
for i in 1..n.len-1:
|
||||||
result.add(newCall("write", newIdentNode("stdout"), toStrLit(n[i])))
|
result.add(newCall("write", newIdentNode("stdout"), toStrLit(n[i])))
|
||||||
result.add(newCall("write", newIdentNode("stdout"), newStrLitNode(": ")))
|
result.add(newCall("write", newIdentNode("stdout"), newStrLitNode(": ")))
|
||||||
result.add(newCall("writeln", newIdentNode("stdout"), n[i]))
|
result.add(newCall("writeLine", newIdentNode("stdout"), n[i]))
|
||||||
|
|
||||||
macrotest(stdout, "finally", 4, 5, "variable", "argument lists")
|
macrotest(stdout, "finally", 4, 5, "variable", "argument lists")
|
||||||
macrotest(stdout)
|
macrotest(stdout)
|
||||||
|
|
@ -38,7 +38,7 @@ macrotest(stdout)
|
||||||
#GC_disable()
|
#GC_disable()
|
||||||
|
|
||||||
echo("This was compiled by Nim version " & system.NimVersion)
|
echo("This was compiled by Nim version " & system.NimVersion)
|
||||||
writeln(stdout, "Hello", " World", "!")
|
writeLine(stdout, "Hello", " World", "!")
|
||||||
|
|
||||||
echo(["a", "b", "c", "d"].len)
|
echo(["a", "b", "c", "d"].len)
|
||||||
for x in items(["What's", "your", "name", "?", ]):
|
for x in items(["What's", "your", "name", "?", ]):
|
||||||
|
|
|
||||||
|
|
@ -8,8 +8,8 @@ proc main() =
|
||||||
a, b: TTime
|
a, b: TTime
|
||||||
a = getLastModificationTime(paramStr(1))
|
a = getLastModificationTime(paramStr(1))
|
||||||
b = getLastModificationTime(paramStr(2))
|
b = getLastModificationTime(paramStr(2))
|
||||||
writeln(stdout, $a)
|
writeLine(stdout, $a)
|
||||||
writeln(stdout, $b)
|
writeLine(stdout, $b)
|
||||||
if a < b:
|
if a < b:
|
||||||
write(stdout, "$2 is newer than $1\n" % [paramStr(1), paramStr(2)])
|
write(stdout, "$2 is newer than $1\n" % [paramStr(1), paramStr(2)])
|
||||||
else:
|
else:
|
||||||
|
|
|
||||||
|
|
@ -24,10 +24,10 @@ var size = parseInt (paramStr (1))
|
||||||
var bit = 128
|
var bit = 128
|
||||||
var byteAcc = 0
|
var byteAcc = 0
|
||||||
|
|
||||||
stdout.writeln ("P4")
|
stdout.writeLine ("P4")
|
||||||
stdout.write ($size)
|
stdout.write ($size)
|
||||||
stdout.write (" ")
|
stdout.write (" ")
|
||||||
stdout.writeln ($size)
|
stdout.writeLine ($size)
|
||||||
|
|
||||||
var fsize = float (size)
|
var fsize = float (size)
|
||||||
for y in 0 .. size-1:
|
for y in 0 .. size-1:
|
||||||
|
|
|
||||||
|
|
@ -9,4 +9,4 @@ var
|
||||||
x = 1
|
x = 1
|
||||||
y = high(int)
|
y = high(int)
|
||||||
|
|
||||||
writeln(stdout, $ ( x +% y ) )
|
writeLine(stdout, $ ( x +% y ) )
|
||||||
|
|
|
||||||
|
|
@ -91,9 +91,9 @@ proc t64(i: int64) =
|
||||||
toVarNum64(i, b)
|
toVarNum64(i, b)
|
||||||
var x = toNum64(b)
|
var x = toNum64(b)
|
||||||
if x != i:
|
if x != i:
|
||||||
writeln(stdout, $i)
|
writeLine(stdout, $i)
|
||||||
writeln(stdout, toBinary(i))
|
writeLine(stdout, toBinary(i))
|
||||||
writeln(stdout, toBinary(x))
|
writeLine(stdout, toBinary(x))
|
||||||
|
|
||||||
proc t32(i: int32) =
|
proc t32(i: int32) =
|
||||||
var
|
var
|
||||||
|
|
@ -101,8 +101,8 @@ proc t32(i: int32) =
|
||||||
toVarNum(i, b)
|
toVarNum(i, b)
|
||||||
var x = toNum(b)
|
var x = toNum(b)
|
||||||
if x != i:
|
if x != i:
|
||||||
writeln(stdout, toBinary(i))
|
writeLine(stdout, toBinary(i))
|
||||||
writeln(stdout, toBinary(x))
|
writeLine(stdout, toBinary(x))
|
||||||
|
|
||||||
proc tm(i: int32) =
|
proc tm(i: int32) =
|
||||||
var
|
var
|
||||||
|
|
@ -110,8 +110,8 @@ proc tm(i: int32) =
|
||||||
toVarNum64(i, b)
|
toVarNum64(i, b)
|
||||||
var x = toNum(b)
|
var x = toNum(b)
|
||||||
if x != i:
|
if x != i:
|
||||||
writeln(stdout, toBinary(i))
|
writeLine(stdout, toBinary(i))
|
||||||
writeln(stdout, toBinary(x))
|
writeLine(stdout, toBinary(x))
|
||||||
|
|
||||||
t32(0)
|
t32(0)
|
||||||
t32(1)
|
t32(1)
|
||||||
|
|
@ -137,6 +137,6 @@ tm(100_000)
|
||||||
tm(low(int32))
|
tm(low(int32))
|
||||||
tm(high(int32))
|
tm(high(int32))
|
||||||
|
|
||||||
writeln(stdout, "Success!") #OUT Success!
|
writeLine(stdout, "Success!") #OUT Success!
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ type
|
||||||
|
|
||||||
proc getPoint( p: var TPoint2d) =
|
proc getPoint( p: var TPoint2d) =
|
||||||
{.breakpoint.}
|
{.breakpoint.}
|
||||||
writeln(stdout, p.x)
|
writeLine(stdout, p.x)
|
||||||
|
|
||||||
var
|
var
|
||||||
p: TPoint3d
|
p: TPoint3d
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ type
|
||||||
TCircle = object of TFigure
|
TCircle = object of TFigure
|
||||||
radius: int
|
radius: int
|
||||||
|
|
||||||
proc drawCircle(my: var TCircle) = stdout.writeln("o " & $my.radius)
|
proc drawCircle(my: var TCircle) = stdout.writeLine("o " & $my.radius)
|
||||||
|
|
||||||
proc init(my: var TCircle) =
|
proc init(my: var TCircle) =
|
||||||
init(TFigure(my)) # call base constructor
|
init(TFigure(my)) # call base constructor
|
||||||
|
|
|
||||||
|
|
@ -11,9 +11,9 @@ var
|
||||||
a = high(int)
|
a = high(int)
|
||||||
b = -2
|
b = -2
|
||||||
try:
|
try:
|
||||||
writeln(stdout, b - a)
|
writeLine(stdout, b - a)
|
||||||
except OverflowError:
|
except OverflowError:
|
||||||
writeln(stdout, "the computation overflowed")
|
writeLine(stdout, "the computation overflowed")
|
||||||
|
|
||||||
{.pop.} # overflow check
|
{.pop.} # overflow check
|
||||||
#OUT the computation overflowed
|
#OUT the computation overflowed
|
||||||
|
|
|
||||||
|
|
@ -58,7 +58,7 @@ for x in low(TAZ) .. high(TAZ):
|
||||||
for x in low(TTokTypeRange) .. high(TTokTypeRange):
|
for x in low(TTokTypeRange) .. high(TTokTypeRange):
|
||||||
if x in tokTypes:
|
if x in tokTypes:
|
||||||
discard
|
discard
|
||||||
#writeln(stdout, "the token '$1' is in the set" % repr(x))
|
#writeLine(stdout, "the token '$1' is in the set" % repr(x))
|
||||||
|
|
||||||
#OUT Ha ein F ist in s!
|
#OUT Ha ein F ist in s!
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,6 @@
|
||||||
|
|
||||||
proc main() =
|
proc main() =
|
||||||
for line in lines("thello.nim"):
|
for line in lines("thello.nim"):
|
||||||
writeln(stdout, line)
|
writeLine(stdout, line)
|
||||||
|
|
||||||
main()
|
main()
|
||||||
|
|
|
||||||
|
|
@ -4,10 +4,10 @@ import
|
||||||
parseopt
|
parseopt
|
||||||
|
|
||||||
proc writeHelp() =
|
proc writeHelp() =
|
||||||
writeln(stdout, "Usage: tparsopt [options] filename [options]")
|
writeLine(stdout, "Usage: tparsopt [options] filename [options]")
|
||||||
|
|
||||||
proc writeVersion() =
|
proc writeVersion() =
|
||||||
writeln(stdout, "Version: 1.0.0")
|
writeLine(stdout, "Version: 1.0.0")
|
||||||
|
|
||||||
var
|
var
|
||||||
filename = ""
|
filename = ""
|
||||||
|
|
@ -20,7 +20,7 @@ for kind, key, val in getopt():
|
||||||
of "help", "h": writeHelp()
|
of "help", "h": writeHelp()
|
||||||
of "version", "v": writeVersion()
|
of "version", "v": writeVersion()
|
||||||
else:
|
else:
|
||||||
writeln(stdout, "Unknown command line option: ", key, ": ", val)
|
writeLine(stdout, "Unknown command line option: ", key, ": ", val)
|
||||||
of cmdEnd: assert(false) # cannot happen
|
of cmdEnd: assert(false) # cannot happen
|
||||||
if filename == "":
|
if filename == "":
|
||||||
# no filename has been given, so we show the help:
|
# no filename has been given, so we show the help:
|
||||||
|
|
|
||||||
|
|
@ -981,7 +981,7 @@ iterator split*(s: string, sep: TPeg): string =
|
||||||
##
|
##
|
||||||
## .. code-block:: nim
|
## .. code-block:: nim
|
||||||
## for word in split("00232this02939is39an22example111", peg"\d+"):
|
## for word in split("00232this02939is39an22example111", peg"\d+"):
|
||||||
## writeln(stdout, word)
|
## writeLine(stdout, word)
|
||||||
##
|
##
|
||||||
## Results in:
|
## Results in:
|
||||||
##
|
##
|
||||||
|
|
@ -1682,7 +1682,7 @@ when isMainModule:
|
||||||
doAssert "ABC".match(peg"\d+ / \w+")
|
doAssert "ABC".match(peg"\d+ / \w+")
|
||||||
|
|
||||||
for word in split("00232this02939is39an22example111", peg"\d+"):
|
for word in split("00232this02939is39an22example111", peg"\d+"):
|
||||||
writeln(stdout, word)
|
writeLine(stdout, word)
|
||||||
|
|
||||||
doAssert matchLen("key", ident) == 3
|
doAssert matchLen("key", ident) == 3
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,8 +9,8 @@ when not defined(windows):
|
||||||
|
|
||||||
discard uname(u)
|
discard uname(u)
|
||||||
|
|
||||||
writeln(stdout, u.sysname)
|
writeLine(stdout, u.sysname)
|
||||||
writeln(stdout, u.nodename)
|
writeLine(stdout, u.nodename)
|
||||||
writeln(stdout, u.release)
|
writeLine(stdout, u.release)
|
||||||
writeln(stdout, u.machine)
|
writeLine(stdout, u.machine)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ type
|
||||||
|
|
||||||
var val = {a, b}
|
var val = {a, b}
|
||||||
stdout.write(repr(val))
|
stdout.write(repr(val))
|
||||||
stdout.writeln(repr({'a'..'z', 'A'..'Z'}))
|
stdout.writeLine(repr({'a'..'z', 'A'..'Z'}))
|
||||||
|
|
||||||
type
|
type
|
||||||
TObj {.pure, inheritable.} = object
|
TObj {.pure, inheritable.} = object
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ q[] = p
|
||||||
|
|
||||||
s = @[q, q, q, q]
|
s = @[q, q, q, q]
|
||||||
|
|
||||||
writeln(stdout, repr(p))
|
writeLine(stdout, repr(p))
|
||||||
writeln(stdout, repr(q))
|
writeLine(stdout, repr(q))
|
||||||
writeln(stdout, repr(s))
|
writeLine(stdout, repr(s))
|
||||||
writeln(stdout, repr(en4))
|
writeLine(stdout, repr(en4))
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ for i in 0..80:
|
||||||
tab["key_" & $i] = "value" & $i
|
tab["key_" & $i] = "value" & $i
|
||||||
|
|
||||||
for key, val in pairs(tab):
|
for key, val in pairs(tab):
|
||||||
writeln(stdout, key, ": ", val)
|
writeLine(stdout, key, ": ", val)
|
||||||
writeln(stdout, "length of table ", $tab.len)
|
writeLine(stdout, "length of table ", $tab.len)
|
||||||
|
|
||||||
writeln(stdout, `%`("$key1 = $key2; ${PATH}", tab, {useEnvironment}))
|
writeLine(stdout, `%`("$key1 = $key2; ${PATH}", tab, {useEnvironment}))
|
||||||
|
|
|
||||||
|
|
@ -5,9 +5,9 @@ import
|
||||||
|
|
||||||
proc main(filter: string) =
|
proc main(filter: string) =
|
||||||
for filename in walkFiles(filter):
|
for filename in walkFiles(filter):
|
||||||
writeln(stdout, filename)
|
writeLine(stdout, filename)
|
||||||
|
|
||||||
for key, val in envPairs():
|
for key, val in envPairs():
|
||||||
writeln(stdout, key & '=' & val)
|
writeLine(stdout, key & '=' & val)
|
||||||
|
|
||||||
main("*.nim")
|
main("*.nim")
|
||||||
|
|
|
||||||
|
|
@ -15,10 +15,10 @@ var abclev = levB
|
||||||
|
|
||||||
template tstLev(abclev: TLev) =
|
template tstLev(abclev: TLev) =
|
||||||
bind tstempl.abclev, `%`
|
bind tstempl.abclev, `%`
|
||||||
writeln(stdout, "global = $1, arg = $2, test = $3" % [
|
writeLine(stdout, "global = $1, arg = $2, test = $3" % [
|
||||||
$tstempl.abclev, $abclev, $(tstempl.abclev == abclev)])
|
$tstempl.abclev, $abclev, $(tstempl.abclev == abclev)])
|
||||||
# evaluates to true, but must be false
|
# evaluates to true, but must be false
|
||||||
|
|
||||||
|
|
||||||
tstLev(levA)
|
tstLev(levA)
|
||||||
writeln(stdout, $abclev)
|
writeLine(stdout, $abclev)
|
||||||
|
|
|
||||||
|
|
@ -13,8 +13,8 @@ template withOpenFile(f: expr, filename: string, mode: TFileMode,
|
||||||
quit("cannot open for writing: " & filename)
|
quit("cannot open for writing: " & filename)
|
||||||
|
|
||||||
withOpenFile(txt, "ttempl3.txt", fmWrite):
|
withOpenFile(txt, "ttempl3.txt", fmWrite):
|
||||||
writeln(txt, "line 1")
|
writeLine(txt, "line 1")
|
||||||
txt.writeln("line 2")
|
txt.writeLine("line 2")
|
||||||
|
|
||||||
var
|
var
|
||||||
myVar: array[0..1, int]
|
myVar: array[0..1, int]
|
||||||
|
|
|
||||||
|
|
@ -137,11 +137,11 @@ proc doScenario(script: string, output: Stream, mode: TRunMode, verbose: bool):
|
||||||
if line.strip.len == 0: continue
|
if line.strip.len == 0: continue
|
||||||
|
|
||||||
if line.startsWith("#"):
|
if line.startsWith("#"):
|
||||||
output.writeln line
|
output.writeLine line
|
||||||
continue
|
continue
|
||||||
elif line.startsWith(">"):
|
elif line.startsWith(">"):
|
||||||
s.doCommand(line.substr(1).strip)
|
s.doCommand(line.substr(1).strip)
|
||||||
output.writeln line, "\n", if verbose: s.lastOutput else: ""
|
output.writeLine line, "\n", if verbose: s.lastOutput else: ""
|
||||||
else:
|
else:
|
||||||
var expectMatch = true
|
var expectMatch = true
|
||||||
var pattern = s.replaceVars(line)
|
var pattern = s.replaceVars(line)
|
||||||
|
|
@ -153,9 +153,9 @@ proc doScenario(script: string, output: Stream, mode: TRunMode, verbose: bool):
|
||||||
s.lastOutput.find(re(pattern, flags = {reStudy})) != -1
|
s.lastOutput.find(re(pattern, flags = {reStudy})) != -1
|
||||||
|
|
||||||
if expectMatch == actualMatch:
|
if expectMatch == actualMatch:
|
||||||
output.writeln "SUCCESS ", line
|
output.writeLine "SUCCESS ", line
|
||||||
else:
|
else:
|
||||||
output.writeln "FAILURE ", line
|
output.writeLine "FAILURE ", line
|
||||||
result = false
|
result = false
|
||||||
|
|
||||||
iterator caasTestsRunner*(filter = "", verbose = false): tuple[test,
|
iterator caasTestsRunner*(filter = "", verbose = false): tuple[test,
|
||||||
|
|
|
||||||
|
|
@ -138,7 +138,7 @@ proc generateHtml*(filename: string, commit: int; onlyFailing: bool) =
|
||||||
# generate navigation:
|
# generate navigation:
|
||||||
outfile.write("""<ul id="tabs">""")
|
outfile.write("""<ul id="tabs">""")
|
||||||
for m in db.rows(sql"select id, name, os, cpu from Machine order by id"):
|
for m in db.rows(sql"select id, name, os, cpu from Machine order by id"):
|
||||||
outfile.writeln """<li><a href="#$#">$#: $#, $#</a></li>""" % m
|
outfile.writeLine """<li><a href="#$#">$#: $#, $#</a></li>""" % m
|
||||||
outfile.write("</ul>")
|
outfile.write("</ul>")
|
||||||
|
|
||||||
for currentMachine in db.rows(sql"select id from Machine order by id"):
|
for currentMachine in db.rows(sql"select id from Machine order by id"):
|
||||||
|
|
@ -195,7 +195,7 @@ proc generateJson*(filename: string, commit: int) =
|
||||||
let machine = $backend.getMachine(db)
|
let machine = $backend.getMachine(db)
|
||||||
let data = db.getRow(sql(selRow), lastCommit, machine)
|
let data = db.getRow(sql(selRow), lastCommit, machine)
|
||||||
|
|
||||||
outfile.writeln("""{"total": $#, "passed": $#, "skipped": $#""" % data)
|
outfile.writeLine("""{"total": $#, "passed": $#, "skipped": $#""" % data)
|
||||||
|
|
||||||
let results = newJArray()
|
let results = newJArray()
|
||||||
for row in db.rows(sql(selResults), lastCommit):
|
for row in db.rows(sql(selResults), lastCommit):
|
||||||
|
|
@ -208,7 +208,7 @@ proc generateJson*(filename: string, commit: int) =
|
||||||
obj["expected"] = %row[5]
|
obj["expected"] = %row[5]
|
||||||
obj["given"] = %row[6]
|
obj["given"] = %row[6]
|
||||||
results.add(obj)
|
results.add(obj)
|
||||||
outfile.writeln(""", "results": """)
|
outfile.writeLine(""", "results": """)
|
||||||
outfile.write(results.pretty)
|
outfile.write(results.pretty)
|
||||||
|
|
||||||
if not previousCommit.isNil:
|
if not previousCommit.isNil:
|
||||||
|
|
@ -220,9 +220,9 @@ proc generateJson*(filename: string, commit: int) =
|
||||||
obj["old"] = %row[1]
|
obj["old"] = %row[1]
|
||||||
obj["new"] = %row[2]
|
obj["new"] = %row[2]
|
||||||
diff.add obj
|
diff.add obj
|
||||||
outfile.writeln(""", "diff": """)
|
outfile.writeLine(""", "diff": """)
|
||||||
outfile.writeln(diff.pretty)
|
outfile.writeLine(diff.pretty)
|
||||||
|
|
||||||
outfile.writeln "}"
|
outfile.writeLine "}"
|
||||||
close(db)
|
close(db)
|
||||||
close(outfile)
|
close(outfile)
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,6 @@ discard """
|
||||||
|
|
||||||
proc f(x: varargs[string, `$`]) = discard
|
proc f(x: varargs[string, `$`]) = discard
|
||||||
template optF{f(x)}(x: varargs[expr]) =
|
template optF{f(x)}(x: varargs[expr]) =
|
||||||
writeln(stdout, x)
|
writeLine(stdout, x)
|
||||||
|
|
||||||
f 1, 2, false, 3, "ha"
|
f 1, 2, false, 3, "ha"
|
||||||
|
|
|
||||||
|
|
@ -7,13 +7,13 @@ discard """
|
||||||
|
|
||||||
template optWrite{
|
template optWrite{
|
||||||
write(f, x)
|
write(f, x)
|
||||||
((write|writeln){w})(f, y)
|
((write|writeLine){w})(f, y)
|
||||||
}(x, y: varargs[expr], f, w: expr) =
|
}(x, y: varargs[expr], f, w: expr) =
|
||||||
w(f, "|", x, y, "|")
|
w(f, "|", x, y, "|")
|
||||||
|
|
||||||
if true:
|
if true:
|
||||||
echo "0"
|
echo "0"
|
||||||
write stdout, "1"
|
write stdout, "1"
|
||||||
writeln stdout, "2"
|
writeLine stdout, "2"
|
||||||
write stdout, "3"
|
write stdout, "3"
|
||||||
echo "4"
|
echo "4"
|
||||||
|
|
|
||||||
|
|
@ -19,9 +19,9 @@ proc process(dir, infile: string, outfile: File,
|
||||||
ig <- (comment / \s+)* """:
|
ig <- (comment / \s+)* """:
|
||||||
# follow the include file:
|
# follow the include file:
|
||||||
if process(dir, matches[0], outfile, processed) == prAddIncludeDir:
|
if process(dir, matches[0], outfile, processed) == prAddIncludeDir:
|
||||||
writeln(outfile, line)
|
writeLine(outfile, line)
|
||||||
else:
|
else:
|
||||||
writeln(outfile, line)
|
writeLine(outfile, line)
|
||||||
|
|
||||||
proc main(dir, outfile: string) =
|
proc main(dir, outfile: string) =
|
||||||
var o: File
|
var o: File
|
||||||
|
|
|
||||||
|
|
@ -119,7 +119,7 @@ proc processFile(filename: string) =
|
||||||
var filenameShown = false
|
var filenameShown = false
|
||||||
template beforeHighlight =
|
template beforeHighlight =
|
||||||
if not filenameShown and optVerbose notin options:
|
if not filenameShown and optVerbose notin options:
|
||||||
stdout.writeln(filename)
|
stdout.writeLine(filename)
|
||||||
filenameShown = true
|
filenameShown = true
|
||||||
|
|
||||||
var buffer: string
|
var buffer: string
|
||||||
|
|
@ -128,7 +128,7 @@ proc processFile(filename: string) =
|
||||||
except IOError:
|
except IOError:
|
||||||
echo "cannot open file: ", filename
|
echo "cannot open file: ", filename
|
||||||
return
|
return
|
||||||
if optVerbose in options: stdout.writeln(filename)
|
if optVerbose in options: stdout.writeLine(filename)
|
||||||
var pegp: TPeg
|
var pegp: TPeg
|
||||||
var rep: Regex
|
var rep: Regex
|
||||||
var result: string
|
var result: string
|
||||||
|
|
|
||||||
|
|
@ -431,7 +431,7 @@ proc buildWebsite(c: var TConfigData) =
|
||||||
if not existsDir("web/upload"):
|
if not existsDir("web/upload"):
|
||||||
createDir("web/upload")
|
createDir("web/upload")
|
||||||
if open(f, outfile, fmWrite):
|
if open(f, outfile, fmWrite):
|
||||||
writeln(f, generateHTMLPage(c, file, content, rss))
|
writeLine(f, generateHTMLPage(c, file, content, rss))
|
||||||
close(f)
|
close(f)
|
||||||
else:
|
else:
|
||||||
quit("[Error] cannot write file: " & outfile)
|
quit("[Error] cannot write file: " & outfile)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue