about summary refs log tree commit diff stats
BranchCommit messageAuthorAge
hlthalt until exception when waiting for keyboardKartik K. Agaram20 months
mainfix other mandelbrot variantsKartik K. Agaram9 months
 
lloc.nim?h=devel&id=ddaedab835fa7ea3457f21a772d636921defdc46'>ddaedab83 ^
3260702a6 ^
ddaedab83 ^




db4f617af ^
e792940f5 ^



ddaedab83 ^


db4f617af ^
ddaedab83 ^

e792940f5 ^

db4f617af ^
e792940f5 ^
db4f617af ^
e792940f5 ^
db4f617af ^

e792940f5 ^
db4f617af ^
ddaedab83 ^












db4f617af ^
ddaedab83 ^







e792940f5 ^


ddaedab83 ^



e792940f5 ^


ddaedab83 ^




5b96eaa95 ^





ddaedab83 ^

e792940f5 ^
ddaedab83 ^



db4f617af ^


e792940f5 ^
ddaedab83 ^
3260702a6 ^
ddaedab83 ^
db4f617af ^
e792940f5 ^






ddaedab83 ^
24ed9d560 ^
e792940f5 ^

ddaedab83 ^

db4f617af ^
ddaedab83 ^
e792940f5 ^
db4f617af ^

3260702a6 ^
e792940f5 ^










ddaedab83 ^
e792940f5 ^




24ed9d560 ^
db4f617af ^
e792940f5 ^



ddaedab83 ^
db4f617af ^

c8d270268 ^
db4f617af ^
ddaedab83 ^
c8d270268 ^


ddaedab83 ^










e792940f5 ^

24ed9d560 ^
ddaedab83 ^
99bcc233c ^
ddaedab83 ^
db4f617af ^
3260702a6 ^
e792940f5 ^


99bcc233c ^

e792940f5 ^

99bcc233c ^
e792940f5 ^


99bcc233c ^
e792940f5 ^



3260702a6 ^
99bcc233c ^
ddaedab83 ^
24ed9d560 ^
e792940f5 ^
24ed9d560 ^


c8d270268 ^
24ed9d560 ^



e792940f5 ^
24ed9d560 ^
e792940f5 ^


ddaedab83 ^
e792940f5 ^
99bcc233c ^
24ed9d560 ^






e792940f5 ^






99bcc233c ^
e792940f5 ^

3260702a6 ^
e792940f5 ^









ddaedab83 ^
e792940f5 ^
99bcc233c ^
3260702a6 ^
e792940f5 ^

ddaedab83 ^
e792940f5 ^

ddaedab83 ^
e792940f5 ^


24ed9d560 ^

















e792940f5 ^



ddaedab83 ^
e792940f5 ^

ddaedab83 ^
e792940f5 ^

99bcc233c ^
e792940f5 ^
99bcc233c ^
e792940f5 ^
db4f617af ^
e792940f5 ^
c8d270268 ^
db4f617af ^
e792940f5 ^





c8d270268 ^
e792940f5 ^




3260702a6 ^
e792940f5 ^
c8d270268 ^
e792940f5 ^





3260702a6 ^
e792940f5 ^
99bcc233c ^
e792940f5 ^


c8d270268 ^
e792940f5 ^





db4f617af ^

e792940f5 ^
99bcc233c ^
3260702a6 ^
e792940f5 ^
db4f617af ^





99bcc233c ^
db4f617af ^






e792940f5 ^
c8d270268 ^


e792940f5 ^

c8d270268 ^
e792940f5 ^



c8d270268 ^
e792940f5 ^

c8d270268 ^
e792940f5 ^

c8d270268 ^
e792940f5 ^


ddaedab83 ^
e792940f5 ^


e792940f5 ^



99bcc233c ^
db4f617af ^

c8d270268 ^
3260702a6 ^
db4f617af ^

99bcc233c ^
e792940f5 ^
c8d270268 ^
db4f617af ^
e792940f5 ^

c8d270268 ^
3260702a6 ^
c8d270268 ^
e792940f5 ^






c8d270268 ^
3260702a6 ^
c8d270268 ^
e792940f5 ^






3260702a6 ^
db4f617af ^
e792940f5 ^




99bcc233c ^
e792940f5 ^
c8d270268 ^
e792940f5 ^

db4f617af ^
e792940f5 ^

db4f617af ^
ddaedab83 ^
3260702a6 ^
e792940f5 ^

99bcc233c ^
e792940f5 ^
c8d270268 ^

e792940f5 ^


c8d270268 ^
e792940f5 ^



e792940f5 ^
db4f617af ^
e792940f5 ^

c8d270268 ^
e792940f5 ^




db4f617af ^
e792940f5 ^
3260702a6 ^
db4f617af ^
ddaedab83 ^
99bcc233c ^
e792940f5 ^
c8d270268 ^

e792940f5 ^
ddaedab83 ^


ddaedab83 ^
e792940f5 ^

ddaedab83 ^
99bcc233c ^




c8d270268 ^

db4f617af ^

e792940f5 ^

ddaedab83 ^


e792940f5 ^
ddaedab83 ^
c8d270268 ^
ddaedab83 ^
e792940f5 ^





c8d270268 ^
ddaedab83 ^
c8d270268 ^
db4f617af ^

c8d270268 ^
e792940f5 ^
c8d270268 ^

e792940f5 ^
c8d270268 ^
e792940f5 ^

c8d270268 ^
e792940f5 ^

c8d270268 ^

e792940f5 ^
ddaedab83 ^
e792940f5 ^
ddaedab83 ^
e792940f5 ^
c8d270268 ^


e792940f5 ^
c8d270268 ^

99bcc233c ^



ddaedab83 ^
99bcc233c ^
e792940f5 ^




ddaedab83 ^
e792940f5 ^
c8d270268 ^
db4f617af ^
ddaedab83 ^
e792940f5 ^
c7e144f97 ^



e792940f5 ^

e792940f5 ^








ddaedab83 ^
c7e144f97 ^

ddaedab83 ^
e792940f5 ^
ddaedab83 ^
99bcc233c ^
3260702a6 ^
e792940f5 ^


db4f617af ^




e792940f5 ^

db4f617af ^

81a917390 ^






c8d270268 ^
81a917390 ^


246b8d18a ^
81a917390 ^



c8d270268 ^
81a917390 ^
c8d270268 ^
81a917390 ^









99bcc233c ^


24ed9d560 ^





99bcc233c ^



3260702a6 ^
99bcc233c ^
24ed9d560 ^
99bcc233c ^

db4f617af ^
c70fa8747 ^
81a917390 ^
c70fa8747 ^

81a917390 ^
c70fa8747 ^

81a917390 ^
8098e2a42 ^

81a917390 ^
db4f617af ^
99bcc233c ^






db4f617af ^
8098e2a42 ^

99bcc233c ^
db4f617af ^
8098e2a42 ^

e792940f5 ^
81a917390 ^

































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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
interf"success", resLen), !!newCall(interf"nxt", input, idx, resLen))
    of nnkCurly, nnkAccQuoted, nnkCharLit:
      result = (newEmptyNode(), newCall(interf"atom", input, idx, it), !!newCall(interf"nxt", input, idx))
    of nnkCurlyExpr:
      if it.len == 3 and it[1].kind == nnkIntLit and it[2].kind == nnkIntLit:
        var h = newTree(nnkPar, it[0])
        for count in 2..it[1].intVal: h.add(it[0])
        for count in it[1].intVal .. it[2].intVal-1: h.add(newTree(nnkPrefix, ident"?", it[0]))
        result = atm(h, input, idx, attached)
      elif it.len == 2 and it[1].kind == nnkIntLit:
        var h = newTree(nnkPar, it[0])
        for count in 2..it[1].intVal: h.add(it[0])
        result = atm(h, input, idx, attached)
      else:
        error("invalid pattern")
    of nnkPar:
      if it.len == 1:
        result = atm(it[0], input, idx, attached)
      else:
        # concatenation:
        var conds: seq[StmtTriple] = @[]
        for x in it: conds.add atm(x, input, idx, attached)
        var res = genSym(nskVar, "res")
        result = (newStmtList(newVarStmt(res, newLit false),
            toIfChain(conds, idx, res, 0)), res, newEmptyNode())
    else:
      error("invalid pattern")

  #var idx = genSym(nskVar, "idx")
  var res = genSym(nskVar, "res")
  result = newTree(nnkStmtListExpr, #newVarStmt(idx, newCall(interf"prepare", input)),
                                    newVarStmt(res, newLit false))
  var conds: seq[StmtTriple] = @[]
  for it in pattern:
    conds.add atm(it, input, idx, nil)
  result.add toIfChain(conds, idx, res, 0)
  result.add res
  when defined(debugScanp):
    echo repr result


when isMainModule:
  proc twoDigits(input: string; x: var int; start: int): int =
    if input[start] == '0' and input[start+1] == '0':
      result = 2
      x = 13
    else:
      result = 0

  proc someSep(input: string; start: int; seps: set[char] = {';',',','-','.'}): int =
    result = 0
    while input[start+result] in seps: inc result

  proc demangle(s: string; res: var string; start: int): int =
    while s[result+start] in {'_', '@'}: inc result
    res = ""
    while result+start < s.len and s[result+start] > ' ' and s[result+start] != '_':
      res.add s[result+start]
      inc result
    while result+start < s.len and s[result+start] > ' ':
      inc result

  proc parseGDB(resp: string): seq[string] =
    const
      digits = {'0'..'9'}
      hexdigits = digits + {'a'..'f', 'A'..'F'}
      whites = {' ', '\t', '\C', '\L'}
    result = @[]
    var idx = 0
    while true:
      var prc = ""
      var info = ""
      if scanp(resp, idx, *`whites`, '#', *`digits`, +`whites`, ?("0x", *`hexdigits`, " in "),
               demangle($input, prc, $index), *`whites`, '(', * ~ ')', ')',
                *`whites`, "at ", +(~{'\C', '\L', '\0'} -> info.add($_)) ):
        result.add prc & " " & info
      else:
        break

  var key, val: string
  var intval: int
  var floatval: float
  doAssert scanf("abc:: xyz 89  33.25", "$w$s::$s$w$s$i  $f", key, val, intval, floatVal)
  doAssert key == "abc"
  doAssert val == "xyz"
  doAssert intval == 89
  doAssert floatVal == 33.25

  let xx = scanf("$abc", "$$$i", intval)
  doAssert xx == false


  let xx2 = scanf("$1234", "$$$i", intval)
  doAssert xx2

  let yy = scanf(";.--Breakpoint00 [output]", "$[someSep]Breakpoint${twoDigits}$[someSep({';','.','-'})] [$+]$.", intVal, key)
  doAssert yy
  doAssert key == "output"
  doAssert intVal == 13

  var ident = ""
  var idx = 0
  let zz = scanp("foobar x x  x   xWZ", idx, +{'a'..'z'} -> add(ident, $_), *(*{' ', '\t'}, "x"), ~'U', "Z")
  doAssert zz
  doAssert ident == "foobar"

  const digits = {'0'..'9'}
  var year = 0
  var idx2 = 0
  if scanp("201655-8-9", idx2, `digits`{4,6} -> (year = year * 10 + ord($_) - ord('0')), "-8", "-9"):
    doAssert year == 201655

  const gdbOut = """
      #0  @foo_96013_1208911747@8 (x0=...)
          at c:/users/anwender/projects/nim/temp.nim:11
      #1  0x00417754 in tempInit000 () at c:/users/anwender/projects/nim/temp.nim:13
      #2  0x0041768d in NimMainInner ()
          at c:/users/anwender/projects/nim/lib/system.nim:2605
      #3  0x004176b1 in NimMain ()
          at c:/users/anwender/projects/nim/lib/system.nim:2613
      #4  0x004176db in main (argc=1, args=0x712cc8, env=0x711ca8)
          at c:/users/anwender/projects/nim/lib/system.nim:2620"""
  const result = @["foo c:/users/anwender/projects/nim/temp.nim:11",
          "tempInit000 c:/users/anwender/projects/nim/temp.nim:13",
          "NimMainInner c:/users/anwender/projects/nim/lib/system.nim:2605",
          "NimMain c:/users/anwender/projects/nim/lib/system.nim:2613",
          "main c:/users/anwender/projects/nim/lib/system.nim:2620"]
  doAssert parseGDB(gdbOut) == result
lt'>