summary refs log tree commit diff stats
path: root/examples/parsecfgex.nim
blob: 0fa03ffb5f6bc33b869a9be26c6639823a689200 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import
  os, parsecfg, strutils, streams

var f = newFileStream(paramStr(1), fmRead)
if f != nil:
  var p: CfgParser
  open(p, f, paramStr(1))
  while true:
    var e = next(p)
    case e.kind
    of cfgEof:
      echo("EOF!")
      break
    of cfgSectionStart:   ## a ``[section]`` has been parsed
      echo("new section: " & e.section)
    of cfgKeyValuePair:
      echo("key-value-pair: " & e.key & ": " & e.value)
    of cfgOption:
      echo("command: " & e.key & ": " & e.value)
    of cfgError:
      echo(e.msg)
  close(p)
else:
  echo("cannot open: " & paramStr(1))
ass="nv">scenario check_text_in_memory [ run [ 1:number <- copy 3 2:character <- copy 97 # 'a' 3:character <- copy 98 # 'b' 4:character <- copy 99 # 'c' ] memory-should-contain [ 1:array:character <- [abc] ] ] scenario check_trace [ run [ 1:number <- add 2, 2 ] trace-should-contain [ mem: storing 4 in location 1 ] ] scenario check_trace_negative [ run [ 1:number <- add 2, 2 ] trace-should-not-contain [ mem: storing 5 in location 1 ] ] scenario check_trace_instruction [ run [ trace 1, [foo], [aaa] ] trace-should-contain [ foo: aaa ] ]