[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 4997 - (download) (as text) (annotate)
Mon Jun 11 18:16:40 2007 UTC (12 years, 7 months ago) by gage
File size: 1343 byte(s)
Fixing docementation so that it can be read from the web.

    1 
    2 loadMacros("Parser.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");

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9