Annotation of loncom/homework/math_parser/Token.pm, revision 1.1
1.1 ! damieng 1: # The LearningOnline Network with CAPA - LON-CAPA
! 2: # A parser token.
! 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: # A token from the equation text
! 22: ##
! 23: package Apache::math_parser::Token;
! 24:
! 25: use strict;
! 26: use warnings;
! 27: use utf8;
! 28:
! 29: use enum qw(UNKNOWN NAME NUMBER OPERATOR);
! 30:
! 31: ##
! 32: # Constructor
! 33: # @param {integer} type - Token type: Token::UNKNOWN, NAME, NUMBER, OPERATOR
! 34: # @param {integer} from - Index of the token's first character
! 35: # @param {integer} to - Index of the token's last character
! 36: # @param {string} value - String content of the token
! 37: # @optional {Operator} op - The matching operator
! 38: ##
! 39: sub new {
! 40: my $class = shift;
! 41: my $self = {
! 42: _type => shift,
! 43: _from => shift,
! 44: _to => shift,
! 45: _value => shift,
! 46: _op => shift,
! 47: };
! 48: bless $self, $class;
! 49: return $self;
! 50: }
! 51:
! 52: # Attribute helpers
! 53:
! 54: sub type {
! 55: my $self = shift;
! 56: return $self->{_type};
! 57: }
! 58: sub from {
! 59: my $self = shift;
! 60: return $self->{_from};
! 61: }
! 62: sub to {
! 63: my $self = shift;
! 64: return $self->{_to};
! 65: }
! 66: sub value {
! 67: my $self = shift;
! 68: return $self->{_value};
! 69: }
! 70: sub op {
! 71: my $self = shift;
! 72: return $self->{_op};
! 73: }
! 74:
! 75: 1;
! 76: __END__
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>