Perl 6 Compiler Perl 6 Compiler Status and the Parrot Compiler Toolkit #16

Tokens can be very efficient

token foo { bar \d+ \S* \s* baz }

$I0 = pos + 3
if $I0 > lastpos goto fail
$S0 = substr target, pos, 3
if $S0 != "bar" goto fail
pos += 3
$I0 = find_not_cclass .CCLASS_DIGIT, target, pos, lastpos
rep = $I0 - pos
if rep < 1 goto fail
pos += rep
$I0 = find_cclass .CCLASS_WHITESPACE, target, pos, lastpos
rep = $I0 - pos
pos += rep
$I0 = find_not_cclass .CCLASS_WHITESPACE, target, pos, lastpos
rep = $I0 - pos
pos += rep
$I0 = pos + 3
if $I0 > lastpos goto fail
$S0 = substr target, pos, 3
if $S0 != "baz" goto fail
pos += 3
goto succeed
Copyright © 2006 Patrick Michaud