Annotation of loncom/homework/math_parser/Token.pm, revision 1.2

1.1       damieng     1: # The LearningOnline Network with CAPA - LON-CAPA
                      2: # A parser token.
                      3: #
1.2     ! raeburn     4: # $Id: Token.pm,v 1.2 2023/03/13 18:30:00 raeburn Exp $
        !             5: #
1.1       damieng     6: # Copyright (C) 2014 Michigan State University Board of Trustees
                      7: #
                      8: # This program is free software: you can redistribute it and/or modify
                      9: # it under the terms of the GNU General Public License as published by
                     10: # the Free Software Foundation, either version 3 of the License, or
                     11: # (at your option) any later version.
                     12: #
                     13: # This program is distributed in the hope that it will be useful,
                     14: # but WITHOUT ANY WARRANTY; without even the implied warranty of
                     15: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
                     16: # GNU General Public License for more details.
                     17: #
                     18: # You should have received a copy of the GNU General Public License
                     19: # along with this program. If not, see <http://www.gnu.org/licenses/>.
                     20: #
                     21: 
                     22: ##
                     23: # A token from the equation text
                     24: ##
                     25: package Apache::math_parser::Token;
                     26: 
                     27: use strict;
                     28: use warnings;
                     29: use utf8;
                     30: 
                     31: use enum qw(UNKNOWN NAME NUMBER OPERATOR);
                     32: 
                     33: ##
                     34: # Constructor
                     35: # @param {integer} type - Token type: Token::UNKNOWN, NAME, NUMBER, OPERATOR
                     36: # @param {integer} from - Index of the token's first character
                     37: # @param {integer} to - Index of the token's last character
                     38: # @param {string} value - String content of the token
                     39: # @optional {Operator} op - The matching operator
                     40: ##
                     41: sub new {
                     42:     my $class = shift;
                     43:     my $self = {
                     44:         _type => shift,
                     45:         _from => shift,
                     46:         _to => shift,
                     47:         _value => shift,
                     48:         _op => shift,
                     49:     };
                     50:     bless $self, $class;
                     51:     return $self;
                     52: }
                     53: 
                     54: # Attribute helpers
                     55: 
                     56: sub type {
                     57:     my $self = shift;
                     58:     return $self->{_type};
                     59: }
                     60: sub from {
                     61:     my $self = shift;
                     62:     return $self->{_from};
                     63: }
                     64: sub to {
                     65:     my $self = shift;
                     66:     return $self->{_to};
                     67: }
                     68: sub value {
                     69:     my $self = shift;
                     70:     return $self->{_value};
                     71: }
                     72: sub op {
                     73:     my $self = shift;
                     74:     return $self->{_op};
                     75: }
                     76: 
                     77: 1;
                     78: __END__

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>