Permalink
Browse files

[lib/PMC] Modified :named parameter syntax in METHODs to match PDD03,…

… per RT

#42292.  Note that this required substantial modifications to the PMC parser.
O frabjous day.

git-svn-id: https://svn.parrot.org/parrot/trunk@26381 d31e2699-5ff4-0310-a27c-f18f2fbe73fe
  • Loading branch information...
1 parent 116cb59 commit 37922cf3977ff6f7c2a12f356c74e8223bda6af7 @chromatic chromatic committed Mar 15, 2008
Showing with 43 additions and 28 deletions.
  1. +6 −4 lib/Parrot/Pmc2c/PCCMETHOD.pm
  2. +12 −2 lib/Parrot/Pmc2c/Parser.pm
  3. +7 −7 src/pmc/class.pmc
  4. +9 −6 src/pmc/exporter.pmc
  5. +1 −1 src/pmc/pccmethod_test.pmc
  6. +8 −8 src/pmc/role.pmc
@@ -277,16 +277,18 @@ sub parse_p_args_string {
my $linear_args = [];
for my $x ( split /,/, $parameters ) {
- my ( $type, $name, $rest ) = split / /, trim($x), 3;
+ my ( $type, $name, $rest ) = split /\s+/, trim($x), 3;
die "invalid PCC arg '$x': did you forget to specify a type?\n"
unless defined $name;
- $name =~ /[\**]?(\"?[\w_]+\"?)/;
+ if ($name =~ /[\**]?(\"?\w+\"?)/) {
+ $name = $1;
+ }
my $arg = {
type => convert_type_string_to_reg_type($type),
- name => $1,
+ name => $name,
attrs => parse_adverb_attributes($rest)
};
@@ -300,7 +302,7 @@ sub is_named {
my ($arg) = @_;
while ( my ( $k, $v ) = each( %{ $arg->{attrs} } ) ) {
- return ( 1, $1 ) if $k =~ /named\[(.*)\]/;
+ return ( 1, $1 ) if $k =~ /named\((.*)\)/;
}
return ( 0, '' );
View
@@ -163,7 +163,17 @@ sub find_methods {
((?:\w+\s*?\**\s*)?\w+) # method name (includes return type)
\s*
- \( ([^\(]*) \) # parameters
+ \(( # parameters
+ (?:\w+\s*\*? # type (pointer optional)
+ \s*
+ \w+ # argument name
+ (?:
+ \s+:\w+ # attribute
+ (?:\("[^\)]+"\))? # with optional parameter
+ )*
+ ,?\s* # probably a comma and whitespace
+ )* # zero or more of these bad boys
+ )\)
\s*
((?::(\w+)\s*)*) # method attrs
\s*
@@ -173,7 +183,7 @@ sub find_methods {
my ( $decorators, $marker, $methodname, $parameters, $rawattrs ) =
( $2, $3, $4, $5, $6 );
my $attrs = parse_method_attrs($rawattrs) if defined $rawattrs;
- $lineno += count_newlines($1);
+ $lineno += count_newlines($1);
my $returntype = '';
View
@@ -1584,10 +1584,10 @@ C<add_method> vtable method.
*/
METHOD add_method(STRING *name, PMC *sub,
- int vtable :optional :named["vtable"],
+ int vtable :optional :named("vtable"),
int has_vtable :opt_flag,
- int anon :optional :named["anon"],
- int has_anon :opt_flag)
+ int anon :optional :named("anon"),
+ int has_anon :opt_flag)
{
/* If it's a vtable method... */
if (has_vtable && vtable) {
@@ -1677,18 +1677,18 @@ Return the roles array PMC.
/*
-=item C<void add_role(PMC *role, PMC *exclude :optional :named["exclude"],
-PMC *alias :optional :named["alias"])>
+=item C<void add_role(PMC *role, PMC *exclude :optional :named("exclude"),
+PMC *alias :optional :named("alias"))>
Compose a role into a class with the given exclusions and aliases.
=cut
*/
METHOD add_role(PMC *role,
- PMC *exclude_method :optional :named["exclude_method"],
+ PMC *exclude_method :optional :named("exclude_method"),
int has_exclude_method :opt_flag,
- PMC *alias_method :optional :named["alias_method"],
+ PMC *alias_method :optional :named("alias_method"),
int has_alias_method :opt_flag) {
Parrot_Class * const _class = PARROT_CLASS(SELF);
View
@@ -304,9 +304,9 @@ Throws an exception if an unknown PMC type is passed.
/*
=item C<METHOD
- import(PMC *dest :optional :named["destination"], int got_dest :opt_flag,
- PMC *src :optional :named["source"], int got_src :opt_flag,
- PMC *globals :optional :named["globals"], int got_globals :opt_flag)>
+ import(PMC *dest :optional :named("destination"), int got_dest :opt_flag,
+ PMC *src :optional :named("source"), int got_src :opt_flag,
+ PMC *globals :optional :named("globals"), int got_globals :opt_flag)>
Import C<globals> from the C<src> namespace to the C<dest> namespace.
If C<src>, C<dest>, or C<globals> are passed, they override the current value.
@@ -319,9 +319,12 @@ Throws an exception upon error.
*/
- METHOD import(PMC *dest :optional :named["destination"], int got_dest :opt_flag,
- PMC *src :optional :named["source"], int got_src :opt_flag,
- PMC *globals :optional :named["globals"], int got_globals :opt_flag) {
+ METHOD import(PMC *dest :optional :named("destination"),
+ int got_dest :opt_flag,
+ PMC *src :optional :named("source"),
+ int got_src :opt_flag,
+ PMC *globals :optional :named("globals"),
+ int got_globals :opt_flag) {
PMC *ns_src, *ns_dest, *ns_globals;
@@ -48,7 +48,7 @@ pmclass PCCMETHOD_Test need_ext provides hash {
RETURN(int 1000, STRING *kevin);
}
- METHOD test_method3(PMC *a1 :named["a1name"], PMC *a2 :named["a2name"])
+ METHOD test_method3(PMC *a1 :named("a1name"), PMC *a2 :named("a2name"))
{
UNUSED(SELF);
PIO_printf(interp, "test_method3\n");
View
@@ -682,21 +682,21 @@ Return the roles array PMC.
=item C<METHOD
add_role(PMC *role,
- PMC *exclude_method :optional :named["exclude_method"],
- int got_exclude_method :opt_flag,
- PMC *alias_method :optional :named["alias_method"],
- int got_alias_method :opt_flag)>
+ PMC *exclude_method :optional :named("exclude_method"),
+ int got_exclude_method :opt_flag,
+ PMC *alias_method :optional :named("alias_method"),
+ int got_alias_method :opt_flag)>
Compose the given role into this one, using the given exclusions and aliases.
=cut
*/
METHOD add_role(PMC *role,
- PMC *exclude_method :optional :named["exclude_method"],
- int got_exclude_method :opt_flag,
- PMC *alias_method :optional :named["alias_method"],
- int got_alias_method :opt_flag) {
+ PMC *exclude_method :optional :named("exclude_method"),
+ int got_exclude_method :opt_flag,
+ PMC *alias_method :optional :named("alias_method"),
+ int got_alias_method :opt_flag) {
Parrot_Role *role_info = PARROT_ROLE(SELF);
STRING *s_name, *r_name;

0 comments on commit 37922cf

Please sign in to comment.