This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<!DOCTYPE language SYSTEM "language.dtd"> | |
<language | |
name="Nimrod" | |
version="1.0" | |
kateversion="2.4" | |
section="Sources" | |
extensions="*.nim" | |
mimetype="text/x-nimrod"> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import winlean, os, asyncdispatch, tables, sets, strutils | |
type | |
AlignedBuffer = tuple[base, start: pointer] | |
FileEvent* = enum | |
feFileCreated | |
feFileRemoved | |
feFileModified | |
feNameChangedNew |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/compiler/parser.nim b/compiler/parser.nim | |
index 2f9deb6..01727c2 100644 | |
--- a/compiler/parser.nim | |
+++ b/compiler/parser.nim | |
@@ -147,8 +147,10 @@ proc expectIdent(p: TParser) = | |
proc eat(p: var TParser, tokType: TTokType) = | |
## Move the parser to the next token if the current token is of type | |
## `tokType`, otherwise error. | |
- if p.tok.tokType == tokType: getTok(p) | |
- else: lexMessage(p.lex, errTokenExpected, TokTypeToStr[tokType]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/compiler/parser.nim b/compiler/parser.nim | |
index 2f9deb6..01727c2 100644 | |
--- a/compiler/parser.nim | |
+++ b/compiler/parser.nim | |
@@ -147,8 +147,10 @@ proc expectIdent(p: TParser) = | |
proc eat(p: var TParser, tokType: TTokType) = | |
## Move the parser to the next token if the current token is of type | |
## `tokType`, otherwise error. | |
- if p.tok.tokType == tokType: getTok(p) | |
- else: lexMessage(p.lex, errTokenExpected, TokTypeToStr[tokType]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::io::stdio::println; | |
fn fib(n: i64) -> Option<i64> { | |
if n <= 1 { | |
return Some(n); | |
} else { | |
return Some(fib(n-1).unwrap() + fib(n-2).unwrap()); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const | |
representativeChars = ['m', 'N', '5', '"', '\'', ' '] | |
startingSeq = (var result = newSeq[string](representativeChars.len); | |
for i, v in representativeChars:( | |
result[i] = $v; | |
); | |
result) | |
vs |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import unsigned, strutils | |
## A random number generator with 1024 bits of state. | |
## Very high performance | |
type | |
TRandState* {.final, pure, acyclic.} = object | |
data*: array[16, int64] | |
pos*: range[0..15] | |
proc next(state: var TRandState): int64 = |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import macros | |
macro teststrval(e: expr): string = | |
echo e.strVal | |
result = e | |
discard teststrval("asd") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type | |
Foo = object | |
a: int | |
b: string | |
proc fnew[T](obj: T): ref T = | |
new(result) | |
{.emit: "memcpy((void*) `result`, (void*)(&`obj`), (NI) sizeof(`obj`));\n".} | |
let a = fnew Foo(a : 1, b : "asd") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type | |
Foo = object | |
a: int | |
b: string | |
proc fnew[T](obj: T): ref T = | |
new(result) | |
{.emit: "memcpy((void*) `result`, (void*)(&`obj`), (NI) sizeof(`obj`));\n".} | |
let a = fnew Foo(a : 1, b : "asd") |