diff options
author | goodale <goodale@17b73243-c579-4c4c-a9d2-2d5706c11dac> | 2002-05-20 16:53:20 +0000 |
---|---|---|
committer | goodale <goodale@17b73243-c579-4c4c-a9d2-2d5706c11dac> | 2002-05-20 16:53:20 +0000 |
commit | 198f32a7660442c2f7c0f83c2ad179e932074db8 (patch) | |
tree | 49e00822cb466dc3b8c3e1642424d430574100e8 /lib/sbin/parameter_parser.pl | |
parent | 2e56de0aaa761f45dc3fb81fae41566c85c03db1 (diff) |
Added AS for parameters. You can now have one name for a parameter as seen
by the user, and another name for the vaiable in your code.
This will be particularly useful for avoiding conflicts when sharing parameters
from other implementations.
Syntax:
[uses|extends] <type> <name> ["<description>"] AS <newname>
Tom
git-svn-id: http://svn.cactuscode.org/flesh/trunk@2832 17b73243-c579-4c4c-a9d2-2d5706c11dac
Diffstat (limited to 'lib/sbin/parameter_parser.pl')
-rw-r--r-- | lib/sbin/parameter_parser.pl | 72 |
1 files changed, 38 insertions, 34 deletions
diff --git a/lib/sbin/parameter_parser.pl b/lib/sbin/parameter_parser.pl index 0af8bed7..d164a544 100644 --- a/lib/sbin/parameter_parser.pl +++ b/lib/sbin/parameter_parser.pl @@ -1,4 +1,13 @@ #! /usr/bin/perl +#/*@@ +# @file parameter_parser.pl +# @date Mon 25 May 08:07:40 1998 +# @author Tom Goodale +# @desc +# Parser for param.ccl files +# @enddesc +# @version $Header$ +#@@*/ #%implementations = ("flesh", "flesh", "test1", "test1", "test2", "test2"); @@ -180,6 +189,32 @@ sub parse_param_ccl } } + my $realname = $variable; + + # First deal with an alias + + if($options =~ m/\bAS\s+([^\s]+)\s*/i) + { + my $alias = $1; + + if($alias !~ m/[a-zA-Z]+[a-zA-Z0-9_]*/) + { + $message = "Invalid alias name '$alias' for $variable of thorn $thorn"; + &CST_error(0,$message,"",__LINE__,__FILE__); + } + elsif($defined_parameters{"\U$alias\E"}) + { + $message = "Invalid alias name '$alias' for $variable of thorn $thorn - parameter of that name already exists"; + &CST_error(0,$message,"",__LINE__,__FILE__); + } + + $options =~ s/\bAS\s+([^\s])+\s*//i; + + # Rename the variable for internal use + $variable = $alias + } + + if($defined_parameters{"\U$variable\E"}) { @@ -228,33 +263,9 @@ sub parse_param_ccl $line_number++; $line_number++; } - + # Parse the options - # First deal with an alias -# if($options =~ m/\bAS\s+([^\s]+)\s*/i) -# { -# my $alias = $1; - -# if($alias !~ m/[a-zA-Z]+[a-zA-Z0-9_]*/) -# { -# $message = "Invalid alias name '$alias' for $variable of thorn $thorn"; -# &CST_error(0,$message,"",__LINE__,__FILE__); -# } -# elsif($defined_parameters{"\U$alias\E"}) -# { -# $message = "Invalid alias name '$alias' for $variable of thorn $thorn - parameter of that name already exists"; -# &CST_error(0,$message,"",__LINE__,__FILE__); -# } -# else -# { -# $parameter_db{"\U$thorn $variable\E alias"} = $alias; -# } - -# $options =~ s/\bAS\s+([^\s])+\s*//i; -# } - - # Now parse options of the form option = value %options = split(/\s*=\s*|\s+/, $options); foreach $option (keys %options) @@ -346,15 +357,8 @@ sub parse_param_ccl # Store data about this variable. - if($alias) - { - $defined_parameters{"\U$alias\E"} = 1; - } - else - { - $defined_parameters{"\U$variable\E"} = 1; - } - + $defined_parameters{"\U$variable\E"} = 1; + $parameter_db{"\U$thorn $variable\E realname"} = $realname; $parameter_db{"\U$thorn $block\E variables"} .= $variable." "; $parameter_db{"\U$thorn $variable\E type"} = $type; $parameter_db{"\U$thorn $variable\E description"} = $description; |