4
---+ package Foswiki::Infix::Node
6
Base class for node types generated by Infix::Parser. You don't *have* to use
7
it, but it may be useful.
11
package Foswiki::Infix::Node;
16
sub MONITOR_EVAL { 0 }
19
use vars qw ($NAME $STRING $NUMBER);
26
---++ ClassMethod newNode( $o, @p ) -> \$if
28
Construct a new parse node (contract with Infix::Parser)
35
my $this = bless( {}, $class );
36
@{ $this->{params} } = @_;
43
---++ ClassMethod newLeaf( $val, $type ) -> \$if
45
Construct a new terminal node (contract with Infix::Parser)
50
my ( $class, $val, $type ) = @_;
51
return newNode( $class, $type, $val );
56
---++ ObjectMethod evaluate(...) -> $result
58
Execute the parse node. The parameter array is passed on, by reference,
59
to the evaluation functions.
64
my ( $this, $clientData ) = @_;
67
if ( !ref( $this->{op} ) ) {
68
$result = $this->{params}[0];
70
print STDERR "LEAF: ", ( defined($result) ? $result : 'undef' ),
75
my $fn = $this->{op}->{evaluate};
76
$result = &$fn( $clientData, @{ $this->{params} } );
78
print STDERR "NODE: ", $this->stringify(), " -> ",
79
( defined($result) ? $result : 'undef' ), "\n";
88
unless ( ref( $this->{op} ) ) {
89
if ( $this->{op} == $Foswiki::Infix::Node::STRING ) {
90
return "'$this->{params}[0]'";
93
return $this->{params}[0];
98
$this->{op}->{name} . '{'
99
. join( ',', map { $_->stringify() } @{ $this->{params} } ) . '}';
105
Module of Foswiki - The Free and Open Source Wiki, http://foswiki.org/, http://Foswiki.org/
107
# Copyright (C) 2008-2009 Foswiki Contributors. All Rights Reserved.
108
# Foswiki Contributors are listed in the AUTHORS file in the root
109
# of this distribution. NOTE: Please extend that file, not this notice.
111
# Additional copyrights apply to some or all of the code in this
114
# Copyright (C) 2005-2007 TWiki Contributors. All Rights Reserved.
115
# TWiki Contributors are listed in the AUTHORS file in the root
116
# of this distribution. NOTE: Please extend that file, not this notice.
118
This program is free software; you can redistribute it and/or
119
modify it under the terms of the GNU General Public License
120
as published by the Free Software Foundation; either version 2
121
of the License, or (at your option) any later version. For
122
more details read LICENSE in the root of this distribution.
124
This program is distributed in the hope that it will be useful,
125
but WITHOUT ANY WARRANTY; without even the implied warranty of
126
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
128
As per the GPL, removal of this notice is prohibited.
130
Author: Crawford Currie http://c-dot.co.uk