summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Hatch <tim@timhatch.com>2014-04-14 14:25:43 -0400
committerTim Hatch <tim@timhatch.com>2014-04-14 14:25:43 -0400
commit2d1261cf7266c521f2fb1874f80a6d4120219acf (patch)
tree6b68d33c837c9af13f5f78a46ba2edd929fa4a0d
parenta9811c3e3434b80cc05cdafe7fcbfaaaa134a20e (diff)
parent7bf4f5b3af57ff5134ee68453add8f5c6359375a (diff)
downloadpygments-2d1261cf7266c521f2fb1874f80a6d4120219acf.tar.gz
Merged in kwadrat/pygments-main2 (pull request #316)
Conflicts: pygments/lexers/jvm.py pygments/lexers/other.py
-rw-r--r--doc/languages.rst1
-rw-r--r--pygments/formatters/rtf.py11
-rw-r--r--pygments/lexers/_mapping.py3
-rw-r--r--pygments/lexers/agile.py422
-rw-r--r--pygments/lexers/compiled.py17
-rw-r--r--pygments/lexers/jvm.py116
-rw-r--r--pygments/lexers/other.py90
-rw-r--r--pygments/lexers/web.py65
-rw-r--r--tests/examplefiles/hello.lsl12
-rw-r--r--tests/examplefiles/test.zep33
10 files changed, 570 insertions, 200 deletions
diff --git a/doc/languages.rst b/doc/languages.rst
index 2e79a35e..426a576b 100644
--- a/doc/languages.rst
+++ b/doc/languages.rst
@@ -82,6 +82,7 @@ Programming languages
* Visual Basic.NET
* Visual FoxPro
* XQuery
+* Zephir
</ul>
Template languages
diff --git a/pygments/formatters/rtf.py b/pygments/formatters/rtf.py
index 59d97742..9d87e8f1 100644
--- a/pygments/formatters/rtf.py
+++ b/pygments/formatters/rtf.py
@@ -10,6 +10,7 @@
"""
from pygments.formatter import Formatter
+from pygments.util import get_int_opt
__all__ = ['RtfFormatter']
@@ -32,6 +33,12 @@ class RtfFormatter(Formatter):
`fontface`
The used font famliy, for example ``Bitstream Vera Sans``. Defaults to
some generic font which is supposed to have fixed width.
+
+ `fontsize`
+ Size of the font used. Size is specified in half points. The
+ default is 24 half-points, giving a size 12 font.
+
+ .. versionadded:: 2.0
"""
name = 'RTF'
aliases = ['rtf']
@@ -49,9 +56,11 @@ class RtfFormatter(Formatter):
specification claims that ``\fmodern`` are "Fixed-pitch serif
and sans serif fonts". Hope every RTF implementation thinks
the same about modern...
+
"""
Formatter.__init__(self, **options)
self.fontface = options.get('fontface') or ''
+ self.fontsize = get_int_opt(options, 'fontsize', 0)
def _escape(self, text):
return text.replace('\\', '\\\\') \
@@ -106,6 +115,8 @@ class RtfFormatter(Formatter):
))
offset += 1
outfile.write(r'}\f0')
+ if self.fontsize:
+ outfile.write(r'\fs%d' % (self.fontsize))
# highlight stream
for ttype, value in tokensource:
diff --git a/pygments/lexers/_mapping.py b/pygments/lexers/_mapping.py
index eaaed7dc..7c753caa 100644
--- a/pygments/lexers/_mapping.py
+++ b/pygments/lexers/_mapping.py
@@ -129,6 +129,7 @@ LEXERS = {
'GherkinLexer': ('pygments.lexers.other', 'Gherkin', ('cucumber', 'gherkin'), ('*.feature',), ('text/x-gherkin',)),
'GnuplotLexer': ('pygments.lexers.other', 'Gnuplot', ('gnuplot',), ('*.plot', '*.plt'), ('text/x-gnuplot',)),
'GoLexer': ('pygments.lexers.compiled', 'Go', ('go',), ('*.go',), ('text/x-gosrc',)),
+ 'GoloLexer': ('pygments.lexers.jvm', 'Golo', ('golo',), ('*.golo',), ()),
'GoodDataCLLexer': ('pygments.lexers.other', 'GoodData-CL', ('gooddata-cl',), ('*.gdc',), ('text/x-gooddata-cl',)),
'GosuLexer': ('pygments.lexers.jvm', 'Gosu', ('gosu',), ('*.gs', '*.gsx', '*.gsp', '*.vark'), ('text/x-gosu',)),
'GosuTemplateLexer': ('pygments.lexers.jvm', 'Gosu Template', ('gst',), ('*.gst',), ('text/x-gosu-template',)),
@@ -173,6 +174,7 @@ LEXERS = {
'KconfigLexer': ('pygments.lexers.other', 'Kconfig', ('kconfig', 'menuconfig', 'linux-config', 'kernel-config'), ('Kconfig', '*Config.in*', 'external.in*', 'standard-modules.in'), ('text/x-kconfig',)),
'KokaLexer': ('pygments.lexers.functional', 'Koka', ('koka',), ('*.kk', '*.kki'), ('text/x-koka',)),
'KotlinLexer': ('pygments.lexers.jvm', 'Kotlin', ('kotlin',), ('*.kt',), ('text/x-kotlin',)),
+ 'LSLLexer': ('pygments.lexers.other', 'LSL', ('lsl',), ('*.lsl',), ('text/x-lsl',)),
'LassoCssLexer': ('pygments.lexers.templates', 'CSS+Lasso', ('css+lasso',), (), ('text/css+lasso',)),
'LassoHtmlLexer': ('pygments.lexers.templates', 'HTML+Lasso', ('html+lasso',), (), ('text/html+lasso', 'application/x-httpd-lasso', 'application/x-httpd-lasso[89]')),
'LassoJavascriptLexer': ('pygments.lexers.templates', 'JavaScript+Lasso', ('js+lasso', 'javascript+lasso'), (), ('application/x-javascript+lasso', 'text/x-javascript+lasso', 'text/javascript+lasso')),
@@ -330,6 +332,7 @@ LEXERS = {
'XsltLexer': ('pygments.lexers.web', 'XSLT', ('xslt',), ('*.xsl', '*.xslt', '*.xpl'), ('application/xsl+xml', 'application/xslt+xml')),
'XtendLexer': ('pygments.lexers.jvm', 'Xtend', ('xtend',), ('*.xtend',), ('text/x-xtend',)),
'YamlLexer': ('pygments.lexers.text', 'YAML', ('yaml',), ('*.yaml', '*.yml'), ('text/x-yaml',)),
+ 'ZephirLexer': ('pygments.lexers.web', 'Zephir', ('zephir',), ('*.zep',), ()),
}
if __name__ == '__main__':
diff --git a/pygments/lexers/agile.py b/pygments/lexers/agile.py
index a49289dc..0a780a3e 100644
--- a/pygments/lexers/agile.py
+++ b/pygments/lexers/agile.py
@@ -1477,232 +1477,272 @@ class FactorLexer(RegexLexer):
flags = re.MULTILINE | re.UNICODE
builtin_kernel = (
- r'(?:or|2bi|2tri|while|wrapper|nip|4dip|wrapper\\?|bi\\*|'
- r'callstack>array|both\\?|hashcode|die|dupd|callstack|'
- r'callstack\\?|3dup|tri@|pick|curry|build|\\?execute|3bi|'
- r'prepose|>boolean|\\?if|clone|eq\\?|tri\\*|\\?|=|swapd|'
- r'2over|2keep|3keep|clear|2dup|when|not|tuple\\?|dup|2bi\\*|'
- r'2tri\\*|call|tri-curry|object|bi@|do|unless\\*|if\\*|loop|'
- r'bi-curry\\*|drop|when\\*|assert=|retainstack|assert\\?|-rot|'
- r'execute|2bi@|2tri@|boa|with|either\\?|3drop|bi|curry\\?|'
- r'datastack|until|3dip|over|3curry|tri-curry\\*|tri-curry@|swap|'
- r'and|2nip|throw|bi-curry|\\(clone\\)|hashcode\\*|compose|2dip|if|3tri|'
- r'unless|compose\\?|tuple|keep|2curry|equal\\?|assert|tri|2drop|'
- r'most|<wrapper>|boolean\\?|identity-hashcode|identity-tuple\\?|'
- r'null|new|dip|bi-curry@|rot|xor|identity-tuple|boolean)\s'
- )
+ r'(?:-rot|2bi|2bi@|2bi\*|2curry|2dip|2drop|2dup|2keep|2nip|'
+ r'2over|2tri|2tri@|2tri\*|3bi|3curry|3dip|3drop|3dup|3keep|'
+ r'3tri|4dip|4drop|4dup|4keep|<wrapper>|=|>boolean|\(clone\)|'
+ r'\?|\?execute|\?if|and|assert|assert=|assert\?|bi|bi-curry|'
+ r'bi-curry@|bi-curry\*|bi@|bi\*|boa|boolean|boolean\?|both\?|'
+ r'build|call|callstack|callstack>array|callstack\?|clear|clone|'
+ r'compose|compose\?|curry|curry\?|datastack|die|dip|do|drop|'
+ r'dup|dupd|either\?|eq\?|equal\?|execute|hashcode|hashcode\*|'
+ r'identity-hashcode|identity-tuple|identity-tuple\?|if|if\*|'
+ r'keep|loop|most|new|nip|not|null|object|or|over|pick|prepose|'
+ r'retainstack|rot|same\?|swap|swapd|throw|tri|tri-curry|'
+ r'tri-curry@|tri-curry\*|tri@|tri\*|tuple|tuple\?|unless|'
+ r'unless\*|until|when|when\*|while|with|wrapper|wrapper\?|xor)\s'
+ )
builtin_assocs = (
- r'(?:\\?at|assoc\\?|assoc-clone-like|assoc=|delete-at\\*|'
- r'assoc-partition|extract-keys|new-assoc|value\\?|assoc-size|'
- r'map>assoc|push-at|assoc-like|key\\?|assoc-intersect|'
- r'assoc-refine|update|assoc-union|assoc-combine|at\\*|'
- r'assoc-empty\\?|at\\+|set-at|assoc-all\\?|assoc-subset\\?|'
- r'assoc-hashcode|change-at|assoc-each|assoc-diff|zip|values|'
- r'value-at|rename-at|inc-at|enum\\?|at|cache|assoc>map|<enum>|'
- r'assoc|assoc-map|enum|value-at\\*|assoc-map-as|>alist|'
- r'assoc-filter-as|clear-assoc|assoc-stack|maybe-set-at|'
- r'substitute|assoc-filter|2cache|delete-at|assoc-find|keys|'
- r'assoc-any\\?|unzip)\s'
- )
+ r'(?:2cache|<enum>|>alist|\?at|\?of|assoc|assoc-all\?|'
+ r'assoc-any\?|assoc-clone-like|assoc-combine|assoc-diff|'
+ r'assoc-diff!|assoc-differ|assoc-each|assoc-empty\?|'
+ r'assoc-filter|assoc-filter!|assoc-filter-as|assoc-find|'
+ r'assoc-hashcode|assoc-intersect|assoc-like|assoc-map|'
+ r'assoc-map-as|assoc-partition|assoc-refine|assoc-size|'
+ r'assoc-stack|assoc-subset\?|assoc-union|assoc-union!|'
+ r'assoc=|assoc>map|assoc\?|at|at+|at\*|cache|change-at|'
+ r'clear-assoc|delete-at|delete-at\*|enum|enum\?|extract-keys|'
+ r'inc-at|key\?|keys|map>assoc|maybe-set-at|new-assoc|of|'
+ r'push-at|rename-at|set-at|sift-keys|sift-values|substitute|'
+ r'unzip|value-at|value-at\*|value\?|values|zip)\s'
+ )
builtin_combinators = (
- r'(?:case|execute-effect|no-cond|no-case\\?|3cleave>quot|2cleave|'
- r'cond>quot|wrong-values\\?|no-cond\\?|cleave>quot|no-case|'
- r'case>quot|3cleave|wrong-values|to-fixed-point|alist>quot|'
- r'case-find|cond|cleave|call-effect|2cleave>quot|recursive-hashcode|'
- r'linear-case-quot|spread|spread>quot)\s'
- )
+ r'(?:2cleave|2cleave>quot|3cleave|3cleave>quot|4cleave|'
+ r'4cleave>quot|alist>quot|call-effect|case|case-find|'
+ r'case>quot|cleave|cleave>quot|cond|cond>quot|deep-spread>quot|'
+ r'execute-effect|linear-case-quot|no-case|no-case\?|no-cond|'
+ r'no-cond\?|recursive-hashcode|shallow-spread>quot|spread|'
+ r'to-fixed-point|wrong-values|wrong-values\?)\s'
+ )
builtin_math = (
- r'(?:number=|if-zero|next-power-of-2|each-integer|\\?1\\+|'
- r'fp-special\\?|imaginary-part|unless-zero|float>bits|number\\?|'
- r'fp-infinity\\?|bignum\\?|fp-snan\\?|denominator|fp-bitwise=|\\*|'
- r'\\+|power-of-2\\?|-|u>=|/|>=|bitand|log2-expects-positive|<|'
- r'log2|>|integer\\?|number|bits>double|2/|zero\\?|(find-integer)|'
- r'bits>float|float\\?|shift|ratio\\?|even\\?|ratio|fp-sign|bitnot|'
- r'>fixnum|complex\\?|/i|/f|byte-array>bignum|when-zero|sgn|>bignum|'
- r'next-float|u<|u>|mod|recip|rational|find-last-integer|>float|'
- r'(all-integers\\?)|2^|times|integer|fixnum\\?|neg|fixnum|sq|'
- r'bignum|(each-integer)|bit\\?|fp-qnan\\?|find-integer|complex|'
- r'<fp-nan>|real|double>bits|bitor|rem|fp-nan-payload|all-integers\\?|'
- r'real-part|log2-expects-positive\\?|prev-float|align|unordered\\?|'
- r'float|fp-nan\\?|abs|bitxor|u<=|odd\\?|<=|/mod|rational\\?|>integer|'
- r'real\\?|numerator)\s'
- )
+ r'(?:-|/|/f|/i|/mod|2/|2\^|<|<=|<fp-nan>|>|>=|>bignum|'
+ r'>fixnum|>float|>integer|\(all-integers\?\)|'
+ r'\(each-integer\)|\(find-integer\)|\*|\+|\?1\+|'
+ r'abs|align|all-integers\?|bignum|bignum\?|bit\?|bitand|'
+ r'bitnot|bitor|bits>double|bits>float|bitxor|complex|'
+ r'complex\?|denominator|double>bits|each-integer|even\?|'
+ r'find-integer|find-last-integer|fixnum|fixnum\?|float|'
+ r'float>bits|float\?|fp-bitwise=|fp-infinity\?|fp-nan-payload|'
+ r'fp-nan\?|fp-qnan\?|fp-sign|fp-snan\?|fp-special\?|'
+ r'if-zero|imaginary-part|integer|integer>fixnum|'
+ r'integer>fixnum-strict|integer\?|log2|log2-expects-positive|'
+ r'log2-expects-positive\?|mod|neg|neg\?|next-float|'
+ r'next-power-of-2|number|number=|number\?|numerator|odd\?|'
+ r'out-of-fixnum-range|out-of-fixnum-range\?|power-of-2\?|'
+ r'prev-float|ratio|ratio\?|rational|rational\?|real|'
+ r'real-part|real\?|recip|rem|sgn|shift|sq|times|u<|u<=|u>|'
+ r'u>=|unless-zero|unordered\?|when-zero|zero\?)\s'
+ )
builtin_sequences = (
- r'(?:member-eq\\?|append|assert-sequence=|find-last-from|trim-head-slice|'
- r'clone-like|3sequence|assert-sequence\\?|map-as|last-index-from|'
- r'reversed|index-from|cut\\*|pad-tail|remove-eq!|concat-as|'
- r'but-last|snip|trim-tail|nths|nth|2selector|sequence|slice\\?|'
- r'<slice>|partition|remove-nth|tail-slice|empty\\?|tail\\*|'
- r'if-empty|find-from|virtual-sequence\\?|member\\?|set-length|'
- r'drop-prefix|unclip|unclip-last-slice|iota|map-sum|'
- r'bounds-error\\?|sequence-hashcode-step|selector-for|'
- r'accumulate-as|map|start|midpoint@|\\(accumulate\\)|rest-slice|'
- r'prepend|fourth|sift|accumulate!|new-sequence|follow|map!|'
- r'like|first4|1sequence|reverse|slice|unless-empty|padding|'
- r'virtual@|repetition\\?|set-last|index|4sequence|max-length|'
- r'set-second|immutable-sequence|first2|first3|replicate-as|'
- r'reduce-index|unclip-slice|supremum|suffix!|insert-nth|'
- r'trim-tail-slice|tail|3append|short|count|suffix|concat|'
- r'flip|filter|sum|immutable\\?|reverse!|2sequence|map-integers|'
- r'delete-all|start\\*|indices|snip-slice|check-slice|sequence\\?|'
- r'head|map-find|filter!|append-as|reduce|sequence=|halves|'
- r'collapse-slice|interleave|2map|filter-as|binary-reduce|'
- r'slice-error\\?|product|bounds-check\\?|bounds-check|harvest|'
- r'immutable|virtual-exemplar|find|produce|remove|pad-head|last|'
- r'replicate|set-fourth|remove-eq|shorten|reversed\\?|'
- r'map-find-last|3map-as|2unclip-slice|shorter\\?|3map|find-last|'
- r'head-slice|pop\\*|2map-as|tail-slice\\*|but-last-slice|'
- r'2map-reduce|iota\\?|collector-for|accumulate|each|selector|'
- r'append!|new-resizable|cut-slice|each-index|head-slice\\*|'
- r'2reverse-each|sequence-hashcode|pop|set-nth|\\?nth|'
- r'<flat-slice>|second|join|when-empty|collector|'
- r'immutable-sequence\\?|<reversed>|all\\?|3append-as|'
- r'virtual-sequence|subseq\\?|remove-nth!|push-either|new-like|'
- r'length|last-index|push-if|2all\\?|lengthen|assert-sequence|'
- r'copy|map-reduce|move|third|first|3each|tail\\?|set-first|'
- r'prefix|bounds-error|any\\?|<repetition>|trim-slice|exchange|'
- r'surround|2reduce|cut|change-nth|min-length|set-third|produce-as|'
- r'push-all|head\\?|delete-slice|rest|sum-lengths|2each|head\\*|'
- r'infimum|remove!|glue|slice-error|subseq|trim|replace-slice|'
- r'push|repetition|map-index|trim-head|unclip-last|mismatch)\s'
- )
+ r'(?:1sequence|2all\?|2each|2map|2map-as|2map-reduce|2reduce|'
+ r'2selector|2sequence|3append|3append-as|3each|3map|3map-as|'
+ r'3sequence|4sequence|<repetition>|<reversed>|<slice>|\?first|'
+ r'\?last|\?nth|\?second|\?set-nth|accumulate|accumulate!|'
+ r'accumulate-as|all\?|any\?|append|append!|append-as|'
+ r'assert-sequence|assert-sequence=|assert-sequence\?|'
+ r'binary-reduce|bounds-check|bounds-check\?|bounds-error|'
+ r'bounds-error\?|but-last|but-last-slice|cartesian-each|'
+ r'cartesian-map|cartesian-product|change-nth|check-slice|'
+ r'check-slice-error|clone-like|collapse-slice|collector|'
+ r'collector-for|concat|concat-as|copy|count|cut|cut-slice|'
+ r'cut\*|delete-all|delete-slice|drop-prefix|each|each-from|'
+ r'each-index|empty\?|exchange|filter|filter!|filter-as|find|'
+ r'find-from|find-index|find-index-from|find-last|find-last-from|'
+ r'first|first2|first3|first4|flip|follow|fourth|glue|halves|'
+ r'harvest|head|head-slice|head-slice\*|head\*|head\?|'
+ r'if-empty|immutable|immutable-sequence|immutable-sequence\?|'
+ r'immutable\?|index|index-from|indices|infimum|infimum-by|'
+ r'insert-nth|interleave|iota|iota-tuple|iota-tuple\?|join|'
+ r'join-as|last|last-index|last-index-from|length|lengthen|'
+ r'like|longer|longer\?|longest|map|map!|map-as|map-find|'
+ r'map-find-last|map-index|map-integers|map-reduce|map-sum|'
+ r'max-length|member-eq\?|member\?|midpoint@|min-length|'
+ r'mismatch|move|new-like|new-resizable|new-sequence|'
+ r'non-negative-integer-expected|non-negative-integer-expected\?|'
+ r'nth|nths|pad-head|pad-tail|padding|partition|pop|pop\*|'
+ r'prefix|prepend|prepend-as|produce|produce-as|product|push|'
+ r'push-all|push-either|push-if|reduce|reduce-index|remove|'
+ r'remove!|remove-eq|remove-eq!|remove-nth|remove-nth!|repetition|'
+ r'repetition\?|replace-slice|replicate|replicate-as|rest|'
+ r'rest-slice|reverse|reverse!|reversed|reversed\?|second|'
+ r'selector|selector-for|sequence|sequence-hashcode|sequence=|'
+ r'sequence\?|set-first|set-fourth|set-last|set-length|set-nth|'
+ r'set-second|set-third|short|shorten|shorter|shorter\?|'
+ r'shortest|sift|slice|slice-error|slice-error\?|slice\?|'
+ r'snip|snip-slice|start|start\*|subseq|subseq\?|suffix|'
+ r'suffix!|sum|sum-lengths|supremum|supremum-by|surround|tail|'
+ r'tail-slice|tail-slice\*|tail\*|tail\?|third|trim|'
+ r'trim-head|trim-head-slice|trim-slice|trim-tail|trim-tail-slice|'
+ r'unclip|unclip-last|unclip-last-slice|unclip-slice|unless-empty|'
+ r'virtual-exemplar|virtual-sequence|virtual-sequence\?|virtual@|'
+ r'when-empty)\s'
+ )
builtin_namespaces = (
- r'(?:global|\\+@|change|set-namestack|change-global|init-namespaces|'
- r'on|off|set-global|namespace|set|with-scope|bind|with-variable|'
- r'inc|dec|counter|initialize|namestack|get|get-global|make-assoc)\s'
- )
+ r'(?:\+@|change|change-global|counter|dec|get|get-global|'
+ r'global|inc|init-namespaces|initialize|is-global|make-assoc|'
+ r'namespace|namestack|off|on|set|set-global|set-namestack|'
+ r'toggle|with-global|with-scope|with-variable|with-variables)\s'
+ )
builtin_arrays = (
- r'(?:<array>|2array|3array|pair|>array|1array|4array|pair\\?|'
- r'array|resize-array|array\\?)\s'
- )
+ r'(?:1array|2array|3array|4array|<array>|>array|array|array\?|'
+ r'pair|pair\?|resize-array)\s'
+ )
builtin_io = (
- r'(?:\\+character\\+|bad-seek-type\\?|readln|each-morsel|stream-seek|'
- r'read|print|with-output-stream|contents|write1|stream-write1|'
- r'stream-copy|stream-element-type|with-input-stream|'
- r'stream-print|stream-read|stream-contents|stream-tell|'
- r'tell-output|bl|seek-output|bad-seek-type|nl|stream-nl|write|'
- r'flush|stream-lines|\\+byte\\+|stream-flush|read1|'
- r'seek-absolute\\?|stream-read1|lines|stream-readln|'
- r'stream-read-until|each-line|seek-end|with-output-stream\\*|'
- r'seek-absolute|with-streams|seek-input|seek-relative\\?|'
- r'input-stream|stream-write|read-partial|seek-end\\?|'
- r'seek-relative|error-stream|read-until|with-input-stream\\*|'
- r'with-streams\\*|tell-input|each-block|output-stream|'
- r'stream-read-partial|each-stream-block|each-stream-line)\s'
- )
+ r'(?:\(each-stream-block-slice\)|\(each-stream-block\)|'
+ r'\(stream-contents-by-block\)|\(stream-contents-by-element\)|'
+ r'\(stream-contents-by-length-or-block\)|'
+ r'\(stream-contents-by-length\)|\+byte\+|\+character\+|'
+ r'bad-seek-type|bad-seek-type\?|bl|contents|each-block|'
+ r'each-block-size|each-block-slice|each-line|each-morsel|'
+ r'each-stream-block|each-stream-block-slice|each-stream-line|'
+ r'error-stream|flush|input-stream|input-stream\?|'
+ r'invalid-read-buffer|invalid-read-buffer\?|lines|nl|'
+ r'output-stream|output-stream\?|print|read|read-into|'
+ r'read-partial|read-partial-into|read-until|read1|readln|'
+ r'seek-absolute|seek-absolute\?|seek-end|seek-end\?|'
+ r'seek-input|seek-output|seek-relative|seek-relative\?|'
+ r'stream-bl|stream-contents|stream-contents\*|stream-copy|'
+ r'stream-copy\*|stream-element-type|stream-flush|'
+ r'stream-length|stream-lines|stream-nl|stream-print|'
+ r'stream-read|stream-read-into|stream-read-partial|'
+ r'stream-read-partial-into|stream-read-partial-unsafe|'
+ r'stream-read-unsafe|stream-read-until|stream-read1|'
+ r'stream-readln|stream-seek|stream-seekable\?|stream-tell|'
+ r'stream-write|stream-write1|tell-input|tell-output|'
+ r'with-error-stream|with-error-stream\*|with-error>output|'
+ r'with-input-output\+error-streams|'
+ r'with-input-output\+error-streams\*|with-input-stream|'
+ r'with-input-stream\*|with-output-stream|with-output-stream\*|'
+ r'with-output>error|with-output\+error-stream|'
+ r'with-output\+error-stream\*|with-streams|with-streams\*|'
+ r'write|write1)\s'
+ )
builtin_strings = (
- r'(?:resize-string|>string|<string>|1string|string|string\\?)\s'
- )
+ r'(?:1string|<string>|>string|resize-string|string|string\?)\s'
+ )
builtin_vectors = (
- r'(?:vector\\?|<vector>|\\?push|vector|>vector|1vector)\s'
- )
+ r'(?:1vector|<vector>|>vector|\?push|vector|vector\?)\s'
+ )
builtin_continuations = (
- r'(?:with-return|restarts|return-continuation|with-datastack|'
- r'recover|rethrow-restarts|<restart>|ifcc|set-catchstack|'
- r'>continuation<|cleanup|ignore-errors|restart\\?|'
- r'compute-restarts|attempt-all-error|error-thread|continue|'
- r'<continuation>|attempt-all-error\\?|condition\\?|'
- r'<condition>|throw-restarts|error|catchstack|continue-with|'
- r'thread-error-hook|continuation|rethrow|callcc1|'
- r'error-continuation|callcc0|attempt-all|condition|'
- r'continuation\\?|restart|return)\s'
- )
+ r'(?:<condition>|<continuation>|<restart>|attempt-all|'
+ r'attempt-all-error|attempt-all-error\?|callback-error-hook|'
+ r'callcc0|callcc1|cleanup|compute-restarts|condition|'
+ r'condition\?|continuation|continuation\?|continue|'
+ r'continue-restart|continue-with|current-continuation|'
+ r'error|error-continuation|error-in-thread|error-thread|'
+ r'ifcc|ignore-errors|in-callback\?|original-error|recover|'
+ r'restart|restart\?|restarts|rethrow|rethrow-restarts|'
+ r'return|return-continuation|thread-error-hook|throw-continue|'
+ r'throw-restarts|with-datastack|with-return)\s'
+ )
tokens = {
'root': [
- # TODO: (( inputs -- outputs ))
- # TODO: << ... >>
+ # factor allows a file to start with a shebang
+ (r'#!.*$', Comment.Preproc),
+ (r'', Text, 'base'),
+ ],
+ 'base': [
+ (r'\s+', Text),
# defining words
- (r'(\s*)(:|::|MACRO:|MEMO:)(\s+)(\S+)',
- bygroups(Text, Keyword, Text, Name.Function)),
- (r'(\s*)(M:)(\s+)(\S+)(\s+)(\S+)',
- bygroups(Text, Keyword, Text, Name.Class, Text, Name.Function)),
- (r'(\s*)(GENERIC:)(\s+)(\S+)',
- bygroups(Text, Keyword, Text, Name.Function)),
- (r'(\s*)(HOOK:|GENERIC#)(\s+)(\S+)(\s+)(\S+)',
- bygroups(Text, Keyword, Text, Name.Function, Text, Name.Function)),
- (r'(\()(\s+)', bygroups(Name.Function, Text), 'stackeffect'),
- (r'\;\s', Keyword),
+ (r'((?:MACRO|MEMO|TYPED)?:[:]?)(\s+)(\S+)',
+ bygroups(Keyword, Text, Name.Function)),
+ (r'(M:[:]?)(\s+)(\S+)(\s+)(\S+)',
+ bygroups(Keyword, Text, Name.Class, Text, Name.Function)),
+ (r'(C:)(\s+)(\S+)(\s+)(\S+)',
+ bygroups(Keyword, Text, Name.Function, Text, Name.Class)),
+ (r'(GENERIC:)(\s+)(\S+)',
+ bygroups(Keyword, Text, Name.Function)),
+ (r'(HOOK:|GENERIC#)(\s+)(\S+)(\s+)(\S+)',
+ bygroups(Keyword, Text, Name.Function, Text, Name.Function)),
+ (r'\(\s', Name.Function, 'stackeffect'),
+ (r';\s', Keyword),
# imports and namespaces
- (r'(USING:)((?:\s|\\\s)+)',
- bygroups(Keyword.Namespace, Text), 'import'),
- (r'(USE:)(\s+)(\S+)',
- bygroups(Keyword.Namespace, Text, Name.Namespace)),
- (r'(UNUSE:)(\s+)(\S+)',
- bygroups(Keyword.Namespace, Text, Name.Namespace)),
- (r'(QUALIFIED:)(\s+)(\S+)',
+ (r'(USING:)(\s+)',
+ bygroups(Keyword.Namespace, Text), 'vocabs'),
+ (r'(USE:|UNUSE:|IN:|QUALIFIED:)(\s+)(\S+)',
bygroups(Keyword.Namespace, Text, Name.Namespace)),
- (r'(QUALIFIED-WITH:)(\s+)(\S+)',
- bygroups(Keyword.Namespace, Text, Name.Namespace)),
- (r'(FROM:|EXCLUDE:)(\s+)(\S+)(\s+)(=>)',
- bygroups(Keyword.Namespace, Text, Name.Namespace, Text, Text)),
- (r'(IN:)(\s+)(\S+)',
- bygroups(Keyword.Namespace, Text, Name.Namespace)),
- (r'(?:ALIAS|DEFER|FORGET|POSTPONE):', Keyword.Namespace),
+ (r'(QUALIFIED-WITH:)(\s+)(\S+)(\s+)(\S+)',
+ bygroups(Keyword.Namespace, Text, Name.Namespace, Text, Name.Namespace)),
+ (r'(FROM:|EXCLUDE:)(\s+)(\S+)(\s+=>\s)',
+ bygroups(Keyword.Namespace, Text, Name.Namespace, Text), 'words'),
+ (r'(RENAME:)(\s+)(\S+)(\s+)(\S+)(\s+=>\s+)(\S+)',
+ bygroups(Keyword.Namespace, Text, Name.Function, Text, Name.Namespace, Text, Name.Function)),
+ (r'(ALIAS:|TYPEDEF:)(\s+)(\S+)(\s+)(\S+)',
+ bygroups(Keyword.Namespace, Text, Name.Function, Text, Name.Function)),
+ (r'(DEFER:|FORGET:|POSTPONE:)(\s+)(\S+)',
+ bygroups(Keyword.Namespace, Text, Name.Function)),
# tuples and classes
- (r'(TUPLE:)(\s+)(\S+)(\s+<\s+)(\S+)',
+ (r'(TUPLE:|ERROR:)(\s+)(\S+)(\s+<\s+)(\S+)',
bygroups(Keyword, Text, Name.Class, Text, Name.Class), 'slots'),
- (r'(TUPLE:)(\s+)(\S+)',
+ (r'(TUPLE:|ERROR:|BUILTIN:)(\s+)(\S+)',
bygroups(Keyword, Text, Name.Class), 'slots'),
- (r'(UNION:)(\s+)(\S+)', bygroups(Keyword, Text, Name.Class)),
- (r'(INTERSECTION:)(\s+)(\S+)', bygroups(Keyword, Text, Name.Class)),
+ (r'(MIXIN:|UNION:|INTERSECTION:)(\s+)(\S+)',
+ bygroups(Keyword, Text, Name.Class)),
(r'(PREDICATE:)(\s+)(\S+)(\s+<\s+)(\S+)',
- bygroups(Keyword, Text, Name.Class, Text, Name.Class)),
+ bygroups(Keyword, Text, Name.Class, Text, Name.Class)),
(r'(C:)(\s+)(\S+)(\s+)(\S+)',
- bygroups(Keyword, Text, Name.Function, Text, Name.Class)),
- (r'INSTANCE:', Keyword),
- (r'SLOT:', Keyword),
- (r'MIXIN:', Keyword),
- (r'(?:SINGLETON|SINGLETONS):', Keyword),
+ bygroups(Keyword, Text, Name.Function, Text, Name.Class)),
+ (r'(INSTANCE:)(\s+)(\S+)(\s+)(\S+)',
+ bygroups(Keyword, Text, Name.Class, Text, Name.Class)),
+ (r'(SLOT:)(\s+)(\S+)', bygroups(Keyword, Text, Name.Function)),
+ (r'(SINGLETON:)(\s+)(\S+)', bygroups(Keyword, Text, Name.Class)),
+ (r'SINGLETONS:', Keyword, 'classes'),
# other syntax
- (r'CONSTANT:', Keyword),
- (r'(?:SYMBOL|SYMBOLS):', Keyword),
- (r'ERROR:', Keyword),
- (r'SYNTAX:', Keyword),
- (r'(HELP:)(\s+)(\S+)', bygroups(Keyword, Text, Name.Function)),
- (r'(MAIN:)(\s+)(\S+)',
- bygroups(Keyword.Namespace, Text, Name.Function)),
- (r'(?:ALIEN|TYPEDEF|FUNCTION|STRUCT):', Keyword),
+ (r'(CONSTANT:|SYMBOL:|MAIN:|HELP:)(\s+)(\S+)',
+ bygroups(Keyword, Text, Name.Function)),
+ (r'SYMBOLS:\s', Keyword, 'words'),
+ (r'SYNTAX:\s', Keyword),
+ (r'ALIEN:\s', Keyword),
+ (r'(STRUCT:)(\s+)(\S+)', bygroups(Keyword, Text, Name.Class)),
+ (r'(FUNCTION:)(\s+\S+\s+)(\S+)(\s+\(\s+[^\)]+\)\s)',
+ bygroups(Keyword.Namespace, Text, Name.Function, Text)),
+ (r'(FUNCTION-ALIAS:)(\s+)(\S+)(\s+\S+\s+)(\S+)(\s+\(\s+[^\)]+\)\s)',
+ bygroups(Keyword.Namespace, Text, Name.Function, Text, Name.Function, Text)),
# vocab.private
- # TODO: words inside vocab.private should have red names?
- (r'(?:<PRIVATE|PRIVATE>)', Keyword.Namespace),
+ (r'(?:<PRIVATE|PRIVATE>)\s', Keyword.Namespace),
# strings
(r'"""\s+(?:.|\n)*?\s+"""', String),
(r'"(?:\\\\|\\"|[^"])*"', String),
- (r'CHAR:\s+(\\[\\abfnrstv]*|\S)\s', String.Char),
+ (r'\S+"\s+(?:\\\\|\\"|[^"])*"', String),
+ (r'CHAR:\s+(\\[\\abfnrstv]|[^\\]\S+)\s', String.Char),
# comments
- (r'\!\s+.*$', Comment),
- (r'#\!\s+.*$', Comment),
+ (r'!\s+.*$', Comment),
+ (r'#!\s+.*$', Comment),
+ (r'/\*\s+(?:.|\n)*?\s\*/\s', Comment),
# boolean constants
(r'(t|f)\s', Name.Constant),
- # numbers
- (r'-?\d+\.\d+\s', Number.Float),
- (r'-?\d+\s', Number.Integer),
- (r'HEX:\s+[a-fA-F\d]+\s', Number.Hex),
- (r'BIN:\s+[01]+\s', Number.Integer),
- (r'OCT:\s+[0-7]+\s', Number.Oct),
+ # symbols and literals
+ (r'[\\$]\s+\S+', Name.Constant),
+ (r'M\\\s+\S+\s+\S+', Name.Constant),
- # operators
- (r'[-+/*=<>^]\s', Operator),
+ # numbers
+ (r'[+-]?([\d,]*\d)?\.(\d([\d,]*\d)?)?([eE][+-]?\d+)?\s', Number),
+ (r'[+-]?\d([\d,]*\d)?([eE][+-]?\d+)?\s', Number),
+ (r'0x[a-fA-F\d]([a-fA-F\d,]*[a-fA-F\d])?(p\d([\d,]*\d)?)?\s', Number),
+ (r'NAN:\s+[a-fA-F\d]([a-fA-F\d,]*[a-fA-F\d])?(p\d([\d,]*\d)?)?\s', Number),
+ (r'0b[01]+\s', Number),
+ (r'0o[0-7]+\s', Number),
+ (r'(\d([\d,]*\d)?)?\+\d([\d,]*\d)?/\d([\d,]*\d)?\s', Number),
+ (r'(\-\d([\d,]*\d)?)?\-\d([\d,]*\d)?/\d([\d,]*\d)?\s', Number),
# keywords
(r'(?:deprecated|final|foldable|flushable|inline|recursive)\s',
@@ -1721,31 +1761,37 @@ class FactorLexer(RegexLexer):
(builtin_vectors, Name.Builtin),
(builtin_continuations, Name.Builtin),
- # whitespaces - usually not relevant
- (r'\s+', Text),
-
# everything else is text
(r'\S+', Text),
],
-
'stackeffect': [
- (r'\s*\(', Name.Function, 'stackeffect'),
- (r'\)', Name.Function, '#pop'),
- (r'\-\-', Name.Function),
(r'\s+', Text),
+ (r'\(\s+', Name.Function, 'stackeffect'),
+ (r'\)\s', Name.Function, '#pop'),
+ (r'--\s', Name.Function),
(r'\S+', Name.Variable),
],
-
'slots': [
(r'\s+', Text),
(r';\s', Keyword, '#pop'),
+ (r'({\s+)(\S+)(\s+[^}]+\s+}\s)',
+ bygroups(Text, Name.Variable, Text)),
(r'\S+', Name.Variable),
],
-
- 'import': [
- (r';', Keyword, '#pop'),
+ 'vocabs': [
+ (r'\s+', Text),
+ (r';\s', Keyword, '#pop'),
(r'\S+', Name.Namespace),
+ ],
+ 'classes': [
+ (r'\s+', Text),
+ (r';\s', Keyword, '#pop'),
+ (r'\S+', Name.Class),
+ ],
+ 'words': [
(r'\s+', Text),
+ (r';\s', Keyword, '#pop'),
+ (r'\S+', Name.Function),
],
}
diff --git a/pygments/lexers/compiled.py b/pygments/lexers/compiled.py
index 2737859b..e6e10098 100644
--- a/pygments/lexers/compiled.py
+++ b/pygments/lexers/compiled.py
@@ -469,20 +469,23 @@ class DLexer(RegexLexer):
(r'(abstract|alias|align|asm|assert|auto|body|break|case|cast'
r'|catch|class|const|continue|debug|default|delegate|delete'
r'|deprecated|do|else|enum|export|extern|finally|final'
- r'|foreach_reverse|foreach|for|function|goto|if|import|inout'
- r'|interface|invariant|in|is|lazy|mixin|module|new|nothrow|out'
+ r'|foreach_reverse|foreach|for|function|goto|if|immutable|import'
+ r'|interface|invariant|inout|in|is|lazy|mixin|module|new|nothrow|out'
r'|override|package|pragma|private|protected|public|pure|ref|return'
- r'|scope|static|struct|super|switch|synchronized|template|this'
+ r'|scope|shared|static|struct|super|switch|synchronized|template|this'
r'|throw|try|typedef|typeid|typeof|union|unittest|version|volatile'
- r'|while|with|__traits)\b', Keyword
+ r'|while|with|__gshared|__traits|__vector|__parameters)\b', Keyword
),
(r'(bool|byte|cdouble|cent|cfloat|char|creal|dchar|double|float'
r'|idouble|ifloat|int|ireal|long|real|short|ubyte|ucent|uint|ulong'
r'|ushort|void|wchar)\b', Keyword.Type
),
(r'(false|true|null)\b', Keyword.Constant),
+ (r'(__FILE__|__MODULE__|__LINE__|__FUNCTION__|__PRETTY_FUNCTION__'
+ r'|__DATE__|__EOF__|__TIME__|__TIMESTAMP__|__VENDOR__|__VERSION__)\b',
+ Keyword.Pseudo),
(r'macro\b', Keyword.Reserved),
- (r'(string|wstring|dstring)\b', Name.Builtin),
+ (r'(string|wstring|dstring|size_t|ptrdiff_t)\b', Name.Builtin),
# FloatLiteral
# -- HexFloat
(r'0[xX]([0-9a-fA-F_]*\.[0-9a-fA-F_]+|[0-9a-fA-F_]+)'
@@ -528,6 +531,8 @@ class DLexer(RegexLexer):
(r'q"(.).*?\1"', String),
# -- TokenString
(r'q{', String, 'token_string'),
+ # Attributes
+ (r'@([a-zA-Z_]\w*)?', Name.Decorator),
# Tokens
(r'(~=|\^=|%=|\*=|==|!>=|!<=|!<>=|!<>|!<|!>|!=|>>>=|>>>|>>=|>>|>='
r'|<>=|<>|<<=|<<|<=|\+\+|\+=|--|-=|\|\||\|=|&&|&=|\.\.\.|\.\.|/=)'
@@ -535,6 +540,8 @@ class DLexer(RegexLexer):
),
# Identifier
(r'[a-zA-Z_]\w*', Name),
+ # Line
+ (r'#line\s.*\n', Comment.Special),
],
'nested_comment': [
(r'[^+/]+', Comment.Multiline),
diff --git a/pygments/lexers/jvm.py b/pygments/lexers/jvm.py
index 64c47b6e..4b91e723 100644
--- a/pygments/lexers/jvm.py
+++ b/pygments/lexers/jvm.py
@@ -12,7 +12,7 @@
import re
from pygments.lexer import Lexer, RegexLexer, include, bygroups, using, \
- this
+ this, combined
from pygments.token import Text, Comment, Operator, Keyword, Name, String, \
Number, Punctuation
from pygments import unistring as uni
@@ -21,7 +21,7 @@ from pygments import unistring as uni
__all__ = ['JavaLexer', 'ScalaLexer', 'GosuLexer', 'GosuTemplateLexer',
'GroovyLexer', 'IokeLexer', 'ClojureLexer', 'ClojureScriptLexer',
'KotlinLexer', 'XtendLexer', 'AspectJLexer', 'CeylonLexer',
- 'PigLexer']
+ 'PigLexer', 'GoloLexer']
class JavaLexer(RegexLexer):
@@ -1146,3 +1146,115 @@ class PigLexer(RegexLexer):
(r'(==|<=|<|>=|>|!=)', Operator),
],
}
+
+
+class GoloLexer(RegexLexer):
+ """
+ For `Golo <http://golo-lang.org/>`_ source code.
+
+ .. versionadded:: 2.0
+ """
+
+ name = 'Golo'
+ filenames = ['*.golo']
+ aliases = ['golo']
+
+ tokens = {
+ 'root': [
+ (r'[^\S\n]+', Text),
+
+ (r'#.*$', Comment),
+
+ (r'(\^|\.\.\.|:|\?:|->|==|!=|=|\+|\*|%|/|<=|<|>=|>|=|\.)',
+ Operator),
+ (r'(?<=[^-])(-)(?=[^-])', Operator),
+
+ (r'(?<=[^`])(is|isnt|and|or|not|oftype|in|orIfNull)\b', Operator.Word),
+ (r'[]{}|(),[]', Punctuation),
+
+ (r'(module|import)(\s+)',
+ bygroups(Keyword.Namespace, Text),
+ 'modname'),
+ (r'\b([a-zA-Z_][a-z$A-Z0-9._]*)(::)', bygroups(Name.Namespace, Punctuation)),
+ (r'\b([a-zA-Z_][a-z$A-Z0-9_]*(?:\.[a-zA-Z_][a-z$A-Z0-9_]*)+)\b', Name.Namespace),
+
+ (r'(let|var)(\s+)',
+ bygroups(Keyword.Declaration, Text),
+ 'varname'),
+ (r'(struct)(\s+)',
+ bygroups(Keyword.Declaration, Text),
+ 'structname'),
+ (r'(function)(\s+)',
+ bygroups(Keyword.Declaration, Text),
+ 'funcname'),
+
+ (r'(null|true|false)\b', Keyword.Constant),
+ (r'(augment|pimp'
+ r'|if|else|case|match|return'
+ r'|case|when|then|otherwise'
+ r'|while|for|foreach'
+ r'|try|catch|finally|throw'
+ r'|local'
+ r'|continue|break)\b', Keyword),
+
+ (r'(map|array|list|set|vector|tuple)(\[)',
+ bygroups(Name.Builtin, Punctuation)),
+ (r'(print|println|readln|raise|fun'
+ r'|asInterfaceInstance)\b', Name.Builtin),
+ (r'(`?[a-zA-Z_][a-z$A-Z0-9_]*)(\()',
+ bygroups(Name.Function, Punctuation)),
+
+ (r'-?[\d_]*\.[\d_]*([eE][+-]?\d[\d_]*)?F?', Number.Float),
+ (r'0[0-7]+j?', Number.Oct),
+ (r'0[xX][a-fA-F0-9]+', Number.Hex),
+ (r'-?\d[\d_]*L', Number.Integer.Long),
+ (r'-?\d[\d_]*', Number.Integer),
+
+ ('`?[a-zA-Z_][a-z$A-Z0-9_]*', Name),
+
+ (r'"""', String, combined('stringescape', 'triplestring')),
+ (r'"', String, combined('stringescape', 'doublestring')),
+ (r"'", String, combined('stringescape', 'singlestring')),
+ (r'----((.|\n)*?)----', String.Doc)
+
+ ],
+
+ 'funcname': [
+ (r'`?[a-zA-Z_][a-z$A-Z0-9_]*', Name.Function, '#pop'),
+ ],
+ 'modname': [
+ (r'[a-zA-Z_][a-z$A-Z0-9._]*\*?', Name.Namespace, '#pop')
+ ],
+ 'structname': [
+ (r'`?[a-zA-Z0-9_.]+\*?', Name.Class, '#pop')
+ ],
+ 'varname': [
+ (r'`?[a-zA-Z_][a-z$A-Z0-9_]*', Name.Variable, '#pop'),
+ ],
+ 'string': [
+ (r'[^\\\'"\n]+', String),
+ (r'[\'"\\]', String)
+ ],
+ 'stringescape': [
+ (r'\\([\\abfnrtv"\']|\n|N{.*?}|u[a-fA-F0-9]{4}|'
+ r'U[a-fA-F0-9]{8}|x[a-fA-F0-9]{2}|[0-7]{1,3})', String.Escape)
+ ],
+ 'triplestring': [
+ (r'"""', String, '#pop'),
+ include('string'),
+ (r'\n', String),
+ ],
+ 'doublestring': [
+ (r'"', String.Double, '#pop'),
+ include('string'),
+ ],
+ 'singlestring': [
+ (r"'", String, '#pop'),
+ include('string'),
+ ],
+ 'operators': [
+ (r'[#=,./%+\-?]', Operator),
+ (r'(eq|gt|lt|gte|lte|neq|matches)\b', Operator),
+ (r'(==|<=|<|>=|>|!=)', Operator),
+ ],
+ }
diff --git a/pygments/lexers/other.py b/pygments/lexers/other.py
index d6e2c7be..dd0ecc53 100644
--- a/pygments/lexers/other.py
+++ b/pygments/lexers/other.py
@@ -37,7 +37,89 @@ __all__ = ['BrainfuckLexer', 'BefungeLexer', 'RedcodeLexer', 'MOOCodeLexer',
'MscgenLexer', 'KconfigLexer', 'VGLLexer', 'SourcePawnLexer',
'RobotFrameworkLexer', 'PuppetLexer', 'NSISLexer', 'RPMSpecLexer',
'CbmBasicV2Lexer', 'AutoItLexer', 'RexxLexer', 'APLLexer',
- 'AmbientTalkLexer']
+ 'LSLLexer', 'AmbientTalkLexer']
+
+
+class LSLLexer(RegexLexer):
+ """
+ For Second Life's Linden Scripting Language source code.
+ """
+
+ name = 'LSL'
+ aliases = ['lsl']
+ filenames = ['*.lsl']
+ mimetypes = ['text/x-lsl']
+
+ flags = re.MULTILINE
+
+ lsl_keywords = r'\b(?:do|else|for|if|jump|return|while)\b'
+ lsl_types = r'\b(?:float|integer|key|list|quaternion|rotation|string|vector)\b'
+ lsl_states = r'\b(?:(?:state)\s+\w+|default)\b'
+ lsl_events = r'\b(?:state_(?:entry|exit)|touch(?:_(?:start|end))?|(?:land_)?collision(?:_(?:start|end))?|timer|listen|(?:no_)?sensor|control|(?:not_)?at_(?:rot_)?target|money|email|run_time_permissions|changed|attach|dataserver|moving_(?:start|end)|link_message|(?:on|object)_rez|remote_data|http_re(?:sponse|quest)|path_update|transaction_result)\b'
+ lsl_functions_builtin = r'\b(?:ll(?:ReturnObjectsBy(?:ID|Owner)|Json(?:2List|[GS]etValue|ValueType)|Sin|Cos|Tan|Atan2|Sqrt|Pow|Abs|Fabs|Frand|Floor|Ceil|Round|Vec(?:Mag|Norm|Dist)|Rot(?:Between|2(?:Euler|Fwd|Left|Up))|(?:Euler|Axes)2Rot|Whisper|(?:Region|Owner)?Say|Shout|Listen(?:Control|Remove)?|Sensor(?:Repeat|Remove)?|Detected(?:Name|Key|Owner|Type|Pos|Vel|Grab|Rot|Group|LinkNumber)|Die|Ground|Wind|(?:[GS]et)(?:AnimationOverride|MemoryLimit|PrimMediaParams|ParcelMusicURL|Object(?:Desc|Name)|PhysicsMaterial|Status|Scale|Color|Alpha|Texture|Pos|Rot|Force|Torque)|ResetAnimationOverride|(?:Scale|Offset|Rotate)Texture|(?:Rot)?Target(?:Remove)?|(?:Stop)?MoveToTarget|Apply(?:Rotational)?Impulse|Set(?:KeyframedMotion|ContentType|RegionPos|(?:Angular)?Velocity|Buoyancy|HoverHeight|ForceAndTorque|TimerEvent|ScriptState|Damage|TextureAnim|Sound(?:Queueing|Radius)|Vehicle(?:Type|(?:Float|Vector|Rotation)Param)|(?:Touch|Sit)?Text|Camera(?:Eye|At)Offset|PrimitiveParams|ClickAction|Link(?:Alpha|Color|PrimitiveParams(?:Fast)?|Texture(?:Anim)?|Camera|Media)|RemoteScriptAccessPin|PayPrice|LocalRot)|ScaleByFactor|Get(?:(?:Max|Min)ScaleFactor|ClosestNavPoint|StaticPath|SimStats|Env|PrimitiveParams|Link(?:PrimitiveParams|Number(?:OfSides)?|Key|Name|Media)|HTTPHeader|FreeURLs|Object(?:Details|PermMask|PrimCount)|Parcel(?:MaxPrims|Details|Prim(?:Count|Owners))|Attached|(?:SPMax|Free|Used)Memory|Region(?:Name|TimeDilation|FPS|Corner|AgentCount)|Root(?:Position|Rotation)|UnixTime|(?:Parcel|Region)Flags|(?:Wall|GMT)clock|SimulatorHostname|BoundingBox|GeometricCenter|Creator|NumberOf(?:Prims|NotecardLines|Sides)|Animation(?:List)?|(?:Camera|Local)(?:Pos|Rot)|Vel|Accel|Omega|Time(?:stamp|OfDay)|(?:Object|CenterOf)?Mass|MassMKS|Energy|Owner|(?:Owner)?Key|SunDirection|Texture(?:Offset|Scale|Rot)|Inventory(?:Number|Name|Key|Type|Creator|PermMask)|Permissions(?:Key)?|StartParameter|List(?:Length|EntryType)|Date|Agent(?:Size|Info|Language|List)|LandOwnerAt|NotecardLine|Script(?:Name|State))|(?:Get|Reset|GetAndReset)Time|PlaySound(?:Slave)?|LoopSound(?:Master|Slave)?|(?:Trigger|Stop|Preload)Sound|(?:(?:Get|Delete)Sub|Insert)String|To(?:Upper|Lower)|Give(?:InventoryList|Money)|RezObject|(?:Stop)?LookAt|Sleep|CollisionFilter|(?:Take|Release)Controls|DetachFromAvatar|AttachToAvatar(?:Temp)?|InstantMessage|(?:GetNext)?Email|StopHover|MinEventDelay|RotLookAt|String(?:Length|Trim)|(?:Start|Stop)Animation|TargetOmega|RequestPermissions|(?:Create|Break)Link|BreakAllLinks|(?:Give|Remove)Inventory|Water|PassTouches|Request(?:Agent|Inventory)Data|TeleportAgent(?:Home|GlobalCoords)?|ModifyLand|CollisionSound|ResetScript|MessageLinked|PushObject|PassCollisions|AxisAngle2Rot|Rot2(?:Axis|Angle)|A(?:cos|sin)|AngleBetween|AllowInventoryDrop|SubStringIndex|List2(?:CSV|Integer|Json|Float|String|Key|Vector|Rot|List(?:Strided)?)|DeleteSubList|List(?:Statistics|Sort|Randomize|(?:Insert|Find|Replace)List)|EdgeOfWorld|AdjustSoundVolume|Key2Name|TriggerSoundLimited|EjectFromLand|(?:CSV|ParseString)2List|OverMyLand|SameGroup|UnSit|Ground(?:Slope|Normal|Contour)|GroundRepel|(?:Set|Remove)VehicleFlags|(?:AvatarOn)?(?:Link)?SitTarget|Script(?:Danger|Profiler)|Dialog|VolumeDetect|ResetOtherScript|RemoteLoadScriptPin|(?:Open|Close)RemoteDataChannel|SendRemoteData|RemoteDataReply|(?:Integer|String)ToBase64|XorBase64|Log(?:10)?|Base64To(?:String|Integer)|ParseStringKeepNulls|RezAtRoot|RequestSimulatorData|ForceMouselook|(?:Load|Release|(?:E|Une)scape)URL|ParcelMedia(?:CommandList|Query)|ModPow|MapDestination|(?:RemoveFrom|AddTo|Reset)Land(?:Pass|Ban)List|(?:Set|Clear)CameraParams|HTTP(?:Request|Response)|TextBox|DetectedTouch(?:UV|Face|Pos|(?:N|Bin)ormal|ST)|(?:MD5|SHA1|DumpList2)String|Request(?:Secure)?URL|Clear(?:Prim|Link)Media|(?:Link)?ParticleSystem|(?:Get|Request)(?:Username|DisplayName)|RegionSayTo|CastRay|GenerateKey|TransferLindenDollars|ManageEstateAccess|(?:Create|Delete)Character|ExecCharacterCmd|Evade|FleeFrom|NavigateTo|PatrolPoints|Pursue|UpdateCharacter|WanderWithin))\b'
+ lsl_constants_float = r'\b(?:DEG_TO_RAD|PI(?:_BY_TWO)?|RAD_TO_DEG|SQRT2|TWO_PI)\b'
+ lsl_constants_integer = r'\b(?:JSON_APPEND|STATUS_(?:PHYSICS|ROTATE_[XYZ]|PHANTOM|SANDBOX|BLOCK_GRAB(?:_OBJECT)?|(?:DIE|RETURN)_AT_EDGE|CAST_SHADOWS|OK|MALFORMED_PARAMS|TYPE_MISMATCH|BOUNDS_ERROR|NOT_(?:FOUND|SUPPORTED)|INTERNAL_ERROR|WHITELIST_FAILED)|AGENT(?:_(?:BY_(?:LEGACY_|USER)NAME|FLYING|ATTACHMENTS|SCRIPTED|MOUSELOOK|SITTING|ON_OBJECT|AWAY|WALKING|IN_AIR|TYPING|CROUCHING|BUSY|ALWAYS_RUN|AUTOPILOT|LIST_(?:PARCEL(?:_OWNER)?|REGION)))?|CAMERA_(?:PITCH|DISTANCE|BEHINDNESS_(?:ANGLE|LAG)|(?:FOCUS|POSITION)(?:_(?:THRESHOLD|LOCKED|LAG))?|FOCUS_OFFSET|ACTIVE)|ANIM_ON|LOOP|REVERSE|PING_PONG|SMOOTH|ROTATE|SCALE|ALL_SIDES|LINK_(?:ROOT|SET|ALL_(?:OTHERS|CHILDREN)|THIS)|ACTIVE|PASSIVE|SCRIPTED|CONTROL_(?:FWD|BACK|(?:ROT_)?(?:LEFT|RIGHT)|UP|DOWN|(?:ML_)?LBUTTON)|PERMISSION_(?:RETURN_OBJECTS|DEBIT|OVERRIDE_ANIMATIONS|SILENT_ESTATE_MANAGEMENT|TAKE_CONTROLS|TRIGGER_ANIMATION|ATTACH|CHANGE_LINKS|(?:CONTROL|TRACK)_CAMERA|TELEPORT)|INVENTORY_(?:TEXTURE|SOUND|OBJECT|SCRIPT|LANDMARK|CLOTHING|NOTECARD|BODYPART|ANIMATION|GESTURE|ALL|NONE)|CHANGED_(?:INVENTORY|COLOR|SHAPE|SCALE|TEXTURE|LINK|ALLOWED_DROP|OWNER|REGION(?:_START)?|TELEPORT|MEDIA)|OBJECT_(?:(?:PHYSICS|SERVER|STREAMING)_COST|UNKNOWN_DETAIL|CHARACTER_TIME|PHANTOM|PHYSICS|TEMP_ON_REZ|NAME|DESC|POS|PRIM_EQUIVALENCE|RETURN_(?:PARCEL(?:_OWNER)?|REGION)|ROO?T|VELOCITY|OWNER|GROUP|CREATOR|ATTACHED_POINT|RENDER_WEIGHT|PATHFINDING_TYPE|(?:RUNNING|TOTAL)_SCRIPT_COUNT|SCRIPT_(?:MEMORY|TIME))|TYPE_(?:INTEGER|FLOAT|STRING|KEY|VECTOR|ROTATION|INVALID)|(?:DEBUG|PUBLIC)_CHANNEL|ATTACH_(?:AVATAR_CENTER|CHEST|HEAD|BACK|PELVIS|MOUTH|CHIN|NECK|NOSE|BELLY|[LR](?:SHOULDER|HAND|FOOT|EAR|EYE|[UL](?:ARM|LEG)|HIP)|(?:LEFT|RIGHT)_PEC|HUD_(?:CENTER_[12]|TOP_(?:RIGHT|CENTER|LEFT)|BOTTOM(?:_(?:RIGHT|LEFT))?))|LAND_(?:LEVEL|RAISE|LOWER|SMOOTH|NOISE|REVERT)|DATA_(?:ONLINE|NAME|BORN|SIM_(?:POS|STATUS|RATING)|PAYINFO)|PAYMENT_INFO_(?:ON_FILE|USED)|REMOTE_DATA_(?:CHANNEL|REQUEST|REPLY)|PSYS_(?:PART_(?:BF_(?:ZERO|ONE(?:_MINUS_(?:DEST_COLOR|SOURCE_(ALPHA|COLOR)))?|DEST_COLOR|SOURCE_(ALPHA|COLOR))|BLEND_FUNC_(DEST|SOURCE)|FLAGS|(?:START|END)_(?:COLOR|ALPHA|SCALE|GLOW)|MAX_AGE|(?:RIBBON|WIND|INTERP_(?:COLOR|SCALE)|BOUNCE|FOLLOW_(?:SRC|VELOCITY)|TARGET_(?:POS|LINEAR)|EMISSIVE)_MASK)|SRC_(?:MAX_AGE|PATTERN|ANGLE_(?:BEGIN|END)|BURST_(?:RATE|PART_COUNT|RADIUS|SPEED_(?:MIN|MAX))|ACCEL|TEXTURE|TARGET_KEY|OMEGA|PATTERN_(?:DROP|EXPLODE|ANGLE(?:_CONE(?:_EMPTY)?)?)))|VEHICLE_(?:REFERENCE_FRAME|TYPE_(?:NONE|SLED|CAR|BOAT|AIRPLANE|BALLOON)|(?:LINEAR|ANGULAR)_(?:FRICTION_TIMESCALE|MOTOR_DIRECTION)|LINEAR_MOTOR_OFFSET|HOVER_(?:HEIGHT|EFFICIENCY|TIMESCALE)|BUOYANCY|(?:LINEAR|ANGULAR)_(?:DEFLECTION_(?:EFFICIENCY|TIMESCALE)|MOTOR_(?:DECAY_)?TIMESCALE)|VERTICAL_ATTRACTION_(?:EFFICIENCY|TIMESCALE)|BANKING_(?:EFFICIENCY|MIX|TIMESCALE)|FLAG_(?:NO_DEFLECTION_UP|LIMIT_(?:ROLL_ONLY|MOTOR_UP)|HOVER_(?:(?:WATER|TERRAIN|UP)_ONLY|GLOBAL_HEIGHT)|MOUSELOOK_(?:STEER|BANK)|CAMERA_DECOUPLED))|PRIM_(?:TYPE(?:_(?:BOX|CYLINDER|PRISM|SPHERE|TORUS|TUBE|RING|SCULPT))?|HOLE_(?:DEFAULT|CIRCLE|SQUARE|TRIANGLE)|MATERIAL(?:_(?:STONE|METAL|GLASS|WOOD|FLESH|PLASTIC|RUBBER))?|SHINY_(?:NONE|LOW|MEDIUM|HIGH)|BUMP_(?:NONE|BRIGHT|DARK|WOOD|BARK|BRICKS|CHECKER|CONCRETE|TILE|STONE|DISKS|GRAVEL|BLOBS|SIDING|LARGETILE|STUCCO|SUCTION|WEAVE)|TEXGEN_(?:DEFAULT|PLANAR)|SCULPT_(?:TYPE_(?:SPHERE|TORUS|PLANE|CYLINDER|MASK)|FLAG_(?:MIRROR|INVERT))|PHYSICS(?:_(?:SHAPE_(?:CONVEX|NONE|PRIM|TYPE)))?|(?:POS|ROT)_LOCAL|SLICE|TEXT|FLEXIBLE|POINT_LIGHT|TEMP_ON_REZ|PHANTOM|POSITION|SIZE|ROTATION|TEXTURE|NAME|OMEGA|DESC|LINK_TARGET|COLOR|BUMP_SHINY|FULLBRIGHT|TEXGEN|GLOW|MEDIA_(?:ALT_IMAGE_ENABLE|CONTROLS|(?:CURRENT|HOME)_URL|AUTO_(?:LOOP|PLAY|SCALE|ZOOM)|FIRST_CLICK_INTERACT|(?:WIDTH|HEIGHT)_PIXELS|WHITELIST(?:_ENABLE)?|PERMS_(?:INTERACT|CONTROL)|PARAM_MAX|CONTROLS_(?:STANDARD|MINI)|PERM_(?:NONE|OWNER|GROUP|ANYONE)|MAX_(?:URL_LENGTH|WHITELIST_(?:SIZE|COUNT)|(?:WIDTH|HEIGHT)_PIXELS)))|MASK_(?:BASE|OWNER|GROUP|EVERYONE|NEXT)|PERM_(?:TRANSFER|MODIFY|COPY|MOVE|ALL)|PARCEL_(?:MEDIA_COMMAND_(?:STOP|PAUSE|PLAY|LOOP|TEXTURE|URL|TIME|AGENT|UNLOAD|AUTO_ALIGN|TYPE|SIZE|DESC|LOOP_SET)|FLAG_(?:ALLOW_(?:FLY|(?:GROUP_)?SCRIPTS|LANDMARK|TERRAFORM|DAMAGE|CREATE_(?:GROUP_)?OBJECTS)|USE_(?:ACCESS_(?:GROUP|LIST)|BAN_LIST|LAND_PASS_LIST)|LOCAL_SOUND_ONLY|RESTRICT_PUSHOBJECT|ALLOW_(?:GROUP|ALL)_OBJECT_ENTRY)|COUNT_(?:TOTAL|OWNER|GROUP|OTHER|SELECTED|TEMP)|DETAILS_(?:NAME|DESC|OWNER|GROUP|AREA|ID|SEE_AVATARS))|LIST_STAT_(?:MAX|MIN|MEAN|MEDIAN|STD_DEV|SUM(?:_SQUARES)?|NUM_COUNT|GEOMETRIC_MEAN|RANGE)|PAY_(?:HIDE|DEFAULT)|REGION_FLAG_(?:ALLOW_DAMAGE|FIXED_SUN|BLOCK_TERRAFORM|SANDBOX|DISABLE_(?:COLLISIONS|PHYSICS)|BLOCK_FLY|ALLOW_DIRECT_TELEPORT|RESTRICT_PUSHOBJECT)|HTTP_(?:METHOD|MIMETYPE|BODY_(?:MAXLENGTH|TRUNCATED)|CUSTOM_HEADER|PRAGMA_NO_CACHE|VERBOSE_THROTTLE|VERIFY_CERT)|STRING_(?:TRIM(?:_(?:HEAD|TAIL))?)|CLICK_ACTION_(?:NONE|TOUCH|SIT|BUY|PAY|OPEN(?:_MEDIA)?|PLAY|ZOOM)|TOUCH_INVALID_FACE|PROFILE_(?:NONE|SCRIPT_MEMORY)|RC_(?:DATA_FLAGS|DETECT_PHANTOM|GET_(?:LINK_NUM|NORMAL|ROOT_KEY)|MAX_HITS|REJECT_(?:TYPES|AGENTS|(?:NON)?PHYSICAL|LAND))|RCERR_(?:CAST_TIME_EXCEEDED|SIM_PERF_LOW|UNKNOWN)|ESTATE_ACCESS_(?:ALLOWED_(?:AGENT|GROUP)_(?:ADD|REMOVE)|BANNED_AGENT_(?:ADD|REMOVE))|DENSITY|FRICTION|RESTITUTION|GRAVITY_MULTIPLIER|KFM_(?:COMMAND|CMD_(?:PLAY|STOP|PAUSE|SET_MODE)|MODE|FORWARD|LOOP|PING_PONG|REVERSE|DATA|ROTATION|TRANSLATION)|ERR_(?:GENERIC|PARCEL_PERMISSIONS|MALFORMED_PARAMS|RUNTIME_PERMISSIONS|THROTTLED)|CHARACTER_(?:CMD_(?:(?:SMOOTH_)?STOP|JUMP)|DESIRED_(?:TURN_)?SPEED|RADIUS|STAY_WITHIN_PARCEL|LENGTH|ORIENTATION|ACCOUNT_FOR_SKIPPED_FRAMES|AVOIDANCE_MODE|TYPE(?:_(?:[ABCD]|NONE))?|MAX_(?:DECEL|TURN_RADIUS|(?:ACCEL|SPEED)))|PURSUIT_(?:OFFSET|FUZZ_FACTOR|GOAL_TOLERANCE|INTERCEPT)|REQUIRE_LINE_OF_SIGHT|FORCE_DIRECT_PATH|VERTICAL|HORIZONTAL|AVOID_(?:CHARACTERS|DYNAMIC_OBSTACLES|NONE)|PU_(?:EVADE_(?:HIDDEN|SPOTTED)|FAILURE_(?:DYNAMIC_PATHFINDING_DISABLED|INVALID_(?:GOAL|START)|NO_(?:NAVMESH|VALID_DESTINATION)|OTHER|TARGET_GONE|(?:PARCEL_)?UNREACHABLE)|(?:GOAL|SLOWDOWN_DISTANCE)_REACHED)|TRAVERSAL_TYPE(?:_(?:FAST|NONE|SLOW))?|CONTENT_TYPE_(?:ATOM|FORM|HTML|JSON|LLSD|RSS|TEXT|XHTML|XML)|GCNP_(?:RADIUS|STATIC)|(?:PATROL|WANDER)_PAUSE_AT_WAYPOINTS|OPT_(?:AVATAR|CHARACTER|EXCLUSION_VOLUME|LEGACY_LINKSET|MATERIAL_VOLUME|OTHER|STATIC_OBSTACLE|WALKABLE)|SIM_STAT_PCT_CHARS_STEPPED)\b'
+ lsl_constants_integer_boolean = r'\b(?:FALSE|TRUE)\b'
+ lsl_constants_rotation = r'\b(?:ZERO_ROTATION)\b'
+ lsl_constants_string = r'\b(?:EOF|JSON_(?:ARRAY|DELETE|FALSE|INVALID|NULL|NUMBER|OBJECT|STRING|TRUE)|NULL_KEY|TEXTURE_(?:BLANK|DEFAULT|MEDIA|PLYWOOD|TRANSPARENT)|URL_REQUEST_(?:GRANTED|DENIED))\b'
+ lsl_constants_vector = r'\b(?:TOUCH_INVALID_(?:TEXCOORD|VECTOR)|ZERO_VECTOR)\b'
+ lsl_invalid_broken = r'\b(?:LAND_(?:LARGE|MEDIUM|SMALL)_BRUSH)\b'
+ lsl_invalid_deprecated = r'\b(?:ATTACH_[LR]PEC|DATA_RATING|OBJECT_ATTACHMENT_(?:GEOMETRY_BYTES|SURFACE_AREA)|PRIM_(?:CAST_SHADOWS|MATERIAL_LIGHT|TYPE_LEGACY)|PSYS_SRC_(?:INNER|OUTER)ANGLE|VEHICLE_FLAG_NO_FLY_UP|ll(?:Cloud|Make(?:Explosion|Fountain|Smoke|Fire)|RemoteDataSetRegion|Sound(?:Preload)?|XorBase64Strings(?:Correct)?))\b'
+ lsl_invalid_illegal = r'\b(?:event)\b'
+ lsl_invalid_unimplemented = r'\b(?:CHARACTER_(?:MAX_ANGULAR_(?:ACCEL|SPEED)|TURN_SPEED_MULTIPLIER)|PERMISSION_(?:CHANGE_(?:JOINTS|PERMISSIONS)|RELEASE_OWNERSHIP|REMAP_CONTROLS)|PRIM_PHYSICS_MATERIAL|PSYS_SRC_OBJ_REL_MASK|ll(?:CollisionSprite|(?:Stop)?PointAt|(?:(?:Refresh|Set)Prim)URL|(?:Take|Release)Camera|RemoteLoadScript))\b'
+ lsl_reserved_godmode = r'\b(?:ll(?:GodLikeRezObject|Set(?:Inventory|Object)PermMask))\b'
+ lsl_reserved_log = r'\b(?:print)\b'
+ lsl_operators = r'\+\+|\-\-|<<|>>|&&?|\|\|?|\^|~|[!%<>=*+\-\/]=?'
+
+ tokens = {
+ 'root':
+ [
+ (r'//.*?\n', Comment.Single),
+ (r'/\*', Comment.Multiline, 'comment'),
+ (r'"', String.Double, 'string'),
+ (lsl_keywords, Keyword),
+ (lsl_types, Keyword.Type),
+ (lsl_states, Name.Class),
+ (lsl_events, Name.Builtin),
+ (lsl_functions_builtin, Name.Function),
+ (lsl_constants_float, Keyword.Constant),
+ (lsl_constants_integer, Keyword.Constant),
+ (lsl_constants_integer_boolean, Keyword.Constant),
+ (lsl_constants_rotation, Keyword.Constant),
+ (lsl_constants_string, Keyword.Constant),
+ (lsl_constants_vector, Keyword.Constant),
+ (lsl_invalid_broken, Error),
+ (lsl_invalid_deprecated, Error),
+ (lsl_invalid_illegal, Error),
+ (lsl_invalid_unimplemented, Error),
+ (lsl_reserved_godmode, Keyword.Reserved),
+ (lsl_reserved_log, Keyword.Reserved),
+ (r'\b([a-zA-Z_][a-zA-Z0-9_]*)\b', Name.Variable),
+ (r'(\d+\.\d*|\.\d+|\d+)[eE][+-]?\d*', Number.Float),
+ (r'(\d+\.\d*|\.\d+)', Number.Float),
+ (r'0[xX][0-9a-fA-F]+', Number.Hex),
+ (r'\d+', Number.Integer),
+ (lsl_operators, Operator),
+ (r':=?', Error),
+ (r'[,;{}\(\)\[\]]', Punctuation),
+ (r'\n+', Whitespace),
+ (r'\s+', Whitespace)
+ ],
+ 'comment':
+ [
+ (r'[^*/]+', Comment.Multiline),
+ (r'/\*', Comment.Multiline, '#push'),
+ (r'\*/', Comment.Multiline, '#pop'),
+ (r'[*/]', Comment.Multiline)
+ ],
+ 'string':
+ [
+ (r'\\([nt"\\])', String.Escape),
+ (r'"', String.Double, '#pop'),
+ (r'\\.', Error),
+ (r'[^"\\]+', String.Double),
+ ]
+ }
class ECLLexer(RegexLexer):
@@ -1236,9 +1318,9 @@ class ModelicaLexer(RegexLexer):
'root': [
include('whitespace'),
include('keywords'),
+ include('classes'),
include('functions'),
include('operators'),
- include('classes'),
(r'("<html>|<html>)', Name.Tag, 'html-content'),
include('statements'),
],
@@ -1265,9 +1347,9 @@ class ModelicaLexer(RegexLexer):
r'terminate)\b', Name.Builtin),
],
'classes': [
- (r'(block|class|connector|end|function|model|package|'
+ (r'(operator)?(\s+)?(block|class|connector|end|function|model|operator|package|'
r'record|type)(\s+)((?!if|when|while)[A-Za-z_]\w*|[\'][^\']+[\'])([;]?)',
- bygroups(Keyword, Text, Name.Class, Text))
+ bygroups(Keyword, Text, Keyword, Text, Name.Class, Text))
],
'quoted_ident': [
(r'\'', Name, '#pop'),
diff --git a/pygments/lexers/web.py b/pygments/lexers/web.py
index c9f07d06..7d3073f1 100644
--- a/pygments/lexers/web.py
+++ b/pygments/lexers/web.py
@@ -28,7 +28,7 @@ __all__ = ['HtmlLexer', 'XmlLexer', 'JavascriptLexer', 'JsonLexer', 'CssLexer',
'ObjectiveJLexer', 'CoffeeScriptLexer', 'LiveScriptLexer',
'DuelLexer', 'ScamlLexer', 'JadeLexer', 'XQueryLexer',
'DtdLexer', 'DartLexer', 'LassoLexer', 'QmlLexer', 'TypeScriptLexer',
- 'KalLexer', 'CirruLexer', 'MaskLexer']
+ 'KalLexer', 'CirruLexer', 'MaskLexer', 'ZephirLexer']
class JavascriptLexer(RegexLexer):
@@ -4336,5 +4336,68 @@ class MaskLexer(RegexLexer):
'string-double-pop2':[
(r'"', String.Single, '#pop:2'),
include('string-base')
+ ],
+ }
+
+
+class ZephirLexer(RegexLexer):
+ """
+ For `Zephir language <http://zephir-lang.com/>`_ source code.
+
+ Zephir is a compiled high level language aimed
+ to the creation of C-extensions for PHP.
+
+ .. versionadded:: 2.0
+ """
+
+ name = 'Zephir'
+ aliases = ['zephir']
+ filenames = ['*.zep']
+
+ zephir_keywords = [ 'fetch', 'echo', 'isset', 'empty']
+ zephir_type = [ 'bit', 'bits' , 'string' ]
+
+ flags = re.DOTALL | re.MULTILINE
+
+ tokens = {
+ 'commentsandwhitespace': [
+ (r'\s+', Text),
+ (r'//.*?\n', Comment.Single),
+ (r'/\*.*?\*/', Comment.Multiline)
+ ],
+ 'slashstartsregex': [
+ include('commentsandwhitespace'),
+ (r'/(\\.|[^[/\\\n]|\[(\\.|[^\]\\\n])*])+/'
+ r'([gim]+\b|\B)', String.Regex, '#pop'),
+ (r'', Text, '#pop')
+ ],
+ 'badregex': [
+ (r'\n', Text, '#pop')
+ ],
+ 'root': [
+ (r'^(?=\s|/|<!--)', Text, 'slashstartsregex'),
+ include('commentsandwhitespace'),
+ (r'\+\+|--|~|&&|\?|:|\|\||\\(?=\n)|'
+ r'(<<|>>>?|==?|!=?|->|[-<>+*%&\|\^/])=?', Operator, 'slashstartsregex'),
+ (r'[{(\[;,]', Punctuation, 'slashstartsregex'),
+ (r'[})\].]', Punctuation),
+ (r'(for|in|while|do|break|return|continue|switch|case|default|if|else|loop|require|inline|'
+ r'throw|try|catch|finally|new|delete|typeof|instanceof|void|namespace|use|extends|'
+ r'this|fetch|isset|unset|echo|fetch|likely|unlikely|empty)\b', Keyword, 'slashstartsregex'),
+ (r'(var|let|with|function)\b', Keyword.Declaration, 'slashstartsregex'),
+ (r'(abstract|boolean|bool|char|class|const|double|enum|export|'
+ r'extends|final|float|goto|implements|import|int|string|interface|long|ulong|char|uchar|native|unsigned|'
+ r'private|protected|public|short|static|self|throws|reverse|'
+ r'transient|volatile)\b', Keyword.Reserved),
+ (r'(true|false|null|undefined)\b', Keyword.Constant),
+ (r'(Array|Boolean|Date|_REQUEST|_COOKIE|_SESSION|'
+ r'_GET|_POST|_SERVER|this|stdClass|range|count|iterator|'
+ r'window)\b', Name.Builtin),
+ (r'[$a-zA-Z_][a-zA-Z0-9_\\]*', Name.Other),
+ (r'[0-9][0-9]*\.[0-9]+([eE][0-9]+)?[fd]?', Number.Float),
+ (r'0x[0-9a-fA-F]+', Number.Hex),
+ (r'[0-9]+', Number.Integer),
+ (r'"(\\\\|\\"|[^"])*"', String.Double),
+ (r"'(\\\\|\\'|[^'])*'", String.Single),
]
}
diff --git a/tests/examplefiles/hello.lsl b/tests/examplefiles/hello.lsl
new file mode 100644
index 00000000..61697e7f
--- /dev/null
+++ b/tests/examplefiles/hello.lsl
@@ -0,0 +1,12 @@
+default
+{
+ state_entry()
+ {
+ llSay(0, "Hello, Avatar!");
+ }
+
+ touch_start(integer total_number)
+ {
+ llSay(0, "Touched.");
+ }
+}
diff --git a/tests/examplefiles/test.zep b/tests/examplefiles/test.zep
new file mode 100644
index 00000000..4724d4c4
--- /dev/null
+++ b/tests/examplefiles/test.zep
@@ -0,0 +1,33 @@
+namespace Test;
+
+use Test\Foo;
+
+class Bar
+{
+ protected a;
+ private b;
+ public c {set, get};
+
+ public function __construct(string str, boolean bool)
+ {
+ let this->c = str;
+ this->setC(bool);
+ let this->b = [];
+ }
+
+ public function sayHello(string name)
+ {
+ echo "Hello " . name;
+ }
+
+ protected function loops()
+ {
+ for a in b {
+ echo a;
+ }
+ loop {
+ return "boo!";
+ }
+ }
+
+} \ No newline at end of file