diff options
author | Michael Galloy <mgalloy@gmail.com> | 2012-10-04 19:10:40 -0600 |
---|---|---|
committer | Michael Galloy <mgalloy@gmail.com> | 2012-10-04 19:10:40 -0600 |
commit | f4fbeca713efdfe7007ad37f7ba3ffe68517798c (patch) | |
tree | a3bbe40cef550a7da1cb8b69810a5942524a3652 | |
parent | 520215091a7b8e4dad1da581b76d10e1d8faf67c (diff) | |
download | pygments-f4fbeca713efdfe7007ad37f7ba3ffe68517798c.tar.gz |
Basic IDL lexer.
-rw-r--r-- | pygments/lexers/_mapping.py | 1 | ||||
-rw-r--r-- | pygments/lexers/math.py | 236 |
2 files changed, 236 insertions, 1 deletions
diff --git a/pygments/lexers/_mapping.py b/pygments/lexers/_mapping.py index ad44fd4b..05177211 100644 --- a/pygments/lexers/_mapping.py +++ b/pygments/lexers/_mapping.py @@ -121,6 +121,7 @@ LEXERS = { 'HtmlSmartyLexer': ('pygments.lexers.templates', 'HTML+Smarty', ('html+smarty',), (), ('text/html+smarty',)), 'HttpLexer': ('pygments.lexers.text', 'HTTP', ('http',), (), ()), 'HybrisLexer': ('pygments.lexers.other', 'Hybris', ('hybris', 'hy'), ('*.hy', '*.hyb'), ('text/x-hybris', 'application/x-hybris')), + 'IDLLexer': ('pygments.lexers.math', 'IDL', ('idl',), ('*.pro',), ('text/idl',)), 'IniLexer': ('pygments.lexers.text', 'INI', ('ini', 'cfg'), ('*.ini', '*.cfg'), ('text/x-ini',)), 'IoLexer': ('pygments.lexers.agile', 'Io', ('io',), ('*.io',), ('text/x-iosrc',)), 'IokeLexer': ('pygments.lexers.jvm', 'Ioke', ('ioke', 'ik'), ('*.ik',), ('text/x-iokesrc',)), diff --git a/pygments/lexers/math.py b/pygments/lexers/math.py index fb39abaf..460028b1 100644 --- a/pygments/lexers/math.py +++ b/pygments/lexers/math.py @@ -21,7 +21,8 @@ from pygments.lexers import _scilab_builtins __all__ = ['JuliaLexer', 'JuliaConsoleLexer', 'MuPADLexer', 'MatlabLexer', 'MatlabSessionLexer', 'OctaveLexer', 'ScilabLexer', 'NumPyLexer', - 'RConsoleLexer', 'SLexer', 'JagsLexer', 'BugsLexer', 'StanLexer'] + 'RConsoleLexer', 'SLexer', 'JagsLexer', 'BugsLexer', 'StanLexer', + 'IDLLexer'] class JuliaLexer(RegexLexer): @@ -1383,3 +1384,236 @@ class StanLexer(RegexLexer): else: return 0.0 +class IDLLexer(RegexLexer): + """ + Pygments Lexer for IDL (Interactive Data Language). + """ + name = 'IDL' + aliases = ['idl'] + filenames = ['*.pro'] + mimetypes = ['text/idl'] + + _RESERVED = ['begin', 'break', 'case', 'catch', 'common', 'compile_opt', + 'continue', 'do', 'else', 'end', 'endcase', 'endelse', + 'endfor', 'endforeach', 'endif', 'endrep', 'endswitch', + 'endwhile', 'for', 'foreach', 'forward_function', 'function', + 'goto', 'if', + 'inherits', 'of', 'pro', 'repeat', 'return', 'stop', + 'switch', 'then', + 'until', 'while'] + _BUILTIN_LIB = ['abs', 'acos', 'adapt_hist_equal', 'alog', 'alog10', + 'amoeba', 'annotate', 'app_user_dir', 'app_user_dir_query', + 'arg_present', 'array_equal', 'array_indices', 'arrow', + 'ascii_template', 'asin', 'assoc', 'atan', 'axis', + 'a_correlate', 'bar_plot', 'barplot', 'beseli', 'beselj', + 'beselk', 'besely', 'beta', 'bilinear', 'binary_template', + 'bindgen', 'binomial', 'bin_date', 'bit_ffs', + 'bit_population', 'blas_axpy', 'blk_con', 'box_cursor', + 'breakpoint', 'broyden', 'butterworth', 'bytarr', + 'byte', 'byteorder', 'bytscl', 'canny', 'caldat', + 'calendar', 'call_external', 'call_function', 'call_method', + 'call_procedure', 'case', 'catch', 'cd', + 'cdf_[0-9a-za-z_]*', + 'ceil', 'chebyshev', 'check_math', 'chisqr_cvf', + 'chisqr_pdf', 'choldc', 'cholsol', 'cindgen', 'cir_3pnt', + 'close', 'cluster', 'cluster_tree', 'clust_wts', + 'cmyk_convert', 'colormap_applicable', 'color_convert', + 'color_exchange', 'color_quan', 'color_range_map', + 'colorbar', 'colorize_sample', 'colormap_gradient', + 'colormap_rotation', 'comfit', 'command_line_args', + 'common', 'complex', 'complexarr', + 'complexround', 'compute_mesh_normals', 'cond', 'congrid', + 'conj', 'constrained_min', 'continue', 'contour', + 'convert_coord', 'convol', 'coord2to3', 'copy_lun', + 'correlate', 'cos', 'cosh', 'cpu', 'cramer', + 'create_cursor', 'create_struct', 'create_view', + 'crossp', 'crvlength', 'cti_test', 'ct_luminance', 'cursor', + 'curvefit', 'cvttobm', 'cv_coord', 'cw_animate', + 'cw_animate_getp', 'cw_animate_load', 'cw_animate_run', + 'cw_arcball', 'cw_bgroup', 'cw_clr_index', 'cw_colorsel', + 'cw_defroi', 'cw_field', 'cw_filesel', 'cw_form', + 'cw_fslider', 'cw_light_editor', 'cw_light_editor_get', + 'cw_light_editor_set', 'cw_orient', 'cw_palette_editor', + 'cw_palette_editor_get', 'cw_palette_editor_set', + 'cw_pdmenu', 'cw_rgbslider', 'cw_tmpl', 'cw_zoom', + 'c_correlate', 'dblarr', 'dcindgen', 'dcomplex', + 'dcomplexarr', 'define_key', 'define_msgblk', + 'define_msgblk_from_file', 'defroi', 'defsysv', 'delvar', + 'dendrogram', 'dendro_plot', 'deriv', 'derivsig', 'determ', + 'device', 'dfpmin', 'diag_matrix', 'dialog_message', + 'dialog_pickfile', 'dialog_printersetup', 'dialog_printjob', + 'dialog_read_image', 'dialog_write_image', + 'dicomex_getconfigfilepath', 'dicomex_getstorscpdir', + 'dicomex_net', 'digital_filter', 'dilate', 'dindgen', + 'dissolve', 'dist', 'distance_measure', 'dlm_load', + 'dlm_register', 'doc_library', 'double', 'draw_roi', + 'edge_dog', 'efont', 'eigenql', 'eigenvec', 'ellipse', + 'elmhes', 'emboss', 'empty', 'enable_sysrtn', 'eof', + 'eos_[0-9a-za-z_]*', 'erase', 'erf', 'erfc', 'erfcx', + 'erode', 'errplot', 'errorplot', 'execute', 'exit', 'exp', + 'expand', 'expand_path', 'expint', 'extrac', + 'extract_slice', 'factorial', 'fft', 'filepath', + 'file_basename', 'file_chmod', 'file_copy', 'file_delete', + 'file_dirname', 'file_expand_path', 'file_info', + 'file_lines', 'file_link', 'file_mkdir', 'file_move', + 'file_poll_input', 'file_readlink', 'file_same', + 'file_search', 'file_test', 'file_which', 'findgen', + 'finite', 'fix', 'flick', 'float', 'floor', 'flow3', + 'fltarr', 'flush', 'format_axis_values', + 'forward_function', 'free_lun', 'fstat', 'fulstr', 'funct', + 'fv_test', 'fx_root', 'fz_roots', 'f_cvf', + 'f_pdf', 'gamma', 'gamma_ct', 'gauss2dfit', 'gaussfit', + 'gaussint', 'gauss_cvf', 'gauss_pdf', 'getenv', + 'get_drive_list', 'get_kbrd', 'get_login_info', 'get_lun', + 'get_screen_size', 'getwindows', 'goto', 'grid3', + 'griddata', 'grid_input', 'grid_tps', 'gs_iter', + 'h5_browser', 'h5_[0-9a-za-z_]*', 'h5a_[0-9a-za-z_]*', + 'h5d_[0-9a-za-z_]*', 'h5f_[0-9a-za-z_]*', + 'h5g_[0-9a-za-z_]*', 'h5i_[0-9a-za-z_]*', + 'h5r_[0-9a-za-z_]*', 'h5s_[0-9a-za-z_]*', + 'h5t_[0-9a-za-z_]*', 'hanning', 'hash', 'hdf_browser', + 'hdf_read', 'hdf_[0-9a-za-z_]*', 'heap_free', 'heap_gc', + 'heap_nosave', 'heap_refcount', 'heap_save', 'help', + 'hilbert', 'histogram', 'hist_2d', 'hist_equal', 'hls', + 'hough', 'hqr', 'hsv', 'h_eq_ct', 'h_eq_int', 'ibeta', + 'icontour', 'identity', 'idlitsys_createtool', + 'idl_container[0-9a-za-z_]*', 'idl_validname', + 'idl_[0-9a-za-z_]*', 'idlan[0-9a-za-z_]*', + 'idlcom[0-9a-za-z_]*', 'idlff[0-9a-za-z_]*', + 'idlgr[0-9a-za-z_]*', 'idlit[0-9a-za-z_]*', 'igamma', + 'iimage', 'image', 'image_cont', 'image_statistics', + 'imaginary', 'imap', 'indgen', 'intarr', 'interpol', + 'interpolate', 'interval_volume', 'int_2d', 'int_3d', + 'int_tabulated', 'invert', 'ioctl', 'iplot', 'ir_filter', + 'isa', 'ishft', 'isocontour', 'isosurface', 'isurface', + 'itcurrent', 'itdelete', 'itgetcurrent', 'itregister', + 'itreset', 'itresolve', 'ivector', 'ivolume', 'journal', + 'julday', 'keyword_set', 'krig2d', 'kurtosis', 'kw_test', + 'l64indgen', 'label_date', 'label_region', 'ladfit', + 'laguerre', 'laplacian', 'la_choldc', 'la_cholmprove', + 'la_cholsol', 'la_determ', 'la_eigenproblem', 'la_eigenql', + 'la_eigenvec', 'la_elmhes', 'la_gm_linear_model', 'la_hqr', + 'la_invert', 'la_least_squares', 'la_least_square_equality', + 'la_linear_equation', 'la_ludc', 'la_lumprove', 'la_lusol', + 'la_svd', 'la_tridc', 'la_trimprove', 'la_triql', + 'la_trired', 'la_trisol', 'leefilt', 'legend', 'legendre', + 'linbcg', 'lindgen', 'linfit', 'linkimage', 'list', + 'll_arc_distance', 'lmfit', 'lmgr', 'lngamma', 'lnp_test', + 'loadct', 'locale_get', 'logical_and', 'logical_or', + 'logical_true', 'lon64arr', 'lonarr', 'long', 'long64', + 'lsode', 'ludc', 'lumprove', 'lusol', 'lu_complex', + 'machar', 'make_array', 'make_dll', 'make_rt', 'map', + 'map_2points', 'map_continents', 'map_grid', 'map_image', + 'map_patch', 'map_proj_forward', 'map_proj_image', + 'map_proj_info', 'map_proj_init', 'map_proj_inverse', + 'map_set', 'mapgrid', 'mapcontinents', 'matrix_multiply', + 'matrix_power', 'max', 'md_test', 'mean', 'meanabsdev', + 'median', 'memory', 'mesh_clip', 'mesh_decimate', + 'mesh_issolid', 'mesh_merge', 'mesh_numtriangles', + 'mesh_obj', 'mesh_smooth', 'mesh_surfacearea', + 'mesh_validate', 'mesh_volume', 'message', 'min', + 'min_curve_surf', 'mk_html_help', 'modifyct', 'moment', + 'morph_close', 'morph_distance', 'morph_gradient', + 'morph_hitormiss', 'morph_open', 'morph_thin', + 'morph_tophat', 'mpeg_close', 'mpeg_open', 'mpeg_put', + 'mpeg_save', 'multi', 'm_correlate', 'ncdf_[0-9a-za-z_]*', + 'newton', 'noise_hurl', 'noise_pick', 'noise_scatter', + 'noise_slur', 'norm', 'n_elements', 'n_params', 'n_tags', + 'objarr', 'obj_class', 'obj_destroy', 'obj_hasmethod', + 'obj_isa', 'obj_new', 'obj_valid', 'online_help', + 'online_help_pdf_index', 'on_error', 'on_ioerror', 'open', + 'openr', 'openw', 'openu', 'oplot', 'oploterr', + 'particle_trace', 'path_cache', 'path_sep', 'pcomp', 'plot', + 'plot3d', 'ploterr', 'plots', 'plot_3dbox', 'plot_field', + 'pnt_line', 'point_lun', 'polar_contour', 'polar_surface', + 'polarplot', 'poly', 'polyfill', 'polyfillv', 'polygon', + 'polyline', 'polyshade', 'polywarp', 'poly_2d', 'poly_area', + 'poly_fit', 'popd', 'powell', 'pref_commit', 'pref_get', + 'pref_migrate', 'pref_set', 'prewitt', 'primes', 'print', + 'printd', 'printf', 'product', 'profile', 'profiler', + 'profiles', 'project_vol', 'psafm', 'pseudo', + 'ps_show_fonts', 'ptrarr', 'ptr_free', 'ptr_new', + 'ptr_valid', 'pushd', 'p_correlate', 'qgrid3', 'qhull', + 'qromb', 'qromo', 'qsimp', 'query_ascii', 'query_bmp', + 'query_dicom', 'query_gif', 'query_image', 'query_jpeg', + 'query_jpeg2000', 'query_mrsid', 'query_pict', 'query_png', + 'query_ppm', 'query_srf', 'query_tiff', 'query_wav', + 'query_[0-9a-za-z_]*', 'radon', 'randomn', 'randomu', + 'ranks', 'rdpix', 'read', 'readf', 'reads', 'readu', + 'read_ascii', 'read_binary', 'read_bmp', 'read_dicom', + 'read_gif', 'read_image', 'read_interfile', 'read_jpeg', + 'read_jpeg2000', 'read_mrsid', 'read_pict', 'read_png', + 'read_ppm', 'read_spr', 'read_srf', 'read_sylk', + 'read_tiff', 'read_wav', 'read_wave', 'read_x11_bitmap', + 'read_xwd', 'real_part', 'rebin', 'recall_commands', + 'recon3', 'reduce_colors', 'reform', 'region_grow', + 'register_cursor', 'regress', 'replicate', + 'replicate_inplace', 'resolve_all', 'resolve_routine', + 'restore', 'retall', 'reverse', 'rk4', 'roberts', + 'rot', 'rotate', 'round', 'routine_filepath', + 'routine_info', 'rs_test', 'r_correlate', 'r_test', 'save', + 'savgol', 'scale3', 'scale3d', 'scope_level', + 'scope_traceback', 'scope_varfetch', 'scope_varname', + 'search2d', 'search3d', 'sem_create', 'sem_delete', + 'sem_lock', 'sem_release', 'setenv', 'setup_keys', + 'set_plot', 'set_shading', 'sfit', 'shade_surf', + 'shade_surf_irr', 'shade_volume', 'shift', 'shift_diff', + 'shmdebug', 'shmmap', 'shmunmap', 'shmvar', 'show3', + 'showfont', 'simplex', 'sin', 'sindgen', 'sinh', 'size', + 'skewness', 'skip_lun', 'slicer3', 'slide_image', 'smooth', + 'sobel', 'socket', 'sort', 'spawn', 'spher_harm', + 'sph_4pnt', 'sph_scat', 'spline', 'spline_p', 'spl_init', + 'spl_interp', 'sprsab', 'sprsax', 'sprsin', 'sprstp', + 'sqrt', 'standardize', 'stddev', 'strarr', 'strcmp', + 'strcompress', 'streamline', 'stregex', 'stretch', 'string', + 'strjoin', 'strlen', 'strlowcase', 'strmatch', 'strmessage', + 'strmid', 'strpos', 'strput', 'strsplit', 'strtrim', + 'struct_assign', 'struct_hide', 'strupcase', 'surface', + 'surfr', 'svdc', 'svdfit', 'svsol', 'swap_endian', + 'swap_endian_inplace', 'switch', 'systime', 's_test', 't3d', + 'tag_names', 'tan', 'tanh', 'tek_color', 'temporary', + 'tetra_clip', 'tetra_surface', 'tetra_volume', 'text', + 'thin', 'threed', 'timegen', 'time_test2', 'tm_test', + 'total', 'trace', 'transpose', 'triangulate', 'trigrid', + 'triql', 'trired', 'trisol', 'tri_surf', 'truncate_lun', + 'ts_coef', 'ts_diff', 'ts_fcast', 'ts_smooth', 'tv', + 'tvcrs', 'tvlct', 'tvrd', 'tvscl', 'typename', 't_cvf', + 't_pdf', 'trackballobject', 'uindgen', 'uint', 'uintarr', + 'ul64indgen', 'ulindgen', 'ulon64arr', 'ulonarr', 'ulong', + 'ulong64', 'uniq', 'unsharp_mask', 'usersym', + 'value_locate', 'variance', 'vector', 'vector_field', 'vel', + 'velovect', 'vert_t3d', 'voigt', 'voronoi', 'voxel_proj', + 'wait', 'warp_tri', 'watershed', 'wdelete', 'wf_draw', + 'where', 'widget_activex', 'widget_base', + 'widget_button', 'widget_combobox', 'widget_control', + 'widget_displaycontextmenu', 'widget_draw', + 'widget_droplist', 'widget_event', 'widget_info', + 'widget_label', 'widget_list', 'widget_propertysheet', + 'widget_slider', 'widget_tab', 'widget_table', + 'widget_text', 'widget_tree', 'widget_tree_move', + 'widget_window', 'window', 'writeu', 'write_bmp', + 'write_gif', 'write_image', 'write_jpeg', 'write_jpeg2000', + 'write_nrif', 'write_pict', 'write_png', 'write_ppm', + 'write_spr', 'write_srf', 'write_sylk', 'write_tiff', + 'write_wav', 'write_wave', 'wset', 'wshow', 'wtn', + 'wv_[0-9a-za-z_]*', 'xbm_edit', 'xdisplayfile', 'xdxf', + 'xfont', 'xinteranimate', 'xloadct', 'xmanager', + 'xmng_tmpl', 'xmtool', 'xobjview', 'xobjview_rotate', + 'xobjview_write_image', 'xpalette', 'xpcolor', 'xplot3d', + 'xregistered', 'xroi', 'xsq_test', 'xsurface', 'xvaredit', + 'xvolume', 'xvolume_rotate', 'xvolume_write_image', + 'xyouts', 'zoom', 'zoom_24'] + + tokens = { + 'root': [ + (r'^\s*;.*?\n', Comment.Singleline), + (r'\b(' + "|".join(_RESERVED) + r')\b', Keyword), + (r'\b(' + "|".join(_BUILTIN_LIB) + r')\b', Name.Builtin), + (r'\+|-|\+\+|--|#|##|\*|/|->|<|>|&&|\^|~|\|\|\?|:', Operator), + (r'\+=|-=|\^=|\*=|/=|#=|##=|<\|>=|=', Operator), + (r'\b(mod|lt|le|eq|ne|ge|gt|not|and|or|xor)\b', Operator), + (r'\b(mod=|lt=|le=|eq=|ne=|ge=|gt=|not=|and=|or=|xor=)', Operator), + (r'\b[0-9](L|B|S|UL|ULL|LL)?\b', Number), + (r'.', Text), + ] + } |