summaryrefslogtreecommitdiff
path: root/pygments/lexers
diff options
context:
space:
mode:
authorjiyinyiyong <jiyinyiyong@gmail.com>2014-01-10 23:47:52 +0800
committerjiyinyiyong <jiyinyiyong@gmail.com>2014-01-10 23:47:52 +0800
commite120e69954bd6c3a61540636b3bb44b03f3280dd (patch)
treef30567242ba581d2944f43fc20fb9a6dcbc05fca /pygments/lexers
parent1fede84d263990555cc90d585642e8c338f47b3d (diff)
downloadpygments-e120e69954bd6c3a61540636b3bb44b03f3280dd.tar.gz
add syntax for Cirru
Diffstat (limited to 'pygments/lexers')
-rw-r--r--pygments/lexers/_mapping.py1
-rw-r--r--pygments/lexers/web.py52
2 files changed, 52 insertions, 1 deletions
diff --git a/pygments/lexers/_mapping.py b/pygments/lexers/_mapping.py
index 15fdbf8a..da5338af 100644
--- a/pygments/lexers/_mapping.py
+++ b/pygments/lexers/_mapping.py
@@ -61,6 +61,7 @@ LEXERS = {
'CheetahJavascriptLexer': ('pygments.lexers.templates', 'JavaScript+Cheetah', ('js+cheetah', 'javascript+cheetah', 'js+spitfire', 'javascript+spitfire'), (), ('application/x-javascript+cheetah', 'text/x-javascript+cheetah', 'text/javascript+cheetah', 'application/x-javascript+spitfire', 'text/x-javascript+spitfire', 'text/javascript+spitfire')),
'CheetahLexer': ('pygments.lexers.templates', 'Cheetah', ('cheetah', 'spitfire'), ('*.tmpl', '*.spt'), ('application/x-cheetah', 'application/x-spitfire')),
'CheetahXmlLexer': ('pygments.lexers.templates', 'XML+Cheetah', ('xml+cheetah', 'xml+spitfire'), (), ('application/xml+cheetah', 'application/xml+spitfire')),
+ 'CirruLexer': ('pygments.lexers.web', 'Cirru', ('cirru',), ('*.cirru',), ('text/x-cirru',)),
'ClayLexer': ('pygments.lexers.compiled', 'Clay', ('clay',), ('*.clay',), ('text/x-clay',)),
'ClojureLexer': ('pygments.lexers.jvm', 'Clojure', ('clojure', 'clj'), ('*.clj',), ('text/x-clojure', 'application/x-clojure')),
'CobolFreeformatLexer': ('pygments.lexers.compiled', 'COBOLFree', ('cobolfree',), ('*.cbl', '*.CBL'), ()),
diff --git a/pygments/lexers/web.py b/pygments/lexers/web.py
index dddaffe5..6f512e1a 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']
+ 'KalLexer', 'CirruLexer']
class JavascriptLexer(RegexLexer):
@@ -4166,3 +4166,53 @@ class QmlLexer(RegexLexer):
(r"'(\\\\|\\'|[^'])*'", String.Single),
]
}
+
+class CirruLexer(RegexLexer):
+ """
+ Syntax rules of Cirru can be found at:
+ http://grammar.cirru.org/
+
+ * using `()` to markup blocks, but limited in the same line
+ * using `""` to markup strings, allow `\` to escape
+ * using `$` as a shorthand for `()` till indentation end or `)`
+ * using indentations for create nesting
+ """
+
+ name = 'Cirru'
+ aliases = ['cirru']
+ filenames = ['*.cirru', '*.cr']
+ mimetypes = ['text/x-cirru']
+ flags = re.MULTILINE
+
+ tokens = {
+ 'string': [
+ (r'[^"\\\n]', String),
+ (r'\\"', String),
+ (r'\\', String),
+ (r'"', String, '#pop'),
+ ],
+ 'function': [
+ (r'[\w-][^\s\(\)\"]*', Name.Function, '#pop'),
+ (r'\)', Operator, '#pop'),
+ (r'(?=\n)', Text.Whitespace, '#pop'),
+ (r'\(', Operator, '#push'),
+ (r'"', String, ('#pop', 'string')),
+ (r'\s+', Text.Whitespace),
+ ],
+ 'line': [
+ (r'^\B', Text.Whitespace, 'function'),
+ (r'\$', Operator, 'function'),
+ (r'\(', Operator, 'function'),
+ (r'\)', Operator),
+ (r'(?=\n)', Text.Whitespace, '#pop'),
+ (r'\n', Text.Whitespace, '#pop'),
+ (r'"', String, 'string'),
+ (r'\s+', Text.Whitespace),
+ (r'[\d\.]+', Number),
+ (r'[\w-][^\"\(\)\s]*', Name.Variable),
+ ],
+ 'root': [
+ (r'^\s*', Text.Whitespace, ('line', 'function')),
+ (r'^\s+$', Text.Whitespace),
+ ]
+ } \ No newline at end of file