1: <?php
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: class Text_Highlighter_CPP extends Text_Highlighter
42: {
43: var $_language = 'cpp';
44:
45: 46: 47: 48: 49: 50:
51: function __construct($options=array())
52: {
53:
54: $this->_options = $options;
55: $this->_regs = array (
56: -1 => '/((?i)")|((?i)\\{)|((?i)\\()|((?i)\\[)|((?i)[a-z_]\\w*)|((?mi)^[ \\t]*#include)|((?mii)^[ \\t]*#[ \\t]*[a-z]+)|((?i)\\d*\\.?\\d+)|((?i)\\/\\*)|((?i)\\/\\/.+)/',
57: 0 => '/((?i)\\\\)/',
58: 1 => '/((?i)")|((?i)\\{)|((?i)\\()|((?i)\\[)|((?i)[a-z_]\\w*)|((?i)\\b0[xX][\\da-f]+)|((?i)\\b\\d\\d*|\\b0\\b)|((?i)\\b0[0-7]+)|((?i)\\b(\\d*\\.\\d+)|(\\d+\\.\\d*))|((?mi)^[ \\t]*#include)|((?mii)^[ \\t]*#[ \\t]*[a-z]+)|((?i)\\d*\\.?\\d+)|((?i)\\/\\*)|((?i)\\/\\/.+)/',
59: 2 => '/((?i)")|((?i)\\{)|((?i)\\()|((?i)\\[)|((?i)[a-z_]\\w*)|((?i)\\b0[xX][\\da-f]+)|((?i)\\b\\d\\d*|\\b0\\b)|((?i)\\b0[0-7]+)|((?i)\\b(\\d*\\.\\d+)|(\\d+\\.\\d*))|((?mi)^[ \\t]*#include)|((?mii)^[ \\t]*#[ \\t]*[a-z]+)|((?i)\\d*\\.?\\d+)|((?i)\\/\\*)|((?i)\\/\\/.+)/',
60: 3 => '/((?i)")|((?i)\\{)|((?i)\\()|((?i)\\[)|((?i)[a-z_]\\w*)|((?i)\\b0[xX][\\da-f]+)|((?i)\\b\\d\\d*|\\b0\\b)|((?i)\\b0[0-7]+)|((?i)\\b(\\d*\\.\\d+)|(\\d+\\.\\d*))|((?mi)^[ \\t]*#include)|((?mii)^[ \\t]*#[ \\t]*[a-z]+)|((?i)\\d*\\.?\\d+)|((?i)\\/\\*)|((?i)\\/\\/.+)/',
61: 4 => '//',
62: 5 => '/((?i)")|((?i)<)/',
63: 6 => '/((?i)")|((?i)\\{)|((?i)\\()|((?i)[a-z_]\\w*)|((?i)\\b0[xX][\\da-f]+)|((?i)\\b\\d\\d*|\\b0\\b)|((?i)\\b0[0-7]+)|((?i)\\b(\\d*\\.\\d+)|(\\d+\\.\\d*))|((?i)\\/\\*)|((?i)\\/\\/.+)/',
64: 7 => '/((?i)\\$\\w+\\s*:.+\\$)/',
65: 8 => '/((?i)\\$\\w+\\s*:.+\\$)/',
66: );
67: $this->_counts = array (
68: -1 =>
69: array (
70: 0 => 0,
71: 1 => 0,
72: 2 => 0,
73: 3 => 0,
74: 4 => 0,
75: 5 => 0,
76: 6 => 0,
77: 7 => 0,
78: 8 => 0,
79: 9 => 0,
80: ),
81: 0 =>
82: array (
83: 0 => 0,
84: ),
85: 1 =>
86: array (
87: 0 => 0,
88: 1 => 0,
89: 2 => 0,
90: 3 => 0,
91: 4 => 0,
92: 5 => 0,
93: 6 => 0,
94: 7 => 0,
95: 8 => 2,
96: 9 => 0,
97: 10 => 0,
98: 11 => 0,
99: 12 => 0,
100: 13 => 0,
101: ),
102: 2 =>
103: array (
104: 0 => 0,
105: 1 => 0,
106: 2 => 0,
107: 3 => 0,
108: 4 => 0,
109: 5 => 0,
110: 6 => 0,
111: 7 => 0,
112: 8 => 2,
113: 9 => 0,
114: 10 => 0,
115: 11 => 0,
116: 12 => 0,
117: 13 => 0,
118: ),
119: 3 =>
120: array (
121: 0 => 0,
122: 1 => 0,
123: 2 => 0,
124: 3 => 0,
125: 4 => 0,
126: 5 => 0,
127: 6 => 0,
128: 7 => 0,
129: 8 => 2,
130: 9 => 0,
131: 10 => 0,
132: 11 => 0,
133: 12 => 0,
134: 13 => 0,
135: ),
136: 4 =>
137: array (
138: ),
139: 5 =>
140: array (
141: 0 => 0,
142: 1 => 0,
143: ),
144: 6 =>
145: array (
146: 0 => 0,
147: 1 => 0,
148: 2 => 0,
149: 3 => 0,
150: 4 => 0,
151: 5 => 0,
152: 6 => 0,
153: 7 => 2,
154: 8 => 0,
155: 9 => 0,
156: ),
157: 7 =>
158: array (
159: 0 => 0,
160: ),
161: 8 =>
162: array (
163: 0 => 0,
164: ),
165: );
166: $this->_delim = array (
167: -1 =>
168: array (
169: 0 => 'quotes',
170: 1 => 'brackets',
171: 2 => 'brackets',
172: 3 => 'brackets',
173: 4 => '',
174: 5 => 'prepro',
175: 6 => 'prepro',
176: 7 => '',
177: 8 => 'mlcomment',
178: 9 => 'comment',
179: ),
180: 0 =>
181: array (
182: 0 => '',
183: ),
184: 1 =>
185: array (
186: 0 => 'quotes',
187: 1 => 'brackets',
188: 2 => 'brackets',
189: 3 => 'brackets',
190: 4 => '',
191: 5 => '',
192: 6 => '',
193: 7 => '',
194: 8 => '',
195: 9 => 'prepro',
196: 10 => 'prepro',
197: 11 => '',
198: 12 => 'mlcomment',
199: 13 => 'comment',
200: ),
201: 2 =>
202: array (
203: 0 => 'quotes',
204: 1 => 'brackets',
205: 2 => 'brackets',
206: 3 => 'brackets',
207: 4 => '',
208: 5 => '',
209: 6 => '',
210: 7 => '',
211: 8 => '',
212: 9 => 'prepro',
213: 10 => 'prepro',
214: 11 => '',
215: 12 => 'mlcomment',
216: 13 => 'comment',
217: ),
218: 3 =>
219: array (
220: 0 => 'quotes',
221: 1 => 'brackets',
222: 2 => 'brackets',
223: 3 => 'brackets',
224: 4 => '',
225: 5 => '',
226: 6 => '',
227: 7 => '',
228: 8 => '',
229: 9 => 'prepro',
230: 10 => 'prepro',
231: 11 => '',
232: 12 => 'mlcomment',
233: 13 => 'comment',
234: ),
235: 4 =>
236: array (
237: ),
238: 5 =>
239: array (
240: 0 => 'quotes',
241: 1 => 'quotes',
242: ),
243: 6 =>
244: array (
245: 0 => 'quotes',
246: 1 => 'brackets',
247: 2 => 'brackets',
248: 3 => '',
249: 4 => '',
250: 5 => '',
251: 6 => '',
252: 7 => '',
253: 8 => 'mlcomment',
254: 9 => 'comment',
255: ),
256: 7 =>
257: array (
258: 0 => '',
259: ),
260: 8 =>
261: array (
262: 0 => '',
263: ),
264: );
265: $this->_inner = array (
266: -1 =>
267: array (
268: 0 => 'string',
269: 1 => 'code',
270: 2 => 'code',
271: 3 => 'code',
272: 4 => 'identifier',
273: 5 => 'prepro',
274: 6 => 'code',
275: 7 => 'number',
276: 8 => 'mlcomment',
277: 9 => 'comment',
278: ),
279: 0 =>
280: array (
281: 0 => 'special',
282: ),
283: 1 =>
284: array (
285: 0 => 'string',
286: 1 => 'code',
287: 2 => 'code',
288: 3 => 'code',
289: 4 => 'identifier',
290: 5 => 'number',
291: 6 => 'number',
292: 7 => 'number',
293: 8 => 'number',
294: 9 => 'prepro',
295: 10 => 'code',
296: 11 => 'number',
297: 12 => 'mlcomment',
298: 13 => 'comment',
299: ),
300: 2 =>
301: array (
302: 0 => 'string',
303: 1 => 'code',
304: 2 => 'code',
305: 3 => 'code',
306: 4 => 'identifier',
307: 5 => 'number',
308: 6 => 'number',
309: 7 => 'number',
310: 8 => 'number',
311: 9 => 'prepro',
312: 10 => 'code',
313: 11 => 'number',
314: 12 => 'mlcomment',
315: 13 => 'comment',
316: ),
317: 3 =>
318: array (
319: 0 => 'string',
320: 1 => 'code',
321: 2 => 'code',
322: 3 => 'code',
323: 4 => 'identifier',
324: 5 => 'number',
325: 6 => 'number',
326: 7 => 'number',
327: 8 => 'number',
328: 9 => 'prepro',
329: 10 => 'code',
330: 11 => 'number',
331: 12 => 'mlcomment',
332: 13 => 'comment',
333: ),
334: 4 =>
335: array (
336: ),
337: 5 =>
338: array (
339: 0 => 'string',
340: 1 => 'string',
341: ),
342: 6 =>
343: array (
344: 0 => 'string',
345: 1 => 'code',
346: 2 => 'code',
347: 3 => 'identifier',
348: 4 => 'number',
349: 5 => 'number',
350: 6 => 'number',
351: 7 => 'number',
352: 8 => 'mlcomment',
353: 9 => 'comment',
354: ),
355: 7 =>
356: array (
357: 0 => 'inlinedoc',
358: ),
359: 8 =>
360: array (
361: 0 => 'inlinedoc',
362: ),
363: );
364: $this->_end = array (
365: 0 => '/(?i)"/',
366: 1 => '/(?i)\\}/',
367: 2 => '/(?i)\\)/',
368: 3 => '/(?i)\\]/',
369: 4 => '/(?i)>/',
370: 5 => '/(?mi)(?<!\\\\)$/',
371: 6 => '/(?mi)(?<!\\\\)$/',
372: 7 => '/(?i)\\*\\//',
373: 8 => '/(?mi)$/',
374: );
375: $this->_states = array (
376: -1 =>
377: array (
378: 0 => 0,
379: 1 => 1,
380: 2 => 2,
381: 3 => 3,
382: 4 => -1,
383: 5 => 5,
384: 6 => 6,
385: 7 => -1,
386: 8 => 7,
387: 9 => 8,
388: ),
389: 0 =>
390: array (
391: 0 => -1,
392: ),
393: 1 =>
394: array (
395: 0 => 0,
396: 1 => 1,
397: 2 => 2,
398: 3 => 3,
399: 4 => -1,
400: 5 => -1,
401: 6 => -1,
402: 7 => -1,
403: 8 => -1,
404: 9 => 5,
405: 10 => 6,
406: 11 => -1,
407: 12 => 7,
408: 13 => 8,
409: ),
410: 2 =>
411: array (
412: 0 => 0,
413: 1 => 1,
414: 2 => 2,
415: 3 => 3,
416: 4 => -1,
417: 5 => -1,
418: 6 => -1,
419: 7 => -1,
420: 8 => -1,
421: 9 => 5,
422: 10 => 6,
423: 11 => -1,
424: 12 => 7,
425: 13 => 8,
426: ),
427: 3 =>
428: array (
429: 0 => 0,
430: 1 => 1,
431: 2 => 2,
432: 3 => 3,
433: 4 => -1,
434: 5 => -1,
435: 6 => -1,
436: 7 => -1,
437: 8 => -1,
438: 9 => 5,
439: 10 => 6,
440: 11 => -1,
441: 12 => 7,
442: 13 => 8,
443: ),
444: 4 =>
445: array (
446: ),
447: 5 =>
448: array (
449: 0 => 0,
450: 1 => 4,
451: ),
452: 6 =>
453: array (
454: 0 => 0,
455: 1 => 1,
456: 2 => 2,
457: 3 => -1,
458: 4 => -1,
459: 5 => -1,
460: 6 => -1,
461: 7 => -1,
462: 8 => 7,
463: 9 => 8,
464: ),
465: 7 =>
466: array (
467: 0 => -1,
468: ),
469: 8 =>
470: array (
471: 0 => -1,
472: ),
473: );
474: $this->_keywords = array (
475: -1 =>
476: array (
477: 0 => -1,
478: 1 => -1,
479: 2 => -1,
480: 3 => -1,
481: 4 =>
482: array (
483: 'reserved' => '/^(and|and_eq|asm|bitand|bitor|break|case|catch|compl|const_cast|continue|default|delete|do|dynamic_cast|else|for|fortran|friend|goto|if|new|not|not_eq|operator|or|or_eq|private|protected|public|reinterpret_cast|return|sizeof|static_cast|switch|this|throw|try|typeid|using|while|xor|xor_eq|false|true)$/',
484: 'types' => '/^(auto|bool|char|class|const|double|enum|explicit|export|extern|float|inline|int|long|mutable|namespace|register|short|signed|static|struct|template|typedef|typename|union|unsigned|virtual|void|volatile|wchar_t)$/',
485: 'Common Macros' => '/^(NULL|TRUE|FALSE|MAX|MIN|__LINE__|__DATA__|__FILE__|__TIME__|__STDC__)$/',
486: ),
487: 5 => -1,
488: 6 => -1,
489: 7 =>
490: array (
491: ),
492: 8 => -1,
493: 9 => -1,
494: ),
495: 0 =>
496: array (
497: 0 =>
498: array (
499: ),
500: ),
501: 1 =>
502: array (
503: 0 => -1,
504: 1 => -1,
505: 2 => -1,
506: 3 => -1,
507: 4 =>
508: array (
509: 'reserved' => '/^(and|and_eq|asm|bitand|bitor|break|case|catch|compl|const_cast|continue|default|delete|do|dynamic_cast|else|for|fortran|friend|goto|if|new|not|not_eq|operator|or|or_eq|private|protected|public|reinterpret_cast|return|sizeof|static_cast|switch|this|throw|try|typeid|using|while|xor|xor_eq|false|true)$/',
510: 'types' => '/^(auto|bool|char|class|const|double|enum|explicit|export|extern|float|inline|int|long|mutable|namespace|register|short|signed|static|struct|template|typedef|typename|union|unsigned|virtual|void|volatile|wchar_t)$/',
511: 'Common Macros' => '/^(NULL|TRUE|FALSE|MAX|MIN|__LINE__|__DATA__|__FILE__|__TIME__|__STDC__)$/',
512: ),
513: 5 =>
514: array (
515: ),
516: 6 =>
517: array (
518: ),
519: 7 =>
520: array (
521: ),
522: 8 =>
523: array (
524: ),
525: 9 => -1,
526: 10 => -1,
527: 11 =>
528: array (
529: ),
530: 12 => -1,
531: 13 => -1,
532: ),
533: 2 =>
534: array (
535: 0 => -1,
536: 1 => -1,
537: 2 => -1,
538: 3 => -1,
539: 4 =>
540: array (
541: 'reserved' => '/^(and|and_eq|asm|bitand|bitor|break|case|catch|compl|const_cast|continue|default|delete|do|dynamic_cast|else|for|fortran|friend|goto|if|new|not|not_eq|operator|or|or_eq|private|protected|public|reinterpret_cast|return|sizeof|static_cast|switch|this|throw|try|typeid|using|while|xor|xor_eq|false|true)$/',
542: 'types' => '/^(auto|bool|char|class|const|double|enum|explicit|export|extern|float|inline|int|long|mutable|namespace|register|short|signed|static|struct|template|typedef|typename|union|unsigned|virtual|void|volatile|wchar_t)$/',
543: 'Common Macros' => '/^(NULL|TRUE|FALSE|MAX|MIN|__LINE__|__DATA__|__FILE__|__TIME__|__STDC__)$/',
544: ),
545: 5 =>
546: array (
547: ),
548: 6 =>
549: array (
550: ),
551: 7 =>
552: array (
553: ),
554: 8 =>
555: array (
556: ),
557: 9 => -1,
558: 10 => -1,
559: 11 =>
560: array (
561: ),
562: 12 => -1,
563: 13 => -1,
564: ),
565: 3 =>
566: array (
567: 0 => -1,
568: 1 => -1,
569: 2 => -1,
570: 3 => -1,
571: 4 =>
572: array (
573: 'reserved' => '/^(and|and_eq|asm|bitand|bitor|break|case|catch|compl|const_cast|continue|default|delete|do|dynamic_cast|else|for|fortran|friend|goto|if|new|not|not_eq|operator|or|or_eq|private|protected|public|reinterpret_cast|return|sizeof|static_cast|switch|this|throw|try|typeid|using|while|xor|xor_eq|false|true)$/',
574: 'types' => '/^(auto|bool|char|class|const|double|enum|explicit|export|extern|float|inline|int|long|mutable|namespace|register|short|signed|static|struct|template|typedef|typename|union|unsigned|virtual|void|volatile|wchar_t)$/',
575: 'Common Macros' => '/^(NULL|TRUE|FALSE|MAX|MIN|__LINE__|__DATA__|__FILE__|__TIME__|__STDC__)$/',
576: ),
577: 5 =>
578: array (
579: ),
580: 6 =>
581: array (
582: ),
583: 7 =>
584: array (
585: ),
586: 8 =>
587: array (
588: ),
589: 9 => -1,
590: 10 => -1,
591: 11 =>
592: array (
593: ),
594: 12 => -1,
595: 13 => -1,
596: ),
597: 4 =>
598: array (
599: ),
600: 5 =>
601: array (
602: 0 => -1,
603: 1 => -1,
604: ),
605: 6 =>
606: array (
607: 0 => -1,
608: 1 => -1,
609: 2 => -1,
610: 3 =>
611: array (
612: 'reserved' => '/^(and|and_eq|asm|bitand|bitor|break|case|catch|compl|const_cast|continue|default|delete|do|dynamic_cast|else|for|fortran|friend|goto|if|new|not|not_eq|operator|or|or_eq|private|protected|public|reinterpret_cast|return|sizeof|static_cast|switch|this|throw|try|typeid|using|while|xor|xor_eq|false|true)$/',
613: 'types' => '/^(auto|bool|char|class|const|double|enum|explicit|export|extern|float|inline|int|long|mutable|namespace|register|short|signed|static|struct|template|typedef|typename|union|unsigned|virtual|void|volatile|wchar_t)$/',
614: 'Common Macros' => '/^(NULL|TRUE|FALSE|MAX|MIN|__LINE__|__DATA__|__FILE__|__TIME__|__STDC__)$/',
615: ),
616: 4 =>
617: array (
618: ),
619: 5 =>
620: array (
621: ),
622: 6 =>
623: array (
624: ),
625: 7 =>
626: array (
627: ),
628: 8 => -1,
629: 9 => -1,
630: ),
631: 7 =>
632: array (
633: 0 =>
634: array (
635: ),
636: ),
637: 8 =>
638: array (
639: 0 =>
640: array (
641: ),
642: ),
643: );
644: $this->_parts = array (
645: 0 =>
646: array (
647: 0 => NULL,
648: ),
649: 1 =>
650: array (
651: 0 => NULL,
652: 1 => NULL,
653: 2 => NULL,
654: 3 => NULL,
655: 4 => NULL,
656: 5 => NULL,
657: 6 => NULL,
658: 7 => NULL,
659: 8 => NULL,
660: 9 => NULL,
661: 10 => NULL,
662: 11 => NULL,
663: 12 => NULL,
664: 13 => NULL,
665: ),
666: 2 =>
667: array (
668: 0 => NULL,
669: 1 => NULL,
670: 2 => NULL,
671: 3 => NULL,
672: 4 => NULL,
673: 5 => NULL,
674: 6 => NULL,
675: 7 => NULL,
676: 8 => NULL,
677: 9 => NULL,
678: 10 => NULL,
679: 11 => NULL,
680: 12 => NULL,
681: 13 => NULL,
682: ),
683: 3 =>
684: array (
685: 0 => NULL,
686: 1 => NULL,
687: 2 => NULL,
688: 3 => NULL,
689: 4 => NULL,
690: 5 => NULL,
691: 6 => NULL,
692: 7 => NULL,
693: 8 => NULL,
694: 9 => NULL,
695: 10 => NULL,
696: 11 => NULL,
697: 12 => NULL,
698: 13 => NULL,
699: ),
700: 4 =>
701: array (
702: ),
703: 5 =>
704: array (
705: 0 => NULL,
706: 1 => NULL,
707: ),
708: 6 =>
709: array (
710: 0 => NULL,
711: 1 => NULL,
712: 2 => NULL,
713: 3 => NULL,
714: 4 => NULL,
715: 5 => NULL,
716: 6 => NULL,
717: 7 => NULL,
718: 8 => NULL,
719: 9 => NULL,
720: ),
721: 7 =>
722: array (
723: 0 => NULL,
724: ),
725: 8 =>
726: array (
727: 0 => NULL,
728: ),
729: );
730: $this->_subst = array (
731: -1 =>
732: array (
733: 0 => false,
734: 1 => false,
735: 2 => false,
736: 3 => false,
737: 4 => false,
738: 5 => false,
739: 6 => false,
740: 7 => false,
741: 8 => false,
742: 9 => false,
743: ),
744: 0 =>
745: array (
746: 0 => false,
747: ),
748: 1 =>
749: array (
750: 0 => false,
751: 1 => false,
752: 2 => false,
753: 3 => false,
754: 4 => false,
755: 5 => false,
756: 6 => false,
757: 7 => false,
758: 8 => false,
759: 9 => false,
760: 10 => false,
761: 11 => false,
762: 12 => false,
763: 13 => false,
764: ),
765: 2 =>
766: array (
767: 0 => false,
768: 1 => false,
769: 2 => false,
770: 3 => false,
771: 4 => false,
772: 5 => false,
773: 6 => false,
774: 7 => false,
775: 8 => false,
776: 9 => false,
777: 10 => false,
778: 11 => false,
779: 12 => false,
780: 13 => false,
781: ),
782: 3 =>
783: array (
784: 0 => false,
785: 1 => false,
786: 2 => false,
787: 3 => false,
788: 4 => false,
789: 5 => false,
790: 6 => false,
791: 7 => false,
792: 8 => false,
793: 9 => false,
794: 10 => false,
795: 11 => false,
796: 12 => false,
797: 13 => false,
798: ),
799: 4 =>
800: array (
801: ),
802: 5 =>
803: array (
804: 0 => false,
805: 1 => false,
806: ),
807: 6 =>
808: array (
809: 0 => false,
810: 1 => false,
811: 2 => false,
812: 3 => false,
813: 4 => false,
814: 5 => false,
815: 6 => false,
816: 7 => false,
817: 8 => false,
818: 9 => false,
819: ),
820: 7 =>
821: array (
822: 0 => false,
823: ),
824: 8 =>
825: array (
826: 0 => false,
827: ),
828: );
829: $this->_conditions = array (
830: );
831: $this->_kwmap = array (
832: 'reserved' => 'reserved',
833: 'types' => 'types',
834: 'Common Macros' => 'prepro',
835: );
836: $this->_defClass = 'code';
837: $this->_checkDefines();
838: }
839:
840: }