Skip to content

Instantly share code, notes, and snippets.

Created August 19, 2010 20:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/538865 to your computer and use it in GitHub Desktop.
Save anonymous/538865 to your computer and use it in GitHub Desktop.
.namespace ["NQP";"Grammar"]
.sub "ws" :subid("21_1282248037.5317") :method :outer("11_1282248037.5317")
.annotate 'line', 4
.local string rx70_tgt
.local int rx70_pos
.local int rx70_off
.local int rx70_eos
.local int rx70_rep
.local pmc rx70_cur
.local pmc rx70_debug
(rx70_cur, rx70_pos, rx70_tgt, $I10) = self."!cursor_start"()
getattribute rx70_debug, rx70_cur, "$!debug"
.lex unicode:"$\x{a2}", rx70_cur
.local pmc match
.lex "$/", match
length rx70_eos, rx70_tgt
gt rx70_pos, rx70_eos, rx70_done
set rx70_off, 0
lt rx70_pos, 2, rx70_start
sub rx70_off, rx70_pos, 1
substr rx70_tgt, rx70_tgt, rx70_off
rx70_start:
eq $I10, 1, rx70_restart
if_null rx70_debug, debug_400
rx70_cur."!cursor_debug"("START", "ws")
debug_400:
.annotate 'line', 33
# rx subrule "MARKED" subtype=zerowidth negate=
rx70_cur."!cursor_pos"(rx70_pos)
$P10 = rx70_cur."MARKED"("ws")
unless $P10, rx70_fail
.annotate 'line', 32
# rx pass
rx70_cur."!cursor_pass"(rx70_pos, "ws")
if_null rx70_debug, debug_401
rx70_cur."!cursor_debug"("PASS", "ws", " at pos=", rx70_pos)
debug_401:
.return (rx70_cur)
rx70_restart:
.annotate 'line', 4
if_null rx70_debug, debug_402
rx70_cur."!cursor_debug"("NEXT", "ws")
debug_402:
rx70_fail:
(rx70_rep, rx70_pos, $I10, $P10) = rx70_cur."!mark_fail"(0)
lt rx70_pos, -1, rx70_done
eq rx70_pos, -1, rx70_fail
jump $I10
rx70_done:
rx70_cur."!cursor_fail"()
if_null rx70_debug, debug_403
rx70_cur."!cursor_debug"("FAIL", "ws")
debug_403:
.return (rx70_cur)
.end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment