forked from m2osw/csspp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlexer-page.cpp
More file actions
2353 lines (2349 loc) · 78.5 KB
/
lexer-page.cpp
File metadata and controls
2353 lines (2349 loc) · 78.5 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
// Documentation only file
/** \page lexer_rules Lexer Rules
* \tableofcontents
*
* \htmlonly
* <style>
* svg.railroad-diagram
* {
* background-color: hsl(30, 20%, 95%);
* }
* svg.railroad-diagram path
* {
* stroke-width: 3;
* stroke: black;
* fill: rgba(0, 0, 0, 0);
* }
* svg.railroad-diagram a
* {
* text-decoration: none;
* }
* svg.railroad-diagram a:hover
* {
* fill: red;
* }
* svg.railroad-diagram text
* {
* font: bold 14px monospace;
* text-anchor: middle;
* }
* svg.railroad-diagram text.label
* {
* text-anchor: start;
* }
* svg.railroad-diagram text.comment
* {
* font: italic 12px monospace;
* fill: #666666;
* }
* svg.railroad-diagram rect
* {
* stroke-width: 3;
* stroke: black;
* fill: hsl(120, 100%, 90%);
* }
* </style>
* \endhtmlonly
*
* \note
* Many of the SVG images below were taken from the
* <a href="http://www.w3.org/TR/css-syntax-3/">CSS Syntax Module Level 3</a>
* document.
*
* The lexer is composed of the following rules:
*
* \section input_stream Input Stream (CSS Preprocessor Detail)
*
* Contrary to CSS 3 which allows for any encoding as long as the first 128
* bytes match ASCII sufficiently, CSS Preprocessor only accepts UTF-8. This
* is because (1) 99% of the CSS files out there are ACSII anyway and
* therefore already UTF-8 compatible and (2) because the Snap! Websites
* environment is using UTF-8 throughout all of its documents (although in
* memory text data may use a different format such as UTF-16 or UTF-32.)
*
* The input stream is checked for invalid data. The lexer generates an
* error if an invalid character is found. Characters that are considered
* invalid are:
*
* \li \0 -- the NULL terminator; the lexer can still parse strings, only
* you have to write such strings in an I/O buffer first and
* you just should not include the NULL terminator in that buffer;
* (see example below)
* \li \xFFFD -- the INVALID character; in CSS 3, this character represents
* the EOF of a stream; in CSS Preprocessor, it is just viewed
* as an error
* \li \x??FFFE and \x??FFFF -- any character that ends with FFFE or FFFF
* is viewed as invalid and generates an error
*
* Note that the parsing will continue after such errors. However, if one
* or more errors occured while parsing an input stream, you should not
* use the output since it is likely invalid.
*
* An example using the CSS Preprocessor lexer with a string:
*
* \code
* ...
* // parse a string with CSS code
* std::stringstream ss;
* ss << my_css_string;
* csspp::position pos("string.css");
* csspp::lexer l(ss, pos);
* csspp::node::pointer_t n(l.next_token());
* ...
* \endcode
*
* \section anything Any Character "ANYTHING" (CSS 3)
*
* \htmlonly
* <div class="railroad">
* <svg class="railroad-diagram" height="62" viewbox="0 0 233 62" width="233">
* <g transform="translate(.5 .5)">
* <path d="M 20 21 v 20 m 10 -20 v 20 m -10 -10 h 20.5"/>
* <path d="M40 31h10"/>
* <g>
* <rect height="22" width="132" x="50.0" y="20"/>
* <text x="116.0" y="35">\??????</text>
* </g>
* <path d="M182 31h10"/>
* <path d="M 192 31 h 20 m -10 -10 v 20 m 10 -20 v 20"/>
* </g>
* </svg>
* </div>
* \endhtmlonly
*
* A valid character is any character code point defined between 0x000000
* and 0x10FFFF inclusive.
*
* The \ref input-stream defines a small set of characters within that range
* that are considered invalid in CSS Preprocessor streams. Any character
* considered invalid is replaced by the 0xFFFD code point so the rest of
* the implementation does not have to check for invalid characters each
* time.
*
* \section ascii ASCII Character "ASCII" (CSS 3)
*
* \htmlonly
* <div class="railroad">
* <svg class="railroad-diagram" height="62" viewbox="0 0 233 62" width="233">
* <g transform="translate(.5 .5)">
* <path d="M 20 21 v 20 m 10 -20 v 20 m -10 -10 h 20.5"/>
* <path d="M40 31h10"/>
* <g>
* <rect height="22" width="132" x="50.0" y="20"/>
* <text x="116.0" y="35">\0-7f</text>
* </g>
* <path d="M182 31h10"/>
* <path d="M 192 31 h 20 m -10 -10 v 20 m 10 -20 v 20"/>
* </g>
* </svg>
* </div>
* \endhtmlonly
*
* An ASCII character is any value between 0 and 127 inclusive.
*
* CSS 3 references ASCII and non-ASCII characters.
*
* \section non_ascii Non-ASCII Character "NON-ASCII" (CSS 3)
*
* \htmlonly
* <div class="railroad">
* <svg class="railroad-diagram" height="62" viewbox="0 0 303 62" width="303">
* <g transform="translate(.5 .5)">
* <path d="M 20 21 v 20 m 10 -20 v 20 m -10 -10 h 20.5"/>
* <path d="M40 31h10"/>
* <g>
* <rect height="22" width="202" x="50.0" y="20"/>
* <a xlink:href="#anything"><text x="95" y="35">ANYTHING</text></a>
* <text x="160" y="35">except</text>
* <a xlink:href="#ascii"><text x="215" y="35">ASCII</text></a>
* </g>
* <path d="M252 31h10"/>
* <path d="M 262 31 h 20 m -10 -10 v 20 m 10 -20 v 20"/>
* </g>
* </svg>
* </div>
* \endhtmlonly
*
* A NON-ASCII character is any valid character code point over 127.
*
* \note
* In CSS 2.x, characters between \80 and \9F were considered invalid
* graphic controls.
*
* \section c_like_comment C-Like Comment "COMMENT" (CSS 3)
*
* \htmlonly
* <div class="railroad">
* <svg class="railroad-diagram" height="81" viewBox="0 0 497 81" width="497">
* <g transform="translate(.5 .5)">
* <path d="M 20 31 v 20 m 10 -20 v 20 m -10 -10 h 20.5"/>
* <path d="M40 41h10"/>
* <g>
* <rect height="22" rx="10" ry="10" width="36" x="50.0" y="30"/>
* <text x="68.0" y="45">/*</text>
* </g>
* <path d="M86 41h10"/>
* <g>
* <path d="M96.0 41a10 10 0 0 0 10 -10v0a10 10 0 0 1 10 -10"/>
* <g>
* <path d="M116.0 21h264"/>
* </g>
* <path d="M380.0 21a10 10 0 0 1 10 10v0a10 10 0 0 0 10 10"/>
* <path d="M96.0 41h20"/>
* <g>
* <path d="M116.0 41h10"/>
* <g>
* <rect height="22" width="244" x="126" y="30"/>
* <a xlink:href="#anything"><text x="168" y="45">ANYTHING</text></a>
* <text x="283" y="45">but * followed by /</text>
* </g>
* <path d="M370.0 41h10"/>
* <path d="M126.0 41a10 10 0 0 0 -10 10v0a10 10 0 0 0 10 10"/>
* <g>
* <path d="M126.0 61h244"/>
* </g>
* <path d="M370.0 61a10 10 0 0 0 10 -10v0a10 10 0 0 0 -10 -10"/>
* </g>
* <path d="M380.0 41h20"/>
* </g>
* <path d="M400 41h10"/>
* <g>
* <rect height="22" rx="10" ry="10" width="36" x="410.0" y="30"/>
* <text x="428.0" y="45">*/</text>
* </g>
* <path d="M446 41h10"/>
* <path d="M 456 41 h 20 m -10 -10 v 20 m 10 -20 v 20"/>
* </g>
* </svg>
* </div>
* \endhtmlonly
*
* Note that "anything" means any character that is not considered invalid
* by the CSS Preprocessor implementation.
*
* \section cpp_comment C++ Comment "COMMENT" (CSS Preprocessor Extension)
*
* \htmlonly
* <div class="railroad">
* <svg class="railroad-diagram" height="81" viewBox="0 0 397 81" width="397">
* <g transform="translate(.5 .5)">
* <path d="M 20 31 v 20 m 10 -20 v 20 m -10 -10 h 20.5"/>
* <path d="M40 41h10"/>
* <g>
* <rect height="22" rx="10" ry="10" width="36" x="50.0" y="30"/>
* <text x="68.0" y="45">//</text>
* </g>
* <path d="M86 41h10"/>
* <g>
* <path d="M96.0 41a10 10 0 0 0 10 -10v0a10 10 0 0 1 10 -10"/>
* <g>
* <path d="M116.0 21h164"/>
* </g>
* <path d="M280.0 21a10 10 0 0 1 10 10v0a10 10 0 0 0 10 10"/>
* <path d="M96.0 41h20"/>
* <g>
* <path d="M116.0 41h10"/>
* <g>
* <rect height="22" width="144" x="126.0" y="30"/>
* <a xlink:href="#anything"><text x="168" y="45">ANYTHING</text></a>
* <text x="233" y="45">but \n</text>
* </g>
* <path d="M270.0 41h10"/>
* <path d="M126.0 41a10 10 0 0 0 -10 10v0a10 10 0 0 0 10 10"/>
* <g>
* <path d="M126.0 61h144"/>
* </g>
* <path d="M270.0 61a10 10 0 0 0 10 -10v0a10 10 0 0 0 -10 -10"/>
* </g>
* <path d="M280.0 41h20"/>
* </g>
* <path d="M300 41h10"/>
* <g>
* <rect height="22" rx="10" ry="10" width="36" x="310" y="30"/>
* <text x="328" y="45">\n</text>
* </g>
* <path d="M346 41h10"/>
* <path d="M 356 41 h 20 m -10 -10 v 20 m 10 -20 v 20"/>
* </g>
* </svg>
* </div>
* \endhtmlonly
*
* Note that "anything" means any character that is not considered invalid
* by the CSS Preprocessor implementation.
*
* The CSS Preprocessor returns a C++ comment appearing on multiple lines,
* one after another, as a single C++ comment token. This is used that way
* because it is possible to mark a comment as \@preserve in order to keep
* said comment in the output. In most cases this is used in the comment at
* the top or bottom which includes the copyright notice about the document.
*
* \code
* // CSS Preprocessor
* // Copyright (c) 2015-2019 Made to Order Software Corp. All Rights Reserved
* //
* // @preserve
* \endcode
*
* \note
* C++ comments are output as standard C-like comments so they are 100%
* compatible with CSS.
*
* \section newline Newline "NEWLINE" (CSS 3)
*
* \htmlonly
* <div class=railroad>
* <svg class=railroad-diagram height=152 viewbox="0 0 173 152" width="173">
* <g transform="translate(.5 .5)">
* <path d="M 20 21 v 20 m 10 -20 v 20 m -10 -10 h 20.5"/>
* <g>
* <path d="M40.0 31h20"/>
* <g>
* <path d="M60.0 31h8.0"/>
* <path d="M104.0 31h8.0"/>
* <rect height="22" rx="10" ry="10" width="36" x="68" y="20"/>
* <text x=86.0 y=35>\n</text>
* </g>
* <path d="M112.0 31h20"/>
* <path d="M40.0 31a10 10 0 0 1 10 10v10a10 10 0 0 0 10 10"/>
* <g>
* <rect height="22" rx="10" ry="10" width="52" x="60" y="50"/>
* <text x="86" y="65">\r\n</text>
* </g>
* <path d="M112.0 61a10 10 0 0 0 10 -10v-10a10 10 0 0 1 10 -10"/>
* <path d="M40.0 31a10 10 0 0 1 10 10v40a10 10 0 0 0 10 10"/>
* <g>
* <path d="M60.0 91h8.0"/>
* <path d="M104.0 91h8.0"/>
* <rect height="22" rx="10" ry="10" width="36" x="68" y="80"/>
* <text x=86.0 y=95>\r</text>
* </g>
* <path d="M112.0 91a10 10 0 0 0 10 -10v-40a10 10 0 0 1 10 -10"/>
* <path d="M40.0 31a10 10 0 0 1 10 10v70a10 10 0 0 0 10 10"/>
* <g>
* <path d="M60.0 121h8.0"/>
* <path d="M104.0 121h8.0"/>
* <rect height="22" rx="10" ry="10" width="36" x="68" y="110"/>
* <text x=86.0 y=125>\f</text>
* </g>
* <path d="M112.0 121a10 10 0 0 0 10 -10v-70a10 10 0 0 1 10 -10"/>
* </g>
* <path d="M 132 31 h 20 m -10 -10 v 20 m 10 -20 v 20"/>
* </g>
* </svg>
* </div>
* \endhtmlonly
*
* CSS Preprocessor counts lines starting at one and incrementing anytime
* a "\n", "\r", "\r\n" sequence is found.
*
* CSS Preprocessor resets the line counter back to one and increments the
* page counter by one each time a "\f" is found.
*
* CSS Preprocessor also counts the total number of lines and pages in a
* separate counter.
*
* The line number is used to print out errors. If you use paging (\f),
* you may have a harder time to find your errors in the current version.
*
* Note that line counting also happens in C++ and C-like comments.
*
* \section non_printable Non-Printable "NON-PRINTABLE" (CSS 3)
*
* \htmlonly
* <div class="railroad">
* <svg class="railroad-diagram" height="182" viewbox="0 0 173 182" width="173">
* <g transform="translate(.5 .5)">
* <path d="M 20 21 v 20 m 10 -20 v 20 m -10 -10 h 20.5"/>
* <g>
*
* <path d="M40.0 31h20"/>
* <g>
* <path d="M60.0 31h8.0"/>
* <path d="M114.0 31h8.0"/>
* <rect height="22" rx="10" ry="10" width="46" x="68" y="20"/>
* <text x="91" y="35">\0</text>
* </g>
* <path d="M122.0 31h20"/>
*
* <path d="M40.0 31a10 10 0 0 1 10 10v10a10 10 0 0 0 10 10"/>
* <g>
* <path d="M60.0 61h8.0"/>
* <path d="M114.0 61h8.0"/>
* <rect height="22" rx="10" ry="10" width="46" x="68" y="50"/>
* <text x="91" y="65">\8</text>
* </g>
* <path d="M122.0 61a10 10 0 0 0 10 -10v-10a10 10 0 0 1 10 -10"/>
*
* <path d="M40.0 31a10 10 0 0 1 10 10v40a10 10 0 0 0 10 10"/>
* <g>
* <path d="M60.0 91h8.0"/>
* <path d="M114.0 91h8.0"/>
* <rect height="22" rx="10" ry="10" width="46" x="68" y="80"/>
* <text x="91" y="95">\b</text>
* </g>
* <path d="M122.0 91a10 10 0 0 0 10 -10v-40a10 10 0 0 1 10 -10"/>
*
* <path d="M40.0 31a10 10 0 0 1 10 10v70a10 10 0 0 0 10 10"/>
* <g>
* <rect height="22" rx="10" ry="10" width="62" x="60" y="110"/>
* <text x="91" y="125">\e-\1f</text>
* </g>
* <path d="M122.0 121a10 10 0 0 0 10 -10v-70a10 10 0 0 1 10 -10"/>
*
* <path d="M40.0 31a10 10 0 0 1 10 10v100a10 10 0 0 0 10 10"/>
* <g>
* <path d="M60 151h8"/>
* <path d="M114 151h8"/>
* <rect height="22" rx="10" ry="10" width="46" x="68" y="140"/>
* <text x="91" y="155">\7f</text>
* </g>
* <path d="M122.0 151a10 10 0 0 0 10 -10v-100a10 10 0 0 1 10 -10"/>
*
* </g>
* <path d="M 142 31 h 20 m -10 -10 v 20 m 10 -20 v 20"/>
* </g>
* </svg>
* </div>
* \endhtmlonly
*
* URL do not accept non-printable characters if not written between quotes.
* This rule shows you which characters are considered non-printable in
* CSS 3.
*
* \section whitespace Whitespace "WHITESPACE" (CSS 3)
*
* \htmlonly
* <div class="railroad">
* <svg class="railroad-diagram" height="122" viewbox="0 0 197 122" width="197">
* <g transform="translate(.5 .5)">
* <path d="M 20 21 v 20 m 10 -20 v 20 m -10 -10 h 20.5"/>
* <g>
* <path d="M40.0 31h20"/>
* <g>
* <path d="M60.0 31h8.0"/>
* <path d="M128.0 31h8.0"/>
* <rect height=22 rx=10 ry=10 width=60 x=68.0 y=20> </rect>
* <text x=98.0 y=35> space</text>
* </g>
* <path d="M136.0 31h20"/>
* <path d="M40.0 31a10 10 0 0 1 10 10v10a10 10 0 0 0 10 10"/>
* <g>
* <path d="M60.0 61h20.0"/>
* <path d="M116.0 61h20.0"/>
* <rect height="22" rx="10" ry="10" width="36" x="80" y="50"/>
* <text x="98" y="65">\t</text>
* </g>
* <path d="M136.0 61a10 10 0 0 0 10 -10v-10a10 10 0 0 1 10 -10"/>
* <path d="M40.0 31a10 10 0 0 1 10 10v40a10 10 0 0 0 10 10"/>
* <g>
* <rect height="22" width="76" x="60" y="80"/>
* <a xlink:href="#newline"><text x=98.0 y=95>NEWLINE</text></a>
* </g>
* <path d="M136.0 91a10 10 0 0 0 10 -10v-40a10 10 0 0 1 10 -10"/>
* </g>
* <path d="M 156 31 h 20 m -10 -10 v 20 m 10 -20 v 20"/>
* </g>
* </svg>
* </div>
* \endhtmlonly
*
* Whitespaces are quite important in CSS since they are required in many
* cases. For example, a dash (-) can start an identifier, so you want to
* add a space after a dash if you want to use the minus sign.
*
* The CSS Preprocessor documentation often references the WHITESPACE token
* meaning that any number of whitespaces, including zero. It may be written
* as WHITESPACE* (0 or more whitespaces) or WHITESPACE+ (one or more
* whitespaces) to be more explicit.
*
* CSS 3 defines a whitespace, a whitespace-token, and a ws* to represents
* all those possibilities.
*
* \code{.scss}
* a - b // 'a' 'minus' 'b'
* a -b // 'a' '-b', which are two identifiers
* a-b // 'a-b', which is one identifier
* \endcode
*
* \section digit Decimal Digit "DIGIT" (CSS 3)
*
* \htmlonly
* <div class=railroad>
* <svg class=railroad-diagram height=62 viewbox="0 0 163 62" width=163>
* <g transform="translate(.5 .5)">
* <path d="M 20 21 v 20 m 10 -20 v 20 m -10 -10 h 20.5"/>
* <path d="M40 31h10"/>
* <g>
* <rect height="22" width="52" x="50" y="20"/>
* <text x="76" y="35">0-9</text>
* </g>
* <path d="M102 31h10"/>
* <path d="M 112 31 h 20 m -10 -10 v 20 m 10 -20 v 20"/>
* </g>
* </svg>
* </div>
* \endhtmlonly
*
* An hexadecimal digit is any digit (0-9) and a letter from A to F
* either in lowercase (a-f) or in uppercase (A-F).
*
* \section hexdigit Hexadecimal Digit "HEXDIGIT" (CSS 3)
*
* \htmlonly
* <div class=railroad>
* <svg class=railroad-diagram height=62 viewbox="0 0 233 62" width="233">
* <g transform="translate(.5 .5)">
* <path d="M 20 21 v 20 m 10 -20 v 20 m -10 -10 h 20.5"/>
* <path d="M40 31h10"/>
* <g>
* <rect height=22 width=132 x=50.0 y=20> </rect>
* <text x=116.0 y=35>0-9 a-f or A-F</text>
* </g>
* <path d="M182 31h10"/>
* <path d="M 192 31 h 20 m -10 -10 v 20 m 10 -20 v 20"/>
* </g>
* </svg>
* </div>
* \endhtmlonly
*
* An hexadecimal digit is any digit (0-9) and a letter from A to F
* either in lowercase (a-f) or in uppercase (A-F).
*
* \section escape Escape "ESCAPE" (CSS 3)
*
* \htmlonly
* <div class="railroad">
* <svg class="railroad-diagram" height="186" viewbox="0 0 441 186" width="441">
* <g transform="translate(.5 .5)">
* <path d="M 20 21 v 20 m 10 -20 v 20 m -10 -10 h 20.5"/>
* <path d="M40 31h10"/>
* <g>
* <rect height="22" rx="10" ry="10" width="28" x="50" y="20"/>
* <text x=64.0 y=35>\</text>
* </g>
* <path d="M78 31h10"/>
* <g>
* <path d="M88.0 31h20"/>
* <g>
* <path d="M108.0 31h30.0"/>
* <path d="M350.0 31h30.0"/>
* <rect height="22" width="212" x="138" y="20"/>
* <text x="159" y="35">not</text>
* <a xlink:href="#newline"><text x="207" y="35">NEWLINE</text></a>
* <text x="254" y="35">or</text>
* <a xlink:href="#hexdigit"><text x="303" y="35">HEXDIGIT</text></a>
* </g>
* <path d="M380.0 31h20"/>
* <path d="M88.0 31a10 10 0 0 1 10 10v10a10 10 0 0 0 10 10"/>
* <g>
* <path d="M108.0 61h10"/>
* <g>
* <path d="M118.0 61h10"/>
* <g>
* <rect height="22" width="92" x="128" y="50"/>
* <a xlink:href="#hexdigit"><text x="174" y="65">HEXDIGIT</text></a>
* </g>
* <path d="M220.0 61h10"/>
* <path d="M128.0 61a10 10 0 0 0 -10 10v10a10 10 0 0 0 10 10"/>
* <g>
* <path d="M128.0 91h9.5"/>
* <path d="M210.5 91h9.5"/>
* <text class=comment x=174.0 y=96>1-5 times</text>
* </g>
* <path d="M220.0 91a10 10 0 0 0 10 -10v-10a10 10 0 0 0 -10 -10"/>
* </g>
* <path d="M230.0 61h10"/>
* <g>
* <path d="M240.0 61h20"/>
* <g>
* <path d="M260.0 61h100"/>
* </g>
* <path d="M360.0 61h20"/>
* <path d="M240.0 61a10 10 0 0 1 10 10v0a10 10 0 0 0 10 10"/>
* <g>
* <rect height="22" width="100" x="260" y="70"/>
* <a xlink:href="#whitespace"><text x="310" y="85">WHITESPACE</text></a>
* </g>
* <path d="M360.0 81a10 10 0 0 0 10 -10v0a10 10 0 0 1 10 -10"/>
* </g>
* </g>
* <path d="M380.0 61a10 10 0 0 0 10 -10v-10a10 10 0 0 1 10 -10"/>
*
* <path d="M88.0 31a10 10 0 0 1 10 10v74a10 10 0 0 0 10 10"/>
* <g>
* <path d="M108.0 125h10"/>
* <g>
* <path d="M118.0 125h10"/>
* <g>
* <rect height="22" width="92" x="128" y="114"/>
* <a xlink:href="#hexdigit"><text x="174" y="129">HEXDIGIT</text></a>
* </g>
* <path d="M220.0 125h10"/>
* <path d="M128.0 125a10 10 0 0 0 -10 10v10a10 10 0 0 0 10 10"/>
* <g>
* <path d="M128.0 155h9.5"/>
* <path d="M210.5 155h9.5"/>
* <text class=comment x="174" y="160">6 times</text>
* </g>
* <path d="M220.0 155a10 10 0 0 0 10 -10v-10a10 10 0 0 0 -10 -10"/>
* </g>
* <path d="M230.0 125h10"/>
* <g>
* <path d="M240.0 125h20"/>
* <g>
* <path d="M260.0 125h100"/>
* </g>
* <path d="M360.0 125h20"/>
* </g>
* </g>
* <path d="M380.0 125a10 10 0 0 0 10 -10v-74a10 10 0 0 1 10 -10"/>
*
* </g>
* <path d="M 400 31 h 20 m -10 -10 v 20 m 10 -20 v 20"/>
* </g>
* </svg>
* </div>
* \endhtmlonly
*
* Allow hexadecimal or direct escaping of any character, except the
* new line character ('\' followed by any newline). There is an
* exception to the newline character in strings.
*
* The hexadecimal syntax allows for any number from 0 to 0xFFFFFF.
* However, the same constraint applies to escape characters and only
* code points that are considered valid from the input stream are
* considered valid in an escape sequence. This means any character
* between 0 and 0x10FFFF except those marked as invalid in the
* \ref input-stream section.
*
* \note
* Contrary to the CSS 3 definition, this definition clearly shows that
* the space after an escape is being skipped if the escape includes 1
* to 5 digits. In case 6 digits are used, the space is NOT skipped in
* our implementation. It looks like this is consistent with the text
* explaining how the escape sequence works. If this is a bug, the lexer
* will need to be changed.
*
* \section identifier Identifier "IDENTIFIER" (CSS 3)
*
* \htmlonly
* <div class="railroad">
* <svg class="railroad-diagram" height=110 viewbox="0 0 729 110" width="729">
* <g transform="translate(.5 .5)">
* <path d="M 20 31 v 20 m 10 -20 v 20 m -10 -10 h 20.5"/>
* <g>
* <path d="M40.0 41h20"/>
* <g>
* <path d="M60.0 41h28"/>
* </g>
* <path d="M88.0 41h20"/>
* <path d="M40.0 41a10 10 0 0 1 10 10v0a10 10 0 0 0 10 10"/>
* <g>
* <rect height="22" rx="10" ry="10" width="28" x="60" y="50"/>
* <text x="74" y="65">-</text>
* </g>
* <path d="M88.0 61a10 10 0 0 0 10 -10v0a10 10 0 0 1 10 -10"/>
* </g>
* <g>
* <path d="M108.0 41h20"/>
* <g>
* <rect height="22" width="196" x="128".0 y="30"/>
* <text x="186" y="45">a-z A-Z _ or</text>
* <a xlink:href="#non-ascii"><text x="277" y="45">NON-ASCII</text></a>
* </g>
* <path d="M324.0 41h20"/>
* <path d="M108.0 41a10 10 0 0 1 10 10v10a10 10 0 0 0 10 10"/>
* <g>
* <path d="M128.0 71h64.0"/>
* <path d="M260.0 71h64.0"/>
* <rect height="22" width="68" x="192" y="60"/>
* <a xlink:href="#escape"><text x=226.0 y=75>ESCAPE</text></a>
* </g>
* <path d="M324.0 71a10 10 0 0 0 10 -10v-10a10 10 0 0 1 10 -10"/>
* </g>
* <g>
* <path d="M344.0 41a10 10 0 0 0 10 -10v0a10 10 0 0 1 10 -10"/>
* <g>
* <path d="M364.0 21h304"/>
* </g>
* <path d="M668.0 21a10 10 0 0 1 10 10v0a10 10 0 0 0 10 10"/>
* <path d="M344.0 41h20"/>
* <g>
* <path d="M364.0 41h10"/>
* <g>
* <path d="M374.0 41h20"/>
* <g>
* <rect height="22" width="244" x="394" y="30"/>
* <text x="475" y="45">a-z A-Z 0-9 _ - or</text>
* <a xlink:href="#non-ascii"><text x="590" y="45">NON-ASCII</text></a>
* </g>
* <path d="M638.0 41h20"/>
* <path d="M374.0 41a10 10 0 0 1 10 10v10a10 10 0 0 0 10 10"/>
* <g>
* <path d="M394.0 71h88.0"/>
* <path d="M550.0 71h88.0"/>
* <rect height="22" width="68" x="482" y="60"/>
* <a xlink:href="#escape"><text x="516" y="75">ESCAPE</text></a>
* </g>
* <path d="M638.0 71a10 10 0 0 0 10 -10v-10a10 10 0 0 1 10 -10"/>
* </g>
* <path d="M658.0 41h10"/>
* <path d="M374.0 41a10 10 0 0 0 -10 10v29a10 10 0 0 0 10 10"/>
* <g>
* <path d="M374.0 90h284"/>
* </g>
* <path d="M658.0 90a10 10 0 0 0 10 -10v-29a10 10 0 0 0 -10 -10"/>
* </g>
* <path d="M668.0 41h20"/>
* </g>
* <path d="M 688 41 h 20 m -10 -10 v 20 m 10 -20 v 20"/>
* </g>
* </svg>
* </div>
* \endhtmlonly
*
* We do not have any exception to the identifier. Our lexer returns the
* same identifiers as CSS 3 allows. Note that there is an extension
* compared to CSS 2.x, characters 0x80 to 0x9F are accepted in identifiers.
*
* Note that since you can write an identifier using escape characters,
* it can really be composed of any character except NEWLINE and invalid
* characters. This allows for CSS to represent any character that can
* be used in an attribute value in HTML.
*
* \code{.scss}
* .class [attribute] #id :state { ... }
* \endcode
*
* \note
* Identifiers that start with a dash must be at least two characters.
*
* \section function Function "FUNCTION" (CSS 3)
*
* \htmlonly
* <div class="railroad">
* <svg class="railroad-diagram" height="62" viewbox="0 0 273 62" width="273">
* <g transform="translate(.5 .5)">
* <path d="M 20 21 v 20 m 10 -20 v 20 m -10 -10 h 20.5"/>
* <path d="M40 31h10"/>
* <g>
* <rect height="22" width="124" x="50.0" y="20"/>
* <a xlink:href="#identifier"><text x=112.0 y=35>IDENTIFIER</text></a>
* </g>
* <path d="M174 31h10"/>
* <path d="M184 31h10"/>
* <g>
* <rect height="22" rx="10" ry="10" width="28" x="194" y="20"/>
* <text x=208.0 y=35>(</text>
* </g>
* <path d="M222 31h10"/>
* <path d="M 232 31 h 20 m -10 -10 v 20 m 10 -20 v 20"/>
* </g>
* </svg>
* </div>
* \endhtmlonly
*
* A FUNCTION token is an IDENTIFIER immediately followed by an open
* parenthesis. No WHITESPACE is allowed between the IDENTIFIER and
* the parenthesis.
*
* \code{.css}
* a { color: rgba(255, 255, 255, 0.3); }
* \endcode
*
* \section at_keyword At Keyword "AT_KEYWORD" (CSS 3)
*
* \htmlonly
* <div class=railroad>
* <svg class=railroad-diagram height=62 viewbox="0 0 273 62" width="273">
* <g transform="translate(.5 .5)">
* <path d="M 20 21 v 20 m 10 -20 v 20 m -10 -10 h 20.5"/>
* <path d="M40 31h10"/>
* <g>
* <rect height=22 rx=10 ry=10 width=28 x=50.0 y="20"/>
* <text x=64.0 y=35>@</text>
* </g>
* <path d="M78 31h10"/>
* <path d="M88 31h10"/>
* <g>
* <rect height=22 width=124 x=98.0 y="20"/>
* <a xlink:href="#identifier"><text x=160.0 y=35>IDENTIFIER</text></a>
* </g>
* <path d="M222 31h10"/>
* <path d="M 232 31 h 20 m -10 -10 v 20 m 10 -20 v 20"/>
* </g>
* </svg>
* </div>
* \endhtmlonly
*
* Various CSS definitions require an AT-KEYWORD. Note that a full
* keyword can be defined, starting with a dash, with escape sequence,
* etc.
*
* Our extensions generally make use of AT-KEYWORD commands to extend
* the capabilities of CSS.
*
* \code{.css}
* @media { ... }
* \endcode
*
* \section placeholder Placeholder "PLACEHOLDER" (CSS Preprocessor Extension)
*
* \htmlonly
* <div class=railroad>
* <svg class=railroad-diagram height=62 viewbox="0 0 273 62" width="273">
* <g transform="translate(.5 .5)">
* <path d="M 20 21 v 20 m 10 -20 v 20 m -10 -10 h 20.5"/>
* <path d="M40 31h10"/>
* <g>
* <rect height=22 rx=10 ry=10 width=28 x=50.0 y="20"/>
* <text x=64.0 y=35>%</text>
* </g>
* <path d="M78 31h10"/>
* <path d="M88 31h10"/>
* <g>
* <rect height=22 width=124 x=98.0 y="20"/>
* <a xlink:href="#identifier"><text x=160.0 y=35>IDENTIFIER</text></a>
* </g>
* <path d="M222 31h10"/>
* <path d="M 232 31 h 20 m -10 -10 v 20 m 10 -20 v 20"/>
* </g>
* </svg>
* </div>
* \endhtmlonly
*
* The PLACEHOLDER is a CSS Preprocessor extension allowing for
* the definition of rules that do not get included in your CSS
* unless they get referenced.
*
* \code{.scss}
* // a simple rule with a placeholder
* rule%one { ... }
*
* // a reference to such a rule
* .extended
* {
* @extend %one;
* }
* \endcode
*
* \warning
* The placeholder token and rules are supported as expected. The @extend
* is not yet supported in version 1.0.0 of CSS Preprocessor.
*
* \section variable Variable "VARIABLE" (CSS Preprocessor Extension)
*
* \htmlonly
* <div class=railroad>
* <svg class=railroad-diagram height=62 viewbox="0 0 293 62" width="293">
* <g transform="translate(.5 .5)">
* <path d="M 20 21 v 20 m 10 -20 v 20 m -10 -10 h 20.5"/>
* <path d="M40 31h10"/>
* <g>
* <rect height="22" rx="10" ry="10" width="28" x="50" y="20"/>
* <text x="64" y="35">$</text>
* </g>
* <path d="M78 31h10"/>
* <path d="M88 31h10"/>
* <g>
* <rect height="22" width="144" x="98" y="20"/>
* <text x="170" y="35">a-z A-Z 0-9 - _</text>
* </g>
* <path d="M242 31h10"/>
* <path d="M 252 31 h 20 m -10 -10 v 20 m 10 -20 v 20"/>
* </g>
* </svg>
* </div>
* \endhtmlonly
*
* Variables are a CSS Preprocess extension, very similar to the variables
* defined in the SASS language (also to variables in PHP).
*
* The name of a variable is very limited on purpose.
*
* \code{.scss}
* $text_color = #ff00ff;
*
* font-color: $text_color;
* \endcode
*
* \warning
* The '-' character is allowed to be backward compatible with SASS, but
* you are expected to use '_' instead. The lexer automatically transforms
* all the '-' characters into '_' when reading the input stream.
*
* \section variable_function Variable Function "VARIABLE_FUNCTION" (CSS Preprocessor Extension)
*
* \htmlonly
* <div class=railroad>
* <svg class=railroad-diagram height=62 viewbox="0 0 341 62" width="341">
* <g transform="translate(.5 .5)">
* <path d="M 20 21 v 20 m 10 -20 v 20 m -10 -10 h 20.5"/>
* <path d="M40 31h10"/>
* <g>
* <rect height="22" rx="10" ry="10" width="28" x="50" y="20"/>
* <text x="64" y="35">$</text>
* </g>
*
* <!--path d="M78 31h20"/>
*
* <g>
* <rect height="22" width="104" x="98" y="20"/>
* <a xlink:href="#whitespace"><text x="150" y="35">WHITESPACE*</text></a>
* </g-->
*
* <path d="M78 31h20"/>
* <g>
* <rect height="22" width="144" x="98" y="20"/>
* <text x="170" y="35">a-z A-Z 0-9 - _</text>
* </g>
* <path d="M242 31h20"/>
*
* <g>
* <rect height="22" rx="10" ry="10" width="28" x="262" y="20"/>
* <text x="276" y="35">(</text>
* </g>
*
* <path d="M290 31h10"/>
* <path d="M 300 31 h 20 m -10 -10 v 20 m 10 -20 v 20"/>
* </g>
* </svg>
* </div>
* \endhtmlonly
*
* Just like regular identifiers followed by a '(', we view variables
* immediately followed by a '(' as Variable Functions.
*
* The name of a variable function is very limited on purpose.
*
* \code{.scss}
* $text_color($color): desaturate($color, 10%);
*
* font-color: $text_color(#334699);
* \endcode
*
* \warning
* The '-' character is allowed to be backward compatible with SASS, but
* you are expected to use '_' instead. The lexer automatically transforms
* all the '-' characters into '_' when reading the input stream.
*
* \section hash Hash "HASH" (CSS 3)
*
* \htmlonly
* <div class=railroad>
* <svg class=railroad-diagram height=100 viewbox="0 0 453 100" width=453>
* <g transform="translate(.5 .5)">
* <path d="M 20 21 v 20 m 10 -20 v 20 m -10 -10 h 20.5"/>
* <path d="M40 31h10"/>
* <g>
* <rect height=22 rx=10 ry=10 width=28 x=50.0 y="20"/>
* <text x=64.0 y=35>#</text>
* </g>
* <path d="M78 31h10"/>
* <path d="M88 31h10"/>
* <g>
* <path d="M98.0 31h10"/>
* <g>
* <path d="M108.0 31h20"/>
* <g>
* <rect height="22" width="244" x="128" y="20"/>
* <text x="208" y="35">a-z A-Z 0-9 _ - or</text>
* <a xlink:href="#non-ascii"><text x="322" y="35">NON-ASCII</text></a>
* </g>
* <path d="M372.0 31h20"/>
* <path d="M108.0 31a10 10 0 0 1 10 10v10a10 10 0 0 0 10 10"/>
* <g>
* <path d="M128.0 61h88.0"/>
* <path d="M284.0 61h88.0"/>
* <rect height=22 width=68 x=216.0 y="50"/>
* <a xlink:href="#escape"><text x=250.0 y=65>ESCAPE</text></a>
* </g>
* <path d="M372.0 61a10 10 0 0 0 10 -10v-10a10 10 0 0 1 10 -10"/>
* </g>
* <path d="M392.0 31h10"/>
* <path d="M108.0 31a10 10 0 0 0 -10 10v29a10 10 0 0 0 10 10"/>
* <g>
* <path d="M108.0 80h284"/>
* </g>
* <path d="M392.0 80a10 10 0 0 0 10 -10v-29a10 10 0 0 0 -10 -10"/>
* </g>
* <path d="M402 31h10"/>
* <path d="M 412 31 h 20 m -10 -10 v 20 m 10 -20 v 20"/>
* </g>
* </svg>
* </div>
* \endhtmlonly
*
* The HASH token is an identifier without the first character being
* limited.
*
* \note
* Contrary to an identifier, "-" by itself can be a HASH token.