[system] / trunk / pg / lib / Parser.pm Repository:
ViewVC logotype

Diff of /trunk/pg/lib/Parser.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 2657 Revision 2660
11# If it is a Value, make an appropriate tree for it. 11# If it is a Value, make an appropriate tree for it.
12# 12#
13sub new { 13sub new {
14 my $self = shift; my $class = ref($self) || $self; 14 my $self = shift; my $class = ref($self) || $self;
15 my $string = shift; 15 my $string = shift;
16 $string = Value::List->new($string,@_)
17 if scalar(@_) > 0 || ref($string) eq 'ARRAY';
16 my $math = bless { 18 my $math = bless {
17 string => undef, 19 string => undef,
18 tokens => [], tree => undef, 20 tokens => [], tree => undef,
19 variables => {}, values => {}, 21 variables => {}, values => {},
20 context => Parser::Context->current, 22 context => Parser::Context->current,
21 }, $class; 23 }, $class;
22 if (ref($string) =~ m/^(Parser|Value::Formula)/) { 24 if (ref($string) =~ m/^(Parser|Value::Formula)/) {
23 my $tree = $string; $tree = $tree->{tree} if exists $tree->{tree}; 25 my $tree = $string; $tree = $tree->{tree} if exists $tree->{tree};
24 $math->{tree} = $tree->copy($math); 26 $math->{tree} = $tree->copy($math);
25 } elsif (ref($string) =~ m/^Value/) { 27 } elsif (Value::isValue($string)) {
26 $math->{tree} = Parser::Value->new($math,$string); 28 $math->{tree} = Parser::Value->new($math,$string);
27 } else { 29 } else {
28 $math->{string} = $string; 30 $math->{string} = $string;
29 $math->tokenize; 31 $math->tokenize;
30 $math->parse; 32 $math->parse;
297 if ($paren->{emptyOK} && $paren->{close} eq $type) { 299 if ($paren->{emptyOK} && $paren->{close} eq $type) {
298 $self->pushOperand(Parser::List->new($self,[],1,$paren)) 300 $self->pushOperand(Parser::List->new($self,[],1,$paren))
299 } 301 }
300 elsif ($type eq 'start') {$self->Error("Missing close parenthesis for '$top->{value}'",$top->{ref})} 302 elsif ($type eq 'start') {$self->Error("Missing close parenthesis for '$top->{value}'",$top->{ref})}
301 elsif ($top->{value} eq 'start') {$self->Error("Extra close parenthesis '$type'",$ref)} 303 elsif ($top->{value} eq 'start') {$self->Error("Extra close parenthesis '$type'",$ref)}
302 else {$self->Error("Empty parentheses: '$top->{value} $type'",$top->{ref})} 304 else {$top->{ref}[3]=$ref->[3]; $self->Error("Empty parentheses",$top->{ref})}
303 last; 305 last;
304 }; 306 };
305 307
306 /operand/ and do { 308 /operand/ and do {
307 $self->Precedence(0); return if ($self->{error}); 309 $self->Precedence(0); return if ($self->{error});

Legend:
Removed from v.2657  
changed lines
  Added in v.2660

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9