lib/TWiki/If/Parser.pm
changeset 0 414e01d06fd5
equal deleted inserted replaced
-1:000000000000 0:414e01d06fd5
       
     1 # See bottom of file for copyright and license details
       
     2 
       
     3 =pod
       
     4 
       
     5 ---+ package TWiki::If::Parser
       
     6 
       
     7 Support for the conditions in %IF{} statements.
       
     8 
       
     9 =cut
       
    10 
       
    11 package TWiki::If::Parser;
       
    12 use base 'TWiki::Query::Parser';
       
    13 
       
    14 use strict;
       
    15 use Assert;
       
    16 use TWiki::If::Node;
       
    17 
       
    18 sub new {
       
    19     my( $class ) = @_;
       
    20 
       
    21     my $this = $class->SUPER::new({
       
    22         nodeClass => 'TWiki::If::Node',
       
    23         words => qr/([A-Za-z][\w:]+|({\w+})+)/});
       
    24 
       
    25     # See TWiki::Query::Parser.pm for an explanation of 'exec'
       
    26     $this->addOperator(
       
    27         name => 'context',
       
    28         prec => 600, arity => 1, casematters => 0,
       
    29         exec => 'OP_context',
       
    30        );
       
    31     $this->addOperator(
       
    32         name => 'allows',
       
    33         prec => 600, arity => 2, casematters => 0,
       
    34         exec => 'OP_allows',
       
    35        );
       
    36     $this->addOperator(
       
    37         name => '$',
       
    38         prec => 600, arity => 1,
       
    39         exec => 'OP_dollar',
       
    40        );
       
    41     $this->addOperator(
       
    42         name => 'defined',
       
    43         prec => 600, arity => 1, casematters => 0,
       
    44         exec => 'OP_defined',
       
    45        );
       
    46     $this->addOperator(
       
    47         name => 'istopic',
       
    48         prec => 600, arity => 1, casematters => 0,
       
    49         exec => 'OP_istopic',
       
    50        );
       
    51     $this->addOperator(
       
    52         name => 'isweb',
       
    53         prec => 600, arity => 1, casematters => 0,
       
    54         exec => 'OP_isweb',
       
    55        );
       
    56     $this->addOperator(
       
    57         name => 'ingroup',
       
    58         prec => 600, arity => 2, casematters => 1,
       
    59         exec => 'OP_ingroup',
       
    60        );       
       
    61 
       
    62     return $this;
       
    63 }
       
    64 
       
    65 1;
       
    66 
       
    67 __DATA__
       
    68 
       
    69 Module of TWiki Enterprise Collaboration Platform, http://TWiki.org/
       
    70 
       
    71 Copyright (C) 2005-2007 TWiki Contributors. All Rights Reserved.
       
    72 TWiki Contributors are listed in the AUTHORS file in the root of
       
    73 this distribution. NOTE: Please extend that file, not this notice.
       
    74 
       
    75 This program is free software; you can redistribute it and/or
       
    76 modify it under the terms of the GNU General Public License
       
    77 as published by the Free Software Foundation; either version 2
       
    78 of the License, or (at your option) any later version. For
       
    79 more details read LICENSE in the root of this distribution.
       
    80 
       
    81 This program is distributed in the hope that it will be useful,
       
    82 but WITHOUT ANY WARRANTY; without even the implied warranty of
       
    83 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
       
    84 
       
    85 As per the GPL, removal of this notice is prohibited.
       
    86 
       
    87 Author: Crawford Currie http://c-dot.co.uk