Debian Codegraph @

codemirror-legacy-modes/mode/idl.js

raw
1 function wordRegexp(words) {
2 return new RegExp('^((' + words.join(')|(') + '))\\b', 'i');
3 };
4
5 var builtinArray = [
6 'a_correlate', 'abs', 'acos', 'adapt_hist_equal', 'alog',
7 'alog2', 'alog10', 'amoeba', 'annotate', 'app_user_dir',
8 'app_user_dir_query', 'arg_present', 'array_equal', 'array_indices',
9 'arrow', 'ascii_template', 'asin', 'assoc', 'atan',
10 'axis', 'axis', 'bandpass_filter', 'bandreject_filter', 'barplot',
11 'bar_plot', 'beseli', 'beselj', 'beselk', 'besely',
12 'beta', 'biginteger', 'bilinear', 'bin_date', 'binary_template',
13 'bindgen', 'binomial', 'bit_ffs', 'bit_population', 'blas_axpy',
14 'blk_con', 'boolarr', 'boolean', 'boxplot', 'box_cursor',
15 'breakpoint', 'broyden', 'bubbleplot', 'butterworth', 'bytarr',
16 'byte', 'byteorder', 'bytscl', 'c_correlate', 'calendar',
17 'caldat', 'call_external', 'call_function', 'call_method',
18 'call_procedure', 'canny', 'catch', 'cd', 'cdf', 'ceil',
19 'chebyshev', 'check_math', 'chisqr_cvf', 'chisqr_pdf', 'choldc',
20 'cholsol', 'cindgen', 'cir_3pnt', 'clipboard', 'close',
21 'clust_wts', 'cluster', 'cluster_tree', 'cmyk_convert', 'code_coverage',
22 'color_convert', 'color_exchange', 'color_quan', 'color_range_map',
23 'colorbar', 'colorize_sample', 'colormap_applicable',
24 'colormap_gradient', 'colormap_rotation', 'colortable',
25 'comfit', 'command_line_args', 'common', 'compile_opt', 'complex',
26 'complexarr', 'complexround', 'compute_mesh_normals', 'cond', 'congrid',
27 'conj', 'constrained_min', 'contour', 'contour', 'convert_coord',
28 'convol', 'convol_fft', 'coord2to3', 'copy_lun', 'correlate',
29 'cos', 'cosh', 'cpu', 'cramer', 'createboxplotdata',
30 'create_cursor', 'create_struct', 'create_view', 'crossp', 'crvlength',
31 'ct_luminance', 'cti_test', 'cursor', 'curvefit', 'cv_coord',
32 'cvttobm', 'cw_animate', 'cw_animate_getp', 'cw_animate_load',
33 'cw_animate_run', 'cw_arcball', 'cw_bgroup', 'cw_clr_index',
34 'cw_colorsel', 'cw_defroi', 'cw_field', 'cw_filesel', 'cw_form',
35 'cw_fslider', 'cw_light_editor', 'cw_light_editor_get',
36 'cw_light_editor_set', 'cw_orient', 'cw_palette_editor',
37 'cw_palette_editor_get', 'cw_palette_editor_set', 'cw_pdmenu',
38 'cw_rgbslider', 'cw_tmpl', 'cw_zoom', 'db_exists',
39 'dblarr', 'dcindgen', 'dcomplex', 'dcomplexarr', 'define_key',
40 'define_msgblk', 'define_msgblk_from_file', 'defroi', 'defsysv',
41 'delvar', 'dendro_plot', 'dendrogram', 'deriv', 'derivsig',
42 'determ', 'device', 'dfpmin', 'diag_matrix', 'dialog_dbconnect',
43 'dialog_message', 'dialog_pickfile', 'dialog_printersetup',
44 'dialog_printjob', 'dialog_read_image',
45 'dialog_write_image', 'dictionary', 'digital_filter', 'dilate', 'dindgen',
46 'dissolve', 'dist', 'distance_measure', 'dlm_load', 'dlm_register',
47 'doc_library', 'double', 'draw_roi', 'edge_dog', 'efont',
48 'eigenql', 'eigenvec', 'ellipse', 'elmhes', 'emboss',
49 'empty', 'enable_sysrtn', 'eof', 'eos', 'erase',
50 'erf', 'erfc', 'erfcx', 'erode', 'errorplot',
51 'errplot', 'estimator_filter', 'execute', 'exit', 'exp',
52 'expand', 'expand_path', 'expint', 'extract', 'extract_slice',
53 'f_cvf', 'f_pdf', 'factorial', 'fft', 'file_basename',
54 'file_chmod', 'file_copy', 'file_delete', 'file_dirname',
55 'file_expand_path', 'file_gunzip', 'file_gzip', 'file_info',
56 'file_lines', 'file_link', 'file_mkdir', 'file_move',
57 'file_poll_input', 'file_readlink', 'file_same',
58 'file_search', 'file_tar', 'file_test', 'file_untar', 'file_unzip',
59 'file_which', 'file_zip', 'filepath', 'findgen', 'finite',
60 'fix', 'flick', 'float', 'floor', 'flow3',
61 'fltarr', 'flush', 'format_axis_values', 'forward_function', 'free_lun',
62 'fstat', 'fulstr', 'funct', 'function', 'fv_test',
63 'fx_root', 'fz_roots', 'gamma', 'gamma_ct', 'gauss_cvf',
64 'gauss_pdf', 'gauss_smooth', 'gauss2dfit', 'gaussfit',
65 'gaussian_function', 'gaussint', 'get_drive_list', 'get_dxf_objects',
66 'get_kbrd', 'get_login_info',
67 'get_lun', 'get_screen_size', 'getenv', 'getwindows', 'greg2jul',
68 'grib', 'grid_input', 'grid_tps', 'grid3', 'griddata',
69 'gs_iter', 'h_eq_ct', 'h_eq_int', 'hanning', 'hash',
70 'hdf', 'hdf5', 'heap_free', 'heap_gc', 'heap_nosave',
71 'heap_refcount', 'heap_save', 'help', 'hilbert', 'hist_2d',
72 'hist_equal', 'histogram', 'hls', 'hough', 'hqr',
73 'hsv', 'i18n_multibytetoutf8',
74 'i18n_multibytetowidechar', 'i18n_utf8tomultibyte',
75 'i18n_widechartomultibyte',
76 'ibeta', 'icontour', 'iconvertcoord', 'idelete', 'identity',
77 'idl_base64', 'idl_container', 'idl_validname',
78 'idlexbr_assistant', 'idlitsys_createtool',
79 'idlunit', 'iellipse', 'igamma', 'igetcurrent', 'igetdata',
80 'igetid', 'igetproperty', 'iimage', 'image', 'image_cont',
81 'image_statistics', 'image_threshold', 'imaginary', 'imap', 'indgen',
82 'int_2d', 'int_3d', 'int_tabulated', 'intarr', 'interpol',
83 'interpolate', 'interval_volume', 'invert', 'ioctl', 'iopen',
84 'ir_filter', 'iplot', 'ipolygon', 'ipolyline', 'iputdata',
85 'iregister', 'ireset', 'iresolve', 'irotate', 'isa',
86 'isave', 'iscale', 'isetcurrent', 'isetproperty', 'ishft',
87 'isocontour', 'isosurface', 'isurface', 'itext', 'itranslate',
88 'ivector', 'ivolume', 'izoom', 'journal', 'json_parse',
89 'json_serialize', 'jul2greg', 'julday', 'keyword_set', 'krig2d',
90 'kurtosis', 'kw_test', 'l64indgen', 'la_choldc', 'la_cholmprove',
91 'la_cholsol', 'la_determ', 'la_eigenproblem', 'la_eigenql', 'la_eigenvec',
92 'la_elmhes', 'la_gm_linear_model', 'la_hqr', 'la_invert',
93 'la_least_square_equality', 'la_least_squares', 'la_linear_equation',
94 'la_ludc', 'la_lumprove', 'la_lusol',
95 'la_svd', 'la_tridc', 'la_trimprove', 'la_triql', 'la_trired',
96 'la_trisol', 'label_date', 'label_region', 'ladfit', 'laguerre',
97 'lambda', 'lambdap', 'lambertw', 'laplacian', 'least_squares_filter',
98 'leefilt', 'legend', 'legendre', 'linbcg', 'lindgen',
99 'linfit', 'linkimage', 'list', 'll_arc_distance', 'lmfit',
100 'lmgr', 'lngamma', 'lnp_test', 'loadct', 'locale_get',
101 'logical_and', 'logical_or', 'logical_true', 'lon64arr', 'lonarr',
102 'long', 'long64', 'lsode', 'lu_complex', 'ludc',
103 'lumprove', 'lusol', 'm_correlate', 'machar', 'make_array',
104 'make_dll', 'make_rt', 'map', 'mapcontinents', 'mapgrid',
105 'map_2points', 'map_continents', 'map_grid', 'map_image', 'map_patch',
106 'map_proj_forward', 'map_proj_image', 'map_proj_info',
107 'map_proj_init', 'map_proj_inverse',
108 'map_set', 'matrix_multiply', 'matrix_power', 'max', 'md_test',
109 'mean', 'meanabsdev', 'mean_filter', 'median', 'memory',
110 'mesh_clip', 'mesh_decimate', 'mesh_issolid',
111 'mesh_merge', 'mesh_numtriangles',
112 'mesh_obj', 'mesh_smooth', 'mesh_surfacearea',
113 'mesh_validate', 'mesh_volume',
114 'message', 'min', 'min_curve_surf', 'mk_html_help', 'modifyct',
115 'moment', 'morph_close', 'morph_distance',
116 'morph_gradient', 'morph_hitormiss',
117 'morph_open', 'morph_thin', 'morph_tophat', 'multi', 'n_elements',
118 'n_params', 'n_tags', 'ncdf', 'newton', 'noise_hurl',
119 'noise_pick', 'noise_scatter', 'noise_slur', 'norm', 'obj_class',
120 'obj_destroy', 'obj_hasmethod', 'obj_isa', 'obj_new', 'obj_valid',
121 'objarr', 'on_error', 'on_ioerror', 'online_help', 'openr',
122 'openu', 'openw', 'oplot', 'oploterr', 'orderedhash',
123 'p_correlate', 'parse_url', 'particle_trace', 'path_cache', 'path_sep',
124 'pcomp', 'plot', 'plot3d', 'plot', 'plot_3dbox',
125 'plot_field', 'ploterr', 'plots', 'polar_contour', 'polar_surface',
126 'polyfill', 'polyshade', 'pnt_line', 'point_lun', 'polarplot',
127 'poly', 'poly_2d', 'poly_area', 'poly_fit', 'polyfillv',
128 'polygon', 'polyline', 'polywarp', 'popd', 'powell',
129 'pref_commit', 'pref_get', 'pref_set', 'prewitt', 'primes',
130 'print', 'printf', 'printd', 'pro', 'product',
131 'profile', 'profiler', 'profiles', 'project_vol', 'ps_show_fonts',
132 'psafm', 'pseudo', 'ptr_free', 'ptr_new', 'ptr_valid',
133 'ptrarr', 'pushd', 'qgrid3', 'qhull', 'qromb',
134 'qromo', 'qsimp', 'query_*', 'query_ascii', 'query_bmp',
135 'query_csv', 'query_dicom', 'query_gif', 'query_image', 'query_jpeg',
136 'query_jpeg2000', 'query_mrsid', 'query_pict', 'query_png', 'query_ppm',
137 'query_srf', 'query_tiff', 'query_video', 'query_wav', 'r_correlate',
138 'r_test', 'radon', 'randomn', 'randomu', 'ranks',
139 'rdpix', 'read', 'readf', 'read_ascii', 'read_binary',
140 'read_bmp', 'read_csv', 'read_dicom', 'read_gif', 'read_image',
141 'read_interfile', 'read_jpeg', 'read_jpeg2000', 'read_mrsid', 'read_pict',
142 'read_png', 'read_ppm', 'read_spr', 'read_srf', 'read_sylk',
143 'read_tiff', 'read_video', 'read_wav', 'read_wave', 'read_x11_bitmap',
144 'read_xwd', 'reads', 'readu', 'real_part', 'rebin',
145 'recall_commands', 'recon3', 'reduce_colors', 'reform', 'region_grow',
146 'register_cursor', 'regress', 'replicate',
147 'replicate_inplace', 'resolve_all',
148 'resolve_routine', 'restore', 'retall', 'return', 'reverse',
149 'rk4', 'roberts', 'rot', 'rotate', 'round',
150 'routine_filepath', 'routine_info', 'rs_test', 's_test', 'save',
151 'savgol', 'scale3', 'scale3d', 'scatterplot', 'scatterplot3d',
152 'scope_level', 'scope_traceback', 'scope_varfetch',
153 'scope_varname', 'search2d',
154 'search3d', 'sem_create', 'sem_delete', 'sem_lock', 'sem_release',
155 'set_plot', 'set_shading', 'setenv', 'sfit', 'shade_surf',
156 'shade_surf_irr', 'shade_volume', 'shift', 'shift_diff', 'shmdebug',
157 'shmmap', 'shmunmap', 'shmvar', 'show3', 'showfont',
158 'signum', 'simplex', 'sin', 'sindgen', 'sinh',
159 'size', 'skewness', 'skip_lun', 'slicer3', 'slide_image',
160 'smooth', 'sobel', 'socket', 'sort', 'spawn',
161 'sph_4pnt', 'sph_scat', 'spher_harm', 'spl_init', 'spl_interp',
162 'spline', 'spline_p', 'sprsab', 'sprsax', 'sprsin',
163 'sprstp', 'sqrt', 'standardize', 'stddev', 'stop',
164 'strarr', 'strcmp', 'strcompress', 'streamline', 'streamline',
165 'stregex', 'stretch', 'string', 'strjoin', 'strlen',
166 'strlowcase', 'strmatch', 'strmessage', 'strmid', 'strpos',
167 'strput', 'strsplit', 'strtrim', 'struct_assign', 'struct_hide',
168 'strupcase', 'surface', 'surface', 'surfr', 'svdc',
169 'svdfit', 'svsol', 'swap_endian', 'swap_endian_inplace', 'symbol',
170 'systime', 't_cvf', 't_pdf', 't3d', 'tag_names',
171 'tan', 'tanh', 'tek_color', 'temporary', 'terminal_size',
172 'tetra_clip', 'tetra_surface', 'tetra_volume', 'text', 'thin',
173 'thread', 'threed', 'tic', 'time_test2', 'timegen',
174 'timer', 'timestamp', 'timestamptovalues', 'tm_test', 'toc',
175 'total', 'trace', 'transpose', 'tri_surf', 'triangulate',
176 'trigrid', 'triql', 'trired', 'trisol', 'truncate_lun',
177 'ts_coef', 'ts_diff', 'ts_fcast', 'ts_smooth', 'tv',
178 'tvcrs', 'tvlct', 'tvrd', 'tvscl', 'typename',
179 'uindgen', 'uint', 'uintarr', 'ul64indgen', 'ulindgen',
180 'ulon64arr', 'ulonarr', 'ulong', 'ulong64', 'uniq',
181 'unsharp_mask', 'usersym', 'value_locate', 'variance', 'vector',
182 'vector_field', 'vel', 'velovect', 'vert_t3d', 'voigt',
183 'volume', 'voronoi', 'voxel_proj', 'wait', 'warp_tri',
184 'watershed', 'wdelete', 'wf_draw', 'where', 'widget_base',
185 'widget_button', 'widget_combobox', 'widget_control',
186 'widget_displaycontextmenu', 'widget_draw',
187 'widget_droplist', 'widget_event', 'widget_info',
188 'widget_label', 'widget_list',
189 'widget_propertysheet', 'widget_slider', 'widget_tab',
190 'widget_table', 'widget_text',
191 'widget_tree', 'widget_tree_move', 'widget_window',
192 'wiener_filter', 'window',
193 'window', 'write_bmp', 'write_csv', 'write_gif', 'write_image',
194 'write_jpeg', 'write_jpeg2000', 'write_nrif', 'write_pict', 'write_png',
195 'write_ppm', 'write_spr', 'write_srf', 'write_sylk', 'write_tiff',
196 'write_video', 'write_wav', 'write_wave', 'writeu', 'wset',
197 'wshow', 'wtn', 'wv_applet', 'wv_cwt', 'wv_cw_wavelet',
198 'wv_denoise', 'wv_dwt', 'wv_fn_coiflet',
199 'wv_fn_daubechies', 'wv_fn_gaussian',
200 'wv_fn_haar', 'wv_fn_morlet', 'wv_fn_paul',
201 'wv_fn_symlet', 'wv_import_data',
202 'wv_import_wavelet', 'wv_plot3d_wps', 'wv_plot_multires',
203 'wv_pwt', 'wv_tool_denoise',
204 'xbm_edit', 'xdisplayfile', 'xdxf', 'xfont', 'xinteranimate',
205 'xloadct', 'xmanager', 'xmng_tmpl', 'xmtool', 'xobjview',
206 'xobjview_rotate', 'xobjview_write_image',
207 'xpalette', 'xpcolor', 'xplot3d',
208 'xregistered', 'xroi', 'xsq_test', 'xsurface', 'xvaredit',
209 'xvolume', 'xvolume_rotate', 'xvolume_write_image',
210 'xyouts', 'zlib_compress', 'zlib_uncompress', 'zoom', 'zoom_24'
211 ];
212 var builtins = wordRegexp(builtinArray);
213
214 var keywordArray = [
215 'begin', 'end', 'endcase', 'endfor',
216 'endwhile', 'endif', 'endrep', 'endforeach',
217 'break', 'case', 'continue', 'for',
218 'foreach', 'goto', 'if', 'then', 'else',
219 'repeat', 'until', 'switch', 'while',
220 'do', 'pro', 'function'
221 ];
222 var keywords = wordRegexp(keywordArray);
223
224 var identifiers = new RegExp('^[_a-z\xa1-\uffff][_a-z0-9\xa1-\uffff]*', 'i');
225
226 var singleOperators = /[+\-*&=<>\/@#~$]/;
227 var boolOperators = new RegExp('(and|or|eq|lt|le|gt|ge|ne|not)', 'i');
228
229 function tokenBase(stream) {
230 // whitespaces
231 if (stream.eatSpace()) return null;
232
233 // Handle one line Comments
234 if (stream.match(';')) {
235 stream.skipToEnd();
236 return 'comment';
237 }
238
239 // Handle Number Literals
240 if (stream.match(/^[0-9\.+-]/, false)) {
241 if (stream.match(/^[+-]?0x[0-9a-fA-F]+/))
242 return 'number';
243 if (stream.match(/^[+-]?\d*\.\d+([EeDd][+-]?\d+)?/))
244 return 'number';
245 if (stream.match(/^[+-]?\d+([EeDd][+-]?\d+)?/))
246 return 'number';
247 }
248
249 // Handle Strings
250 if (stream.match(/^"([^"]|(""))*"/)) { return 'string'; }
251 if (stream.match(/^'([^']|(''))*'/)) { return 'string'; }
252
253 // Handle words
254 if (stream.match(keywords)) { return 'keyword'; }
255 if (stream.match(builtins)) { return 'builtin'; }
256 if (stream.match(identifiers)) { return 'variable'; }
257
258 if (stream.match(singleOperators) || stream.match(boolOperators)) {
259 return 'operator'; }
260
261 // Handle non-detected items
262 stream.next();
263 return null;
264 };
265
266 export const idl = {
267 name: "idl",
268 token: function(stream) {
269 return tokenBase(stream);
270 },
271 languageData: {
272 autocomplete: builtinArray.concat(keywordArray)
273 }
274 }