Skip to content

Instantly share code, notes, and snippets.

@jnthn
Created November 21, 2010 21:17
Show Gist options
  • Save jnthn/709162 to your computer and use it in GitHub Desktop.
Save jnthn/709162 to your computer and use it in GitHub Desktop.
> /h/
>>>>>>>>>> From here...
"past" => PMC 'PAST;Block' {
<loadlibs> => ResizablePMCArray (size:2) [
"nqp_group",
"nqp_ops"
]
<pos> => 0
<source> => "/h/\n"
[0] => PMC 'PAST;Op' {
<pirop> => "nqp_dynop_setup v"
}
[1] => PMC 'PAST;Stmts'
[2] => PMC 'PAST;Op' {
<inline> => ResizablePMCArray (size:6) [
" $P0 = find_dynamic_lex \"$*CTXSAVE\"",
" if null $P0 goto ctxsave_done",
" $I0 = can $P0, \"ctxsave\"",
" unless $I0 goto ctxsave_done",
" $P0.\"ctxsave\"()",
" ctxsave_done:"
]
}
[3] => PMC 'PAST;Op' {
<pirop> => "return"
[0] => PMC 'PAST;Stmts' {
<pos> => 0
<source> => \past
>>>>>>>>>> to here is just boilerplate, nothing to do with the regex.
>>>>>>>>>> It starts on the line below. /.../ just implies a block that
>>>>>>>>>> is parsed using regex syntax. So it has a PAST::Block around
>>>>>>>>>> it.
[0] => PMC 'PAST;Block' {
<blocktype> => "method"
<symtable> => Hash {
"$/" => Hash {
"scope" => "lexical"
},
"$¢" => Hash {
"scope" => "lexical"
}
}
>>>>>>>>>> This is the .symbol table, declaring $/ and $¢ are lexicals
[0] => PMC 'PAST;Stmts'
>>>>>>>>>> This is whre regex things start.
[1] => PMC 'PAST;Regex' {
>>>>>>>>>> There are no captures...
<capnames> => Hash {
"" => 0
}
>>>>>>>>>> The concat regex node type just joins bits of the regex.
>>>>>>>>>> From a code-gen perspective it's also just concat, I expect
<pasttype> => "concat"
>>>>>>>>>> This marks the start of a match.
[0] => PMC 'PAST;Regex' {
<pasttype> => "scan"
}
>>>>>>>>>> Nested concat node...they're almost like the regex version of PAST::Stmts
[1] => PMC 'PAST;Regex' {
<pasttype> => "concat"
<pos> => 1
<source> => \past
>>>>>>>>>> Literal node, matches the h
[0] => PMC 'PAST;Regex' {
<pasttype> => "literal"
<pos> => 1
<source> => \past
[0] => "h"
}
}
>>>>>>>>>> This marks the end of the match, saying that it was a success (passed)
[2] => PMC 'PAST;Regex' {
<backtrack> => "g"
<pasttype> => "pass"
}
}
}
>>>>>>>>>> finally, more boilerplate...
}
}
[4] => PMC 'PAST;Block' {
<lexical> => 0
<namespace> => ""
<pirflags> => ":load"
[0] => PMC 'PAST;Op' {
<pasttype> => "call"
[0] => PMC 'PAST;Val' {
<value> => \past
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment