[system] / trunk / pg / macros / contextLimitedNumeric.pl Repository:
ViewVC logotype

View of /trunk/pg/macros/contextLimitedNumeric.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 5373 - (download) (as text) (annotate)
Sun Aug 19 02:01:57 2007 UTC (12 years, 3 months ago) by dpvc
File size: 1364 byte(s)
Normalized comments and headers to that they will format their POD
documentation properly.  (I know that the POD processing was supposed
to strip off the initial #, but that doesn't seem to happen, so I've
added a space throughout.)

    1 
    2 loadMacros("MathObjects.pl");
    3 
    4 sub _contextLimitedNumeric_init {}; # don't load it again
    5 
    6 =head3 Context("LimitedNumeric")
    7 
    8  ##########################################################
    9  #
   10  #  Implements a context in which numbers can be entered,
   11  #  but no operations are permitted between them.
   12  #
   13  #  There are two versions:  one for lists of numbers
   14  #  and one for a single number.  Select them using
   15  #  one of the following commands:
   16  #
   17  #      Context("LimitedNumeric-list");
   18  #      Context("LimiteNumeric");
   19  #
   20 
   21 =cut
   22 
   23 package LimitedNumeric::UOP::minus;
   24 our @ISA = qw(Parser::UOP::minus);
   25 
   26 sub _check {
   27   my $self = shift;
   28   $self->SUPER::_check;
   29   my $uop = $self->{def}{string} || $self->{uop};
   30   $self->Error("Can't use '%s' in this context",$uop)
   31     unless $self->{op}->class eq 'Number';
   32 }
   33 
   34 package main;
   35 
   36 $context{LimitedNumeric} = Context("Numeric");
   37 $context{LimitedNumeric}->operators->set('u-' => {class => 'LimitedNumeric::UOP::minus'});
   38 $context{LimitedNumeric}->operators->undefine(
   39    '+', '-', '*', '* ', ' *', ' ', '/', '/ ', ' /', '^', '**',
   40    'U', '.', '><', 'u+', '!', '_',
   41 );
   42 $context{LimitedNumeric}->parens->undefine('|','{','(','[');
   43 Parser::Context::Functions::Disable('All');
   44 
   45 $context{'LimitedNumeric-List'} = $context{LimitedNumeric}->copy;
   46 
   47 $context{LimitedNumeric}->operators->undefine(',');
   48 
   49 Context("LimitedNumeric");
   50 
   51 1;

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9