summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorthatch <devnull@localhost>2008-08-05 12:50:38 -0700
committerthatch <devnull@localhost>2008-08-05 12:50:38 -0700
commitfc04caa3a2b6b495a301f59fed9379602063326c (patch)
treec41a11ad5389d4368092280bff36f10d1c4354d6
parent4fe95497e7dd7f7d6178db88fca2233cf98c7b13 (diff)
downloadpygments-fc04caa3a2b6b495a301f59fed9379602063326c.tar.gz
POV-Ray lexer provided by pi31 on the irc channel. Clsoes #348.
-rw-r--r--pygments/lexers/_mapping.py1
-rw-r--r--pygments/lexers/other.py89
-rw-r--r--tests/examplefiles/sphere.pov18
-rw-r--r--tests/examplefiles/while.pov13
4 files changed, 120 insertions, 1 deletions
diff --git a/pygments/lexers/_mapping.py b/pygments/lexers/_mapping.py
index feb85860..4892571c 100644
--- a/pygments/lexers/_mapping.py
+++ b/pygments/lexers/_mapping.py
@@ -107,6 +107,7 @@ LEXERS = {
'OcamlLexer': ('pygments.lexers.functional', 'OCaml', ('ocaml',), ('*.ml', '*.mli', '*.mll', '*.mly'), ('text/x-ocaml',)),
'PerlLexer': ('pygments.lexers.agile', 'Perl', ('perl', 'pl'), ('*.pl', '*.pm'), ('text/x-perl', 'application/x-perl')),
'PhpLexer': ('pygments.lexers.web', 'PHP', ('php', 'php3', 'php4', 'php5'), ('*.php', '*.php[345]'), ('text/x-php',)),
+ 'PovrayLexer': ('pygments.lexers.other', 'POVRay', ('pov',), ('*.pov', '*.inc'), ('text/x-povray',)),
'Python3Lexer': ('pygments.lexers.agile', 'Python 3', ('python3', 'py3'), (), ('text/x-python3', 'application/x-python3')),
'PythonConsoleLexer': ('pygments.lexers.agile', 'Python console session', ('pycon',), (), ('text/x-python-doctest',)),
'PythonLexer': ('pygments.lexers.agile', 'Python', ('python', 'py'), ('*.py', '*.pyw', '*.sc', 'SConstruct', 'SConscript'), ('text/x-python', 'application/x-python')),
diff --git a/pygments/lexers/other.py b/pygments/lexers/other.py
index 6fd48bb0..ed018b32 100644
--- a/pygments/lexers/other.py
+++ b/pygments/lexers/other.py
@@ -20,7 +20,8 @@ from pygments.util import shebang_matches
__all__ = ['SqlLexer', 'MySqlLexer', 'BrainfuckLexer', 'BashLexer',
'BatchLexer', 'BefungeLexer', 'RedcodeLexer', 'MOOCodeLexer',
- 'SmalltalkLexer', 'TcshLexer', 'LogtalkLexer', 'GnuplotLexer']
+ 'SmalltalkLexer', 'TcshLexer', 'LogtalkLexer', 'GnuplotLexer',
+ 'PovrayLexer']
class SqlLexer(RegexLexer):
@@ -984,3 +985,89 @@ class GnuplotLexer(RegexLexer):
include('genericargs'),
],
}
+
+
+class PovrayLexer(RegexLexer):
+ """
+ For `Persistence of Vision Raytracer http://www.povray.org/>`_ files.
+
+ *New in Pygments 0.11.*
+ """
+ name = 'POVRay'
+ aliases = ['pov']
+ filenames = ['*.pov', '*.inc']
+ mimetypes = ['text/x-povray']
+
+ tokens = {
+ 'root': [
+ (r'/\*[\w\W]*?\*/', Comment.Multiline),
+ (r'//.*\n', Comment.Single),
+ (r'"(?:\\.|[^"])+"', String.Double),
+ (r'#(debug|default|else|end|error|fclose|fopen|if|ifdef|ifndef|'
+ r'include|range|read|render|statistics|switch|undef|version|'
+ r'warning|while|write|define|macro|local|declare)',
+ Comment.Preproc),
+ (r'\b(aa_level|aa_threshold|abs|acos|acosh|adaptive|adc_bailout|'
+ r'agate|agate_turb|all|alpha|ambient|ambient_light|angle|'
+ r'aperture|arc_angle|area_light|asc|asin|asinh|assumed_gamma|'
+ r'atan|atan2|atanh|atmosphere|atmospheric_attenuation|'
+ r'attenuating|average|background|black_hole|blue|blur_samples|'
+ r'bounded_by|box_mapping|bozo|break|brick|brick_size|'
+ r'brightness|brilliance|bumps|bumpy1|bumpy2|bumpy3|bump_map|'
+ r'bump_size|case|caustics|ceil|checker|chr|clipped_by|clock|'
+ r'color|color_map|colour|colour_map|component|composite|concat|'
+ r'confidence|conic_sweep|constant|control0|control1|cos|cosh|'
+ r'count|crackle|crand|cube|cubic_spline|cylindrical_mapping|'
+ r'debug|declare|default|degrees|dents|diffuse|direction|'
+ r'distance|distance_maximum|div|dust|dust_type|eccentricity|'
+ r'else|emitting|end|error|error_bound|exp|exponent|'
+ r'fade_distance|fade_power|falloff|falloff_angle|false|'
+ r'file_exists|filter|finish|fisheye|flatness|flip|floor|'
+ r'focal_point|fog|fog_alt|fog_offset|fog_type|frequency|gif|'
+ r'global_settings|glowing|gradient|granite|gray_threshold|'
+ r'green|halo|hexagon|hf_gray_16|hierarchy|hollow|hypercomplex|'
+ r'if|ifdef|iff|image_map|incidence|include|int|interpolate|'
+ r'inverse|ior|irid|irid_wavelength|jitter|lambda|leopard|'
+ r'linear|linear_spline|linear_sweep|location|log|looks_like|'
+ r'look_at|low_error_factor|mandel|map_type|marble|material_map|'
+ r'matrix|max|max_intersections|max_iteration|max_trace_level|'
+ r'max_value|metallic|min|minimum_reuse|mod|mortar|'
+ r'nearest_count|no|normal|normal_map|no_shadow|number_of_waves|'
+ r'octaves|off|offset|omega|omnimax|on|once|onion|open|'
+ r'orthographic|panoramic|pattern1|pattern2|pattern3|'
+ r'perspective|pgm|phase|phong|phong_size|pi|pigment|'
+ r'pigment_map|planar_mapping|png|point_at|pot|pow|ppm|'
+ r'precision|pwr|quadratic_spline|quaternion|quick_color|'
+ r'quick_colour|quilted|radial|radians|radiosity|radius|rainbow|'
+ r'ramp_wave|rand|range|reciprocal|recursion_limit|red|'
+ r'reflection|refraction|render|repeat|rgb|rgbf|rgbft|rgbt|'
+ r'right|ripples|rotate|roughness|samples|scale|scallop_wave|'
+ r'scattering|seed|shadowless|sin|sine_wave|sinh|sky|sky_sphere|'
+ r'slice|slope_map|smooth|specular|spherical_mapping|spiral|'
+ r'spiral1|spiral2|spotlight|spotted|sqr|sqrt|statistics|str|'
+ r'strcmp|strength|strlen|strlwr|strupr|sturm|substr|switch|sys|'
+ r't|tan|tanh|test_camera_1|test_camera_2|test_camera_3|'
+ r'test_camera_4|texture|texture_map|tga|thickness|threshold|'
+ r'tightness|tile2|tiles|track|transform|translate|transmit|'
+ r'triangle_wave|true|ttf|turbulence|turb_depth|type|'
+ r'ultra_wide_angle|up|use_color|use_colour|use_index|u_steps|'
+ r'val|variance|vaxis_rotate|vcross|vdot|version|vlength|'
+ r'vnormalize|volume_object|volume_rendered|vol_with_light|'
+ r'vrotate|v_steps|warning|warp|water_level|waves|while|width|'
+ r'wood|wrinkles|yes)\b', Keyword),
+ (r'bicubic_patch|blob|box|camera|cone|cubic|cylinder|difference|'
+ r'disc|height_field|intersection|julia_fractal|lathe|'
+ r'light_source|merge|mesh|object|plane|poly|polygon|prism|'
+ r'quadric|quartic|smooth_triangle|sor|sphere|superellipsoid|'
+ r'text|torus|triangle|union', Name.Builtin),
+ #TODO: <=, etc
+ (r'[\[\](){}<>;,]', Punctuation),
+ (r'[-+*/=]', Operator),
+ (r'\b(x|y|z|u|v)\b', Name.Builtin.Pseudo),
+ (r'[a-zA-Z_][a-zA-Z_0-9]*', Name),
+ (r'[0-9]+\.[0-9]*', Number.Float),
+ (r'\.[0-9]+', Number.Float),
+ (r'[0-9]+', Number.Integer),
+ (r'\s+', Text),
+ ]
+ }
diff --git a/tests/examplefiles/sphere.pov b/tests/examplefiles/sphere.pov
new file mode 100644
index 00000000..847ed451
--- /dev/null
+++ b/tests/examplefiles/sphere.pov
@@ -0,0 +1,18 @@
+#include "colors.inc"
+
+background { color Cyan }
+
+camera {
+ location <0, 2, -3>
+ look_at <0, 1, 2>
+}
+
+sphere {
+ <0, 1, 2>, 2
+ texture {
+ pigment { color Yellow }
+ }
+}
+
+light_source { <2, 4, -3> color White}
+
diff --git a/tests/examplefiles/while.pov b/tests/examplefiles/while.pov
new file mode 100644
index 00000000..fb182454
--- /dev/null
+++ b/tests/examplefiles/while.pov
@@ -0,0 +1,13 @@
+#declare Index1 = 0;
+#while(Index1 <= 9)
+
+ #declare Index2 = 0;
+ #while(Index2 <= 19)
+
+ sphere { <Index1, Index2, 0>, .5 }
+
+ #declare Index2 = Index2 + 1;
+ #end
+
+ #declare Index1 = Index1 + 1;
+#end