Module: Flor::Parser

Includes:
Raabro
Defined in:
lib/flor/parser.rb

Defined Under Namespace

Classes: Nod

Constant Summary collapse

UNESCAPE =
{
  "'" => "'", '"' => '"', '\\' => '\\', '/' => '/',
  'b' => "\b", 'f' => "\f", 'n' => "\n", 'r' => "\r", 't' => "\t"
}

Instance Method Summary collapse

Instance Method Details

#arr(i) ⇒ Object



200
# File 'lib/flor/parser.rb', line 200

def arr(i); eseq(:arr, i, :sbstart, :exp_qmark, :coll_sep, :sbend); end

#att(i) ⇒ Object



248
# File 'lib/flor/parser.rb', line 248

def att(i); seq(:att, i, :sep, :keycol, '?', :exp); end

#boolean(i) ⇒ Object



74
# File 'lib/flor/parser.rb', line 74

def boolean(i); alt(:boolean, i, :tru, :fls); end

#coll_sep(i) ⇒ Object



186
# File 'lib/flor/parser.rb', line 186

def coll_sep(i); alt(nil, i, :comma_qmark_eol, :wstar); end

#colon(i) ⇒ Object



51
# File 'lib/flor/parser.rb', line 51

def colon(i); str(nil, i, ':'); end

#colon_eol(i) ⇒ Object



76
# File 'lib/flor/parser.rb', line 76

def colon_eol(i); seq(:colo, i, :colon, :eol); end

#colon_exp(i) ⇒ Object



82
83
84
# File 'lib/flor/parser.rb', line 82

def colon_exp(i)
  seq(nil, i, :colon_eol, :exp_qmark)
end

#comma(i) ⇒ Object



53
# File 'lib/flor/parser.rb', line 53

def comma(i); str(nil, i, ','); end

#comma_eol(i) ⇒ Object



182
# File 'lib/flor/parser.rb', line 182

def comma_eol(i); seq(nil, i, :comma, :eol, :wstar); end

#comma_qmark_eol(i) ⇒ Object



185
# File 'lib/flor/parser.rb', line 185

def comma_qmark_eol(i); seq(nil, i, :comma, '?', :eol); end

#comment(i) ⇒ Object



175
# File 'lib/flor/parser.rb', line 175

def comment(i); rex(nil, i, /(#|\/\/)[^\r\n]*/); end

#dollar(i) ⇒ Object



56
# File 'lib/flor/parser.rb', line 56

def dollar(i); str(nil, i, '$'); end

#dor_lines(i) ⇒ Object



133
134
135
# File 'lib/flor/parser.rb', line 133

def dor_lines(i)
  seq(:dpar_lines, i, :pipepipe, :eol_wstar, :line, '+')
end

#dot(i) ⇒ Object



50
# File 'lib/flor/parser.rb', line 50

def dot(i); str(nil, i, '.'); end

#dpar(i) ⇒ Object



140
141
142
143
144
# File 'lib/flor/parser.rb', line 140

def dpar(i)
  seq(
    :dpar, i,
    :dollar, :pstart, :dpar_lines, :dor_lines, '?', :eol_wstar, :pend)
end

#dpar_lines(i) ⇒ Object



136
137
138
# File 'lib/flor/parser.rb', line 136

def dpar_lines(i)
  seq(:dpar_lines, i, :eol_wstar, :line, '+')
end

#dpar_or_dqsc(i) ⇒ Object



150
# File 'lib/flor/parser.rb', line 150

def dpar_or_dqsc(i); alt(nil, i, :dpar, :dqsc); end

#dpar_or_rxoc(i) ⇒ Object



146
# File 'lib/flor/parser.rb', line 146

def dpar_or_rxoc(i); alt(nil, i, :dpar, :rxoc); end

#dpar_or_rxsc(i) ⇒ Object



151
# File 'lib/flor/parser.rb', line 151

def dpar_or_rxsc(i); alt(nil, i, :dpar, :rxsc); end

#dqsc(i) ⇒ Object



109
110
111
112
113
114
115
116
117
118
# File 'lib/flor/parser.rb', line 109

def dqsc(i)
  rex(:dqsc, i, %r{
    (
      \\["\\\/bfnrt] |
      \\u[0-9a-fA-F]{4} |
      \$(?!\() |
      [^\$"\\\b\f\n\r\t]
    )+
  }x)
end

#dqstring(i) ⇒ Object



153
154
155
# File 'lib/flor/parser.rb', line 153

def dqstring(i)
  seq(:dqstring, i, :dquote, :dpar_or_dqsc, '*', :dquote)
end

#dquote(i) ⇒ Object



54
# File 'lib/flor/parser.rb', line 54

def dquote(i); str(nil, i, '"'); end

#eand(i) ⇒ Object



240
# File 'lib/flor/parser.rb', line 240

def eand(i); jseq(:exp, i, :eequ, :sand); end

#eequ(i) ⇒ Object



239
# File 'lib/flor/parser.rb', line 239

def eequ(i); jseq(:exp, i, :elgt, :sequ); end

#elgt(i) ⇒ Object



238
# File 'lib/flor/parser.rb', line 238

def elgt(i); jseq(:exp, i, :esum, :slgt); end

#emod(i) ⇒ Object



235
# File 'lib/flor/parser.rb', line 235

def emod(i); jseq(:exp, i, :val_ws, :smod); end

#ent(i) ⇒ Object



190
191
192
# File 'lib/flor/parser.rb', line 190

def ent(i)
  seq(:ent, i, :key, :postval, :colon, :postval, :exp, :postval)
end

#ent_qmark(i) ⇒ Object



193
194
195
# File 'lib/flor/parser.rb', line 193

def ent_qmark(i)
  rep(nil, i, :ent, 0, 1)
end

#eol(i) ⇒ Object



177
# File 'lib/flor/parser.rb', line 177

def eol(i); seq(nil, i, :wstar, :comment, '?', :rnstar); end

#eol_plus(i) ⇒ Object



179
# File 'lib/flor/parser.rb', line 179

def eol_plus(i); seq(nil, i, :wstar, :comment, '?', :rnplus); end

#eol_wstar(i) ⇒ Object



178
# File 'lib/flor/parser.rb', line 178

def eol_wstar(i); seq(nil, i, :wstar, :comment, '?', :rnstar, :wstar); end

#eor(i) ⇒ Object Also known as: exp



241
# File 'lib/flor/parser.rb', line 241

def eor(i); jseq(:exp, i, :eand, :sor); end

#eprd(i) ⇒ Object



236
# File 'lib/flor/parser.rb', line 236

def eprd(i); jseq(:exp, i, :emod, :sprd); end

#esum(i) ⇒ Object



237
# File 'lib/flor/parser.rb', line 237

def esum(i); jseq(:exp, i, :eprd, :ssum); end

#exp_qmark(i) ⇒ Object



197
# File 'lib/flor/parser.rb', line 197

def exp_qmark(i); rep(nil, i, :exp, 0, 1); end

#flor(i) ⇒ Object



269
# File 'lib/flor/parser.rb', line 269

def flor(i); rep(:flor, i, :line, 0); end

#fls(i) ⇒ Object



73
# File 'lib/flor/parser.rb', line 73

def fls(i); str(nil, i, 'false'); end

#head(i) ⇒ Object



253
# File 'lib/flor/parser.rb', line 253

def head(i); seq(:head, i, :exp); end

#indent(i) ⇒ Object



254
# File 'lib/flor/parser.rb', line 254

def indent(i); rex(:indent, i, /[ \t]*/); end

#invert(operation, operand) ⇒ Object



450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
# File 'lib/flor/parser.rb', line 450

def invert(operation, operand)

  l = operand[2]

  case operation
  when '+'
    if operand[0] == '_num' && operand[1].is_a?(Numeric)
      [ operand[0], - operand[1], l ]
    else
      [ '-', [ operand ], l ]
    end
  when '*'
    [ '/', [ [ 'num', 1, l ], operand ], l ]
  else
fail "don't know how to invert #{operation.inspect}" # FIXME
  end
end

#iou(i) ⇒ Object

If Or Unless



250
# File 'lib/flor/parser.rb', line 250

def iou(i); seq(nil, i, :sep, :riou); end

#key(i) ⇒ Object



245
# File 'lib/flor/parser.rb', line 245

def key(i); seq(:key, i, :exp); end

#keycol(i) ⇒ Object



246
# File 'lib/flor/parser.rb', line 246

def keycol(i); seq(nil, i, :key, :wstar, :colon, :eol_wstar); end

#line(i) ⇒ Object



262
263
264
# File 'lib/flor/parser.rb', line 262

def line(i)
  seq(:line, i, :node, '?', :outdent)
end

#line_number(t) ⇒ Object Also known as: ln

rewriting



273
274
275
276
# File 'lib/flor/parser.rb', line 273

def line_number(t)

  t.input.string[0..t.offset].scan("\n").count + 1
end

#linjoin(i) ⇒ Object



257
# File 'lib/flor/parser.rb', line 257

def linjoin(i); rex(nil, i, /[ \t]*(\\|\|(?!\|)|;)[ \t]*/); end

#natt(i) ⇒ Object



251
# File 'lib/flor/parser.rb', line 251

def natt(i); alt(nil, i, :iou, :att); end

#node(i) ⇒ Object



255
# File 'lib/flor/parser.rb', line 255

def node(i); seq(:node, i, :indent, :head, :natt, '*'); end

#null(i) ⇒ Object



66
# File 'lib/flor/parser.rb', line 66

def null(i); str(:null, i, 'null'); end

#number(i) ⇒ Object



68
69
70
# File 'lib/flor/parser.rb', line 68

def number(i)
  rex(:number, i, /[-+]?[0-9]+(\.[0-9]+)?([eE][+-]?[0-9]+)?/)
end

#obj(i) ⇒ Object



199
# File 'lib/flor/parser.rb', line 199

def obj(i); eseq(:obj, i, :pbstart, :ent_qmark, :coll_sep, :pbend); end

#outdent(i) ⇒ Object



260
# File 'lib/flor/parser.rb', line 260

def outdent(i); alt(:outdent, i, :outjnl, :outnlj, :eol); end

#outjnl(i) ⇒ Object



258
# File 'lib/flor/parser.rb', line 258

def outjnl(i); seq(nil, i, :linjoin, :comment, '?', :rnstar); end

#outnlj(i) ⇒ Object



259
# File 'lib/flor/parser.rb', line 259

def outnlj(i); seq(nil, i, :wstar, :comment, '?', :rnstar, :linjoin); end

#panode(i) ⇒ Object



265
266
267
# File 'lib/flor/parser.rb', line 265

def panode(i)
  seq(:panode, i, :pstart, :eol_wstar, :line, '*', :eol, :pend)
end

#par(i) ⇒ Object



202
203
204
# File 'lib/flor/parser.rb', line 202

def par(i)
  seq(:par, i, :pstart, :eol_wstar, :node, :eol_wstar, :pend)
end

#pbend(i) ⇒ Object



64
# File 'lib/flor/parser.rb', line 64

def pbend(i); str(nil, i, '}'); end

#pbstart(i) ⇒ Object



63
# File 'lib/flor/parser.rb', line 63

def pbstart(i); str(nil, i, '{'); end

#pend(i) ⇒ Object



60
# File 'lib/flor/parser.rb', line 60

def pend(i); str(nil, i, ')'); end

#pipepipe(i) ⇒ Object



57
# File 'lib/flor/parser.rb', line 57

def pipepipe(i); str(nil, i, '||'); end

#postval(i) ⇒ Object



180
# File 'lib/flor/parser.rb', line 180

def postval(i); rep(nil, i, :eol, 0); end

#pstart(i) ⇒ Object



59
# File 'lib/flor/parser.rb', line 59

def pstart(i); str(nil, i, '('); end

#reference(i) ⇒ Object



107
# File 'lib/flor/parser.rb', line 107

def reference(i); seq(:ref, i, :rf_symbol, :rf_index, '*'); end

#restring(s) ⇒ Object



359
360
361
362
363
364
365
# File 'lib/flor/parser.rb', line 359

def restring(s)
  s.gsub(
    /\\(?:(['"\\\/bfnrt])|u([\da-fA-F]{4}))/
  ) {
    $1 ? UNESCAPE[$1] : [ "#$2".hex ].pack('U*')
  }
end

#rewrite_arr(t) ⇒ Object



435
436
437
438
439
440
441
442
443
# File 'lib/flor/parser.rb', line 435

def rewrite_arr(t)

  l = ln(t)

  cn = t.subgather(nil).collect { |n| rewrite(n) }
  cn = [ [ '_att', [ [ '_', [], l ] ], l ] ] if cn.empty?

  [ '_arr', cn, l ]
end

#rewrite_boolean(t) ⇒ Object



413
# File 'lib/flor/parser.rb', line 413

def rewrite_boolean(t); [ '_boo', t.string == 'true', line_number(t) ]; end

#rewrite_dpar(t) ⇒ Object



376
377
378
379
# File 'lib/flor/parser.rb', line 376

def rewrite_dpar(t)

  [ '_dol', t.subgather(nil).collect { |ct| rewrite(ct) }, ln(t) ]
end

#rewrite_dpar_lines(t) ⇒ Object



370
371
372
373
374
# File 'lib/flor/parser.rb', line 370

def rewrite_dpar_lines(t)

#Raabro.pp(t, colours: true); p t.string
  [ '_dmute', t.subgather(:node).collect { |ct| rewrite(ct) }, ln(t) ]
end

#rewrite_dqsc(t) ⇒ Object Also known as: rewrite_rxsc



367
# File 'lib/flor/parser.rb', line 367

def rewrite_dqsc(t); [ '_sqs', restring(t.string), ln(t) ]; end

#rewrite_dqstring(t) ⇒ Object Also known as: rewrite_rxopts



381
382
383
384
385
386
387
388
389
390
391
392
# File 'lib/flor/parser.rb', line 381

def rewrite_dqstring(t)

  cn = t.subgather(nil).collect { |tt| rewrite(tt) }

  if cn.size == 1 && cn[0][0] == '_sqs'
    cn[0]
  elsif cn.size == 0
    [ '_sqs', '', ln(t) ]
  else
    [ '_dqs', cn, ln(t) ]
  end
end

#rewrite_exp(t) ⇒ Object



468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
# File 'lib/flor/parser.rb', line 468

def rewrite_exp(t)

#puts "-" * 80
#puts caller[0, 7]
#Raabro.pp(t, colours: true)
  return rewrite(t.c0) if t.children.size == 1
#puts "-" * 80
#puts caller[0, 7]
#Raabro.pp(t, colours: true)

  cn = t.children.collect { |ct| ct.lookup(nil) }

  operation = cn.find { |ct| ct.name == :sop }.string

  operator = operation
  operands = []

  cn.each do |ct|
    if ct.name == :sop
      operator = ct.string
    else
      o = rewrite(ct)
      o = invert(operation, o) if operator != operation
      operands << o
    end
  end

  [ operation, operands, operands.first[2] ]
end

#rewrite_flor(t) ⇒ Object Also known as: rewrite_panode



683
684
685
686
687
688
689
690
691
692
693
694
695
696
# File 'lib/flor/parser.rb', line 683

def rewrite_flor(t)

  prev = root = Nod.new(nil, nil)

  t.gather(:line).each do |lt|
    nt = lt.lookup(:node); next unless nt
    ot = lt.children.last.string
    n = Nod.new(nt, ot)
    prev.append(n)
    prev = n
  end

  root.children.count == 1 ? root.children.first.to_a : root.to_a
end

#rewrite_node(t) ⇒ Object



284
285
286
287
# File 'lib/flor/parser.rb', line 284

def rewrite_node(t)

  Nod.new(t, nil).to_a
end

#rewrite_null(t) ⇒ Object



414
# File 'lib/flor/parser.rb', line 414

def rewrite_null(t); [ '_nul', nil, line_number(t) ]; end

#rewrite_number(t) ⇒ Object



416
417
418
419
# File 'lib/flor/parser.rb', line 416

def rewrite_number(t)

  s = t.string; [ '_num', s.index('.') ? s.to_f : s.to_i, ln(t) ]
end

#rewrite_obj(t) ⇒ Object



421
422
423
424
425
426
427
428
429
430
431
432
433
# File 'lib/flor/parser.rb', line 421

def rewrite_obj(t)

  l = ln(t)

  cn =
    t.subgather(nil).inject([]) do |a, tt|
      a << rewrite(tt.c0.c0)
      a << rewrite(tt.c4)
    end
  cn = [ [ '_att', [ [ '_', [], l ] ], l ] ] if cn.empty?

  [ '_obj', cn, l ]
end

#rewrite_par(t) ⇒ Object



279
280
281
282
# File 'lib/flor/parser.rb', line 279

def rewrite_par(t)

  Nod.new(t.lookup(:node), nil).to_a
end

#rewrite_ref(t) ⇒ Object



289
290
291
292
293
294
295
296
297
298
299
# File 'lib/flor/parser.rb', line 289

def rewrite_ref(t)

  tts = t.subgather(nil)

  if tts.length == 1
    tt = tts.first
    [ tt.string, [], ln(tt) ]
  else
    [ '_ref', tts.collect { |ct| rewrite(ct) }, ln(t) ]
  end
end

#rewrite_refsl(t) ⇒ Object



323
324
325
326
327
328
329
330
331
# File 'lib/flor/parser.rb', line 323

def rewrite_refsl(t)

  st, co = t.subgather(nil)

  [ '_obj', [
    [ '_sqs', 'start', ln(st) ], rewrite(st),
    [ '_sqs', 'count', ln(co) ], rewrite(co),
  ], ln(t) ]
end

#rewrite_refsq(t) ⇒ Object



312
313
314
315
316
317
318
319
320
321
# File 'lib/flor/parser.rb', line 312

def rewrite_refsq(t)

  tts = t.subgather(nil)

  if tts.length == 1
    rewrite(tts.first)
  else
    [ '_arr', tts.collect { |tt| rewrite(tt) }, ln(t) ]
  end
end

#rewrite_refst(t) ⇒ Object



333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
# File 'lib/flor/parser.rb', line 333

def rewrite_refst(t)

#puts "-" * 80
#Raabro.pp(t, colours: true)
  ts = t.subgather(nil).collect { |tt| tt.name == :colo ? ':' : tt }
  ts.unshift(0) if ts.first == ':'                 # begin
  ts.push(':') if ts.count { |ct| ct == ':' } < 2  #
  ts.push(1) if ts.last == ':'                     # step
  ts.insert(2, -1) if ts[2] == ':'                 # end

  be, _, en, _, st = ts
  be = be.is_a?(Integer) ? [ '_num', be, ln(t) ] : rewrite(be)
  en = en.is_a?(Integer) ? [ '_num', en, ln(t) ] : rewrite(en)
  st = st.is_a?(Integer) ? [ '_num', st, ln(t) ] : rewrite(st)

  [ '_obj', [
    [ '_sqs', 'start', be[2] ], be,
    [ '_sqs', 'end', en[2] ], en,
    [ '_sqs', 'step', st[2] ], st,
  ], ln(t) ]
end

#rewrite_refsym(t) ⇒ Object



301
302
303
304
305
306
307
308
309
310
# File 'lib/flor/parser.rb', line 301

def rewrite_refsym(t)

  s = t.string

  if s.match(/\A\d+\z/)
    [ '_num', s.to_i, ln(t) ]
  else
    [ '_sqs', s, ln(t) ]
  end
end

#rewrite_rxoc(t) ⇒ Object



396
# File 'lib/flor/parser.rb', line 396

def rewrite_rxoc(t); [ '_sqs', t.string, ln(t) ]; end

#rewrite_rxstring(t) ⇒ Object



398
399
400
401
402
403
404
405
406
407
408
409
410
# File 'lib/flor/parser.rb', line 398

def rewrite_rxstring(t)

  l = ln(t)
  cts = t.subgather(nil)
  rot = cts.pop

  cn = cts.collect(&method(:rewrite))

  cn.unshift([ '_att', [ [ 'rxopts', [], l ], rewrite(rot) ], l ]) \
    if rot.length > 0

  [ '_rxs', cn, l ]
end

#rewrite_sqstring(t) ⇒ Object



412
# File 'lib/flor/parser.rb', line 412

def rewrite_sqstring(t); [ '_sqs', restring(t.string[1..-2]), ln(t) ]; end

#rewrite_val(t) ⇒ Object



445
446
447
448
# File 'lib/flor/parser.rb', line 445

def rewrite_val(t)

  rewrite(t.c0)
end

#rf_dot_idx(i) ⇒ Object



97
98
99
# File 'lib/flor/parser.rb', line 97

def rf_dot_idx(i)
  seq(nil, i, :dot, :rf_symbol)
end

#rf_index(i) ⇒ Object



100
# File 'lib/flor/parser.rb', line 100

def rf_index(i); alt(nil, i, :rf_dot_idx, :rf_sqa_idx); end

#rf_slice(i) ⇒ Object



79
80
81
# File 'lib/flor/parser.rb', line 79

def rf_slice(i)
  seq(:refsl, i, :exp, :comma_qmark_eol, :exp)
end

#rf_sqa_idx(i) ⇒ Object



94
95
96
# File 'lib/flor/parser.rb', line 94

def rf_sqa_idx(i)
  seq(:refsq, i, :sbstart, :rf_sqa_index, :rf_sqa_semico_index, '*', :sbend)
end

#rf_sqa_index(i) ⇒ Object



88
89
90
# File 'lib/flor/parser.rb', line 88

def rf_sqa_index(i)
  alt(nil, i, :rf_slice, :rf_steps, :exp)
end

#rf_sqa_semico_index(i) ⇒ Object



91
92
93
# File 'lib/flor/parser.rb', line 91

def rf_sqa_semico_index(i)
  seq(nil, i, :semicolon_eol, :rf_sqa_index)
end

#rf_steps(i) ⇒ Object



85
86
87
# File 'lib/flor/parser.rb', line 85

def rf_steps(i)
  seq(:refst, i, :exp_qmark, :colon_exp, :colon_exp, '?')
end

#rf_symbol(i) ⇒ Object



102
103
104
105
# File 'lib/flor/parser.rb', line 102

def rf_symbol(i)
  rex(:refsym, i, /([^.:;| \b\f\n\r\t"',()\[\]{}#\\\/]|\/(?!\/))+/)
    # anything but... a slash is ok, but not a double slash...
end

#riou(i) ⇒ Object



249
# File 'lib/flor/parser.rb', line 249

def riou(i); rex(:iou, i, /(if|unless)/); end

#rnplus(i) ⇒ Object



48
# File 'lib/flor/parser.rb', line 48

def rnplus(i); rex(nil, i, /[\r\n]+/); end

#rnstar(i) ⇒ Object



47
# File 'lib/flor/parser.rb', line 47

def rnstar(i); rex(nil, i, /[\r\n]*/); end

#rxoc(i) ⇒ Object



120
# File 'lib/flor/parser.rb', line 120

def rxoc(i); rex(:rxoc, i, /[imxouesn]/); end

#rxopts(i) ⇒ Object



148
# File 'lib/flor/parser.rb', line 148

def rxopts(i); rep(:rxopts, i, :dpar_or_rxoc, 0); end

#rxr(i) ⇒ Object

used to break ambiguity against / (infix division)



157
158
159
# File 'lib/flor/parser.rb', line 157

def rxr(i) # used to break ambiguity against / (infix division)
  rex(nil, i, /(regex|rex|rx|re|r)/)
end

#rxsc(i) ⇒ Object



122
123
124
125
126
127
128
129
130
131
# File 'lib/flor/parser.rb', line 122

def rxsc(i)
  rex(:rxsc, i, %r{
    (
      \\[\/bfnrt] |
      \\u[0-9a-fA-F]{4} |
      \$(?!\() |
      [^\$/\b\f\n\r\t]
    )+
  }x)
end

#rxstring(i) ⇒ Object



161
162
163
# File 'lib/flor/parser.rb', line 161

def rxstring(i)
  seq(:rxstring, i, :rxr, '?', :slash, :dpar_or_rxsc, '*', :slash, :rxopts)
end

#sand(i) ⇒ Object

space or eol



232
# File 'lib/flor/parser.rb', line 232

def sand(i); seq(nil, i, :ssand, :woreol); end

#sbend(i) ⇒ Object



62
# File 'lib/flor/parser.rb', line 62

def sbend(i); str(nil, i, ']'); end

#sbstart(i) ⇒ Object



61
# File 'lib/flor/parser.rb', line 61

def sbstart(i); str(nil, i, '['); end

#semicolon(i) ⇒ Object



52
# File 'lib/flor/parser.rb', line 52

def semicolon(i); str(nil, i, ';'); end

#semicolon_eol(i) ⇒ Object



77
# File 'lib/flor/parser.rb', line 77

def semicolon_eol(i); seq(nil, i, :semicolon, :eol); end

#sep(i) ⇒ Object



183
# File 'lib/flor/parser.rb', line 183

def sep(i); alt(nil, i, :comma_eol, :wstar); end

#sequ(i) ⇒ Object



231
# File 'lib/flor/parser.rb', line 231

def sequ(i); seq(nil, i, :ssequ, :eol, '?'); end

#slash(i) ⇒ Object



55
# File 'lib/flor/parser.rb', line 55

def slash(i); rex(nil, i, /\/(?!\/)/); end

#slgt(i) ⇒ Object



230
# File 'lib/flor/parser.rb', line 230

def slgt(i); seq(nil, i, :sslgt, :eol, '?'); end

#smod(i) ⇒ Object



227
# File 'lib/flor/parser.rb', line 227

def smod(i); seq(nil, i, :ssmod, :eol, '?'); end

#sor(i) ⇒ Object

space or eol



233
# File 'lib/flor/parser.rb', line 233

def sor(i); seq(nil, i, :ssor, :woreol); end

#sprd(i) ⇒ Object



228
# File 'lib/flor/parser.rb', line 228

def sprd(i); seq(nil, i, :ssprd, :eol, '?'); end

#sqstring(i) ⇒ Object



165
166
167
168
169
170
171
172
173
# File 'lib/flor/parser.rb', line 165

def sqstring(i)
  rex(:sqstring, i, %r{
    '(
      \\['\\\/bfnrt] |
      \\u[0-9a-fA-F]{4} |
      [^'\\\b\f\n\r\t]
    )*'
  }x)
end

#ssand(i) ⇒ Object



224
# File 'lib/flor/parser.rb', line 224

def ssand(i); str(:sop, i, 'and'); end

#ssequ(i) ⇒ Object



223
# File 'lib/flor/parser.rb', line 223

def ssequ(i); rex(:sop, i, /(==?|!=|<>)/); end

#sslgt(i) ⇒ Object



222
# File 'lib/flor/parser.rb', line 222

def sslgt(i); rex(:sop, i, /(<=?|>=?)/); end

#ssmod(i) ⇒ Object

precedence

%w[ or or ], %w[ and and ],
%w[ equ == != <> ], %w[ lgt < > <= >= ], %w[ sum + - ], %w[ prd * / % ],


219
# File 'lib/flor/parser.rb', line 219

def ssmod(i); str(:sop, i, /%/); end

#ssor(i) ⇒ Object



225
# File 'lib/flor/parser.rb', line 225

def ssor(i); str(:sop, i, 'or'); end

#ssprd(i) ⇒ Object



220
# File 'lib/flor/parser.rb', line 220

def ssprd(i); rex(:sop, i, /(\*|\/(?!\/))/); end

#sssum(i) ⇒ Object



221
# File 'lib/flor/parser.rb', line 221

def sssum(i); rex(:sop, i, /[+-]/); end

#ssum(i) ⇒ Object



229
# File 'lib/flor/parser.rb', line 229

def ssum(i); seq(nil, i, :sssum, :eol, '?'); end

#tru(i) ⇒ Object



72
# File 'lib/flor/parser.rb', line 72

def tru(i); str(nil, i, 'true'); end

#val(i) ⇒ Object



206
207
208
209
210
211
212
# File 'lib/flor/parser.rb', line 206

def val(i)
  altg(:val, i,
    :panode, :par,
    :reference, :sqstring, :dqstring, :rxstring,
    :arr, :obj,
    :number, :boolean, :null)
end

#val_ws(i) ⇒ Object



213
# File 'lib/flor/parser.rb', line 213

def val_ws(i); seq(nil, i, :val, :wstar); end

#woreol(i) ⇒ Object



188
# File 'lib/flor/parser.rb', line 188

def woreol(i); alt(:woreol, i, :wplus, :eol_plus); end

#wplus(i) ⇒ Object



45
# File 'lib/flor/parser.rb', line 45

def wplus(i); rex(nil, i, /[ \t]+/); end

#wstar(i) ⇒ Object

parsing



44
# File 'lib/flor/parser.rb', line 44

def wstar(i); rex(nil, i, /[ \t]*/); end