Current Version: 1.0.20
Project Name: csspp
expression.h
Go to the documentation of this file.
1 #ifndef CSSPP_EXPRESSION_H
2 #define CSSPP_EXPRESSION_H
3 // CSS Preprocessor
4 // Copyright (c) 2015-2018 Made to Order Software Corp. All Rights Reserved
5 //
6 // This program is free software; you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation; either version 2 of the License, or
9 // (at your option) any later version.
10 //
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
15 //
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the Free Software
18 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 
20 #include "csspp/node.h"
21 
22 namespace csspp
23 {
24 
26 {
27 public:
29 
30  virtual node::pointer_t get_variable(std::string const & variable_name, bool global_only = false) const = 0;
32 };
33 
34 // bare pointer problem
35 #pragma GCC diagnostic push
36 #pragma GCC diagnostic ignored "-Weffc++"
38 {
39 public:
41 
42  void set_variable_handler(expression_variables_interface * handler);
43 
44  void compile_args(bool divide_font_metrics);
45  node::pointer_t compile();
46 
47  static bool boolean(node::pointer_t n);
48  static void set_unique_id_counter(int counter);
49  static int get_unique_id_counter();
50 
51 private:
52  typedef std::map<std::string, node::pointer_t> variable_vector_t;
53  typedef std::vector<std::string> dimension_vector_t;
54 
55  bool end_of_nodes();
56  void mark_start();
57  node::pointer_t replace_with_result(node::pointer_t result);
58  void next();
59 
60  node::pointer_t compile_list(node::pointer_t parent);
61 
62  node::pointer_t conditional();
63 
64  bool is_label() const;
65  node::pointer_t expression_list();
66 
67  node::pointer_t assignment();
68 
69  node::pointer_t logical_or();
70 
71  node::pointer_t logical_and();
72 
73  bool is_comparable(node::pointer_t lhs, node::pointer_t rhs);
74  bool is_equal(node::pointer_t lhs, node::pointer_t rhs);
75  node::pointer_t equality();
76 
77  bool is_less_than(node::pointer_t lhs, node::pointer_t rhs);
78  node::pointer_t relational();
79 
80  node::pointer_t additive();
81 
82  void dimensions_to_vectors(position const & pos, std::string const & dimension, dimension_vector_t & dividend, dimension_vector_t & divisor);
83  std::string multiplicative_dimension(position const & pos, std::string const & dim1, node_type_t const op, std::string const & dim2);
84  std::string rebuild_dimension(dimension_vector_t const & dividend, dimension_vector_t const & divisor);
86  node::pointer_t multiplicative();
87 
88  node::pointer_t apply_power(node::pointer_t lhs, node::pointer_t rhs);
89  node::pointer_t power();
90 
91  node::pointer_t post();
92 
93  node::pointer_t unary();
94 
95  // in internal_functions.cpp
96  node::pointer_t internal_function__get_any(node::pointer_t func, size_t argn);
97  node::pointer_t internal_function__get_color(node::pointer_t func, size_t argn, color & col);
98  node::pointer_t internal_function__get_number(node::pointer_t func, size_t argn, decimal_number_t & number);
99  node::pointer_t internal_function__get_number_or_percent(node::pointer_t func, size_t argn, decimal_number_t & number);
100  node::pointer_t internal_function__get_string(node::pointer_t func, size_t argn, std::string & str);
101  node::pointer_t internal_function__get_string_or_identifier(node::pointer_t func, size_t argn, std::string & str);
102 
103  node::pointer_t internal_function__abs(node::pointer_t func);
104  node::pointer_t internal_function__acos(node::pointer_t func);
105  node::pointer_t internal_function__adjust_hue(node::pointer_t func);
106  node::pointer_t internal_function__alpha(node::pointer_t func);
107  node::pointer_t internal_function__asin(node::pointer_t func);
108  node::pointer_t internal_function__atan(node::pointer_t func);
109  node::pointer_t internal_function__blue(node::pointer_t func);
110  node::pointer_t internal_function__ceil(node::pointer_t func);
111  node::pointer_t internal_function__cos(node::pointer_t func);
112  node::pointer_t internal_function__decimal_number(node::pointer_t func);
113  node::pointer_t internal_function__floor(node::pointer_t func);
114  node::pointer_t internal_function__frgb(node::pointer_t func);
115  node::pointer_t internal_function__frgba(node::pointer_t func);
116  node::pointer_t internal_function__function_exists(node::pointer_t func);
117  node::pointer_t internal_function__global_variable_exists(node::pointer_t func);
118  node::pointer_t internal_function__green(node::pointer_t func);
119  node::pointer_t internal_function__hsl(node::pointer_t func);
120  node::pointer_t internal_function__hsla(node::pointer_t func);
121  node::pointer_t internal_function__hue(node::pointer_t func);
122  node::pointer_t internal_function__identifier(node::pointer_t func);
123  node::pointer_t internal_function__if(node::pointer_t func);
124  node::pointer_t internal_function__integer(node::pointer_t func);
125  node::pointer_t internal_function__inspect(node::pointer_t func);
126  node::pointer_t internal_function__lightness(node::pointer_t func);
127  node::pointer_t internal_function__log(node::pointer_t func);
128  node::pointer_t internal_function__max(node::pointer_t func);
129  node::pointer_t internal_function__min(node::pointer_t func);
130  node::pointer_t internal_function__not(node::pointer_t func);
131  node::pointer_t internal_function__percentage(node::pointer_t func);
132  node::pointer_t internal_function__random(node::pointer_t func);
133  node::pointer_t internal_function__red(node::pointer_t func);
134  node::pointer_t internal_function__rgb(node::pointer_t func);
135  node::pointer_t internal_function__rgba(node::pointer_t func);
136  node::pointer_t internal_function__round(node::pointer_t func);
137  node::pointer_t internal_function__saturation(node::pointer_t func);
138  node::pointer_t internal_function__sign(node::pointer_t func);
139  node::pointer_t internal_function__sin(node::pointer_t func);
140  node::pointer_t internal_function__sqrt(node::pointer_t func);
141  node::pointer_t internal_function__string(node::pointer_t func);
142  node::pointer_t internal_function__str_length(node::pointer_t func);
143  node::pointer_t internal_function__tan(node::pointer_t func);
144  node::pointer_t internal_function__type_of(node::pointer_t func);
145  node::pointer_t internal_function__unique_id(node::pointer_t funct);
146  node::pointer_t internal_function__unit(node::pointer_t func);
147  node::pointer_t internal_function__variable_exists(node::pointer_t func);
148 
149  node::pointer_t excecute_function(node::pointer_t func);
150 
152  size_t f_pos = 0;
153  size_t f_start = static_cast<size_t>(-1);
155  variable_vector_t f_variables = variable_vector_t();
156  bool f_divide_font_metrics = false;
157  expression_variables_interface * f_variable_handler = nullptr;
158 };
159 #pragma GCC diagnostic pop
160 
161 } // namespace csspp
162 #endif
163 // #ifndef CSSPP_LEXER_H
164 
165 // Local Variables:
166 // mode: cpp
167 // indent-tabs-mode: nil
168 // c-basic-offset: 4
169 // tab-width: 4
170 // End:
171 
172 // vim: ts=4 sw=4 et
std::shared_ptr< node > pointer_t
Definition: node.h:128
The namespace of all the classes in the CSS Preprocessor.
Definition: assembler.cpp:40
node_type_t
Definition: node.h:36
virtual node::pointer_t get_variable(std::string const &variable_name, bool global_only=false) const =0
double decimal_number_t
Definition: csspp.h:55
virtual node::pointer_t execute_user_function(node::pointer_t func)=0
std::map< std::string, node::pointer_t > variable_vector_t
Definition: expression.h:52
std::vector< std::string > dimension_vector_t
Definition: expression.h:53

Documentation of CSS Preprocessor.

This document is part of the Snap! Websites Project.

Copyright by Made to Order Software Corp.