Skip to content

Commit

Permalink
change most uses of "pragma" with "modifier" for consistency with pdd19
Browse files Browse the repository at this point in the history
  • Loading branch information
cotto committed Jun 27, 2010
1 parent a40b7e7 commit feeef08
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 38 deletions.
20 changes: 10 additions & 10 deletions docs/pirgrammar.pod
Original file line number Diff line number Diff line change
Expand Up @@ -132,33 +132,33 @@ document.


sub_def:
".sub" sub_id sub_pragmas* nl body
".sub" sub_id sub_modifiers* nl body

sub_id:
identifier | string_constant

sub_pragma:
sub_modifier:
":load"
| ":init"
| ":immediate"
| ":postcomp"
| ":main"
| ":anon"
| ":lex"
| vtable_pragma
| multi_pragma
| outer_pragma
| vtable_modifier
| multi_modifier
| outer_modifier

vtable_pragma:
vtable_modifier:
":vtable" parenthesized_string?

parenthesized_string:
"(" string_constant ")"

multi_pragma:
multi_modifier:
":multi" "(" multi_types? ")"

outer_pragma:
outer_modifier:
":outer" "(" sub_id ")"

multi_tyes:
Expand Down Expand Up @@ -210,7 +210,7 @@ discussed in the section defining local declarations.

Run this subroutine during the B<load_library> opcode.
B<:load> is ignored, if another subroutine in that file is marked with
B<:main>. If multiple subs have the B<:load> pragma, the subs are
B<:main>. If multiple subs have the B<:load> modifier, the subs are
run in source code order.

=item *
Expand Down Expand Up @@ -1059,7 +1059,7 @@ then one can write in a subroutine:

=head2 PIR Pragmas

pragma:
modifier:
new_operators
| loadlib
| namespace
Expand Down
4 changes: 2 additions & 2 deletions src/PIR/Actions.pm
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ method compilation_unit:sym<sub> ($/) {
my $name := $<subname>.ast;
$!BLOCK.name( $name );

# TODO Handle pragmas.
# TODO Handle modifiers.

# TODO Handle :main pragma
# TODO Handle :main modifier
$!MAIN := $name unless $!MAIN;

if $<statement> {
Expand Down
36 changes: 18 additions & 18 deletions src/PIR/Grammar.pm
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ rule compilation_unit:sym<sub> {
<.newpad>
'.sub' <subname>
[
|| [ <.ws> <sub_pragma> ]*
|| <.panic: "Unknown .sub pragma">
|| [ <.ws> <sub_modifier> ]*
|| <.panic: "Unknown .sub modifier">
]
<ws> <.nl>

Expand Down Expand Up @@ -79,22 +79,22 @@ token macro_statement:sym<.label> { <sym> <.ws> '$' <ident> ':' <pir_instruction

#token compilation_unit:sym<pragma> { }

proto regex sub_pragma { <...> }
token sub_pragma:sym<main> { ':' <sym> }
token sub_pragma:sym<init> { ':' <sym> }
token sub_pragma:sym<load> { ':' <sym> }
token sub_pragma:sym<immediate> { ':' <sym> }
token sub_pragma:sym<postcomp> { ':' <sym> }
token sub_pragma:sym<anon> { ':' <sym> }
token sub_pragma:sym<method> { ':' <sym> }
token sub_pragma:sym<lex> { ':' <sym> }

token sub_pragma:sym<nsentry> { ':' <sym> [ '(' <string_constant> ')' ]? }
token sub_pragma:sym<vtable> { ':' <sym> [ '(' <string_constant> ')' ]? }
token sub_pragma:sym<outer> { ':' <sym> '(' <subname> ')' }
token sub_pragma:sym<subid> { ':' <sym> '(' <string_constant> ')' }

token sub_pragma:sym<multi> { ':' <sym> '(' [ [<.ws><multi_type><.ws>] ** ',' ]? ')' }
proto regex sub_modifier { <...> }
token sub_modifier:sym<main> { ':' <sym> }
token sub_modifier:sym<init> { ':' <sym> }
token sub_modifier:sym<load> { ':' <sym> }
token sub_modifier:sym<immediate> { ':' <sym> }
token sub_modifier:sym<postcomp> { ':' <sym> }
token sub_modifier:sym<anon> { ':' <sym> }
token sub_modifier:sym<method> { ':' <sym> }
token sub_modifier:sym<lex> { ':' <sym> }

token sub_modifier:sym<nsentry> { ':' <sym> [ '(' <string_constant> ')' ]? }
token sub_modifier:sym<vtable> { ':' <sym> [ '(' <string_constant> ')' ]? }
token sub_modifier:sym<outer> { ':' <sym> '(' <subname> ')' }
token sub_modifier:sym<subid> { ':' <sym> '(' <string_constant> ')' }

token sub_modifier:sym<multi> { ':' <sym> '(' [ [<.ws><multi_type><.ws>] ** ',' ]? ')' }

# TODO Do more strict parsing.
token multi_type {
Expand Down
16 changes: 8 additions & 8 deletions t/01-parse/01-subs.t
Original file line number Diff line number Diff line change
Expand Up @@ -17,41 +17,41 @@ $res := parse($c, q{
.end
});

ok(!$res, "Wrong pragma was caught");
ok(!$res, "Wrong modifier was caught");

for <main init load immediate postcomp anon method nsentry> -> $pragma {
for <main init load immediate postcomp anon method nsentry> -> $modifier {
$res := parse($c, qq{
.sub "foo" :$pragma
.sub "foo" :$modifier
.end
});

ok($res, ":$pragma pragma parsed");
ok($res, ":$modifier modifier parsed");
}

$res := parse($c, q{
.sub "foo" :init :load :anon
.end
});

ok($res, "Multiple pragmas parsed");
ok($res, "Multiple modifiers parsed");

$res := parse($c, q{
.sub "foo" :vtable("get_string")
.end
});
ok($res, ":vtable pragma parsed");
ok($res, ":vtable modifier parsed");

$res := parse($c, q{
.sub "foo" :outer("outer")
.end
});
ok($res, ":outer pragma parsed");
ok($res, ":outer modifier parsed");

$res := parse($c, q{
.sub "foo" :subid("subid")
.end
});
ok($res, ":subid pragma parsed");
ok($res, ":subid modifier parsed");

$res := parse($c, q{
.sub "foo" :multi(_)
Expand Down

0 comments on commit feeef08

Please sign in to comment.