Patch Realtime into CodeMirror in CryptPad
This commit is contained in:
1 parent
05ce2695b2
commit
32f44161a7
721 files changed
+148708
-1
No files matched your search
@@ -0,0 +1,64 @@
|
||||
<!doctype html>
|
||||
|
||||
<title>CodeMirror: PHP mode</title>
|
||||
<meta charset="utf-8"/>
|
||||
<link rel=stylesheet href="../../doc/docs.css">
|
||||
|
||||
<link rel="stylesheet" href="../../lib/codemirror.css">
|
||||
<script src="../../lib/codemirror.js"></script>
|
||||
<script src="../../addon/edit/matchbrackets.js"></script>
|
||||
<script src="../htmlmixed/htmlmixed.js"></script>
|
||||
<script src="../xml/xml.js"></script>
|
||||
<script src="../javascript/javascript.js"></script>
|
||||
<script src="../css/css.js"></script>
|
||||
<script src="../clike/clike.js"></script>
|
||||
<script src="php.js"></script>
|
||||
<style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
|
||||
<div id=nav>
|
||||
<a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
|
||||
|
||||
<ul>
|
||||
<li><a href="../../index.html">Home</a>
|
||||
<li><a href="../../doc/manual.html">Manual</a>
|
||||
<li><a href="https://github.com/codemirror/codemirror">Code</a>
|
||||
</ul>
|
||||
<ul>
|
||||
<li><a href="../index.html">Language modes</a>
|
||||
<li><a class=active href="#">PHP</a>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<article>
|
||||
<h2>PHP mode</h2>
|
||||
<form><textarea id="code" name="code">
|
||||
<?php
|
||||
$a = array('a' => 1, 'b' => 2, 3 => 'c');
|
||||
|
||||
echo "$a[a] ${a[3] /* } comment */} {$a[b]} \$a[a]";
|
||||
|
||||
function hello($who) {
|
||||
return "Hello $who!";
|
||||
}
|
||||
?>
|
||||
<p>The program says <?= hello("World") ?>.</p>
|
||||
<script>
|
||||
alert("And here is some JS code"); // also colored
|
||||
</script>
|
||||
</textarea></form>
|
||||
|
||||
<script>
|
||||
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
|
||||
lineNumbers: true,
|
||||
matchBrackets: true,
|
||||
mode: "application/x-httpd-php",
|
||||
indentUnit: 4,
|
||||
indentWithTabs: true
|
||||
});
|
||||
</script>
|
||||
|
||||
<p>Simple HTML/PHP mode based on
|
||||
the <a href="../clike/">C-like</a> mode. Depends on XML,
|
||||
JavaScript, CSS, HTMLMixed, and C-like modes.</p>
|
||||
|
||||
<p><strong>MIME types defined:</strong> <code>application/x-httpd-php</code> (HTML with PHP code), <code>text/x-php</code> (plain, non-wrapped PHP code).</p>
|
||||
</article>
|
||||
@@ -0,0 +1,234 @@
|
||||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
||||
|
||||
(function(mod) {
|
||||
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
||||
mod(require("../../lib/codemirror"), require("../htmlmixed/htmlmixed"), require("../clike/clike"));
|
||||
else if (typeof define == "function" && define.amd) // AMD
|
||||
define(["../../lib/codemirror", "../htmlmixed/htmlmixed", "../clike/clike"], mod);
|
||||
else // Plain browser env
|
||||
mod(CodeMirror);
|
||||
})(function(CodeMirror) {
|
||||
"use strict";
|
||||
|
||||
function keywords(str) {
|
||||
var obj = {}, words = str.split(" ");
|
||||
for (var i = 0; i < words.length; ++i) obj[words[i]] = true;
|
||||
return obj;
|
||||
}
|
||||
|
||||
// Helper for phpString
|
||||
function matchSequence(list, end, escapes) {
|
||||
if (list.length == 0) return phpString(end);
|
||||
return function (stream, state) {
|
||||
var patterns = list[0];
|
||||
for (var i = 0; i < patterns.length; i++) if (stream.match(patterns[i][0])) {
|
||||
state.tokenize = matchSequence(list.slice(1), end);
|
||||
return patterns[i][1];
|
||||
}
|
||||
state.tokenize = phpString(end, escapes);
|
||||
return "string";
|
||||
};
|
||||
}
|
||||
function phpString(closing, escapes) {
|
||||
return function(stream, state) { return phpString_(stream, state, closing, escapes); };
|
||||
}
|
||||
function phpString_(stream, state, closing, escapes) {
|
||||
// "Complex" syntax
|
||||
if (escapes !== false && stream.match("${", false) || stream.match("{$", false)) {
|
||||
state.tokenize = null;
|
||||
return "string";
|
||||
}
|
||||
|
||||
// Simple syntax
|
||||
if (escapes !== false && stream.match(/^\$[a-zA-Z_][a-zA-Z0-9_]*/)) {
|
||||
// After the variable name there may appear array or object operator.
|
||||
if (stream.match("[", false)) {
|
||||
// Match array operator
|
||||
state.tokenize = matchSequence([
|
||||
[["[", null]],
|
||||
[[/\d[\w\.]*/, "number"],
|
||||
[/\$[a-zA-Z_][a-zA-Z0-9_]*/, "variable-2"],
|
||||
[/[\w\$]+/, "variable"]],
|
||||
[["]", null]]
|
||||
], closing, escapes);
|
||||
}
|
||||
if (stream.match(/\-\>\w/, false)) {
|
||||
// Match object operator
|
||||
state.tokenize = matchSequence([
|
||||
[["->", null]],
|
||||
[[/[\w]+/, "variable"]]
|
||||
], closing, escapes);
|
||||
}
|
||||
return "variable-2";
|
||||
}
|
||||
|
||||
var escaped = false;
|
||||
// Normal string
|
||||
while (!stream.eol() &&
|
||||
(escaped || escapes === false ||
|
||||
(!stream.match("{$", false) &&
|
||||
!stream.match(/^(\$[a-zA-Z_][a-zA-Z0-9_]*|\$\{)/, false)))) {
|
||||
if (!escaped && stream.match(closing)) {
|
||||
state.tokenize = null;
|
||||
state.tokStack.pop(); state.tokStack.pop();
|
||||
break;
|
||||
}
|
||||
escaped = stream.next() == "\\" && !escaped;
|
||||
}
|
||||
return "string";
|
||||
}
|
||||
|
||||
var phpKeywords = "abstract and array as break case catch class clone const continue declare default " +
|
||||
"do else elseif enddeclare endfor endforeach endif endswitch endwhile extends final " +
|
||||
"for foreach function global goto if implements interface instanceof namespace " +
|
||||
"new or private protected public static switch throw trait try use var while xor " +
|
||||
"die echo empty exit eval include include_once isset list require require_once return " +
|
||||
"print unset __halt_compiler self static parent yield insteadof finally";
|
||||
var phpAtoms = "true false null TRUE FALSE NULL __CLASS__ __DIR__ __FILE__ __LINE__ __METHOD__ __FUNCTION__ __NAMESPACE__ __TRAIT__";
|
||||
var phpBuiltin = "func_num_args func_get_arg func_get_args strlen strcmp strncmp strcasecmp strncasecmp each error_reporting define defined trigger_error user_error set_error_handler restore_error_handler get_declared_classes get_loaded_extensions extension_loaded get_extension_funcs debug_backtrace constant bin2hex hex2bin sleep usleep time mktime gmmktime strftime gmstrftime strtotime date gmdate getdate localtime checkdate flush wordwrap htmlspecialchars htmlentities html_entity_decode md5 md5_file crc32 getimagesize image_type_to_mime_type phpinfo phpversion phpcredits strnatcmp strnatcasecmp substr_count strspn strcspn strtok strtoupper strtolower strpos strrpos strrev hebrev hebrevc nl2br basename dirname pathinfo stripslashes stripcslashes strstr stristr strrchr str_shuffle str_word_count strcoll substr substr_replace quotemeta ucfirst ucwords strtr addslashes addcslashes rtrim str_replace str_repeat count_chars chunk_split trim ltrim strip_tags similar_text explode implode setlocale localeconv parse_str str_pad chop strchr sprintf printf vprintf vsprintf sscanf fscanf parse_url urlencode urldecode rawurlencode rawurldecode readlink linkinfo link unlink exec system escapeshellcmd escapeshellarg passthru shell_exec proc_open proc_close rand srand getrandmax mt_rand mt_srand mt_getrandmax base64_decode base64_encode abs ceil floor round is_finite is_nan is_infinite bindec hexdec octdec decbin decoct dechex base_convert number_format fmod ip2long long2ip getenv putenv getopt microtime gettimeofday getrusage uniqid quoted_printable_decode set_time_limit get_cfg_var magic_quotes_runtime set_magic_quotes_runtime get_magic_quotes_gpc get_magic_quotes_runtime import_request_variables error_log serialize unserialize memory_get_usage var_dump var_export debug_zval_dump print_r highlight_file show_source highlight_string ini_get ini_get_all ini_set ini_alter ini_restore get_include_path set_include_path restore_include_path setcookie header headers_sent connection_aborted connection_status ignore_user_abort parse_ini_file is_uploaded_file move_uploaded_file intval floatval doubleval strval gettype settype is_null is_resource is_bool is_long is_float is_int is_integer is_double is_real is_numeric is_string is_array is_object is_scalar ereg ereg_replace eregi eregi_replace split spliti join sql_regcase dl pclose popen readfile rewind rmdir umask fclose feof fgetc fgets fgetss fread fopen fpassthru ftruncate fstat fseek ftell fflush fwrite fputs mkdir rename copy tempnam tmpfile file file_get_contents file_put_contents stream_select stream_context_create stream_context_set_params stream_context_set_option stream_context_get_options stream_filter_prepend stream_filter_append fgetcsv flock get_meta_tags stream_set_write_buffer set_file_buffer set_socket_blocking stream_set_blocking socket_set_blocking stream_get_meta_data stream_register_wrapper stream_wrapper_register stream_set_timeout socket_set_timeout socket_get_status realpath fnmatch fsockopen pfsockopen pack unpack get_browser crypt opendir closedir chdir getcwd rewinddir readdir dir glob fileatime filectime filegroup fileinode filemtime fileowner fileperms filesize filetype file_exists is_writable is_writeable is_readable is_executable is_file is_dir is_link stat lstat chown touch clearstatcache mail ob_start ob_flush ob_clean ob_end_flush ob_end_clean ob_get_flush ob_get_clean ob_get_length ob_get_level ob_get_status ob_get_contents ob_implicit_flush ob_list_handlers ksort krsort natsort natcasesort asort arsort sort rsort usort uasort uksort shuffle array_walk count end prev next reset current key min max in_array array_search extract compact array_fill range array_multisort array_push array_pop array_shift array_unshift array_splice array_slice array_merge array_merge_recursive array_keys array_values array_count_values array_reverse array_reduce array_pad array_flip array_change_key_case array_rand array_unique array_intersect array_intersect_assoc array_diff array_diff_assoc array_sum array_filter array_map array_chunk array_key_exists pos sizeof key_exists assert assert_options version_compare ftok str_rot13 aggregate session_name session_module_name session_save_path session_id session_regenerate_id session_decode session_register session_unregister session_is_registered session_encode session_start session_destroy session_unset session_set_save_handler session_cache_limiter session_cache_expire session_set_cookie_params session_get_cookie_params session_write_close preg_match preg_match_all preg_replace preg_replace_callback preg_split preg_quote preg_grep overload ctype_alnum ctype_alpha ctype_cntrl ctype_digit ctype_lower ctype_graph ctype_print ctype_punct ctype_space ctype_upper ctype_xdigit virtual apache_request_headers apache_note apache_lookup_uri apache_child_terminate apache_setenv apache_response_headers apache_get_version getallheaders mysql_connect mysql_pconnect mysql_close mysql_select_db mysql_create_db mysql_drop_db mysql_query mLine truncated
|
||||
CodeMirror.registerHelper("hintWords", "php", [phpKeywords, phpAtoms, phpBuiltin].join(" ").split(" "));
|
||||
CodeMirror.registerHelper("wordChars", "php", /[\w$]/);
|
||||
|
||||
var phpConfig = {
|
||||
name: "clike",
|
||||
helperType: "php",
|
||||
keywords: keywords(phpKeywords),
|
||||
blockKeywords: keywords("catch do else elseif for foreach if switch try while finally"),
|
||||
defKeywords: keywords("class function interface namespace trait"),
|
||||
atoms: keywords(phpAtoms),
|
||||
builtin: keywords(phpBuiltin),
|
||||
multiLineStrings: true,
|
||||
hooks: {
|
||||
"$": function(stream) {
|
||||
stream.eatWhile(/[\w\$_]/);
|
||||
return "variable-2";
|
||||
},
|
||||
"<": function(stream, state) {
|
||||
var before;
|
||||
if (before = stream.match(/<<\s*/)) {
|
||||
var quoted = stream.eat(/['"]/);
|
||||
stream.eatWhile(/[\w\.]/);
|
||||
var delim = stream.current().slice(before[0].length + (quoted ? 2 : 1));
|
||||
if (quoted) stream.eat(quoted);
|
||||
if (delim) {
|
||||
(state.tokStack || (state.tokStack = [])).push(delim, 0);
|
||||
state.tokenize = phpString(delim, quoted != "'");
|
||||
return "string";
|
||||
}
|
||||
}
|
||||
return false;
|
||||
},
|
||||
"#": function(stream) {
|
||||
while (!stream.eol() && !stream.match("?>", false)) stream.next();
|
||||
return "comment";
|
||||
},
|
||||
"/": function(stream) {
|
||||
if (stream.eat("/")) {
|
||||
while (!stream.eol() && !stream.match("?>", false)) stream.next();
|
||||
return "comment";
|
||||
}
|
||||
return false;
|
||||
},
|
||||
'"': function(_stream, state) {
|
||||
(state.tokStack || (state.tokStack = [])).push('"', 0);
|
||||
state.tokenize = phpString('"');
|
||||
return "string";
|
||||
},
|
||||
"{": function(_stream, state) {
|
||||
if (state.tokStack && state.tokStack.length)
|
||||
state.tokStack[state.tokStack.length - 1]++;
|
||||
return false;
|
||||
},
|
||||
"}": function(_stream, state) {
|
||||
if (state.tokStack && state.tokStack.length > 0 &&
|
||||
!--state.tokStack[state.tokStack.length - 1]) {
|
||||
state.tokenize = phpString(state.tokStack[state.tokStack.length - 2]);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
CodeMirror.defineMode("php", function(config, parserConfig) {
|
||||
var htmlMode = CodeMirror.getMode(config, "text/html");
|
||||
var phpMode = CodeMirror.getMode(config, phpConfig);
|
||||
|
||||
function dispatch(stream, state) {
|
||||
var isPHP = state.curMode == phpMode;
|
||||
if (stream.sol() && state.pending && state.pending != '"' && state.pending != "'") state.pending = null;
|
||||
if (!isPHP) {
|
||||
if (stream.match(/^<\?\w*/)) {
|
||||
state.curMode = phpMode;
|
||||
if (!state.php) state.php = CodeMirror.startState(phpMode, htmlMode.indent(state.html, ""))
|
||||
state.curState = state.php;
|
||||
return "meta";
|
||||
}
|
||||
if (state.pending == '"' || state.pending == "'") {
|
||||
while (!stream.eol() && stream.next() != state.pending) {}
|
||||
var style = "string";
|
||||
} else if (state.pending && stream.pos < state.pending.end) {
|
||||
stream.pos = state.pending.end;
|
||||
var style = state.pending.style;
|
||||
} else {
|
||||
var style = htmlMode.token(stream, state.curState);
|
||||
}
|
||||
if (state.pending) state.pending = null;
|
||||
var cur = stream.current(), openPHP = cur.search(/<\?/), m;
|
||||
if (openPHP != -1) {
|
||||
if (style == "string" && (m = cur.match(/[\'\"]$/)) && !/\?>/.test(cur)) state.pending = m[0];
|
||||
else state.pending = {end: stream.pos, style: style};
|
||||
stream.backUp(cur.length - openPHP);
|
||||
}
|
||||
return style;
|
||||
} else if (isPHP && state.php.tokenize == null && stream.match("?>")) {
|
||||
state.curMode = htmlMode;
|
||||
state.curState = state.html;
|
||||
if (!state.php.context.prev) state.php = null;
|
||||
return "meta";
|
||||
} else {
|
||||
return phpMode.token(stream, state.curState);
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
startState: function() {
|
||||
var html = CodeMirror.startState(htmlMode)
|
||||
var php = parserConfig.startOpen ? CodeMirror.startState(phpMode) : null
|
||||
return {html: html,
|
||||
php: php,
|
||||
curMode: parserConfig.startOpen ? phpMode : htmlMode,
|
||||
curState: parserConfig.startOpen ? php : html,
|
||||
pending: null};
|
||||
},
|
||||
|
||||
copyState: function(state) {
|
||||
var html = state.html, htmlNew = CodeMirror.copyState(htmlMode, html),
|
||||
php = state.php, phpNew = php && CodeMirror.copyState(phpMode, php), cur;
|
||||
if (state.curMode == htmlMode) cur = htmlNew;
|
||||
else cur = phpNew;
|
||||
return {html: htmlNew, php: phpNew, curMode: state.curMode, curState: cur,
|
||||
pending: state.pending};
|
||||
},
|
||||
|
||||
token: dispatch,
|
||||
|
||||
indent: function(state, textAfter) {
|
||||
if ((state.curMode != phpMode && /^\s*<\//.test(textAfter)) ||
|
||||
(state.curMode == phpMode && /^\?>/.test(textAfter)))
|
||||
return htmlMode.indent(state.html, textAfter);
|
||||
return state.curMode.indent(state.curState, textAfter);
|
||||
},
|
||||
|
||||
blockCommentStart: "/*",
|
||||
blockCommentEnd: "*/",
|
||||
lineComment: "//",
|
||||
|
||||
innerMode: function(state) { return {state: state.curState, mode: state.curMode}; }
|
||||
};
|
||||
}, "htmlmixed", "clike");
|
||||
|
||||
CodeMirror.defineMIME("application/x-httpd-php", "php");
|
||||
CodeMirror.defineMIME("application/x-httpd-php-open", {name: "php", startOpen: true});
|
||||
CodeMirror.defineMIME("text/x-php", phpConfig);
|
||||
});
|
||||
@@ -0,0 +1,154 @@
|
||||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
||||
|
||||
(function() {
|
||||
var mode = CodeMirror.getMode({indentUnit: 2}, "php");
|
||||
function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1)); }
|
||||
|
||||
MT('simple_test',
|
||||
'[meta <?php] ' +
|
||||
'[keyword echo] [string "aaa"]; ' +
|
||||
'[meta ?>]');
|
||||
|
||||
MT('variable_interpolation_non_alphanumeric',
|
||||
'[meta <?php]',
|
||||
'[keyword echo] [string "aaa$~$!$@$#$$$%$^$&$*$($)$.$<$>$/$\\$}$\\\"$:$;$?$|$[[$]]$+$=aaa"]',
|
||||
'[meta ?>]');
|
||||
|
||||
MT('variable_interpolation_digits',
|
||||
'[meta <?php]',
|
||||
'[keyword echo] [string "aaa$1$2$3$4$5$6$7$8$9$0aaa"]',
|
||||
'[meta ?>]');
|
||||
|
||||
MT('variable_interpolation_simple_syntax_1',
|
||||
'[meta <?php]',
|
||||
'[keyword echo] [string "aaa][variable-2 $aaa][string .aaa"];',
|
||||
'[meta ?>]');
|
||||
|
||||
MT('variable_interpolation_simple_syntax_2',
|
||||
'[meta <?php]',
|
||||
'[keyword echo] [string "][variable-2 $aaaa][[','[number 2]', ']][string aa"];',
|
||||
'[keyword echo] [string "][variable-2 $aaaa][[','[number 2345]', ']][string aa"];',
|
||||
'[keyword echo] [string "][variable-2 $aaaa][[','[number 2.3]', ']][string aa"];',
|
||||
'[keyword echo] [string "][variable-2 $aaaa][[','[variable aaaaa]', ']][string aa"];',
|
||||
'[keyword echo] [string "][variable-2 $aaaa][[','[variable-2 $aaaaa]',']][string aa"];',
|
||||
|
||||
'[keyword echo] [string "1aaa][variable-2 $aaaa][[','[number 2]', ']][string aa"];',
|
||||
'[keyword echo] [string "aaa][variable-2 $aaaa][[','[number 2345]', ']][string aa"];',
|
||||
'[keyword echo] [string "aaa][variable-2 $aaaa][[','[number 2.3]', ']][string aa"];',
|
||||
'[keyword echo] [string "aaa][variable-2 $aaaa][[','[variable aaaaa]', ']][string aa"];',
|
||||
'[keyword echo] [string "aaa][variable-2 $aaaa][[','[variable-2 $aaaaa]',']][string aa"];',
|
||||
'[meta ?>]');
|
||||
|
||||
MT('variable_interpolation_simple_syntax_3',
|
||||
'[meta <?php]',
|
||||
'[keyword echo] [string "aaa][variable-2 $aaaa]->[variable aaaaa][string .aaaaaa"];',
|
||||
'[keyword echo] [string "aaa][variable-2 $aaaa][string ->][variable-2 $aaaaa][string .aaaaaa"];',
|
||||
'[keyword echo] [string "aaa][variable-2 $aaaa]->[variable aaaaa][string [[2]].aaaaaa"];',
|
||||
'[keyword echo] [string "aaa][variable-2 $aaaa]->[variable aaaaa][string ->aaaa2.aaaaaa"];',
|
||||
'[meta ?>]');
|
||||
|
||||
MT('variable_interpolation_escaping',
|
||||
'[meta <?php] [comment /* Escaping */]',
|
||||
'[keyword echo] [string "aaa\\$aaaa->aaa.aaa"];',
|
||||
'[keyword echo] [string "aaa\\$aaaa[[2]]aaa.aaa"];',
|
||||
'[keyword echo] [string "aaa\\$aaaa[[asd]]aaa.aaa"];',
|
||||
'[keyword echo] [string "aaa{\\$aaaa->aaa.aaa"];',
|
||||
'[keyword echo] [string "aaa{\\$aaaa[[2]]aaa.aaa"];',
|
||||
'[keyword echo] [string "aaa{\\aaaaa[[asd]]aaa.aaa"];',
|
||||
'[keyword echo] [string "aaa\\${aaaa->aaa.aaa"];',
|
||||
'[keyword echo] [string "aaa\\${aaaa[[2]]aaa.aaa"];',
|
||||
'[keyword echo] [string "aaa\\${aaaa[[asd]]aaa.aaa"];',
|
||||
'[meta ?>]');
|
||||
|
||||
MT('variable_interpolation_complex_syntax_1',
|
||||
'[meta <?php]',
|
||||
'[keyword echo] [string "aaa][variable-2 $]{[variable aaaa]}[string ->aaa.aaa"];',
|
||||
'[keyword echo] [string "aaa][variable-2 $]{[variable-2 $aaaa]}[string ->aaa.aaa"];',
|
||||
'[keyword echo] [string "aaa][variable-2 $]{[variable-2 $aaaa][[',' [number 42]',']]}[string ->aaa.aaa"];',
|
||||
'[keyword echo] [string "aaa][variable-2 $]{[variable aaaa][meta ?>]aaaaaa');
|
||||
|
||||
MT('variable_interpolation_complex_syntax_2',
|
||||
'[meta <?php] [comment /* Monsters */]',
|
||||
'[keyword echo] [string "][variable-2 $]{[variable aaa][comment /*}?>} $aaa<?php } */]}[string ->aaa.aaa"];',
|
||||
'[keyword echo] [string "][variable-2 $]{[variable aaa][comment /*}?>*/][[',' [string "aaa][variable-2 $aaa][string {}][variable-2 $]{[variable aaa]}[string "]',']]}[string ->aaa.aaa"];',
|
||||
'[keyword echo] [string "][variable-2 $]{[variable aaa][comment /*} } $aaa } */]}[string ->aaa.aaa"];');
|
||||
|
||||
|
||||
function build_recursive_monsters(nt, t, n){
|
||||
var monsters = [t];
|
||||
for (var i = 1; i <= n; ++i)
|
||||
monsters[i] = nt.join(monsters[i - 1]);
|
||||
return monsters;
|
||||
}
|
||||
|
||||
var m1 = build_recursive_monsters(
|
||||
['[string "][variable-2 $]{[variable aaa] [operator +] ', '}[string "]'],
|
||||
'[comment /* }?>} */] [string "aaa][variable-2 $aaa][string .aaa"]',
|
||||
10
|
||||
);
|
||||
|
||||
MT('variable_interpolation_complex_syntax_3_1',
|
||||
'[meta <?php] [comment /* Recursive monsters */]',
|
||||
'[keyword echo] ' + m1[4] + ';',
|
||||
'[keyword echo] ' + m1[7] + ';',
|
||||
'[keyword echo] ' + m1[8] + ';',
|
||||
'[keyword echo] ' + m1[5] + ';',
|
||||
'[keyword echo] ' + m1[1] + ';',
|
||||
'[keyword echo] ' + m1[6] + ';',
|
||||
'[keyword echo] ' + m1[9] + ';',
|
||||
'[keyword echo] ' + m1[0] + ';',
|
||||
'[keyword echo] ' + m1[10] + ';',
|
||||
'[keyword echo] ' + m1[2] + ';',
|
||||
'[keyword echo] ' + m1[3] + ';',
|
||||
'[keyword echo] [string "end"];',
|
||||
'[meta ?>]');
|
||||
|
||||
var m2 = build_recursive_monsters(
|
||||
['[string "a][variable-2 $]{[variable aaa] [operator +] ', ' [operator +] ', '}[string .a"]'],
|
||||
'[comment /* }?>{{ */] [string "a?>}{{aa][variable-2 $aaa][string .a}a?>a"]',
|
||||
5
|
||||
);
|
||||
|
||||
MT('variable_interpolation_complex_syntax_3_2',
|
||||
'[meta <?php] [comment /* Recursive monsters 2 */]',
|
||||
'[keyword echo] ' + m2[0] + ';',
|
||||
'[keyword echo] ' + m2[1] + ';',
|
||||
'[keyword echo] ' + m2[5] + ';',
|
||||
'[keyword echo] ' + m2[4] + ';',
|
||||
'[keyword echo] ' + m2[2] + ';',
|
||||
'[keyword echo] ' + m2[3] + ';',
|
||||
'[keyword echo] [string "end"];',
|
||||
'[meta ?>]');
|
||||
|
||||
function build_recursive_monsters_2(mf1, mf2, nt, t, n){
|
||||
var monsters = [t];
|
||||
for (var i = 1; i <= n; ++i)
|
||||
monsters[i] = nt[0] + mf1[i - 1] + nt[1] + mf2[i - 1] + nt[2] + monsters[i - 1] + nt[3];
|
||||
return monsters;
|
||||
}
|
||||
|
||||
var m3 = build_recursive_monsters_2(
|
||||
m1,
|
||||
m2,
|
||||
['[string "a][variable-2 $]{[variable aaa] [operator +] ', ' [operator +] ', ' [operator +] ', '}[string .a"]'],
|
||||
'[comment /* }?>{{ */] [string "a?>}{{aa][variable-2 $aaa][string .a}a?>a"]',
|
||||
4
|
||||
);
|
||||
|
||||
MT('variable_interpolation_complex_syntax_3_3',
|
||||
'[meta <?php] [comment /* Recursive monsters 2 */]',
|
||||
'[keyword echo] ' + m3[4] + ';',
|
||||
'[keyword echo] ' + m3[0] + ';',
|
||||
'[keyword echo] ' + m3[3] + ';',
|
||||
'[keyword echo] ' + m3[1] + ';',
|
||||
'[keyword echo] ' + m3[2] + ';',
|
||||
'[keyword echo] [string "end"];',
|
||||
'[meta ?>]');
|
||||
|
||||
MT("variable_interpolation_heredoc",
|
||||
"[meta <?php]",
|
||||
"[string <<<here]",
|
||||
"[string doc ][variable-2 $]{[variable yay]}[string more]",
|
||||
"[string here]; [comment // normal]");
|
||||
})();
|
||||
Reference in new issue
Block a user