[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 2575 Revision 2576
1# handle sqrt(-1) and log of negatives (make complexes)
2# do division by zero and log of zero checks in compound functions
3# add context flags for various reduction checks
4# make context flag for reduction of constants
5# make reduce have reduce patterns as parameters
6# more reduce patterns
7# make operator strings customizable (reduce, and other places they are used)
8# add parens alternately as () and []?
9
10package Parser; 1package Parser;
11my $pkg = "Parser"; 2my $pkg = "Parser";
12 3
13use strict; 4use strict;
14#use Carp; 5#use Carp;
22sub new { 13sub new {
23 my $self = shift; my $class = ref($self) || $self; 14 my $self = shift; my $class = ref($self) || $self;
24 my $string = shift; 15 my $string = shift;
25 my $math = bless { 16 my $math = bless {
26 string => undef, 17 string => undef,
27 tokens => [], 18 tokens => [], tree => undef,
28 tree => undef,
29 variables => {}, values => {}, 19 variables => {}, values => {},
30 context => Parser::Context->current, 20 context => Parser::Context->current,
31 error => 0, errorPos => undef,
32 message => '',
33 }, $class; 21 }, $class;
34 if (ref($string) =~ m/^(Parser|Value::Formula)/) { 22 if (ref($string) =~ m/^(Parser|Value::Formula)/) {
35 my $tree = $string; $tree = $tree->{tree} if exists $tree->{tree}; 23 my $tree = $string; $tree = $tree->{tree} if exists $tree->{tree};
36 $math->{tree} = $tree->copy($math); 24 $math->{tree} = $tree->copy($math);
37 } elsif (ref($string) =~ m/^Value/) { 25 } elsif (ref($string) =~ m/^Value/) {
652 unless Parser::Item::typeMatch($type,$variables->{$x}{type}); 640 unless Parser::Item::typeMatch($type,$variables->{$x}{type});
653 $self->{values}{$x} = $value; 641 $self->{values}{$x} = $value;
654 } 642 }
655} 643}
656 644
645
657######################################################################### 646#########################################################################
658######################################################################### 647#########################################################################
659# 648#
660# Load the sub-classes and Value.pm 649# Load the sub-classes and Value.pm
661# 650#
664use Value; 653use Value;
665use Value::Formula; 654use Value::Formula;
666use Parser::Context; 655use Parser::Context;
667# use Parser::Differentiation; 656# use Parser::Differentiation;
668 657
658###########################################################################
659###########################################################################
660#
661# To Do:
662#
663# handle sqrt(-1) and log of negatives (make complexes)
664# do division by zero and log of zero checks in compound functions
665# add context flags for various reduction checks
666# make context flag for reduction of constants
667# make reduce have reduce patterns as parameters
668# more reduce patterns
669# make operator strings customizable (reduce, and other places they are used)
670# add parens alternately as () and []?
671# eliminate Complex class (it only gets used by main::Complex() when the
672# arguments are formulas; use $a + $b*i and let overload handle it instead.)
673#
669######################################################################### 674#########################################################################
670 675
6711; 6761;
672 677

Legend:
Removed from v.2575  
changed lines
  Added in v.2576

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9