summary refs log tree commit diff stats
path: root/compiler/parser.nim
Commit message (Expand)AuthorAgeFilesLines
* 'inject' for 'for' loop variablesAraq2013-05-141-5/+5
* completed expr/stmt unificationAraq2013-05-031-3/+3
* new parser works with docgenAraq2013-05-021-0/+1
* proper scoping for 'if'Araq2013-04-301-8/+11
* first steps to the expr/stmt unificationAraq2013-04-301-12/+82
* new parser: diallow more thingsAraq2013-04-231-0/+1
* made some tests greenAraq2013-04-221-0/+4
* bugfix: 'import x var y' without newline doesn't parse anymoreAraq2013-04-211-1/+1
* new parsing scheme is documentedAraq2013-04-211-27/+27
* new parser worksAraq2013-04-201-36/+61
* next steps for the new parserAraq2013-04-201-31/+32
* next steps for the new parser/grammarAraq2013-04-201-221/+233
* first steps to the new parser/grammarAraq2013-04-191-184/+304
* fixes #310Araq2013-04-131-2/+2
* fixes #283Araq2013-04-111-1/+1
* Removes executable bit for text files.Grzegorz Adam Hankiewicz2013-03-161-0/+0
* next steps for object construction expressionsAraq2013-03-071-1/+1
* first steps to implement object construction expressionsAraq2013-03-071-20/+27
* merged upstream masterZahary Karadjov2013-01-271-80/+36
|\
* idetools improvements (2)Araq2012-08-031-1/+1
* idetools improvements; preparation of first class iterators; fixes #183Araq2012-08-021-3/+5
* bugfixes for the symbol mangling; implements #129Araq2012-07-191-1/+15
* implemented #133Araq2012-07-191-1/+25
* improvements for 'bind', fixes #166Araq2012-07-181-5/+4
* preparations for making 'closure' the default calling convention for proc typesAraq2012-07-161-1/+1
* ';' as statement separatorAraq2012-07-121-6/+7
* fixes #112Araq2012-07-111-0/+2
* ';' now valid for parameter listsAraq2012-07-111-3/+3
* documented optional indentation for 'case' statements/'case' objectsAraq2012-06-221-0/+9
* better support for unsigned integers.Zahary Karadjov2012-06-111-0/+24
* optional indentation for case statementsZahary Karadjov2012-05-231-3/+22
* stand-alone except and finally blocksZahary Karadjov2012-05-231-1/+10
* produce errors on proc types with implicit empty param lists.Zahary Karadjov2012-04-201-6/+8
* made built-in types primary expressions to allow infix operators to be used w...Zahary Karadjov2012-04-201-50/+47
lass="n">data: string): PCaseNode = if flip == 0: result = PCaseNode(kind: nkStr, data: data) else: result = PCaseNode(kind: nkWhole, unused: @["", "abc", "abdc"]) flip = 1 - flip proc newCaseNode(a, b: PCaseNode): PCaseNode = result = PCaseNode(kind: nkList, sons: @[a, b]) proc caseTree(lvl: int = 0): PCaseNode = if lvl == 3: result = newCaseNode("data item") else: result = newCaseNode(caseTree(lvl+1), caseTree(lvl+1)) proc finalizeNode(n: PNode) = assert(n != nil) write(stdout, "finalizing: ") writeLine(stdout, "not nil") var id: int = 1 proc buildTree(depth = 1): PNode = if depth == 7: return nil new(result, finalizeNode) result.le = buildTree(depth+1) result.ri = buildTree(depth+1) result.data = $id inc(id) proc returnTree(): PNode = writeLine(stdout, "creating id: " & $id) new(result, finalizeNode) result.data = $id new(result.le, finalizeNode) result.le.data = $id & ".1" new(result.ri, finalizeNode) result.ri.data = $id & ".2" inc(id) # now create a cycle: writeLine(stdout, "creating id (cyclic): " & $id) var cycle: PNode new(cycle, finalizeNode) cycle.data = $id cycle.le = cycle cycle.ri = cycle inc(id) #writeLine(stdout, "refcount: " & $refcount(cycle)) #writeLine(stdout, "refcount le: " & $refcount(cycle.le)) #writeLine(stdout, "refcount ri: " & $refcount(cycle.ri)) proc printTree(t: PNode) = if t == nil: return writeLine(stdout, "printing") writeLine(stdout, t.data) printTree(t.le) printTree(t.ri) proc unsureNew(result: var PNode) = writeLine(stdout, "creating unsure id: " & $id) new(result, finalizeNode) result.data = $id new(result.le, finalizeNode) result.le.data = $id & ".a" new(result.ri, finalizeNode) result.ri.data = $id & ".b" inc(id) proc setSons(n: var TBNode) = n.sons = @[] # free memory of the sons n.t.data = @[] var m: seq[string] m = @[] setLen(m, len(n.t.data) * 2) for i in 0..high(m): m[i] = "..." n.t.data = m proc buildBTree(father: var TBNode) = father.data = "father" father.other = nil father.sons = @[] for i in 1..10: write(stdout, "next iteration!\n") var n: TBNode n.other = returnTree() n.data = "B node: " & $i if i mod 2 == 0: n.sons = @[] # nil and [] need to be handled correctly! add father.sons, n father.t.counter = 0 father.t.max = 3 father.t.data = @["ha", "lets", "stress", "it"] setSons(father) proc getIdent(identifier: cstring, length: int, h: int): PIdent = new(result) result.h = h result.s = newString(length) proc main() = discard getIdent("addr", 4, 0) discard getIdent("hall", 4, 0) discard getIdent("echo", 4, 0) discard getIdent("huch", 4, 0) var father: TBNode for i in 1..1_00: buildBTree(father) for i in 1..1_00: var t = returnTree() var t2: PNode unsureNew(t2) write(stdout, "now building bigger trees: ") var t2: PNode for i in 1..100: t2 = buildTree() printTree(t2) write(stdout, "now test sequences of strings:") var s: seq[string] = @[] for i in 1..100: add s, "hohoho" # test reallocation writeLine(stdout, s[89]) write(stdout, "done!\n") var father {.threadvar.}: TBNode s {.threadvar.}: string fatherAsGlobal: TBNode proc start = s = "" s = "" writeLine(stdout, repr(caseTree())) father.t.data = @["ha", "lets", "stress", "it"] father.t.data = @["ha", "lets", "stress", "it"] var t = buildTree() write(stdout, repr(t[])) buildBTree(father) write(stdout, repr(father)) write(stdout, "starting main...\n") main() GC_fullCollect() # the M&S GC fails with this call and it's unclear why. Definitely something # we need to fix! #GC_fullCollect() writeLine(stdout, GC_getStatistics()) write(stdout, "finished\n") fatherAsGlobal.t.data = @["ha", "lets", "stress", "it"] var tg = buildTree() buildBTree(fatherAsGlobal) var thr: array[8, Thread[void]] for i in low(thr)..high(thr): createThread(thr[i], start) joinThreads(thr) start()