ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
yaml.php
Go to the documentation of this file.
1<?php
2/*************************************************************************************
3 * yaml.php
4 * --------
5 * Author: Josh Ventura (JoshV10@gmail.com)
6 * Copyright: (c) 2010 Josh Ventura
7 * Release Version: 1.0.9.0
8 * Date Started: 2010/12/14
9 *
10 * YAML language file for GeSHi.
11 *
12 * YAML gets hairy sometimes. If anything needs fixed, drop me an email and
13 * I'll probably spit up on it. This is, in general, not a long format.
14 *
15 * CHANGES
16 * ---------
17 * 2010/12/14
18 * - Started project in rage over GML support but not YAML support. WTFH?
19 * 2010/12/15
20 * - Submitted to Ben.
21 *
22 * TODO (not updated since release)
23 * ----------------------------------
24 * - Field testing and necessary corrections: this grammar file is usable, but not
25 * completely accurate. There are, in fact, multiple cases in which it will mess
26 * up, and some of it may need moved around. It is the most temperamental parser
27 * I have ever associated my name with. Points of interest follow:
28 * * Improvised support for | and >: since PHP offers no variable-width lookbehind,
29 * these blocks will still be highlighted even when commented out. As it happens,
30 * any line ending with | or > could result in the unintentional highlighting of
31 * all remaining lines in the file, just because I couldn't check for this regex
32 * as a lookbehind: '/:(\s+)(!!(\w+)(\s+))?/'
33 * If there is a workaround for that, it needs implemented.
34 * * I may be missing some operators. I deliberately omitted inline array notation
35 * as, in general, it's ugly and tends to conflict with plain-text. Ensuring all
36 * highlighted list delimiters are not plain text would be as simple as checking
37 * that they follow a colon directly. Alas, without variable-length lookbehinds,
38 * if there is a way to do so in GeSHi I am unaware of it.
39 * * I kind of whored the comment regexp array. It seemed like a safe bet, so it's
40 * where I crammed everything. Some of it may need moved elsewhere for neatness.
41 * * The !!typename highlight needs not to interfere with ": |" and ": >": Pairing
42 * key: !!type | value is perfectly legal, but again due to lookbehind issues, I
43 * can't add a case for that. Also, it is likely that multiple spaces can be put
44 * between the colon and pipe symbol, which would also break it.
45 *
46 *************************************************************************************
47 *
48 * This file is part of GeSHi.
49 *
50 * GeSHi is free software; you can redistribute it and/or modify it
51 * under the terms of the GNU General Public License as published by
52 * the Free Software Foundation; either version 2 of the License, or
53 * (at your option) any later version.
54 *
55 * GeSHi is distributed in the hope that it will be useful,
56 * but WITHOUT ANY WARRANTY; without even the implied warranty of
57 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
58 * GNU General Public License for more details.
59 *
60 * You should have received a copy of the GNU General Public License
61 * along with GeSHi; if not, write to the Free Software
62 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
63 *
64 ************************************************************************************/
65
67 'LANG_NAME' => 'YAML',
68 'COMMENT_SINGLE' => array(),
69 'COMMENT_MULTI' => array(),
70 //Keys
71 'COMMENT_REGEXP' => array( // ENTRY ZERO SHOULD CHECK FOR (\n(\s*)([^#%]+?):(\s+)(!!(\w+)(\s+))?) AS A LOOKBEHIND, BUT IT CAN'T.
72 0 => '/(?<=\s[\|>]\n)(\s+)(.*)((?=[\n$])(([\n^](\1(.*)|(?=[\n$])))*)|$)/', // Pipe blocks and > blocks.
73 1 => '/#(.*)/', // Blue # comments
74 2 => '/%(.*)/', // Red % comments
75 3 => '/(^|\n)([^#%^\n]+?)(?=: )/', // Key-value names
76 4 => '/(^|\n)([^#%^\n]+?)(?=:\n)/',// Key-group names
77 5 => '/(?<=^---)(\s*)!(\S+)/', // Comments after ---
78 6 => '/(?<=: )(\s*)\&(\S+)/', // References
79 7 => '/(?<=: )(\s*)\*(\S+)/', // Dereferences
80 8 => '/!!(\w+)/', // Types
81 //9 => '/(?<=\n)(\s*)-(?!-)/', // List items: This needs to search within comments 3 and 4, but I don't know how.
82 ),
83 'CASE_KEYWORDS' => GESHI_CAPS_NO_CHANGE,
84 'QUOTEMARKS' => array('"'),
85 'ESCAPE_CHAR' => '',
86 'NUMBERS' => array(),
87 'KEYWORDS' => array(
88 1 => array(
89 'all','any','none', "yes", "no"
90 ),
91 ),
92 'SYMBOLS' => array(
93 1 => array('---', '...'),
94 2 => array(': ', ">\n", "|\n", '<<:', ":\n") // It'd be nice if I could specify that the colon must
95 // follow comment 3 or 4 to be considered, and the > and |
96 // must follow such a colon.
97 ),
98 'CASE_SENSITIVE' => array(
99 GESHI_COMMENTS => false,
100 1 => false,
101 ),
102 'STYLES' => array(
103 'KEYWORDS' => array(
104 1 => 'font-weight: bold;'
105 ),
106 'COMMENTS' => array(
107 0 => 'color: #303050;background-color: #F5F5F5',
108 1 => 'color: blue;',
109 2 => 'font-weight: bold; color: red;',
110 3 => 'color: green;',
111 4 => 'color: #007F45;',
112 5 => 'color: #7f7fFF;',
113 6 => 'color: #FF7000;',
114 7 => 'color: #FF45C0;',
115 8 => 'font-weight: bold; color: #005F5F;',
116 //9 => 'font-weight: bold; color: #000000;',
117 ),
118 'ESCAPE_CHAR' => array(
119 ),
120 'BRACKETS' => array(
121 ),
122 'STRINGS' => array(
123 0 => 'color: #CF00CF;'
124 ),
125 'NUMBERS' => array(
126 // 0 => 'color: #33f;' // Don't highlight numbers, really...
127 ),
128 'METHODS' => array(
129 1 => '',
130 2 => ''
131 ),
132 'SYMBOLS' => array(
133 1 => 'color: cyan;',
134 2 => 'font-weight: bold; color: brown;'
135 ),
136 'REGEXPS' => array(
137 ),
138 'SCRIPT' => array(
139 0 => ''
140 )
141 ),
142 'URLS' => array(1 => ''),
143 'OOLANG' => false,
144 'OBJECT_SPLITTERS' => array(),
145 'REGEXPS' => array(),
146 'STRICT_MODE_APPLIES' => GESHI_NEVER,
147 'SCRIPT_DELIMITERS' => array(),
148 'HIGHLIGHT_STRICT_BLOCK' => array()
149);
An exception for terminatinating execution or to throw for unit testing.
const GESHI_CAPS_NO_CHANGE
Lowercase keywords found.
Definition: geshi.php:94
const GESHI_COMMENTS
Used in language files to mark comments.
Definition: geshi.php:149
const GESHI_NEVER
#+ @access private
Definition: geshi.php:123
$language_data
Definition: yaml.php:66