summaryrefslogtreecommitdiff
path: root/pygments
diff options
context:
space:
mode:
authorGusakov Nikita <dev@nkt.me>2014-02-16 21:09:40 +0400
committerGusakov Nikita <dev@nkt.me>2014-02-16 21:09:40 +0400
commitc185cdf3bee199db573c436723b366b1803c4980 (patch)
treeb94f815bacbe98e8bc366269352295a57ab74e42 /pygments
parent76a3e173102b440ae5566be2fb01507ad1c423cc (diff)
downloadpygments-c185cdf3bee199db573c436723b366b1803c4980.tar.gz
Add zephir lexer and test
Diffstat (limited to 'pygments')
-rw-r--r--pygments/lexers/web.py60
1 files changed, 59 insertions, 1 deletions
diff --git a/pygments/lexers/web.py b/pygments/lexers/web.py
index 9a714638..c458a420 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']
+ 'KalLexer', 'CirruLexer', 'ZephirLexer']
class JavascriptLexer(RegexLexer):
@@ -4222,3 +4222,61 @@ class CirruLexer(RegexLexer):
(r'^\s+$', Text.Whitespace),
]
}
+
+class ZephirLexer(RegexLexer):
+ """
+ For Zephir language
+ Zephir is a compiled high level language aimed
+ to the creation of C-extensions for PHP http://zephir-lang.com/
+ """
+
+ name = 'Zephir'
+ aliases = ['zephir']
+ filenames = ['*.zep']
+
+ zephir_keywords = [ 'fetch', 'echo', 'isset', 'empty']
+ zephir_type = [ 'bit', 'bits' , 'string' ]
+
+ flags = re.DOTALL
+ 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),
+ ]
+ }