summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVincentZurczak <devnull@localhost>2015-02-20 14:10:08 +0100
committerVincentZurczak <devnull@localhost>2015-02-20 14:10:08 +0100
commit12a789a4608049824edbc66376c6366ccdc401e5 (patch)
treece05ad993b1f922c6255ce900e25de87d83d8ef1
parent2993eb7a2275211bd4e156a5013be2f3f501a5d3 (diff)
downloadpygments-12a789a4608049824edbc66376c6366ccdc401e5.tar.gz
Support Roboconf's DSL
-rw-r--r--.hgignore1
-rw-r--r--AUTHORS1
-rwxr-xr-xpygments/formatters/_mapping.py1
-rw-r--r--pygments/lexers/_mapping.py2
-rw-r--r--pygments/lexers/roboconf.py57
-rw-r--r--tests/examplefiles/roboconf.graph40
-rw-r--r--tests/examplefiles/roboconf.instances24
7 files changed, 125 insertions, 1 deletions
diff --git a/.hgignore b/.hgignore
index 6fd21b49..17e6d700 100644
--- a/.hgignore
+++ b/.hgignore
@@ -9,6 +9,7 @@ Pygments.egg-info/*
.ropeproject
tests/examplefiles/output
.idea/
+.project
.tags
TAGS
tests/.coverage
diff --git a/AUTHORS b/AUTHORS
index 06119231..3513a469 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -170,5 +170,6 @@ Other contributors, listed alphabetically, are:
* Enrique Zamudio -- Ceylon lexer
* Alex Zimin -- Nemerle lexer
* Rob Zimmerman -- Kal lexer
+* Vincent Zurczak -- Roboconf lexer
Many thanks for all contributions!
diff --git a/pygments/formatters/_mapping.py b/pygments/formatters/_mapping.py
index f01206e0..bfc82253 100755
--- a/pygments/formatters/_mapping.py
+++ b/pygments/formatters/_mapping.py
@@ -32,7 +32,6 @@ FORMATTERS = {
'TestcaseFormatter': ('pygments.formatters.other', 'Testcase', ('testcase',), (), 'Format tokens as appropriate for a new testcase.')
}
-
if __name__ == '__main__': # pragma: no cover
import sys
import os
diff --git a/pygments/lexers/_mapping.py b/pygments/lexers/_mapping.py
index dcaefb48..bca29783 100644
--- a/pygments/lexers/_mapping.py
+++ b/pygments/lexers/_mapping.py
@@ -305,6 +305,8 @@ LEXERS = {
'ResourceLexer': ('pygments.lexers.resource', 'ResourceBundle', ('resource', 'resourcebundle'), ('*.txt',), ()),
'RexxLexer': ('pygments.lexers.scripting', 'Rexx', ('rexx', 'arexx'), ('*.rexx', '*.rex', '*.rx', '*.arexx'), ('text/x-rexx',)),
'RhtmlLexer': ('pygments.lexers.templates', 'RHTML', ('rhtml', 'html+erb', 'html+ruby'), ('*.rhtml',), ('text/html+ruby',)),
+ 'RoboconfGraphLexer': ('pygments.lexers.roboconf', 'Roboconf Graph', ('roboconf-graph',), ('*.graph',), ()),
+ 'RoboconfInstancesLexer': ('pygments.lexers.roboconf', 'Roboconf Instances', ('roboconf-instances',), ('*.instances',), ()),
'RobotFrameworkLexer': ('pygments.lexers.robotframework', 'RobotFramework', ('robotframework',), ('*.txt', '*.robot'), ('text/x-robotframework',)),
'RqlLexer': ('pygments.lexers.sql', 'RQL', ('rql',), ('*.rql',), ('text/x-rql',)),
'RslLexer': ('pygments.lexers.dsls', 'RSL', ('rsl',), ('*.rsl',), ('text/rsl',)),
diff --git a/pygments/lexers/roboconf.py b/pygments/lexers/roboconf.py
new file mode 100644
index 00000000..e3e8a836
--- /dev/null
+++ b/pygments/lexers/roboconf.py
@@ -0,0 +1,57 @@
+from pygments.lexer import RegexLexer, words, bygroups, re, include
+from pygments.token import *
+
+__all__ = ['RoboconfGraphLexer', 'RoboconfInstancesLexer']
+
+class RoboconfGraphLexer(RegexLexer):
+ name = 'Roboconf Graph'
+ aliases = ['roboconf-graph']
+ filenames = ['*.graph']
+
+ flags = re.IGNORECASE | re.MULTILINE
+ tokens = {
+ 'root': [
+ # Skip white spaces
+ (r'\s+', Text),
+
+ # There is one operator
+ (r'=',Operator),
+
+ # Keywords
+ (words(('facet', 'import'), suffix=r'\s*\b', prefix=r'\b'), Keyword),
+ (words(('installer', 'extends', 'exports', 'imports', 'facets', 'children'), suffix=r'\s*:?', prefix=r'\b'), Name),
+
+ # Comments
+ (r'#.*\n', Comment),
+
+ # Default
+ (r'[^#]', Text),
+ (r'.*\n', Text)
+ ]
+ }
+
+class RoboconfInstancesLexer(RegexLexer):
+ name = 'Roboconf Instances'
+ aliases = ['roboconf-instances']
+ filenames = ['*.instances']
+
+ flags = re.IGNORECASE | re.MULTILINE
+ tokens = {
+ 'root': [
+
+ # Skip white spaces
+ (r'\s+', Text),
+
+ # Keywords
+ (words(('instance of', 'import'), suffix=r'\s*\b', prefix=r'\b'), Keyword),
+ (words(('name', 'count'), suffix=r's*:?', prefix=r'\b'), Name),
+ (r'\s*[\w.-]+\s*:', Name),
+
+ # Comments
+ (r'#.*\n', Comment),
+
+ # Default
+ (r'[^#]', Text),
+ (r'.*\n', Text)
+ ]
+ }
diff --git a/tests/examplefiles/roboconf.graph b/tests/examplefiles/roboconf.graph
new file mode 100644
index 00000000..e5fdedff
--- /dev/null
+++ b/tests/examplefiles/roboconf.graph
@@ -0,0 +1,40 @@
+##################
+# A sample graph
+##################
+
+import some-definition.graph;
+import another-definition.graph;
+
+VM {
+ installer : target;
+ children: deployable;
+}
+
+facet deployable {
+ # nothing
+}
+
+# Sample deployables
+mysql {
+ insTaller: puppet;
+ facets: deployable;
+ exports: ip, port = 3306;
+}
+
+tomcat {
+ installer: bash;
+ facets: deployable;
+ exports: ip;
+ children: web-application;
+}
+
+facet web-application {
+ exports: full-path = undefined;
+}
+
+my-war-1 {
+ facets: web-application;
+ installer: file;
+ exports: full-path = apps/my-war-1; # the relative path
+ imports: mysql.*;
+}
diff --git a/tests/examplefiles/roboconf.instances b/tests/examplefiles/roboconf.instances
new file mode 100644
index 00000000..c69a2ab0
--- /dev/null
+++ b/tests/examplefiles/roboconf.instances
@@ -0,0 +1,24 @@
+
+# Deal with imports
+import others.instances;
+
+instance of VM {
+ name: VM-mysql;
+ instance of mysql {
+ name: MySQL;
+ }
+}
+
+instance of VM {
+ name: VM ;
+ count: 5;
+
+ INSTANCE of tomcat {
+ name: Tomcat;
+
+ instance of my-war-1 {
+ name: my-war-1;
+ full-path: apps/my-war;
+ }
+ }
+}