forked from m2osw/csspp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnode.cpp
More file actions
1757 lines (1464 loc) · 39.6 KB
/
node.cpp
File metadata and controls
1757 lines (1464 loc) · 39.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// CSS Preprocessor
// Copyright (c) 2015-2019 Made to Order Software Corp. All Rights Reserved
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
/** \file
* \brief Implementation of the CSS Preprocessor node.
*
* The CSS Preprocessor node handles the tree of nodes that the parser
* generates, the compiler crunches, and the assembler outputs.
*
* All the code that handles the nodes is found here, however, the
* compiler and expression classes handle the various operations that
* are required between nodes. The nodes are nearly only limited to
* handling the data they hold and the tree.
*
* \sa \ref lexer_rules
*/
#include <csspp/node.h>
#include <csspp/exceptions.h>
#include <csspp/nth_child.h>
#include <csspp/unicode_range.h>
#include <algorithm>
#include <iostream>
namespace csspp
{
// make sure we have a copy (catch makes it a requirement probably because
// of template use)
size_t const node::npos;
namespace
{
uint32_t g_node_count = 0;
uint32_t g_node_max_count = 0;
union convert_t
{
integer_t f_int;
decimal_number_t f_flt;
};
void type_supports_integer(node_type_t const type)
{
switch(type)
{
case node_type_t::AN_PLUS_B:
case node_type_t::ARG:
case node_type_t::AT_KEYWORD:
case node_type_t::COMMENT:
case node_type_t::INTEGER:
case node_type_t::UNICODE_RANGE:
break;
default:
{
std::stringstream ss;
ss << "trying to access (read/write) the integer of a node of type " << type << ", which does not support integers.";
throw csspp_exception_logic(ss.str());
}
}
}
void type_supports_boolean(node_type_t const type)
{
switch(type)
{
case node_type_t::BOOLEAN:
case node_type_t::DECIMAL_NUMBER:
case node_type_t::INTEGER:
case node_type_t::OPEN_CURLYBRACKET:
case node_type_t::PERCENT:
break;
default:
{
std::stringstream ss;
ss << "trying to access (read/write) the boolean of a node of type " << type << ", which does not support booleans.";
throw csspp_exception_logic(ss.str());
}
}
}
void type_supports_decimal_number(node_type_t const type)
{
switch(type)
{
case node_type_t::DECIMAL_NUMBER:
case node_type_t::PERCENT:
case node_type_t::FRAME:
break;
default:
{
std::stringstream ss;
ss << "trying to access (read/write) the decimal number of a node of type " << type << ", which does not support decimal numbers.";
throw csspp_exception_logic(ss.str());
}
}
}
void type_supports_string(node_type_t const type)
{
switch(type)
{
case node_type_t::AT_KEYWORD:
case node_type_t::COMMENT:
case node_type_t::DECIMAL_NUMBER:
case node_type_t::DECLARATION:
case node_type_t::EXCLAMATION:
case node_type_t::FUNCTION:
case node_type_t::HASH:
case node_type_t::IDENTIFIER:
case node_type_t::INTEGER:
case node_type_t::PLACEHOLDER:
case node_type_t::STRING:
case node_type_t::URL:
case node_type_t::VARIABLE:
case node_type_t::VARIABLE_FUNCTION:
break;
default:
{
std::stringstream ss;
ss << "trying to access (read/write) the string of a node of type " << type << ", which does not support strings.";
throw csspp_exception_logic(ss.str());
}
}
}
void type_supports_color(node_type_t const type)
{
switch(type)
{
case node_type_t::COLOR:
break;
default:
{
std::stringstream ss;
ss << "trying to access (read/write) the color of a node of type " << type << ", which does not support colors.";
throw csspp_exception_logic(ss.str());
}
}
}
void type_supports_font_metrics(node_type_t const type)
{
switch(type)
{
case node_type_t::FONT_METRICS:
break;
default:
{
std::stringstream ss;
ss << "trying to access (read/write) the line height of a node of type " << type << ", which does not support line heights.";
throw csspp_exception_logic(ss.str());
}
}
}
void type_supports_children(node_type_t const type)
{
switch(type)
{
case node_type_t::ARG:
case node_type_t::ARRAY:
case node_type_t::AT_KEYWORD:
case node_type_t::COMPONENT_VALUE:
case node_type_t::DECLARATION:
case node_type_t::FUNCTION:
case node_type_t::LIST:
case node_type_t::MAP:
case node_type_t::OPEN_CURLYBRACKET:
case node_type_t::OPEN_PARENTHESIS:
case node_type_t::OPEN_SQUAREBRACKET:
case node_type_t::VARIABLE_FUNCTION:
case node_type_t::FRAME:
break;
default:
{
std::stringstream ss;
ss << "trying to access (read/write) the children of a node of type " << type << ", which does not support children.";
throw csspp_exception_logic(ss.str());
}
}
}
} // no name namespace
node::node(node_type_t const type, position const & pos)
: f_type(type)
, f_position(pos)
{
++g_node_count;
if(g_node_max_count != 0
&& g_node_count >= g_node_max_count)
{
// This is NOT a bug per se, you may limit the number of nodes in case
// you have a limited amount of memory available or you suspect the
// CSS Preprocessor has a bug which allocates nodes forever; this is
// used for our tests with a maximum number of nodes equal to one
// million (which generally represents a lot less than 1Gb of RAM.)
std::cerr << "error: node of type " << type << " cannot be allocated.\n"; // LCOV_EXCL_LINE
throw csspp_exception_overflow("node.cpp: node::node() too many nodes allocated at the same time, we are probably having a leak."); // LCOV_EXCL_LINE
}
}
node::~node()
{
--g_node_count;
}
node::pointer_t node::clone() const
{
// create the clone
pointer_t result(new node(f_type, f_position));
// copy the other simple values
result->f_boolean = f_boolean;
result->f_integer = f_integer;
result->f_decimal_number = f_decimal_number;
result->f_string = f_string;
result->f_flags = f_flags;
for(auto c : f_children)
{
result->f_children.push_back(c->clone());
}
result->copy_variable(const_cast<node *>(this)->shared_from_this());
return result;
}
node_type_t node::get_type() const
{
return f_type;
}
bool node::is(node_type_t const type) const
{
return f_type == type;
}
boolean_t node::to_boolean() const
{
switch(f_type)
{
case node_type_t::BOOLEAN:
return f_boolean ? boolean_t::BOOLEAN_TRUE : boolean_t::BOOLEAN_FALSE;
case node_type_t::IDENTIFIER:
if(f_string == "true")
{
return boolean_t::BOOLEAN_TRUE;
}
if(f_string == "false"
|| f_string == "null")
{
return boolean_t::BOOLEAN_FALSE;
}
return boolean_t::BOOLEAN_INVALID;
case node_type_t::INTEGER:
return f_integer != 0 ? boolean_t::BOOLEAN_TRUE : boolean_t::BOOLEAN_FALSE;
case node_type_t::DECIMAL_NUMBER:
case node_type_t::PERCENT:
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wfloat-equal"
return f_decimal_number != 0.0 ? boolean_t::BOOLEAN_TRUE : boolean_t::BOOLEAN_FALSE;
#pragma GCC diagnostic pop
case node_type_t::STRING:
return f_string.empty() ? boolean_t::BOOLEAN_FALSE : boolean_t::BOOLEAN_TRUE;
case node_type_t::ARRAY:
case node_type_t::LIST:
case node_type_t::MAP:
return f_children.empty() ? boolean_t::BOOLEAN_FALSE : boolean_t::BOOLEAN_TRUE;
case node_type_t::COLOR:
{
color c(get_color());
return (c.get_color() & 0x00FFFFFF) == 0
? boolean_t::BOOLEAN_FALSE
: boolean_t::BOOLEAN_TRUE;
}
break;
case node_type_t::NULL_TOKEN:
return boolean_t::BOOLEAN_FALSE;
default:
return boolean_t::BOOLEAN_INVALID;
}
/*NOTREACHED*/
}
position const & node::get_position() const
{
return f_position;
}
std::string const & node::get_string() const
{
type_supports_string(f_type);
return f_string;
}
void node::set_string(std::string const & str)
{
type_supports_string(f_type);
f_string = str;
}
std::string const & node::get_lowercase_string() const
{
type_supports_string(f_type);
return f_lowercase_string;
}
void node::set_lowercase_string(std::string const & str)
{
type_supports_string(f_type);
f_lowercase_string = str;
}
integer_t node::get_integer() const
{
type_supports_integer(f_type);
return f_integer;
}
void node::set_integer(integer_t integer)
{
type_supports_integer(f_type);
f_integer = integer;
}
bool node::get_boolean() const
{
type_supports_boolean(f_type);
return f_boolean;
}
void node::set_boolean(bool boolean)
{
type_supports_boolean(f_type);
f_boolean = boolean;
}
decimal_number_t node::get_decimal_number() const
{
type_supports_decimal_number(f_type);
return f_decimal_number;
}
void node::set_decimal_number(decimal_number_t decimal_number)
{
type_supports_decimal_number(f_type);
f_decimal_number = decimal_number;
}
color node::get_color() const
{
type_supports_color(f_type);
union color_transfer_t
{
uint64_t f_int;
double f_dbl;
float f_flt[2];
};
color_transfer_t c1, c2;
c1.f_int = f_integer;
c2.f_dbl = f_decimal_number;
color c;
c.set_color(c1.f_flt[0], c1.f_flt[1], c2.f_flt[0], c2.f_flt[1]);
return c;
}
void node::set_color(color c)
{
type_supports_color(f_type);
union color_transfer_t
{
uint64_t f_int;
double f_dbl;
float f_flt[2];
};
color_transfer_t c1, c2;
c.get_color(c1.f_flt[0], c1.f_flt[1], c2.f_flt[0], c2.f_flt[1]);
f_integer = c1.f_int;
f_decimal_number = c2.f_dbl;
}
decimal_number_t node::get_font_size() const
{
type_supports_font_metrics(f_type);
return f_decimal_number;
}
void node::set_font_size(decimal_number_t font_size)
{
type_supports_font_metrics(f_type);
f_decimal_number = font_size;
}
decimal_number_t node::get_line_height() const
{
type_supports_font_metrics(f_type);
convert_t c;
c.f_int = f_integer;
return c.f_flt;
}
void node::set_line_height(decimal_number_t line_height)
{
type_supports_font_metrics(f_type);
convert_t c;
c.f_flt = line_height;
f_integer = c.f_int;
}
std::string node::get_dim1() const
{
type_supports_font_metrics(f_type);
std::string::size_type pos(f_string.find('/'));
if(pos == std::string::npos)
{
return f_string;
}
else
{
return f_string.substr(0, pos);
}
}
void node::set_dim1(std::string const & dimension)
{
type_supports_font_metrics(f_type);
if(f_string.empty())
{
f_string = dimension;
}
else
{
std::string::size_type pos(f_string.find('/'));
if(pos == std::string::npos)
{
f_string = dimension;
}
else
{
f_string = dimension + f_string.substr(pos);
}
}
}
std::string node::get_dim2() const
{
type_supports_font_metrics(f_type);
std::string::size_type pos(f_string.find('/'));
if(pos == std::string::npos)
{
return "";
}
else
{
return f_string.substr(pos + 1);
}
}
void node::set_dim2(std::string const & dimension)
{
type_supports_font_metrics(f_type);
if(dimension.empty())
{
std::string::size_type pos(f_string.find('/'));
if(pos != std::string::npos)
{
// remove the '/...'
f_string = f_string.substr(0, pos);
}
return;
}
if(f_string.empty())
{
f_string = "/" + dimension;
}
else
{
std::string::size_type pos(f_string.find('/'));
if(pos == std::string::npos)
{
f_string += "/" + dimension;
}
else
{
f_string = f_string.substr(0, pos + 1) + dimension;
}
}
}
bool node::empty() const
{
type_supports_children(f_type);
return f_children.empty();
}
void node::clear()
{
type_supports_children(f_type);
f_children.clear();
}
size_t node::size() const
{
type_supports_children(f_type);
return f_children.size();
}
size_t node::child_position(pointer_t child)
{
type_supports_children(f_type);
auto it(std::find(f_children.begin(), f_children.end(), child));
if(it == f_children.end())
{
return npos;
}
return it - f_children.begin();
}
void node::add_child(pointer_t child)
{
type_supports_children(f_type);
// make sure we totally ignore EOF in a child list
// (this dramatically ease the coding of the parser)
//
// also we do not need to save two WHITESPACE tokens
// one after another
//
if(!child->is(node_type_t::EOF_TOKEN)
&& (!child->is(node_type_t::WHITESPACE)
|| f_children.empty()
|| !f_children.back()->is(node_type_t::WHITESPACE)))
{
f_children.push_back(child);
}
}
void node::insert_child(size_t idx, pointer_t child)
{
// attempting to insert at the end?
if(idx == f_children.size())
{
add_child(child);
return;
}
type_supports_children(f_type);
if(idx >= f_children.size())
{
throw csspp_exception_overflow("insert_child() called with an index out of range.");
}
// avoid the EOF_TOKEN, although really it should not happen here
if(!child->is(node_type_t::EOF_TOKEN))
{
f_children.insert(f_children.begin() + idx, child);
}
}
void node::remove_child(pointer_t child)
{
type_supports_children(f_type);
auto it(std::find(f_children.begin(), f_children.end(), child));
if(it == f_children.end())
{
throw csspp_exception_logic("remove_child() called with a node which is not a child of this node.");
}
f_children.erase(it);
}
void node::remove_child(size_t idx)
{
type_supports_children(f_type);
if(idx >= f_children.size())
{
throw csspp_exception_overflow("remove_child() called with an index out of range.");
}
f_children.erase(f_children.begin() + idx);
}
node::pointer_t node::get_child(size_t idx) const
{
type_supports_children(f_type);
if(idx >= f_children.size())
{
throw csspp_exception_overflow("get_child() called with an index out of range.");
}
return f_children[idx];
}
node::pointer_t node::get_last_child() const
{
// if empty, get_child() will throw
return get_child(f_children.size() - 1);
}
void node::take_over_children_of(pointer_t n)
{
type_supports_children(f_type);
type_supports_children(n->f_type);
// children are copied to this node and cleared
// in the other node (TBD: should this node have
// an empty list of children to start with?)
f_children.clear();
swap(f_children, n->f_children);
}
void node::replace_child(pointer_t o, pointer_t n)
{
auto it(std::find(f_children.begin(), f_children.end(), o));
if(it == f_children.end())
{
//std::cerr << "------------ Node being replaced:\n" << *o
// << "------------ Node to replace with:\n" << *n
// << "------------ This node:\n" << *this
// << "+++++++++++++++++++++++++++++++++++++++\n";
throw csspp_exception_logic("replace_child() called with a node which is not a child of this node.");
}
size_t const pos(it - f_children.begin());
f_children.insert(it, n);
f_children.erase(f_children.begin() + pos + 1);
}
void node::clear_variables()
{
f_variables.clear();
}
void node::set_variable(std::string const & name, pointer_t value)
{
f_variables[name] = value;
}
void node::copy_variable(node::pointer_t source)
{
if(source)
{
for(auto v : source->f_variables)
{
f_variables[v.first] = v.second->clone();
}
}
}
node::pointer_t node::get_variable(std::string const & name)
{
auto const it(f_variables.find(name));
if(it == f_variables.end())
{
return pointer_t();
}
return it->second;
}
void node::clear_flags()
{
f_flags.clear();
}
void node::set_flag(std::string const & name, bool value)
{
if(value)
{
f_flags[name] = value;
}
else
{
auto it(f_flags.find(name));
if(it != f_flags.end())
{
f_flags.erase(it);
}
}
}
bool node::get_flag(std::string const & name)
{
auto it(f_flags.find(name));
return it != f_flags.end();
}
std::string node::to_string(int flags) const
{
std::stringstream out;
switch(f_type)
{
case node_type_t::ADD:
out << "+";
break;
case node_type_t::AND:
out << "&&";
break;
case node_type_t::ASSIGNMENT:
out << ":=";
break;
case node_type_t::AT_KEYWORD:
out << "@" << f_string;
break;
case node_type_t::BOOLEAN:
out << (f_boolean ? "true" : "false");
break;
case node_type_t::COLON:
out << ":";
break;
case node_type_t::COLOR:
{
color c(get_color());
out << c.to_string();
}
break;
case node_type_t::COLUMN:
out << "||";
break;
case node_type_t::COMMA:
out << ",";
break;
case node_type_t::COMMENT:
if(f_integer == 0)
{
// note: a completely empty comment is possible here and
// nothing will be output; however, in a valid CSS Preprocessor
// output, only comments with the @preserve keyword are kept
// so it won't be empty (until we decide to remove the @preserve
// from the comments...)
//
std::string::size_type start(0);
std::string::size_type end(f_string.find('\n'));
while(end != std::string::npos)
{
out << "// " << f_string.substr(start, end - start) << std::endl;
start = end + 1;
end = f_string.find('\n', start);
}
if(start < f_string.size())
{
out << "// " << f_string.substr(start) << std::endl;
}
}
else
{
out << "/* " << f_string << " */";
}
break;
case node_type_t::CONDITIONAL:
out << '?';
break;
case node_type_t::DASH_MATCH:
out << "|=";
break;
case node_type_t::DECIMAL_NUMBER:
// this may be a dimension, if not f_string is empty anyway
out << (f_boolean && f_integer >= 0 ? "+" : "") << f_decimal_number << f_string;
break;
case node_type_t::DIVIDE:
if((flags & g_to_string_flag_add_spaces) != 0)
{
out << " / ";
}
else
{
out << "/";
}
break;
case node_type_t::DOLLAR:
out << '$';
break;
case node_type_t::EQUAL:
out << '=';
break;
case node_type_t::EXCLAMATION:
out << '!';
break;
case node_type_t::FONT_METRICS:
// this is a mouthful!
out << decimal_number_to_string(get_font_size() * (get_dim1() == "%" ? 100.0 : 1.0), false) << get_dim1()
<< "/" << decimal_number_to_string(get_line_height() * (get_dim2() == "%" ? 100.0 : 1.0), false) << get_dim2();
break;
case node_type_t::VARIABLE_FUNCTION:
out << '$';
#if __cplusplus >= 201700
[[fallthrough]];
#endif
case node_type_t::FUNCTION:
{
out << f_string << "(";
bool first(true);
for(auto c : f_children)
{
if(first)
{
first = false;
}
else
{
out << ",";
}
out << c->to_string(flags);
}
out << ")";
}
break;
case node_type_t::GREATER_EQUAL:
out << ">=";
break;
case node_type_t::GREATER_THAN:
out << ">";
break;
case node_type_t::HASH:
out << "#" << f_string;
break;
case node_type_t::IDENTIFIER:
out << f_string;
break;
case node_type_t::INCLUDE_MATCH:
out << "~=";
break;
case node_type_t::INTEGER:
// this may be a dimension, if not f_string is empty anyway
out << (f_boolean && f_integer >= 0 ? "+" : "") << f_integer << f_string;
break;
case node_type_t::LESS_EQUAL:
out << "<=";
break;
case node_type_t::LESS_THAN:
out << "<";
break;
case node_type_t::MODULO:
if((flags & g_to_string_flag_add_spaces) != 0)
{
out << " % ";
}
else
{
out << "%";
}
break;
case node_type_t::MULTIPLY:
out << "*";
break;
case node_type_t::NOT_EQUAL:
out << "!=";
break;
case node_type_t::NULL_TOKEN:
// should null be "null" or ""?
out << "";
break;
case node_type_t::OPEN_CURLYBRACKET:
out << "{";
for(auto c : f_children)
{
out << c->to_string(flags);
}
out << "}";
break;
case node_type_t::OPEN_PARENTHESIS:
out << "(";
for(auto c : f_children)
{
out << c->to_string(flags);
}
out << ")";
break;
case node_type_t::OPEN_SQUAREBRACKET:
out << "[";
for(auto c : f_children)
{
out << c->to_string(flags);
}
out << "]";
break;
case node_type_t::PERCENT:
out << (f_boolean && f_integer >= 0 ? "+" : "") << decimal_number_to_string(f_decimal_number * 100.0, false) << "%";
break;
case node_type_t::PERIOD:
out << ".";
break;
case node_type_t::PLACEHOLDER:
out << "%" << f_string;
break;
case node_type_t::POWER:
out << "**";
break;
case node_type_t::PRECEDED:
out << "~";
break;
case node_type_t::PREFIX_MATCH:
out << "^=";
break;