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

Commit

Permalink
More bootstrap refactoring.
Browse files Browse the repository at this point in the history
  • Loading branch information
pmichaud committed Oct 17, 2009
1 parent 2f2704b commit 6c418a8
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 6 deletions.
12 changes: 8 additions & 4 deletions src/Regex/P6Grammar.pir
Expand Up @@ -9,11 +9,17 @@ Regex::P6Grammar - scaffolding compiler for NQP / Perl 6 grammars

=cut

.namespace ['Regex';'P6Grammar';'Compiler']

.sub '' :anon :load :init
load_bytecode 'PCT.pbc'
load_bytecode 'p6regex.pbc'
.end

.include 'src/gen/p6grammar-grammar.pir'
.include 'src/gen/p6grammar-actions.pir'

.namespace ['Regex';'P6Grammar';'Compiler']

.sub '' :anon :load :init
.local pmc p6meta, p6grammar
p6meta = get_hll_global 'P6metaclass'
p6grammar = p6meta.'new_class'('Regex::P6Grammar::Compiler', 'parent'=>'HLL::Compiler')
Expand All @@ -32,8 +38,6 @@ Regex::P6Grammar - scaffolding compiler for NQP / Perl 6 grammars
exit 0
.end
.include 'src/gen/p6grammar-grammar.pir'
.include 'src/gen/p6grammar-actions.pir'
.sub '' :anon :load :init
.local pmc p6grammar
Expand Down
4 changes: 2 additions & 2 deletions src/Regex/P6Regex/Grammar.pm
Expand Up @@ -14,7 +14,7 @@ grammar Regex::P6Regex::Grammar;
{*}
}

rule arglist { <arg> ** ',' {*} }
rule arglist { <arg> [ ',' <arg> ]* {*} }

token TOP {
<nibbler>
Expand Down Expand Up @@ -132,9 +132,9 @@ grammar Regex::P6Regex::Grammar;
$<longname>=[\w+]
[
| <?before '>'>
| <.normspace> <nibbler>
| '=' <assertion>
| ':' <arglist>
| <.normspace> <nibbler>
]?
{*}
}
Expand Down
23 changes: 23 additions & 0 deletions src/cheats/p6regex-grammar.pir
Expand Up @@ -33,6 +33,29 @@
.sub 'panic' :method
.param pmc args :slurpy

.local int pos
.local pmc target
$I0 = isa self, ['Regex';'Cursor']
if $I0 goto cursor_pos
pos = self.'to'()
target = self.'orig'()
goto have_pos
cursor_pos:
pos = self.'pos'()
target = getattribute self, '$!target'
have_pos:

$I1 = target.'lineof'(pos)
push args, ' at line '
push args, $I1

$S0 = target
$S0 = substr $S0, pos, 10
$S0 = escape $S0
push args, ', near "'
push args, $S0
push args, '"'

.local string message
message = join '', args

Expand Down

0 comments on commit 6c418a8

Please sign in to comment.