Annotation of loncom/homework/math_parser/Operator.pm, revision 1.1
1.1 ! damieng 1: # The LearningOnline Network with CAPA - LON-CAPA
! 2: # Parser operator
! 3: #
! 4: # Copyright (C) 2014 Michigan State University Board of Trustees
! 5: #
! 6: # This program is free software: you can redistribute it and/or modify
! 7: # it under the terms of the GNU General Public License as published by
! 8: # the Free Software Foundation, either version 3 of the License, or
! 9: # (at your option) any later version.
! 10: #
! 11: # This program is distributed in the hope that it will be useful,
! 12: # but WITHOUT ANY WARRANTY; without even the implied warranty of
! 13: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
! 14: # GNU General Public License for more details.
! 15: #
! 16: # You should have received a copy of the GNU General Public License
! 17: # along with this program. If not, see <http://www.gnu.org/licenses/>.
! 18: #
! 19:
! 20: ##
! 21: # Parser operator, like "(".
! 22: ##
! 23: package Apache::math_parser::Operator;
! 24:
! 25: use strict;
! 26: use warnings;
! 27: use utf8;
! 28:
! 29: use enum qw(UNKNOWN UNARY BINARY TERNARY);
! 30:
! 31: ##
! 32: # Constructor
! 33: # @param {string} id - Characters used to recognize the operator
! 34: # @param {integer} arity (Operator::UNKNOWN, UNARY, BINARY, TERNARY)
! 35: # @param {integer} lbp - left binding power
! 36: # @param {integer} rbp - right binding power
! 37: # @param {nudFunction} nud - Null denotation function. Parameters: Parser p. Returns: ENode.
! 38: # @param {ledFunction} led - Left denotation function Parameters: Parser p, ENode left. Returns: ENode.
! 39: ##
! 40: sub new {
! 41: my $class = shift;
! 42: my $self = {
! 43: _id => shift,
! 44: _arity => shift,
! 45: _lbp => shift,
! 46: _rbp => shift,
! 47: _nud => shift,
! 48: _led => shift,
! 49: };
! 50: bless $self, $class;
! 51: return $self;
! 52: }
! 53:
! 54: # Attribute helpers
! 55:
! 56: sub id {
! 57: my $self = shift;
! 58: return $self->{_id};
! 59: }
! 60: sub arity {
! 61: my $self = shift;
! 62: return $self->{_arity};
! 63: }
! 64: sub lbp {
! 65: my $self = shift;
! 66: return $self->{_lbp};
! 67: }
! 68: sub rbp {
! 69: my $self = shift;
! 70: return $self->{_rbp};
! 71: }
! 72: sub nud {
! 73: my $self = shift;
! 74: return $self->{_nud};
! 75: }
! 76: sub led {
! 77: my $self = shift;
! 78: return $self->{_led};
! 79: }
! 80:
! 81: 1;
! 82: __END__
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>