Rename to Nim

This commit is contained in:
Flaviu Tamas 2014-12-11 17:04:49 -05:00
commit 2bd2af6e1c
25 changed files with 64 additions and 64 deletions

View file

@ -1,5 +1,5 @@
[![wercker status](https://app.wercker.com/status/389477226e537a45143ea91336dca281/m "wercker status")](https://app.wercker.com/project/bykey/389477226e537a45143ea91336dca281) [![wercker status](https://app.wercker.com/status/389477226e537a45143ea91336dca281/m "wercker status")](https://app.wercker.com/project/bykey/389477226e537a45143ea91336dca281)
This repo contains the sources for the Nimrod by Example book. This repo contains the sources for the Nim by Example book.
If you'd like, use `nanoc` to build. However, its easiest to simply write things and wait for the webpage at http://nimrod-by-example.github.io/ to update, courtesy of the people at wercker. If you'd like, use `nanoc` to build. However, its easiest to simply write things and wait for the webpage at http://nim-by-example.github.io/ to update, courtesy of the people at wercker.

View file

@ -4,7 +4,7 @@ title: Arrays
# Arrays # Arrays
The arrays in Nimrod are like classic C arrays, their size is specified at compile-time and cannot given or changed at runtime. The arrays in Nim are like classic C arrays, their size is specified at compile-time and cannot given or changed at runtime.
``` nimrod ``` nimrod
type type
@ -57,7 +57,7 @@ echo mat1 + mat2
``` ```
``` console ``` console
$ nimrod c -r matrix.nim $ nim c -r matrix.nim
1, 1, 1, 1,
1, 1, 1, 1,

View file

@ -4,7 +4,7 @@ title: Bitsets
# Bitsets # Bitsets
Nimrod comes with a built in way to build a set of ordinal types. In order for a type to be usable in a bitset, it must be an ordinal and <<\texttt{high(T)} < 2^{16}>>. For sets of non-ordinal types, see the [sets module](http://nimrod-lang.org/sets.html), which contains hashsets. Nim comes with a built in way to build a set of ordinal types. In order for a type to be usable in a bitset, it must be an ordinal and <<\texttt{high(T)} < 2^{16}>>. For sets of non-ordinal types, see the [sets module](http://nim-lang.org/sets.html), which contains hashsets.
However, best practice is to keep bitset size significantly smaller since each possible element in the set consumes one bit, therefore a bitset of <<2^{16}>> elements will consume 64KiB. However, best practice is to keep bitset size significantly smaller since each possible element in the set consumes one bit, therefore a bitset of <<2^{16}>> elements will consume 64KiB.

View file

@ -21,7 +21,7 @@ block:
let b = "3" # shadowing is probably a dumb idea let b = "3" # shadowing is probably a dumb idea
``` ```
Parentheses can be used as an expression, but they do not provide end of statement inference, so it is necessary to place semicolons yourself. An interesting and unexpected side effect of this syntax is that Nimrod is suitable even for brace purists! Parentheses can be used as an expression, but they do not provide end of statement inference, so it is necessary to place semicolons yourself. An interesting and unexpected side effect of this syntax is that Nim is suitable even for brace purists!
``` nimrod ``` nimrod
proc square(inSeq: seq[float]): seq[float] = ( proc square(inSeq: seq[float]): seq[float] = (

View file

@ -3,7 +3,7 @@ title: Case Statements
--- ---
# Case Statements # Case Statements
Nimrod also supports case statements, which are like switches in other languages. There are several things to note here: Nim also supports case statements, which are like switches in other languages. There are several things to note here:
* You can use strings in the switch statement * You can use strings in the switch statement
* Sets and ranges of ordinal types are also usable * Sets and ranges of ordinal types are also usable
@ -44,7 +44,7 @@ echo positiveOrNegative(-1)
``` ```
``` console ``` console
$ nimrod c -r ./case_stmts.nim $ nim c -r ./case_stmts.nim
C C
Consonant Consonant
negative negative
@ -61,6 +61,6 @@ case (x and 3) + 7:
of 10: echo "D" of 10: echo "D"
``` ```
``` console ``` console
$ nimrod c -r ./case_stmts_1.nim $ nim c -r ./case_stmts_1.nim
C C
``` ```

View file

@ -3,11 +3,11 @@ title: For Loops & Iterators
--- ---
# For Loops & Iterators # For Loops & Iterators
Nimrod has first class iterators and syntax to use them, for loops. The `continue` and `break` keywords also work inside of for loops. There are two kinds of iterator, and two special methods that for loops work with. Nim has first class iterators and syntax to use them, for loops. The `continue` and `break` keywords also work inside of for loops. There are two kinds of iterator, and two special methods that for loops work with.
## `items` and `pair` ## `items` and `pair`
When iterating over an object with one item, Nimrod will call an iterator called `items` with the first parameter the type you want to iterate over. The same thing happens when iterating with two items, but in that case, the `pairs` iterator is called. When iterating over an object with one item, Nim will call an iterator called `items` with the first parameter the type you want to iterate over. The same thing happens when iterating with two items, but in that case, the `pairs` iterator is called.
``` nimrod ``` nimrod
type type
@ -29,7 +29,7 @@ for i, c in TRange(low: 1, high: 3):
echo c echo c
``` ```
``` console ``` console
$ nimrod c -r items_pair.nim $ nim c -r items_pair.nim
b b
c c
d d
@ -50,7 +50,7 @@ for i in 0...5:
echo i echo i
``` ```
``` console ``` console
$ nimrod c -r operatoriterator.nim $ nim c -r operatoriterator.nim
0 0
1 1
2 2
@ -73,7 +73,7 @@ for i in countTo(5):
echo i echo i
``` ```
```console ```console
$ nimrod c -r ./inline_iter.nim $ nim c -r ./inline_iter.nim
0 0
1 1
2 2
@ -118,7 +118,7 @@ for i in countTo9():
echo output echo output
``` ```
```console ```console
$ nimrod c -r ./closure_iter.nim $ nim c -r ./closure_iter.nim
0 0
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
0123456789 0123456789

View file

@ -2,10 +2,10 @@
title: Getting Started title: Getting Started
--- ---
# Getting Started # Getting Started
When installing Nimrod, you have two options: downloading a copy directly from git, or downloading a prepackaged distribution from the website When installing Nim, you have two options: downloading a copy directly from git, or downloading a prepackaged distribution from the website
## Downloading a Nimrod Distribution ## Downloading a Nim Distribution
To get started with Nimrod, head over to the [downloads page](http://nimrod-lang.org/download.html) and download the version you'd like. To get started with Nim, head over to the [downloads page](http://nim-lang.org/download.html) and download the version you'd like.
The Windows distribution comes with the MinGW compiler, which is recommended, but if you'd like to use your own compiler, download the version without MinGW. The Windows distribution comes with the MinGW compiler, which is recommended, but if you'd like to use your own compiler, download the version without MinGW.
@ -13,23 +13,23 @@ On Mac and Linux, it is recommended to use either GCC or Clang.
| | i386 | amd64 | | | i386 | amd64 |
| -- | ---- | ----- | | -- | ---- | ----- |
| Windows | [Download](http://nimrod-lang.org/download/nimrod_0.9.4_windows_i386_full.zip) ([w/o MinGW](http://nimrod-lang.org/download/nimrod_0.9.4_windows_i386_slim.zip))| [Download](http://nimrod-lang.org/download/nimrod_0.9.4_windows_amd64_full.zip) ([w/o MinGW](http://nimrod-lang.org/download/nimrod_0.9.4_windows_amd64_slim.zip)) | | Windows | [Download](http://nim-lang.org/download/nim_0.9.4_windows_i386_full.zip) ([w/o MinGW](http://nim-lang.org/download/nim_0.9.4_windows_i386_slim.zip))| [Download](http://nim-lang.org/download/nim_0.9.4_windows_amd64_full.zip) ([w/o MinGW](http://nim-lang.org/download/nim_0.9.4_windows_amd64_slim.zip)) |
| Mac | NA | [Download](http://nimrod-lang.org/download/nimrod_0.9.4_macosx_amd64.zip) | | Mac | NA | [Download](http://nim-lang.org/download/nim_0.9.4_macosx_amd64.zip) |
| Linux | [Download](http://nimrod-lang.org/download/nimrod_0.9.4_linux_i386.tar.gz) | [Download](http://nimrod-lang.org/download/nimrod_0.9.4_linux_amd64.tar.gz) | | Linux | [Download](http://nim-lang.org/download/nim_0.9.4_linux_i386.tar.gz) | [Download](http://nim-lang.org/download/nim_0.9.4_linux_amd64.tar.gz) |
Once you have downloaded the appropriate distribution and extracted the files somewhere convenient, feel free to place the `bin` directory in the path for easier access. Once you have downloaded the appropriate distribution and extracted the files somewhere convenient, feel free to place the `bin` directory in the path for easier access.
## Downloading from Git ## Downloading from Git
To install Nimrod from git, ensure that you have gcc installed on Windows, Linux, and BSDs and clang on Mac. Afterwards, run the following series of commands to download and bootstrap Nimrod: To install Nim from git, ensure that you have gcc installed on Windows, Linux, and BSDs and clang on Mac. Afterwards, run the following series of commands to download and bootstrap Nim:
```console ```console
$ git clone -b master git://github.com/Araq/Nimrod.git $ git clone -b master git://github.com/Araq/Nim.git
$ cd Nimrod $ cd Nim
$ git clone --depth 1 git://github.com/nimrod-code/csources $ git clone --depth 1 git://github.com/nim-code/csources
$ cd csources $ cd csources
$ sh build.sh # Replace with build.bat on windows $ sh build.sh # Replace with build.bat on windows
$ cd .. $ cd ..
$ bin/nimrod c koch $ bin/nim c koch
$ ./koch boot -d:release $ ./koch boot -d:release
``` ```

View file

@ -12,13 +12,13 @@ echo "Hello World"
Save this text as `helloworld.nim`. To compile and execute the program, the following command should be run Save this text as `helloworld.nim`. To compile and execute the program, the following command should be run
``` console ``` console
$ nimrod c -r --verbosity:0 helloworld.nim $ nim c -r --verbosity:0 helloworld.nim
Hello World Hello World
``` ```
The command has several elements: The command has several elements:
* `c` is an alias for `compile`, which compiles the Nimrod sources into C and then invokes the C compiler on them * `c` is an alias for `compile`, which compiles the Nim sources into C and then invokes the C compiler on them
* `-r` is an alias for `--run`, which runs the program * `-r` is an alias for `--run`, which runs the program
* `--verbosity:0` makes the compiler only output essential messages, since by default it also outputs some debugging messages. From now on, we assume that `--verbosity:0` is set * `--verbosity:0` makes the compiler only output essential messages, since by default it also outputs some debugging messages. From now on, we assume that `--verbosity:0` is set
* `./helloworld.nim` is the path to the source you want to compile * `./helloworld.nim` is the path to the source you want to compile

View file

@ -4,13 +4,13 @@ title: If, Else, While
# If, Else, While # If, Else, While
Nimrod has many different control flow constructs, including the standard `if`s, `else`s, and `while`s. However, Nimrod does not use an `else if` construct like many languages, it uses a more condensed `elif`. Nim has many different control flow constructs, including the standard `if`s, `else`s, and `while`s. However, Nim does not use an `else if` construct like many languages, it uses a more condensed `elif`.
When inside a loop, `continue` can be used to skip the rest of the loop body and to begin the next iteration; `break` can be used to immediately leave the loop body. When inside a loop, `continue` can be used to skip the rest of the loop body and to begin the next iteration; `break` can be used to immediately leave the loop body.
Along with [its other uses](/block/), the `block` statement can be used to create a label so that it's possible to break out of nested loops. Along with [its other uses](/block/), the `block` statement can be used to create a label so that it's possible to break out of nested loops.
<!--skip-->``` nimrod <!--skip-->``` nim
import strutils, math import strutils, math
randomize() randomize()

View file

@ -2,15 +2,15 @@
title: Main title: Main
--- ---
# Nimrod by Example # Nim by Example
[Nimrod] is a powerful statically typed language that allows the programmer expressiveness without compromising run-time performance. As a general purpose programming language, it gives the same sort of power and performance as C++, but in a nicer package and with even more powerful tools! [Nim] is a powerful statically typed language that allows the programmer expressiveness without compromising run-time performance. As a general purpose programming language, it gives the same sort of power and performance as C++, but in a nicer package and with even more powerful tools!
[Nimrod]: http://nimrod-lang.org/ [Nim]: http://nim-lang.org/
Getting started? Head over to the [installation instructions](/getting_started/)! Getting started? Head over to the [installation instructions](/getting_started/)!
<!--skip-->``` nimrod <!--skip-->``` nim
import tables, strutils import tables, strutils
var wordFrequencies = initCountTable[string]() var wordFrequencies = initCountTable[string]()

View file

@ -32,7 +32,7 @@ for a in animals:
echo a.ageHumanYrs() echo a.ageHumanYrs()
``` ```
``` console ``` console
$ nimrod c -r oop.nim $ nim c -r oop.nim
woof woof
70 70
meow meow

View file

@ -4,7 +4,7 @@ title: OOP Macro
<!--- Thanks to fowl for creating this page, filwit for fixing some oddities --> <!--- Thanks to fowl for creating this page, filwit for fixing some oddities -->
# OOP Macro # OOP Macro
This is the code that we currently must write to use OOP in Nimrod: This is the code that we currently must write to use OOP in Nim:
```nimrod ```nimrod
type Animal = ref object of TObject type Animal = ref object of TObject
@ -47,7 +47,7 @@ macro class*(head: expr, body: stmt): stmt {.immediate.} =
# The macro is immediate so that it doesn't # The macro is immediate so that it doesn't
# resolve identifiers passed to it # resolve identifiers passed to it
var typeName, baseName: PNimrodNode var typeName, baseName: PNimNode
if head.kind == NnkIdent: if head.kind == NnkIdent:
# `head` is expression `typeName` # `head` is expression `typeName`
@ -222,7 +222,7 @@ for a in animals:
echo a.age_human_yrs() echo a.age_human_yrs()
``` ```
``` console ``` console
$ nimrod c -r oopmacro.nim $ nim c -r oopmacro.nim
woof woof
70 70
meow meow

View file

@ -7,9 +7,9 @@ The following code depends on the ``opengl`` and ``nim-glfw`` packages which
can be installed via babel by executing ``babel install opengl@#head nim-glfw@#head``. can be installed via babel by executing ``babel install opengl@#head nim-glfw@#head``.
You will need the GLFW DLL in order to run this on Windows. You will need the GLFW DLL in order to run this on Windows.
![Triangle Windows](https://nimrod-by-example.github.io/images/triangle.png) ![Triangle Windows](https://nim-by-example.github.io/images/triangle.png)
One thing to keep in mind when writing OpenGL code in Nimrod is that ``float`` One thing to keep in mind when writing OpenGL code in Nim is that ``float``
is actually ``float64``. But vertices must be ``float32`` so you must explicitly is actually ``float64``. But vertices must be ``float32`` so you must explicitly
specify that by casting or using ``'f32`` as is done in the example. specify that by casting or using ``'f32`` as is done in the example.

View file

@ -3,7 +3,7 @@ title: Primitives
--- ---
# Primitives # Primitives
Nimrod has several primitive types: Nim has several primitive types:
* signed integers: `int8`, `int16`, `int32`, `int64`, and `int`, where `int` is the same size as a pointer * signed integers: `int8`, `int16`, `int32`, `int64`, and `int`, where `int` is the same size as a pointer
* unsigned integers are similar with `u` prepended to the type * unsigned integers are similar with `u` prepended to the type
@ -31,7 +31,7 @@ let
echo 4/2 echo 4/2
``` ```
``` console ``` console
$ nimrod c -r numbers2.nim $ nim c -r numbers2.nim
2.0 2.0
``` ```
Another difference that may be surprising is that the `/` operator returns a floating point result, even when the operands are integers. If integer division is needed, the `div` operator should be used. Another difference that may be surprising is that the `/` operator returns a floating point result, even when the operands are integers. If integer division is needed, the `div` operator should be used.

View file

@ -3,7 +3,7 @@ title: Procs
--- ---
# Procs # Procs
Procedures in Nimrod are declared using `proc` and require that their parameter and return types be annotated. After the types and parameters, an `=` is used to denote the start of the function body. Another thing to note is that procedures have uniform function call syntax, which means that they can called as both `foo(a, b)` or `a.foo(b)`. Procedures in Nim are declared using `proc` and require that their parameter and return types be annotated. After the types and parameters, an `=` is used to denote the start of the function body. Another thing to note is that procedures have uniform function call syntax, which means that they can called as both `foo(a, b)` or `a.foo(b)`.
``` nimrod ``` nimrod
proc fibonacci(n: int): int = proc fibonacci(n: int): int =
@ -30,7 +30,7 @@ echo bar() # will not compile
## Side effect analyses ## Side effect analyses
Nimrod provides support for functional programming and so includes the `{.noSideEffect.}` pragma, which statically ensures there are no side effects. Nim provides support for functional programming and so includes the `{.noSideEffect.}` pragma, which statically ensures there are no side effects.
``` nimrod ``` nimrod
proc sum(x, y: int): int {. noSideEffect .} = proc sum(x, y: int): int {. noSideEffect .} =

View file

@ -4,7 +4,7 @@ title: First Class Functions
# First Class Functions # First Class Functions
Nimrod supports closures as well as passing functions. Two different syntaxes available for closures, proc syntax, which is identical to regular procedure syntax, and "do notation", which is a bit shorter. Nim supports closures as well as passing functions. Two different syntaxes available for closures, proc syntax, which is identical to regular procedure syntax, and "do notation", which is a bit shorter.
``` nimrod ``` nimrod
import sequtils import sequtils
@ -15,7 +15,7 @@ echo powersOfTwo.filter do (x: int) -> bool : x > 32
echo powersOfTwo.filter(proc (x: int): bool = x > 32) echo powersOfTwo.filter(proc (x: int): bool = x > 32)
``` ```
``` console ``` console
$ nimrod c -r filterclosure.nim $ nim c -r filterclosure.nim
@[64, 128, 256] @[64, 128, 256]
@[64, 128, 256] @[64, 128, 256]
``` ```

View file

@ -20,7 +20,7 @@ echo r" "" "
echo re"\b[a-z]++\b" echo re"\b[a-z]++\b"
``` ```
``` console ``` console
$ nimrod c -r strings.nim $ nim c -r strings.nim
words words words ⚑ words words words ⚑
<html> <html>
<head> <head>

View file

@ -2,7 +2,7 @@
title: Enums title: Enums
--- ---
# Enums # Enums
Enums in Nimrod are like enums in C, but are type-checked. There are no anonymous enums in Nimrod. Enums in Nim are like enums in C, but are type-checked. There are no anonymous enums in Nim.
``` nimrod ``` nimrod
type type
@ -34,7 +34,7 @@ dec ordinal
echo high(char) echo high(char)
``` ```
```console ```console
$ nimrod c -r enums.nim $ nim c -r enums.nim
cdNorth ord: 0 cdNorth ord: 0
cdEast ord: 1 cdEast ord: 1
cdSouth ord: 2 cdSouth ord: 2

View file

@ -3,7 +3,7 @@ title: Objects
--- ---
# Objects # Objects
In Nimrod, objects are like structs from C family languages and define a grouping of fields. They are by default traced by the garbage collector, so there is no need to explicitly free them when allocated. In Nim, objects are like structs from C family languages and define a grouping of fields. They are by default traced by the garbage collector, so there is no need to explicitly free them when allocated.
``` nimrod ``` nimrod
type type

View file

@ -13,7 +13,7 @@ proc printThings(things: varargs[string]) =
printThings "words", "to", "print" printThings "words", "to", "print"
``` ```
```console ```console
$ nimrod c -r ./varargs1.nim $ nim c -r ./varargs1.nim
words words
to to
print print
@ -36,7 +36,7 @@ printThings "thing 1", 2, @[4, 5, 6]
``` ```
```console ```console
$ nimrod c -r ./varargs2.nim $ nim c -r ./varargs2.nim
thing 1 thing 1
2 2
@[4, 5, 6] @[4, 5, 6]

View file

@ -3,7 +3,7 @@ title: Variables
--- ---
# Variables # Variables
Nimrod supports three different types of variables, `let`, `var`, and `const`. As with most things, multiple variables can be declared in the same section. Nim supports three different types of variables, `let`, `var`, and `const`. As with most things, multiple variables can be declared in the same section.
``` nimrod ``` nimrod
proc getAlphabet(): string = proc getAlphabet(): string =
@ -43,7 +43,7 @@ e += 1
``` ```
``` console ``` console
$ nimrod c --verbosity:2 ./variables.nim $ nim c --verbosity:2 ./variables.nim
variables.nim(22, 2) Error: 'let' symbol requires an initialization variables.nim(22, 2) Error: 'let' symbol requires an initialization
f: float f: float
^ ^

View file

@ -3,7 +3,7 @@ title: Type Casting and Inference
--- ---
# Type Casting and Inference # Type Casting and Inference
Nimrod is a statically typed language. As such, each variable has a type associated with it. As seen in the previous example these types are inferred in the `const`, `let` and `var` declarations by the compiler. Nim is a statically typed language. As such, each variable has a type associated with it. As seen in the previous example these types are inferred in the `const`, `let` and `var` declarations by the compiler.
```nimrod ```nimrod
# These types are inferred. # These types are inferred.
@ -15,7 +15,7 @@ x = y
``` ```
```console ```console
$ nimrod c -r typeinference.nim $ nim c -r typeinference.nim
typeinference.nim(6, 4) Error: type mismatch: got (string) but expected 'int' typeinference.nim(6, 4) Error: type mismatch: got (string) but expected 'int'
``` ```
@ -33,6 +33,6 @@ ffi(cast[ptr array[6, char]](addr y[0]))
``` ```
```console ```console
$ nimrod c -r typecasting.nim $ nim c -r typecasting.nim
ref 002C8030 --> ['F', 'o', 'o', 'b', 'a', 'r'] ref 002C8030 --> ['F', 'o', 'o', 'b', 'a', 'r']
``` ```

View file

@ -2,7 +2,7 @@
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<title>Nimrod by Example - <%= @item[:title] %></title> <title>Nim by Example - <%= @item[:title] %></title>
<link rel="stylesheet" type="text/css" href="http://necolas.github.io/normalize.css/3.0.1/normalize.css"> <link rel="stylesheet" type="text/css" href="http://necolas.github.io/normalize.css/3.0.1/normalize.css">
<link rel="stylesheet" href="<%= @items['/stylesheets/main/'].path %>"> <link rel="stylesheet" href="<%= @items['/stylesheets/main/'].path %>">
<link rel="stylesheet" href="<%= @items['/stylesheets/colorful/'].path %>" title="colorful"> <link rel="stylesheet" href="<%= @items['/stylesheets/colorful/'].path %>" title="colorful">
@ -23,7 +23,7 @@
<%= @items["/toc/"].compiled_content(:snapshot => :last) %> <%= @items["/toc/"].compiled_content(:snapshot => :last) %>
</div> </div>
<div id="main"> <div id="main">
<h1 id="gh-buttons"><a class="icon-fork" href="https://github.com/flaviut/nimrod-by-example/"></a> <a class="icon-star" href="https://github.com/flaviut/nimrod-by-example/stargazers" /><div id="starcount"></div></a></h1> <h1 id="gh-buttons"><a class="icon-fork" href="https://github.com/flaviut/nim-by-example/"></a> <a class="icon-star" href="https://github.com/flaviut/nim-by-example/stargazers" /><div id="starcount"></div></a></h1>
<script> <script>
function setVisibleTags(){ function setVisibleTags(){
var tocLinks = document.querySelectorAll("#sidebar a:link, a:visited"); var tocLinks = document.querySelectorAll("#sidebar a:link, a:visited");
@ -40,7 +40,7 @@
} }
var request = new XMLHttpRequest(); var request = new XMLHttpRequest();
// horrible hack... but stargazer output is capped at 30 per request. // horrible hack... but stargazer output is capped at 30 per request.
request.open("GET", "https://api.github.com/search/repositories?q=nimrod-by-example", true); request.open("GET", "https://api.github.com/search/repositories?q=nim-by-example", true);
request.onload = function (e) { request.onload = function (e) {
var searchResults = JSON.parse(request.responseText); var searchResults = JSON.parse(request.responseText);
var starcount = searchResults.items[0].stargazers_count; var starcount = searchResults.items[0].stargazers_count;

View file

@ -9,17 +9,17 @@ for filePath in walkFiles(markdownFilesGlob):
let fileContents = file.readAll() let fileContents = file.readAll()
file.close() file.close()
let sourceSegments = fileContents.findAll(re"""\n(?i)```\s*nimrod[\s\S]*?```""") let sourceSegments = fileContents.findAll(re"""\n(?i)```\s*nim[\s\S]*?```""")
for match in sourceSegments: for match in sourceSegments:
echo filePath echo filePath
let code = match.replacef(re"""\n(?i)```\s*nimrod[ \t]*\s([\s\S]*?)```""", "$1") let code = match.replacef(re"""\n(?i)```\s*nim[ \t]*\s([\s\S]*?)```""", "$1")
let codeHash = code.getMD5() let codeHash = code.getMD5()
if not configFilePath.readFile().contains(codeHash): # Hasn't been verified yet if not configFilePath.readFile().contains(codeHash): # Hasn't been verified yet
let tempCodePath = getTempDir() / "code.nim" let tempCodePath = getTempDir() / "code.nim"
tempCodePath.writeFile(code) tempCodePath.writeFile(code)
let (output, exitCode) = execCmdEx("nimrod c -r --verbosity:0 " & tempCodePath) let (output, exitCode) = execCmdEx("nim c -r --verbosity:0 " & tempCodePath)
var printableCode = "" var printableCode = ""
for line in code.splitLines(): for line in code.splitLines():

View file

@ -1,4 +1,4 @@
box: flaviut/nimrod-by-example-build-vm@0.0.3 box: flaviut/nim-by-example-build-vm@0.0.3
build: build:
steps: steps:
- script: - script: