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

Documentation of CSS Preprocessor.

This document is part of the Snap! Websites Project.

Copyright by Made to Order Software Corp.