php.js 13 KB

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