php.js 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499
  1. "use strict";
  2. /*!-----------------------------------------------------------------------------
  3. * Copyright (c) Microsoft Corporation. All rights reserved.
  4. * Version: 0.37.1(20a8d5a651d057aaed7875ad1c1f2ecf13c4e773)
  5. * Released under the MIT license
  6. * https://github.com/microsoft/monaco-editor/blob/main/LICENSE.txt
  7. *-----------------------------------------------------------------------------*/
  8. define("vs/basic-languages/php/php", ["require"],(require)=>{
  9. var moduleExports = (() => {
  10. var __defProp = Object.defineProperty;
  11. var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
  12. var __getOwnPropNames = Object.getOwnPropertyNames;
  13. var __hasOwnProp = Object.prototype.hasOwnProperty;
  14. var __export = (target, all) => {
  15. for (var name in all)
  16. __defProp(target, name, { get: all[name], enumerable: true });
  17. };
  18. var __copyProps = (to, from, except, desc) => {
  19. if (from && typeof from === "object" || typeof from === "function") {
  20. for (let key of __getOwnPropNames(from))
  21. if (!__hasOwnProp.call(to, key) && key !== except)
  22. __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  23. }
  24. return to;
  25. };
  26. var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
  27. // src/basic-languages/php/php.ts
  28. var php_exports = {};
  29. __export(php_exports, {
  30. conf: () => conf,
  31. language: () => language
  32. });
  33. var conf = {
  34. wordPattern: /(-?\d*\.\d\w*)|([^\`\~\!\@\#\%\^\&\*\(\)\-\=\+\[\{\]\}\\\|\;\:\'\"\,\.\<\>\/\?\s]+)/g,
  35. comments: {
  36. lineComment: "//",
  37. blockComment: ["/*", "*/"]
  38. },
  39. brackets: [
  40. ["{", "}"],
  41. ["[", "]"],
  42. ["(", ")"]
  43. ],
  44. autoClosingPairs: [
  45. { open: "{", close: "}", notIn: ["string"] },
  46. { open: "[", close: "]", notIn: ["string"] },
  47. { open: "(", close: ")", notIn: ["string"] },
  48. { open: '"', close: '"', notIn: ["string"] },
  49. { open: "'", close: "'", notIn: ["string", "comment"] }
  50. ],
  51. folding: {
  52. markers: {
  53. start: new RegExp("^\\s*(#|//)region\\b"),
  54. end: new RegExp("^\\s*(#|//)endregion\\b")
  55. }
  56. }
  57. };
  58. var language = {
  59. defaultToken: "",
  60. tokenPostfix: "",
  61. tokenizer: {
  62. root: [
  63. [/<\?((php)|=)?/, { token: "@rematch", switchTo: "@phpInSimpleState.root" }],
  64. [/<!DOCTYPE/, "metatag.html", "@doctype"],
  65. [/<!--/, "comment.html", "@comment"],
  66. [/(<)(\w+)(\/>)/, ["delimiter.html", "tag.html", "delimiter.html"]],
  67. [/(<)(script)/, ["delimiter.html", { token: "tag.html", next: "@script" }]],
  68. [/(<)(style)/, ["delimiter.html", { token: "tag.html", next: "@style" }]],
  69. [/(<)([:\w]+)/, ["delimiter.html", { token: "tag.html", next: "@otherTag" }]],
  70. [/(<\/)(\w+)/, ["delimiter.html", { token: "tag.html", next: "@otherTag" }]],
  71. [/</, "delimiter.html"],
  72. [/[^<]+/]
  73. ],
  74. doctype: [
  75. [/<\?((php)|=)?/, { token: "@rematch", switchTo: "@phpInSimpleState.comment" }],
  76. [/[^>]+/, "metatag.content.html"],
  77. [/>/, "metatag.html", "@pop"]
  78. ],
  79. comment: [
  80. [/<\?((php)|=)?/, { token: "@rematch", switchTo: "@phpInSimpleState.comment" }],
  81. [/-->/, "comment.html", "@pop"],
  82. [/[^-]+/, "comment.content.html"],
  83. [/./, "comment.content.html"]
  84. ],
  85. otherTag: [
  86. [/<\?((php)|=)?/, { token: "@rematch", switchTo: "@phpInSimpleState.otherTag" }],
  87. [/\/?>/, "delimiter.html", "@pop"],
  88. [/"([^"]*)"/, "attribute.value"],
  89. [/'([^']*)'/, "attribute.value"],
  90. [/[\w\-]+/, "attribute.name"],
  91. [/=/, "delimiter"],
  92. [/[ \t\r\n]+/]
  93. ],
  94. script: [
  95. [/<\?((php)|=)?/, { token: "@rematch", switchTo: "@phpInSimpleState.script" }],
  96. [/type/, "attribute.name", "@scriptAfterType"],
  97. [/"([^"]*)"/, "attribute.value"],
  98. [/'([^']*)'/, "attribute.value"],
  99. [/[\w\-]+/, "attribute.name"],
  100. [/=/, "delimiter"],
  101. [
  102. />/,
  103. {
  104. token: "delimiter.html",
  105. next: "@scriptEmbedded.text/javascript",
  106. nextEmbedded: "text/javascript"
  107. }
  108. ],
  109. [/[ \t\r\n]+/],
  110. [
  111. /(<\/)(script\s*)(>)/,
  112. ["delimiter.html", "tag.html", { token: "delimiter.html", next: "@pop" }]
  113. ]
  114. ],
  115. scriptAfterType: [
  116. [
  117. /<\?((php)|=)?/,
  118. {
  119. token: "@rematch",
  120. switchTo: "@phpInSimpleState.scriptAfterType"
  121. }
  122. ],
  123. [/=/, "delimiter", "@scriptAfterTypeEquals"],
  124. [
  125. />/,
  126. {
  127. token: "delimiter.html",
  128. next: "@scriptEmbedded.text/javascript",
  129. nextEmbedded: "text/javascript"
  130. }
  131. ],
  132. [/[ \t\r\n]+/],
  133. [/<\/script\s*>/, { token: "@rematch", next: "@pop" }]
  134. ],
  135. scriptAfterTypeEquals: [
  136. [
  137. /<\?((php)|=)?/,
  138. {
  139. token: "@rematch",
  140. switchTo: "@phpInSimpleState.scriptAfterTypeEquals"
  141. }
  142. ],
  143. [
  144. /"([^"]*)"/,
  145. {
  146. token: "attribute.value",
  147. switchTo: "@scriptWithCustomType.$1"
  148. }
  149. ],
  150. [
  151. /'([^']*)'/,
  152. {
  153. token: "attribute.value",
  154. switchTo: "@scriptWithCustomType.$1"
  155. }
  156. ],
  157. [
  158. />/,
  159. {
  160. token: "delimiter.html",
  161. next: "@scriptEmbedded.text/javascript",
  162. nextEmbedded: "text/javascript"
  163. }
  164. ],
  165. [/[ \t\r\n]+/],
  166. [/<\/script\s*>/, { token: "@rematch", next: "@pop" }]
  167. ],
  168. scriptWithCustomType: [
  169. [
  170. /<\?((php)|=)?/,
  171. {
  172. token: "@rematch",
  173. switchTo: "@phpInSimpleState.scriptWithCustomType.$S2"
  174. }
  175. ],
  176. [
  177. />/,
  178. {
  179. token: "delimiter.html",
  180. next: "@scriptEmbedded.$S2",
  181. nextEmbedded: "$S2"
  182. }
  183. ],
  184. [/"([^"]*)"/, "attribute.value"],
  185. [/'([^']*)'/, "attribute.value"],
  186. [/[\w\-]+/, "attribute.name"],
  187. [/=/, "delimiter"],
  188. [/[ \t\r\n]+/],
  189. [/<\/script\s*>/, { token: "@rematch", next: "@pop" }]
  190. ],
  191. scriptEmbedded: [
  192. [
  193. /<\?((php)|=)?/,
  194. {
  195. token: "@rematch",
  196. switchTo: "@phpInEmbeddedState.scriptEmbedded.$S2",
  197. nextEmbedded: "@pop"
  198. }
  199. ],
  200. [/<\/script/, { token: "@rematch", next: "@pop", nextEmbedded: "@pop" }]
  201. ],
  202. style: [
  203. [/<\?((php)|=)?/, { token: "@rematch", switchTo: "@phpInSimpleState.style" }],
  204. [/type/, "attribute.name", "@styleAfterType"],
  205. [/"([^"]*)"/, "attribute.value"],
  206. [/'([^']*)'/, "attribute.value"],
  207. [/[\w\-]+/, "attribute.name"],
  208. [/=/, "delimiter"],
  209. [
  210. />/,
  211. {
  212. token: "delimiter.html",
  213. next: "@styleEmbedded.text/css",
  214. nextEmbedded: "text/css"
  215. }
  216. ],
  217. [/[ \t\r\n]+/],
  218. [
  219. /(<\/)(style\s*)(>)/,
  220. ["delimiter.html", "tag.html", { token: "delimiter.html", next: "@pop" }]
  221. ]
  222. ],
  223. styleAfterType: [
  224. [
  225. /<\?((php)|=)?/,
  226. {
  227. token: "@rematch",
  228. switchTo: "@phpInSimpleState.styleAfterType"
  229. }
  230. ],
  231. [/=/, "delimiter", "@styleAfterTypeEquals"],
  232. [
  233. />/,
  234. {
  235. token: "delimiter.html",
  236. next: "@styleEmbedded.text/css",
  237. nextEmbedded: "text/css"
  238. }
  239. ],
  240. [/[ \t\r\n]+/],
  241. [/<\/style\s*>/, { token: "@rematch", next: "@pop" }]
  242. ],
  243. styleAfterTypeEquals: [
  244. [
  245. /<\?((php)|=)?/,
  246. {
  247. token: "@rematch",
  248. switchTo: "@phpInSimpleState.styleAfterTypeEquals"
  249. }
  250. ],
  251. [
  252. /"([^"]*)"/,
  253. {
  254. token: "attribute.value",
  255. switchTo: "@styleWithCustomType.$1"
  256. }
  257. ],
  258. [
  259. /'([^']*)'/,
  260. {
  261. token: "attribute.value",
  262. switchTo: "@styleWithCustomType.$1"
  263. }
  264. ],
  265. [
  266. />/,
  267. {
  268. token: "delimiter.html",
  269. next: "@styleEmbedded.text/css",
  270. nextEmbedded: "text/css"
  271. }
  272. ],
  273. [/[ \t\r\n]+/],
  274. [/<\/style\s*>/, { token: "@rematch", next: "@pop" }]
  275. ],
  276. styleWithCustomType: [
  277. [
  278. /<\?((php)|=)?/,
  279. {
  280. token: "@rematch",
  281. switchTo: "@phpInSimpleState.styleWithCustomType.$S2"
  282. }
  283. ],
  284. [
  285. />/,
  286. {
  287. token: "delimiter.html",
  288. next: "@styleEmbedded.$S2",
  289. nextEmbedded: "$S2"
  290. }
  291. ],
  292. [/"([^"]*)"/, "attribute.value"],
  293. [/'([^']*)'/, "attribute.value"],
  294. [/[\w\-]+/, "attribute.name"],
  295. [/=/, "delimiter"],
  296. [/[ \t\r\n]+/],
  297. [/<\/style\s*>/, { token: "@rematch", next: "@pop" }]
  298. ],
  299. styleEmbedded: [
  300. [
  301. /<\?((php)|=)?/,
  302. {
  303. token: "@rematch",
  304. switchTo: "@phpInEmbeddedState.styleEmbedded.$S2",
  305. nextEmbedded: "@pop"
  306. }
  307. ],
  308. [/<\/style/, { token: "@rematch", next: "@pop", nextEmbedded: "@pop" }]
  309. ],
  310. phpInSimpleState: [
  311. [/<\?((php)|=)?/, "metatag.php"],
  312. [/\?>/, { token: "metatag.php", switchTo: "@$S2.$S3" }],
  313. { include: "phpRoot" }
  314. ],
  315. phpInEmbeddedState: [
  316. [/<\?((php)|=)?/, "metatag.php"],
  317. [
  318. /\?>/,
  319. {
  320. token: "metatag.php",
  321. switchTo: "@$S2.$S3",
  322. nextEmbedded: "$S3"
  323. }
  324. ],
  325. { include: "phpRoot" }
  326. ],
  327. phpRoot: [
  328. [
  329. /[a-zA-Z_]\w*/,
  330. {
  331. cases: {
  332. "@phpKeywords": { token: "keyword.php" },
  333. "@phpCompileTimeConstants": { token: "constant.php" },
  334. "@default": "identifier.php"
  335. }
  336. }
  337. ],
  338. [
  339. /[$a-zA-Z_]\w*/,
  340. {
  341. cases: {
  342. "@phpPreDefinedVariables": {
  343. token: "variable.predefined.php"
  344. },
  345. "@default": "variable.php"
  346. }
  347. }
  348. ],
  349. [/[{}]/, "delimiter.bracket.php"],
  350. [/[\[\]]/, "delimiter.array.php"],
  351. [/[()]/, "delimiter.parenthesis.php"],
  352. [/[ \t\r\n]+/],
  353. [/(#|\/\/)$/, "comment.php"],
  354. [/(#|\/\/)/, "comment.php", "@phpLineComment"],
  355. [/\/\*/, "comment.php", "@phpComment"],
  356. [/"/, "string.php", "@phpDoubleQuoteString"],
  357. [/'/, "string.php", "@phpSingleQuoteString"],
  358. [/[\+\-\*\%\&\|\^\~\!\=\<\>\/\?\;\:\.\,\@]/, "delimiter.php"],
  359. [/\d*\d+[eE]([\-+]?\d+)?/, "number.float.php"],
  360. [/\d*\.\d+([eE][\-+]?\d+)?/, "number.float.php"],
  361. [/0[xX][0-9a-fA-F']*[0-9a-fA-F]/, "number.hex.php"],
  362. [/0[0-7']*[0-7]/, "number.octal.php"],
  363. [/0[bB][0-1']*[0-1]/, "number.binary.php"],
  364. [/\d[\d']*/, "number.php"],
  365. [/\d/, "number.php"]
  366. ],
  367. phpComment: [
  368. [/\*\//, "comment.php", "@pop"],
  369. [/[^*]+/, "comment.php"],
  370. [/./, "comment.php"]
  371. ],
  372. phpLineComment: [
  373. [/\?>/, { token: "@rematch", next: "@pop" }],
  374. [/.$/, "comment.php", "@pop"],
  375. [/[^?]+$/, "comment.php", "@pop"],
  376. [/[^?]+/, "comment.php"],
  377. [/./, "comment.php"]
  378. ],
  379. phpDoubleQuoteString: [
  380. [/[^\\"]+/, "string.php"],
  381. [/@escapes/, "string.escape.php"],
  382. [/\\./, "string.escape.invalid.php"],
  383. [/"/, "string.php", "@pop"]
  384. ],
  385. phpSingleQuoteString: [
  386. [/[^\\']+/, "string.php"],
  387. [/@escapes/, "string.escape.php"],
  388. [/\\./, "string.escape.invalid.php"],
  389. [/'/, "string.php", "@pop"]
  390. ]
  391. },
  392. phpKeywords: [
  393. "abstract",
  394. "and",
  395. "array",
  396. "as",
  397. "break",
  398. "callable",
  399. "case",
  400. "catch",
  401. "cfunction",
  402. "class",
  403. "clone",
  404. "const",
  405. "continue",
  406. "declare",
  407. "default",
  408. "do",
  409. "else",
  410. "elseif",
  411. "enddeclare",
  412. "endfor",
  413. "endforeach",
  414. "endif",
  415. "endswitch",
  416. "endwhile",
  417. "extends",
  418. "false",
  419. "final",
  420. "for",
  421. "foreach",
  422. "function",
  423. "global",
  424. "goto",
  425. "if",
  426. "implements",
  427. "interface",
  428. "instanceof",
  429. "insteadof",
  430. "namespace",
  431. "new",
  432. "null",
  433. "object",
  434. "old_function",
  435. "or",
  436. "private",
  437. "protected",
  438. "public",
  439. "resource",
  440. "static",
  441. "switch",
  442. "throw",
  443. "trait",
  444. "try",
  445. "true",
  446. "use",
  447. "var",
  448. "while",
  449. "xor",
  450. "die",
  451. "echo",
  452. "empty",
  453. "exit",
  454. "eval",
  455. "include",
  456. "include_once",
  457. "isset",
  458. "list",
  459. "require",
  460. "require_once",
  461. "return",
  462. "print",
  463. "unset",
  464. "yield",
  465. "__construct"
  466. ],
  467. phpCompileTimeConstants: [
  468. "__CLASS__",
  469. "__DIR__",
  470. "__FILE__",
  471. "__LINE__",
  472. "__NAMESPACE__",
  473. "__METHOD__",
  474. "__FUNCTION__",
  475. "__TRAIT__"
  476. ],
  477. phpPreDefinedVariables: [
  478. "$GLOBALS",
  479. "$_SERVER",
  480. "$_GET",
  481. "$_POST",
  482. "$_FILES",
  483. "$_REQUEST",
  484. "$_SESSION",
  485. "$_ENV",
  486. "$_COOKIE",
  487. "$php_errormsg",
  488. "$HTTP_RAW_POST_DATA",
  489. "$http_response_header",
  490. "$argc",
  491. "$argv"
  492. ],
  493. escapes: /\\(?:[abfnrtv\\"']|x[0-9A-Fa-f]{1,4}|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8})/
  494. };
  495. return __toCommonJS(php_exports);
  496. })();
  497. return moduleExports;
  498. });