Current Version: 1.0.10
Project Name: csspp
expr_logical_or.cpp
Go to the documentation of this file.
1 // CSS Preprocessor
2 // Copyright (C) 2015-2016 Made to Order Software Corp.
3 //
4 // This program is free software; you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation; either version 2 of the License, or
7 // (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with this program; if not, write to the Free Software
16 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17 
27 #include "csspp/expression.h"
28 
29 #include "csspp/exceptions.h"
30 #include "csspp/parser.h"
31 #include "csspp/unicode_range.h"
32 
33 #include <algorithm>
34 #include <cmath>
35 #include <iostream>
36 
37 namespace csspp
38 {
39 
41 {
42  // logical_or: logical_and
43  // | logical_or IDENTIFIER (='or') logical_and
44  // | logical_or '||' logical_and
45 
46  node::pointer_t result(logical_and());
47  if(!result)
48  {
49  return false;
50  }
51 
52  while((f_current->is(node_type_t::IDENTIFIER) && f_current->get_string() == "or")
54  {
55  position pos(f_current->get_position());
56 
57  // skip the OR
58  next();
59 
61  if(!rhs)
62  {
63  return false;
64  }
65 
66  // apply the OR
67  bool const lr(boolean(result));
68  bool const rr(boolean(rhs));
69  result.reset(new node(node_type_t::BOOLEAN, pos));
70  result->set_boolean(lr || rr);
71  }
72 
73  return result;
74 }
75 
76 } // namespace csspp
77 
78 // Local Variables:
79 // mode: cpp
80 // indent-tabs-mode: nil
81 // c-basic-offset: 4
82 // tab-width: 4
83 // End:
84 
85 // vim: ts=4 sw=4 et
node::pointer_t logical_and()
std::shared_ptr< node > pointer_t
Definition: node.h:122
node::pointer_t f_current
Definition: expression.h:151
node::pointer_t logical_or()

Documentation of CSS Preprocessor.

This document is part of the Snap! Websites Project.

Copyright by Made to Order Software Corp.