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

Commit

Permalink
Switch to using !PREFIX__* instead of *__PEEK.
Browse files Browse the repository at this point in the history
  • Loading branch information
pmichaud committed Oct 22, 2009
1 parent 0abc653 commit 9197d53
Show file tree
Hide file tree
Showing 5 changed files with 956 additions and 778 deletions.
4 changes: 2 additions & 2 deletions src/PAST/Compiler-Regex.pir
Expand Up @@ -107,9 +107,9 @@ Return the POST representation of the regex AST rooted by C<node>.
goto token_loop
token_done:
$S0 = regexname
$S0 = concat $S0, '__PEEK'
$S0 = concat '!PREFIX__', $S0
$P99 = get_hll_global ['PAST'], 'Block'
tpast = $P99.'new'(tpast, 'name'=>$S0, 'lexical'=>0)
tpast = $P99.'new'(tpast, 'name'=>$S0, 'lexical'=>0, 'blocktype'=>'method')
tpost = self.'as_post'(tpast, 'rtype'=>'v')
ops.'push'(tpost)
peek_done:
Expand Down
38 changes: 23 additions & 15 deletions src/Regex/Cursor-protoregex-peek.pir
Expand Up @@ -34,12 +34,6 @@ Perform a match for protoregex C<name>.
prototable = self.'!protoregex_gen_table'(parrotclass)
have_prototable:

$P0 = getattribute self, '$!type'
if null $P0 goto peek_done
unless $P0 == CURSOR_TYPE_PEEK goto peek_done
.tailcall self.'!prototype_peek'(prototable, name)
peek_done:

self.'!cursor_debug'('PROTO ', name)

# Obtain the toxrk and toklen hashes for the current grammar
Expand Down Expand Up @@ -209,11 +203,6 @@ called C<name>.
mprefix = concat name, ':sym<'
mlen = length mprefix
.local pmc peekcur
peekcur = self.'!cursor_start'()
$P0 = box CURSOR_TYPE_PEEK
setattribute peekcur, '$!type', $P0
.local pmc method_it, method
.local string method_name
method_it = iter prototable
Expand All @@ -224,11 +213,30 @@ called C<name>.
if $S0 != mprefix goto method_loop
# Okay, we've found a method name intended for this protoregex.
# Now we look up the method itself, and ask it for its prefix tokens.
# If it doesn't return any, we use '' as its only prefix.
.local pmc rx, tokens, tokens_it
# Look up the method itself.
.local pmc rx
rx = find_method self, method_name
(tokens :slurpy) = peekcur.rx()

# Now let's find out its prefix tokens; calling the methodname
# with a !PREFIX__ suffix will give us a list of valid token prefixes.
# If there is no such !PREFIX__ method, we use '' as the only token prefix.
.local pmc tokens, tokens_it
$S0 = concat '!PREFIX__', method_name
$I0 = can self, $S0
unless $I0 goto method_peek_none
tokens = self.$S0()
goto method_peek_done
method_peek_none:
tokens = new ['ResizablePMCArray']
push tokens, ''
method_peek_done:
# printerr name
# printerr ' '
# printerr $S0
# printerr ' tokens=('
# $S0 = join ' ', tokens
# printerr $S0
# printerr ")\n"

# Now loop through all of the tokens for the method, updating
# the longest initial key and adding it to the tokrx hash.
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
90 changes: 45 additions & 45 deletions src/stage0/P6Grammar-s0.pir
Expand Up @@ -17,28 +17,28 @@ Regex::P6Grammar - scaffolding compiler for NQP / Perl 6 grammars
### .include 'src/gen/p6grammar-grammar.pir'

.namespace ["Regex";"P6Grammar";"Grammar"]
.sub "_block11" :subid("10_1256208768.03444")
.sub "_block11" :subid("10_1256210833.82607")
.annotate "line", 0
.const 'Sub' $P48 = "19_1256208768.03444"
.const 'Sub' $P48 = "19_1256210833.82607"
capture_lex $P48
.const 'Sub' $P34 = "17_1256208768.03444"
.const 'Sub' $P34 = "17_1256210833.82607"
capture_lex $P34
.const 'Sub' $P26 = "15_1256208768.03444"
.const 'Sub' $P26 = "15_1256210833.82607"
capture_lex $P26
.const 'Sub' $P20 = "13_1256208768.03444"
.const 'Sub' $P20 = "13_1256210833.82607"
capture_lex $P20
.const 'Sub' $P13 = "11_1256208768.03444"
.const 'Sub' $P13 = "11_1256210833.82607"
capture_lex $P13
.annotate "line", 19
.const 'Sub' $P48 = "19_1256208768.03444"
.const 'Sub' $P48 = "19_1256210833.82607"
capture_lex $P48
.annotate "line", 1
.return ($P48)
.end


.namespace ["Regex";"P6Grammar";"Grammar"]
.sub "" :load :init :subid("post21") :outer("10_1256208768.03444")
.sub "" :load :init :subid("post21") :outer("10_1256210833.82607")
.annotate "line", 0
get_hll_global $P12, ["Regex";"P6Grammar";"Grammar"], "_block11"
.local pmc block
Expand All @@ -50,7 +50,7 @@ Regex::P6Grammar - scaffolding compiler for NQP / Perl 6 grammars
.namespace ["Regex";"P6Grammar";"Grammar"]
.sub "TOP" :subid("11_1256208768.03444") :method :outer("10_1256208768.03444")
.sub "TOP" :subid("11_1256210833.82607") :method :outer("10_1256210833.82607")
.annotate "line", 3
.local string rx14_tgt
.local int rx14_pos
Expand Down Expand Up @@ -125,7 +125,7 @@ Regex::P6Grammar - scaffolding compiler for NQP / Perl 6 grammars
.namespace ["Regex";"P6Grammar";"Grammar"]
.sub "TOP__PEEK" :subid("12_1256208768.03444")
.sub "!PREFIX__TOP" :subid("12_1256210833.82607") :method
.annotate "line", 3
new $P16, "ResizablePMCArray"
push $P16, ""
Expand All @@ -134,7 +134,7 @@ Regex::P6Grammar - scaffolding compiler for NQP / Perl 6 grammars
.namespace ["Regex";"P6Grammar";"Grammar"]
.sub "name" :subid("13_1256208768.03444") :method :outer("10_1256208768.03444")
.sub "name" :subid("13_1256210833.82607") :method :outer("10_1256210833.82607")
.annotate "line", 9
.local string rx21_tgt
.local int rx21_pos
Expand Down Expand Up @@ -189,7 +189,7 @@ Regex::P6Grammar - scaffolding compiler for NQP / Perl 6 grammars
.namespace ["Regex";"P6Grammar";"Grammar"]
.sub "name__PEEK" :subid("14_1256208768.03444")
.sub "!PREFIX__name" :subid("14_1256210833.82607") :method
.annotate "line", 9
new $P23, "ResizablePMCArray"
push $P23, ""
Expand All @@ -198,7 +198,7 @@ Regex::P6Grammar - scaffolding compiler for NQP / Perl 6 grammars
.namespace ["Regex";"P6Grammar";"Grammar"]
.sub "longname" :subid("15_1256208768.03444") :method :outer("10_1256208768.03444")
.sub "longname" :subid("15_1256210833.82607") :method :outer("10_1256210833.82607")
.annotate "line", 11
.local string rx27_tgt
.local int rx27_pos
Expand Down Expand Up @@ -275,7 +275,7 @@ Regex::P6Grammar - scaffolding compiler for NQP / Perl 6 grammars
.namespace ["Regex";"P6Grammar";"Grammar"]
.sub "longname__PEEK" :subid("16_1256208768.03444")
.sub "!PREFIX__longname" :subid("16_1256210833.82607") :method
.annotate "line", 11
new $P29, "ResizablePMCArray"
push $P29, ""
Expand All @@ -284,7 +284,7 @@ Regex::P6Grammar - scaffolding compiler for NQP / Perl 6 grammars
.namespace ["Regex";"P6Grammar";"Grammar"]
.sub "grammar_stmt" :subid("17_1256208768.03444") :method :outer("10_1256208768.03444")
.sub "grammar_stmt" :subid("17_1256210833.82607") :method :outer("10_1256210833.82607")
.annotate "line", 17
.local string rx35_tgt
.local int rx35_pos
Expand Down Expand Up @@ -401,7 +401,7 @@ Regex::P6Grammar - scaffolding compiler for NQP / Perl 6 grammars
.namespace ["Regex";"P6Grammar";"Grammar"]
.sub "grammar_stmt__PEEK" :subid("18_1256208768.03444")
.sub "!PREFIX__grammar_stmt" :subid("18_1256210833.82607") :method
.annotate "line", 17
new $P37, "ResizablePMCArray"
push $P37, ""
Expand All @@ -410,7 +410,7 @@ Regex::P6Grammar - scaffolding compiler for NQP / Perl 6 grammars
.namespace ["Regex";"P6Grammar";"Grammar"]
.sub "regex_stmt" :subid("19_1256208768.03444") :method :outer("10_1256208768.03444")
.sub "regex_stmt" :subid("19_1256210833.82607") :method :outer("10_1256210833.82607")
.annotate "line", 19
.local string rx49_tgt
.local int rx49_pos
Expand Down Expand Up @@ -685,7 +685,7 @@ Regex::P6Grammar - scaffolding compiler for NQP / Perl 6 grammars
.namespace ["Regex";"P6Grammar";"Grammar"]
.sub "regex_stmt__PEEK" :subid("20_1256208768.03444")
.sub "!PREFIX__regex_stmt" :subid("20_1256210833.82607") :method
.annotate "line", 19
new $P51, "ResizablePMCArray"
push $P51, ""
Expand All @@ -695,7 +695,7 @@ Regex::P6Grammar - scaffolding compiler for NQP / Perl 6 grammars
### .include 'src/gen/p6grammar-actions.pir'
.namespace []
.sub "_block11" :anon :subid("10_1256208680.95757")
.sub "_block11" :anon :subid("10_1256210828.93317")
.annotate "line", 3
get_hll_global $P14, ["Regex";"P6Grammar";"Actions"], "_block13"
.annotate "line", 1
Expand All @@ -704,29 +704,29 @@ Regex::P6Grammar - scaffolding compiler for NQP / Perl 6 grammars
.namespace ["Regex";"P6Grammar";"Actions"]
.sub "_block13" :init :load :subid("11_1256208680.95757")
.sub "_block13" :init :load :subid("11_1256210828.93317")
.annotate "line", 3
.const 'Sub' $P83 = "15_1256208680.95757"
.const 'Sub' $P83 = "15_1256210828.93317"
capture_lex $P83
.const 'Sub' $P44 = "14_1256208680.95757"
.const 'Sub' $P44 = "14_1256210828.93317"
capture_lex $P44
.const 'Sub' $P16 = "12_1256208680.95757"
.const 'Sub' $P16 = "12_1256210828.93317"
capture_lex $P16
$P15 = get_root_global ["parrot"], "P6metaclass"
$P15."new_class"("Regex::P6Grammar::Actions", "Regex::P6Regex::Actions" :named("parent"))
.annotate "line", 30
.const 'Sub' $P83 = "15_1256208680.95757"
.const 'Sub' $P83 = "15_1256210828.93317"
capture_lex $P83
.annotate "line", 3
.return ($P83)
.end
.namespace ["Regex";"P6Grammar";"Actions"]
.sub "TOP" :subid("12_1256208680.95757") :method :outer("11_1256208680.95757")
.sub "TOP" :subid("12_1256210828.93317") :method :outer("11_1256210828.93317")
.param pmc param_19
.annotate "line", 3
.const 'Sub' $P29 = "13_1256208680.95757"
.const 'Sub' $P29 = "13_1256210828.93317"
capture_lex $P29
new $P18, 'ExceptionHandler'
set_addr $P18, control_17
Expand Down Expand Up @@ -759,7 +759,7 @@ $P15 = get_root_global ["parrot"], "P6metaclass"
unless $P23, loop35_done
shift $P27, $P23
loop35_redo:
.const 'Sub' $P29 = "13_1256208680.95757"
.const 'Sub' $P29 = "13_1256210828.93317"
capture_lex $P29
$P29($P27)
loop35_next:
Expand Down Expand Up @@ -802,7 +802,7 @@ $P15 = get_root_global ["parrot"], "P6metaclass"
.namespace ["Regex";"P6Grammar";"Actions"]
.sub "_block28" :anon :subid("13_1256208680.95757") :outer("12_1256208680.95757")
.sub "_block28" :anon :subid("13_1256210828.93317") :outer("12_1256210828.93317")
.param pmc param_30
.annotate "line", 5
.lex "$_", param_30
Expand All @@ -823,7 +823,7 @@ $P15 = get_root_global ["parrot"], "P6metaclass"
.namespace ["Regex";"P6Grammar";"Actions"]
.sub "grammar_stmt" :subid("14_1256208680.95757") :method :outer("11_1256208680.95757")
.sub "grammar_stmt" :subid("14_1256210828.93317") :method :outer("11_1256210828.93317")
.param pmc param_47
.annotate "line", 13
new $P46, 'ExceptionHandler'
Expand Down Expand Up @@ -937,16 +937,16 @@ $P15 = get_root_global ["parrot"], "P6metaclass"
.namespace ["Regex";"P6Grammar";"Actions"]
.sub "regex_stmt" :subid("15_1256208680.95757") :method :outer("11_1256208680.95757")
.sub "regex_stmt" :subid("15_1256210828.93317") :method :outer("11_1256210828.93317")
.param pmc param_86
.param pmc param_87 :optional
.param int has_param_87 :opt_flag
.annotate "line", 30
.const 'Sub' $P141 = "20_1256208680.95757"
.const 'Sub' $P141 = "20_1256210828.93317"
capture_lex $P141
.const 'Sub' $P130 = "19_1256208680.95757"
.const 'Sub' $P130 = "19_1256210828.93317"
capture_lex $P130
.const 'Sub' $P95 = "16_1256208680.95757"
.const 'Sub' $P95 = "16_1256210828.93317"
capture_lex $P95
new $P85, 'ExceptionHandler'
set_addr $P85, control_84
Expand All @@ -972,7 +972,7 @@ $P15 = get_root_global ["parrot"], "P6metaclass"
set $S92, $P91
iseq $I93, $S92, "open"
unless $I93, if_90_end
.const 'Sub' $P95 = "16_1256208680.95757"
.const 'Sub' $P95 = "16_1256210828.93317"
capture_lex $P95
$P95()
if_90_end:
Expand All @@ -997,13 +997,13 @@ $P15 = get_root_global ["parrot"], "P6metaclass"
vivify_51:
if $P128, if_126
.annotate "line", 57
.const 'Sub' $P141 = "20_1256208680.95757"
.const 'Sub' $P141 = "20_1256210828.93317"
capture_lex $P141
$P141()
goto if_126_end
if_126:
.annotate "line", 43
.const 'Sub' $P130 = "19_1256208680.95757"
.const 'Sub' $P130 = "19_1256210828.93317"
capture_lex $P130
$P130()
if_126_end:
Expand All @@ -1026,11 +1026,11 @@ $P15 = get_root_global ["parrot"], "P6metaclass"
.namespace ["Regex";"P6Grammar";"Actions"]
.sub "_block94" :anon :subid("16_1256208680.95757") :outer("15_1256208680.95757")
.sub "_block94" :anon :subid("16_1256210828.93317") :outer("15_1256210828.93317")
.annotate "line", 34
.const 'Sub' $P112 = "18_1256208680.95757"
.const 'Sub' $P112 = "18_1256210828.93317"
capture_lex $P112
.const 'Sub' $P103 = "17_1256208680.95757"
.const 'Sub' $P103 = "17_1256210828.93317"
capture_lex $P103
.annotate "line", 35
new $P96, "Hash"
Expand All @@ -1044,7 +1044,7 @@ $P15 = get_root_global ["parrot"], "P6metaclass"
set $S100, $P99
iseq $I101, $S100, "token"
unless $I101, if_97_end
.const 'Sub' $P103 = "17_1256208680.95757"
.const 'Sub' $P103 = "17_1256210828.93317"
capture_lex $P103
$P103()
if_97_end:
Expand All @@ -1057,7 +1057,7 @@ $P15 = get_root_global ["parrot"], "P6metaclass"
set $S109, $P108
iseq $I110, $S109, "rule"
unless $I110, if_106_end
.const 'Sub' $P112 = "18_1256208680.95757"
.const 'Sub' $P112 = "18_1256210828.93317"
capture_lex $P112
$P112()
if_106_end:
Expand All @@ -1084,7 +1084,7 @@ $P15 = get_root_global ["parrot"], "P6metaclass"
.namespace ["Regex";"P6Grammar";"Actions"]
.sub "_block102" :anon :subid("17_1256208680.95757") :outer("16_1256208680.95757")
.sub "_block102" :anon :subid("17_1256210828.93317") :outer("16_1256210828.93317")
.annotate "line", 36
new $P104, "Integer"
assign $P104, 1
Expand All @@ -1099,7 +1099,7 @@ $P15 = get_root_global ["parrot"], "P6metaclass"
.namespace ["Regex";"P6Grammar";"Actions"]
.sub "_block111" :anon :subid("18_1256208680.95757") :outer("16_1256208680.95757")
.sub "_block111" :anon :subid("18_1256210828.93317") :outer("16_1256210828.93317")
.annotate "line", 37
new $P113, "Integer"
assign $P113, 1
Expand All @@ -1122,7 +1122,7 @@ $P15 = get_root_global ["parrot"], "P6metaclass"
.namespace ["Regex";"P6Grammar";"Actions"]
.sub "_block140" :anon :subid("20_1256208680.95757") :outer("15_1256208680.95757")
.sub "_block140" :anon :subid("20_1256210828.93317") :outer("15_1256210828.93317")
.annotate "line", 58
find_lex $P142, "$/"
set $P143, $P142["nibbler"]
Expand Down Expand Up @@ -1196,7 +1196,7 @@ $P15 = get_root_global ["parrot"], "P6metaclass"
.namespace ["Regex";"P6Grammar";"Actions"]
.sub "_block129" :anon :subid("19_1256208680.95757") :outer("15_1256208680.95757")
.sub "_block129" :anon :subid("19_1256210828.93317") :outer("15_1256210828.93317")
.annotate "line", 45
get_hll_global $P131, ["PAST"], "Block"
find_lex $P132, "$name"
Expand Down

0 comments on commit 9197d53

Please sign in to comment.