Skip to content
This repository has been archived by the owner on Feb 3, 2021. It is now read-only.

Commit

Permalink
Convert token peeks to use separate *__PEEK methods.
Browse files Browse the repository at this point in the history
  • Loading branch information
pmichaud committed Oct 22, 2009
1 parent 503d396 commit 0abc653
Show file tree
Hide file tree
Showing 5 changed files with 5,618 additions and 5,517 deletions.
1 change: 1 addition & 0 deletions build/Makefile.in
Expand Up @@ -120,6 +120,7 @@ $(P6GRAMMAR_PBC_0): $(P6REGEX_PBC_0) src/stage0/P6Grammar-s0.pir
$(PARROT) -o $(P6GRAMMAR_PBC_0) src/stage0/P6Grammar-s0.pir

$(P6REGEX_PBC_1): $(P6GRAMMAR_PBC_0) $(P6REGEX_A) $(P6REGEX_SOURCES)
$(RM) $(P6REGEX_PBC) $(P6GRAMMAR_PBC)
$(MKPATH) $(STAGE1)/src/gen
$(PARROT) --library=$(STAGE0) $(P6GRAMMAR_PBC_0) \
--target=pir --output=$(P6REGEX_G_1) \
Expand Down
16 changes: 8 additions & 8 deletions src/PAST/Compiler-Regex.pir
Expand Up @@ -63,9 +63,7 @@ Return the POST representation of the regex AST rooted by C<node>.
goto iter_loop
iter_done:

.local pmc peeklabel, startlabel, donelabel, faillabel
$S0 = concat prefix, 'peek'
peeklabel = self.'post_new'('Label', 'result'=>$S0)
.local pmc startlabel, donelabel, faillabel
$S0 = concat prefix, 'start'
startlabel = self.'post_new'('Label', 'result'=>$S0)
$S0 = concat prefix, 'done'
Expand Down Expand Up @@ -97,22 +95,24 @@ Return the POST representation of the regex AST rooted by C<node>.
.local string cur, rep, pos, tgt, off, eos
(cur, rep, pos, tgt, off, eos) = self.'!rxregs'('cur rep pos tgt off eos')

unless regexname goto peek_done
.local pmc tpast, token, tpost
$P99 = get_hll_global ['PAST'], 'Op'
tpast = $P99.'new'( 'pirop'=>'return v*', 'node'=>node )
tpast = $P99.'new'( 'pasttype'=>'list', 'node'=>node )
(token :slurpy) = node.'prefix'('')
token_loop:
unless token goto token_done
$P0 = shift token
push tpast, $P0
goto token_loop
token_done:
$S0 = regexname
$S0 = concat $S0, '__PEEK'
$P99 = get_hll_global ['PAST'], 'Block'
tpast = $P99.'new'(tpast, 'name'=>$S0, 'lexical'=>0)
tpost = self.'as_post'(tpast, 'rtype'=>'v')
ops.'push_pirop'('getattribute', '$P10', 'self', '"$!type"')
ops.'push_pirop'('if_null', '$P10', peeklabel)
ops.'push_pirop'('ne', '$P10', CURSOR_TYPE_PEEK, peeklabel)
ops.'push'(tpost)
ops.'push'(peeklabel)
peek_done:

$S0 = concat '(', cur
concat $S0, ', '
Expand Down
4 changes: 2 additions & 2 deletions src/Regex/P6Regex.pir
Expand Up @@ -16,10 +16,10 @@ Regex::P6Regex - Parser/compiler for Perl 6 regexes
.include 'src/PAST/Compiler-Regex.pir'
.include 'src/Regex/Cursor.pir'
.include 'src/Regex/Cursor-builtins.pir'
.include 'src/Regex/Cursor-protoregex-peek.pir'
# .include 'src/Regex/Cursor-protoregex-peek.pir'
.include 'src/Regex/Match.pir'
.include 'src/Regex/Dumper.pir'
# .include 'src/cheats/regex-cursor-protoregex.pir'
.include 'src/cheats/regex-cursor-protoregex.pir'

.include 'src/gen/p6regex-grammar.pir'
.include 'src/gen/p6regex-actions.pir'
Expand Down

0 comments on commit 0abc653

Please sign in to comment.