-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
More variables for better code compression (#1489)
This introduces more variables for better code compression in a few languages.
- Loading branch information
1 parent
70a4041
commit bc53e09
Showing
10 changed files
with
201 additions
and
220 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,67 +1,73 @@ | ||
Prism.languages.parser = Prism.languages.extend('markup', { | ||
'keyword': { | ||
pattern: /(^|[^^])(?:\^(?:case|eval|for|if|switch|throw)\b|@(?:BASE|CLASS|GET(?:_DEFAULT)?|OPTIONS|SET_DEFAULT|USE)\b)/, | ||
lookbehind: true | ||
}, | ||
'variable': { | ||
pattern: /(^|[^^])\B\$(?:\w+|(?=[.{]))(?:(?:\.|::?)\w+)*(?:\.|::?)?/, | ||
lookbehind: true, | ||
inside: { | ||
'punctuation': /\.|:+/ | ||
(function (Prism) { | ||
|
||
var parser = Prism.languages.parser = Prism.languages.extend('markup', { | ||
'keyword': { | ||
pattern: /(^|[^^])(?:\^(?:case|eval|for|if|switch|throw)\b|@(?:BASE|CLASS|GET(?:_DEFAULT)?|OPTIONS|SET_DEFAULT|USE)\b)/, | ||
lookbehind: true | ||
}, | ||
'variable': { | ||
pattern: /(^|[^^])\B\$(?:\w+|(?=[.{]))(?:(?:\.|::?)\w+)*(?:\.|::?)?/, | ||
lookbehind: true, | ||
inside: { | ||
'punctuation': /\.|:+/ | ||
} | ||
}, | ||
'function': { | ||
pattern: /(^|[^^])\B[@^]\w+(?:(?:\.|::?)\w+)*(?:\.|::?)?/, | ||
lookbehind: true, | ||
inside: { | ||
'keyword': { | ||
pattern: /(^@)(?:GET_|SET_)/, | ||
lookbehind: true | ||
}, | ||
'punctuation': /\.|:+/ | ||
} | ||
}, | ||
'escape': { | ||
pattern: /\^(?:[$^;@()\[\]{}"':]|#[a-f\d]*)/i, | ||
alias: 'builtin' | ||
}, | ||
'punctuation': /[\[\](){};]/ | ||
}); | ||
|
||
parser = Prism.languages.insertBefore('parser', 'keyword', { | ||
'parser-comment': { | ||
pattern: /(\s)#.*/, | ||
lookbehind: true, | ||
alias: 'comment' | ||
}, | ||
'expression': { | ||
// Allow for 3 levels of depth | ||
pattern: /(^|[^^])\((?:[^()]|\((?:[^()]|\((?:[^()])*\))*\))*\)/, | ||
greedy: true, | ||
lookbehind: true, | ||
inside: { | ||
'string': { | ||
pattern: /(^|[^^])(["'])(?:(?!\2)[^^]|\^[\s\S])*\2/, | ||
lookbehind: true | ||
}, | ||
'keyword': parser.keyword, | ||
'variable': parser.variable, | ||
'function': parser.function, | ||
'boolean': /\b(?:true|false)\b/, | ||
'number': /\b(?:0x[a-f\d]+|\d+\.?\d*(?:e[+-]?\d+)?)\b/i, | ||
'escape': parser.escape, | ||
'operator': /[~+*\/\\%]|!(?:\|\|?|=)?|&&?|\|\|?|==|<[<=]?|>[>=]?|-[fd]?|\b(?:def|eq|ge|gt|in|is|le|lt|ne)\b/, | ||
'punctuation': parser.punctuation | ||
} | ||
} | ||
}, | ||
'function': { | ||
pattern: /(^|[^^])\B[@^]\w+(?:(?:\.|::?)\w+)*(?:\.|::?)?/, | ||
lookbehind: true, | ||
inside: { | ||
'keyword': { | ||
pattern: /(^@)(?:GET_|SET_)/, | ||
lookbehind: true | ||
}, | ||
'punctuation': /\.|:+/ | ||
}); | ||
|
||
parser = Prism.languages.insertBefore('inside', 'punctuation', { | ||
'expression': parser.expression, | ||
'keyword': parser.keyword, | ||
'variable': parser.variable, | ||
'function': parser.function, | ||
'escape': parser.escape, | ||
'parser-punctuation': { | ||
pattern: parser.punctuation, | ||
alias: 'punctuation' | ||
} | ||
}, | ||
'escape': { | ||
pattern: /\^(?:[$^;@()\[\]{}"':]|#[a-f\d]*)/i, | ||
alias: 'builtin' | ||
}, | ||
'punctuation': /[\[\](){};]/ | ||
}); | ||
Prism.languages.insertBefore('parser', 'keyword', { | ||
'parser-comment': { | ||
pattern: /(\s)#.*/, | ||
lookbehind: true, | ||
alias: 'comment' | ||
}, | ||
'expression': { | ||
// Allow for 3 levels of depth | ||
pattern: /(^|[^^])\((?:[^()]|\((?:[^()]|\((?:[^()])*\))*\))*\)/, | ||
greedy: true, | ||
lookbehind: true, | ||
inside: { | ||
'string': { | ||
pattern: /(^|[^^])(["'])(?:(?!\2)[^^]|\^[\s\S])*\2/, | ||
lookbehind: true | ||
}, | ||
'keyword': Prism.languages.parser.keyword, | ||
'variable': Prism.languages.parser.variable, | ||
'function': Prism.languages.parser.function, | ||
'boolean': /\b(?:true|false)\b/, | ||
'number': /\b(?:0x[a-f\d]+|\d+\.?\d*(?:e[+-]?\d+)?)\b/i, | ||
'escape': Prism.languages.parser.escape, | ||
'operator': /[~+*\/\\%]|!(?:\|\|?|=)?|&&?|\|\|?|==|<[<=]?|>[>=]?|-[fd]?|\b(?:def|eq|ge|gt|in|is|le|lt|ne)\b/, | ||
'punctuation': Prism.languages.parser.punctuation | ||
} | ||
} | ||
}); | ||
Prism.languages.insertBefore('inside', 'punctuation', { | ||
'expression': Prism.languages.parser.expression, | ||
'keyword': Prism.languages.parser.keyword, | ||
'variable': Prism.languages.parser.variable, | ||
'function': Prism.languages.parser.function, | ||
'escape': Prism.languages.parser.escape, | ||
'parser-punctuation': { | ||
pattern: Prism.languages.parser.punctuation, | ||
alias: 'punctuation' | ||
} | ||
}, Prism.languages.parser['tag'].inside['attr-value']); | ||
}, parser['tag'].inside['attr-value']); | ||
|
||
}(Prism)); |
Oops, something went wrong.