source: node_modules/refractor/lang/parser.js

main
Last change on this file was d24f17c, checked in by Aleksandar Panovski <apano77@…>, 15 months ago

Initial commit

  • Property mode set to 100644
File size: 2.4 KB
Line 
1'use strict'
2
3module.exports = parser
4parser.displayName = 'parser'
5parser.aliases = []
6function parser(Prism) {
7 ;(function (Prism) {
8 var parser = (Prism.languages.parser = Prism.languages.extend('markup', {
9 keyword: {
10 pattern:
11 /(^|[^^])(?:\^(?:case|eval|for|if|switch|throw)\b|@(?:BASE|CLASS|GET(?:_DEFAULT)?|OPTIONS|SET_DEFAULT|USE)\b)/,
12 lookbehind: true
13 },
14 variable: {
15 pattern: /(^|[^^])\B\$(?:\w+|(?=[.{]))(?:(?:\.|::?)\w+)*(?:\.|::?)?/,
16 lookbehind: true,
17 inside: {
18 punctuation: /\.|:+/
19 }
20 },
21 function: {
22 pattern: /(^|[^^])\B[@^]\w+(?:(?:\.|::?)\w+)*(?:\.|::?)?/,
23 lookbehind: true,
24 inside: {
25 keyword: {
26 pattern: /(^@)(?:GET_|SET_)/,
27 lookbehind: true
28 },
29 punctuation: /\.|:+/
30 }
31 },
32 escape: {
33 pattern: /\^(?:[$^;@()\[\]{}"':]|#[a-f\d]*)/i,
34 alias: 'builtin'
35 },
36 punctuation: /[\[\](){};]/
37 }))
38 parser = Prism.languages.insertBefore('parser', 'keyword', {
39 'parser-comment': {
40 pattern: /(\s)#.*/,
41 lookbehind: true,
42 alias: 'comment'
43 },
44 expression: {
45 // Allow for 3 levels of depth
46 pattern: /(^|[^^])\((?:[^()]|\((?:[^()]|\((?:[^()])*\))*\))*\)/,
47 greedy: true,
48 lookbehind: true,
49 inside: {
50 string: {
51 pattern: /(^|[^^])(["'])(?:(?!\2)[^^]|\^[\s\S])*\2/,
52 lookbehind: true
53 },
54 keyword: parser.keyword,
55 variable: parser.variable,
56 function: parser.function,
57 boolean: /\b(?:false|true)\b/,
58 number: /\b(?:0x[a-f\d]+|\d+(?:\.\d*)?(?:e[+-]?\d+)?)\b/i,
59 escape: parser.escape,
60 operator:
61 /[~+*\/\\%]|!(?:\|\|?|=)?|&&?|\|\|?|==|<[<=]?|>[>=]?|-[fd]?|\b(?:def|eq|ge|gt|in|is|le|lt|ne)\b/,
62 punctuation: parser.punctuation
63 }
64 }
65 })
66 Prism.languages.insertBefore(
67 'inside',
68 'punctuation',
69 {
70 expression: parser.expression,
71 keyword: parser.keyword,
72 variable: parser.variable,
73 function: parser.function,
74 escape: parser.escape,
75 'parser-punctuation': {
76 pattern: parser.punctuation,
77 alias: 'punctuation'
78 }
79 },
80 parser['tag'].inside['attr-value']
81 )
82 })(Prism)
83}
Note: See TracBrowser for help on using the repository browser.