904 # include('statements'), |
1097 # include('statements'), |
905 # ('\{', Punctuation, '#push'), |
1098 # ('\{', Punctuation, '#push'), |
906 # ('\}', Punctuation, '#pop') |
1099 # ('\}', Punctuation, '#pop') |
907 #], |
1100 #], |
908 'string_squote': [ |
1101 'string_squote': [ |
909 (r'[^\']*\'', String, '#pop'), |
1102 (r'([^\'\\]|\\.)*\'', String, '#pop'), |
910 ], |
1103 ], |
911 'string_dquote': [ |
1104 'string_dquote': [ |
912 (r'[^\"]*\"', String, '#pop'), |
1105 (r'([^"\\]|\\.)*"', String, '#pop'), |
913 ], |
1106 ], |
914 } |
1107 } |
915 |
1108 |
916 def analyse_text(text): |
1109 def analyse_text(text): |
917 return '<-' in text |
1110 return '<-' in text |
|
1111 |
|
1112 |
|
1113 class BugsLexer(RegexLexer): |
|
1114 """ |
|
1115 Pygments Lexer for `OpenBugs <http://www.openbugs.info/w/>`_ and WinBugs |
|
1116 models. |
|
1117 |
|
1118 *New in Pygments 1.6.* |
|
1119 """ |
|
1120 |
|
1121 name = 'BUGS' |
|
1122 aliases = ['bugs', 'winbugs', 'openbugs'] |
|
1123 filenames = ['*.bug'] |
|
1124 |
|
1125 _FUNCTIONS = [ |
|
1126 # Scalar functions |
|
1127 'abs', 'arccos', 'arccosh', 'arcsin', 'arcsinh', 'arctan', 'arctanh', |
|
1128 'cloglog', 'cos', 'cosh', 'cumulative', 'cut', 'density', 'deviance', |
|
1129 'equals', 'expr', 'gammap', 'ilogit', 'icloglog', 'integral', 'log', |
|
1130 'logfact', 'loggam', 'logit', 'max', 'min', 'phi', 'post.p.value', |
|
1131 'pow', 'prior.p.value', 'probit', 'replicate.post', 'replicate.prior', |
|
1132 'round', 'sin', 'sinh', 'solution', 'sqrt', 'step', 'tan', 'tanh', |
|
1133 'trunc', |
|
1134 # Vector functions |
|
1135 'inprod', 'interp.lin', 'inverse', 'logdet', 'mean', 'eigen.vals', |
|
1136 'ode', 'prod', 'p.valueM', 'rank', 'ranked', 'replicate.postM', |
|
1137 'sd', 'sort', 'sum', |
|
1138 ## Special |
|
1139 'D', 'I', 'F', 'T', 'C'] |
|
1140 """ OpenBUGS built-in functions |
|
1141 |
|
1142 From http://www.openbugs.info/Manuals/ModelSpecification.html#ContentsAII |
|
1143 |
|
1144 This also includes |
|
1145 |
|
1146 - T, C, I : Truncation and censoring. |
|
1147 ``T`` and ``C`` are in OpenBUGS. ``I`` in WinBUGS. |
|
1148 - D : ODE |
|
1149 - F : Functional http://www.openbugs.info/Examples/Functionals.html |
|
1150 |
|
1151 """ |
|
1152 |
|
1153 _DISTRIBUTIONS = ['dbern', 'dbin', 'dcat', 'dnegbin', 'dpois', |
|
1154 'dhyper', 'dbeta', 'dchisqr', 'ddexp', 'dexp', |
|
1155 'dflat', 'dgamma', 'dgev', 'df', 'dggamma', 'dgpar', |
|
1156 'dloglik', 'dlnorm', 'dlogis', 'dnorm', 'dpar', |
|
1157 'dt', 'dunif', 'dweib', 'dmulti', 'ddirch', 'dmnorm', |
|
1158 'dmt', 'dwish'] |
|
1159 """ OpenBUGS built-in distributions |
|
1160 |
|
1161 Functions from |
|
1162 http://www.openbugs.info/Manuals/ModelSpecification.html#ContentsAI |
|
1163 """ |
|
1164 |
|
1165 |
|
1166 tokens = { |
|
1167 'whitespace' : [ |
|
1168 (r"\s+", Text), |
|
1169 ], |
|
1170 'comments' : [ |
|
1171 # Comments |
|
1172 (r'#.*$', Comment.Single), |
|
1173 ], |
|
1174 'root': [ |
|
1175 # Comments |
|
1176 include('comments'), |
|
1177 include('whitespace'), |
|
1178 # Block start |
|
1179 (r'(model)(\s+)({)', |
|
1180 bygroups(Keyword.Namespace, Text, Punctuation)), |
|
1181 # Reserved Words |
|
1182 (r'(for|in)(?![0-9a-zA-Z\._])', Keyword.Reserved), |
|
1183 # Built-in Functions |
|
1184 (r'(%s)(?=\s*\()' |
|
1185 % r'|'.join(_FUNCTIONS + _DISTRIBUTIONS), |
|
1186 Name.Builtin), |
|
1187 # Regular variable names |
|
1188 (r'[A-Za-z][A-Za-z0-9_.]*', Name), |
|
1189 # Number Literals |
|
1190 (r'[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?', Number), |
|
1191 # Punctuation |
|
1192 (r'\[|\]|\(|\)|:|,|;', Punctuation), |
|
1193 # Assignment operators |
|
1194 # SLexer makes these tokens Operators. |
|
1195 (r'<-|~', Operator), |
|
1196 # Infix and prefix operators |
|
1197 (r'\+|-|\*|/', Operator), |
|
1198 # Block |
|
1199 (r'[{}]', Punctuation), |
|
1200 ] |
|
1201 } |
|
1202 |
|
1203 def analyse_text(text): |
|
1204 if re.search(r"^\s*model\s*{", text, re.M): |
|
1205 return 0.7 |
|
1206 else: |
|
1207 return 0.0 |
|
1208 |
|
1209 class JagsLexer(RegexLexer): |
|
1210 """ |
|
1211 Pygments Lexer for JAGS. |
|
1212 |
|
1213 *New in Pygments 1.6.* |
|
1214 """ |
|
1215 |
|
1216 name = 'JAGS' |
|
1217 aliases = ['jags'] |
|
1218 filenames = ['*.jag', '*.bug'] |
|
1219 |
|
1220 ## JAGS |
|
1221 _FUNCTIONS = [ |
|
1222 'abs', 'arccos', 'arccosh', 'arcsin', 'arcsinh', 'arctan', 'arctanh', |
|
1223 'cos', 'cosh', 'cloglog', |
|
1224 'equals', 'exp', 'icloglog', 'ifelse', 'ilogit', 'log', 'logfact', |
|
1225 'loggam', 'logit', 'phi', 'pow', 'probit', 'round', 'sin', 'sinh', |
|
1226 'sqrt', 'step', 'tan', 'tanh', 'trunc', 'inprod', 'interp.lin', |
|
1227 'logdet', 'max', 'mean', 'min', 'prod', 'sum', 'sd', 'inverse', |
|
1228 'rank', 'sort', 't', 'acos', 'acosh', 'asin', 'asinh', 'atan', |
|
1229 # Truncation/Censoring (should I include) |
|
1230 'T', 'I'] |
|
1231 # Distributions with density, probability and quartile functions |
|
1232 _DISTRIBUTIONS = ['[dpq]%s' % x for x in |
|
1233 ['bern', 'beta', 'dchiqsqr', 'ddexp', 'dexp', |
|
1234 'df', 'gamma', 'gen.gamma', 'logis', 'lnorm', |
|
1235 'negbin', 'nchisqr', 'norm', 'par', 'pois', 'weib']] |
|
1236 # Other distributions without density and probability |
|
1237 _OTHER_DISTRIBUTIONS = [ |
|
1238 'dt', 'dunif', 'dbetabin', 'dbern', 'dbin', 'dcat', 'dhyper', |
|
1239 'ddirch', 'dmnorm', 'dwish', 'dmt', 'dmulti', 'dbinom', 'dchisq', |
|
1240 'dnbinom', 'dweibull', 'ddirich'] |
|
1241 |
|
1242 tokens = { |
|
1243 'whitespace' : [ |
|
1244 (r"\s+", Text), |
|
1245 ], |
|
1246 'names' : [ |
|
1247 # Regular variable names |
|
1248 (r'[a-zA-Z][a-zA-Z0-9_.]*\b', Name), |
|
1249 ], |
|
1250 'comments' : [ |
|
1251 # do not use stateful comments |
|
1252 (r'(?s)/\*.*?\*/', Comment.Multiline), |
|
1253 # Comments |
|
1254 (r'#.*$', Comment.Single), |
|
1255 ], |
|
1256 'root': [ |
|
1257 # Comments |
|
1258 include('comments'), |
|
1259 include('whitespace'), |
|
1260 # Block start |
|
1261 (r'(model|data)(\s+)({)', |
|
1262 bygroups(Keyword.Namespace, Text, Punctuation)), |
|
1263 (r'var(?![0-9a-zA-Z\._])', Keyword.Declaration), |
|
1264 # Reserved Words |
|
1265 (r'(for|in)(?![0-9a-zA-Z\._])', Keyword.Reserved), |
|
1266 # Builtins |
|
1267 # Need to use lookahead because . is a valid char |
|
1268 (r'(%s)(?=\s*\()' % r'|'.join(_FUNCTIONS |
|
1269 + _DISTRIBUTIONS |
|
1270 + _OTHER_DISTRIBUTIONS), |
|
1271 Name.Builtin), |
|
1272 # Names |
|
1273 include('names'), |
|
1274 # Number Literals |
|
1275 (r'[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?', Number), |
|
1276 (r'\[|\]|\(|\)|:|,|;', Punctuation), |
|
1277 # Assignment operators |
|
1278 (r'<-|~', Operator), |
|
1279 # # JAGS includes many more than OpenBUGS |
|
1280 (r'\+|-|\*|\/|\|\|[&]{2}|[<>=]=?|\^|%.*?%', Operator), |
|
1281 (r'[{}]', Punctuation), |
|
1282 ] |
|
1283 } |
|
1284 |
|
1285 def analyse_text(text): |
|
1286 if re.search(r'^\s*model\s*\{', text, re.M): |
|
1287 if re.search(r'^\s*data\s*\{', text, re.M): |
|
1288 return 0.9 |
|
1289 elif re.search(r'^\s*var', text, re.M): |
|
1290 return 0.9 |
|
1291 else: |
|
1292 return 0.3 |
|
1293 else: |
|
1294 return 0 |
|
1295 |
|
1296 class StanLexer(RegexLexer): |
|
1297 """ |
|
1298 Pygments Lexer for Stan models. |
|
1299 |
|
1300 *New in Pygments 1.6.* |
|
1301 """ |
|
1302 |
|
1303 name = 'Stan' |
|
1304 aliases = ['stan'] |
|
1305 filenames = ['*.stan'] |
|
1306 |
|
1307 _RESERVED = ('for', 'in', 'while', 'repeat', 'until', 'if', |
|
1308 'then', 'else', 'true', 'false', 'T', |
|
1309 'lower', 'upper', 'print') |
|
1310 |
|
1311 _TYPES = ('int', 'real', 'vector', 'simplex', 'ordered', 'row_vector', |
|
1312 'matrix', 'corr_matrix', 'cov_matrix', 'positive_ordered') |
|
1313 |
|
1314 tokens = { |
|
1315 'whitespace' : [ |
|
1316 (r"\s+", Text), |
|
1317 ], |
|
1318 'comments' : [ |
|
1319 (r'(?s)/\*.*?\*/', Comment.Multiline), |
|
1320 # Comments |
|
1321 (r'(//|#).*$', Comment.Single), |
|
1322 ], |
|
1323 'root': [ |
|
1324 # Stan is more restrictive on strings than this regex |
|
1325 (r'"[^"]*"', String), |
|
1326 # Comments |
|
1327 include('comments'), |
|
1328 # block start |
|
1329 include('whitespace'), |
|
1330 # Block start |
|
1331 (r'(%s)(\s*)({)' % |
|
1332 r'|'.join(('data', r'transformed\s+?data', |
|
1333 'parameters', r'transformed\s+parameters', |
|
1334 'model', r'generated\s+quantities')), |
|
1335 bygroups(Keyword.Namespace, Text, Punctuation)), |
|
1336 # Reserved Words |
|
1337 (r'(%s)\b' % r'|'.join(_RESERVED), Keyword.Reserved), |
|
1338 # Data types |
|
1339 (r'(%s)\b' % r'|'.join(_TYPES), Keyword.Type), |
|
1340 # Punctuation |
|
1341 (r"[;:,\[\]()<>]", Punctuation), |
|
1342 # Builtin |
|
1343 (r'(%s)(?=\s*\()' |
|
1344 % r'|'.join(_stan_builtins.FUNCTIONS |
|
1345 + _stan_builtins.DISTRIBUTIONS), |
|
1346 Name.Builtin), |
|
1347 (r'(%s)(?=\s*\()' |
|
1348 % r'|'.join(_stan_builtins.CONSTANTS), Keyword.Constant), |
|
1349 # Special names ending in __, like lp__ |
|
1350 (r'[A-Za-z][A-Za-z0-9_]*__\b', Name.Builtin.Pseudo), |
|
1351 # Regular variable names |
|
1352 (r'[A-Za-z][A-Za-z0-9_]*\b', Name), |
|
1353 # Real Literals |
|
1354 (r'-?[0-9]+(\.[0-9]+)?[eE]-?[0-9]+', Number.Float), |
|
1355 (r'-?[0-9]*\.[0-9]*', Number.Float), |
|
1356 # Integer Literals |
|
1357 (r'-?[0-9]+', Number.Integer), |
|
1358 # Assignment operators |
|
1359 # SLexer makes these tokens Operators. |
|
1360 (r'<-|~', Operator), |
|
1361 # Infix and prefix operators (and = ) |
|
1362 (r"\+|-|\.?\*|\.?/|\\|'|=", Operator), |
|
1363 # Block delimiters |
|
1364 (r'[{}]', Punctuation), |
|
1365 ] |
|
1366 } |
|
1367 |
|
1368 def analyse_text(text): |
|
1369 if re.search(r'^\s*parameters\s*\{', text, re.M): |
|
1370 return 1.0 |
|
1371 else: |
|
1372 return 0.0 |
|
1373 |
|
1374 |
|
1375 class IDLLexer(RegexLexer): |
|
1376 """ |
|
1377 Pygments Lexer for IDL (Interactive Data Language). |
|
1378 |
|
1379 *New in Pygments 1.6.* |
|
1380 """ |
|
1381 name = 'IDL' |
|
1382 aliases = ['idl'] |
|
1383 filenames = ['*.pro'] |
|
1384 mimetypes = ['text/idl'] |
|
1385 |
|
1386 _RESERVED = ['and', 'begin', 'break', 'case', 'common', 'compile_opt', |
|
1387 'continue', 'do', 'else', 'end', 'endcase', 'elseelse', |
|
1388 'endfor', 'endforeach', 'endif', 'endrep', 'endswitch', |
|
1389 'endwhile', 'eq', 'for', 'foreach', 'forward_function', |
|
1390 'function', 'ge', 'goto', 'gt', 'if', 'inherits', 'le', |
|
1391 'lt', 'mod', 'ne', 'not', 'of', 'on_ioerror', 'or', 'pro', |
|
1392 'repeat', 'switch', 'then', 'until', 'while', 'xor'] |
|
1393 """Reserved words from: http://www.exelisvis.com/docs/reswords.html""" |
|
1394 |
|
1395 _BUILTIN_LIB = ['abs', 'acos', 'adapt_hist_equal', 'alog', 'alog10', |
|
1396 'amoeba', 'annotate', 'app_user_dir', 'app_user_dir_query', |
|
1397 'arg_present', 'array_equal', 'array_indices', 'arrow', |
|
1398 'ascii_template', 'asin', 'assoc', 'atan', 'axis', |
|
1399 'a_correlate', 'bandpass_filter', 'bandreject_filter', |
|
1400 'barplot', 'bar_plot', 'beseli', 'beselj', 'beselk', |
|
1401 'besely', 'beta', 'bilinear', 'binary_template', 'bindgen', |
|
1402 'binomial', 'bin_date', 'bit_ffs', 'bit_population', |
|
1403 'blas_axpy', 'blk_con', 'box_cursor', 'breakpoint', |
|
1404 'broyden', 'butterworth', 'bytarr', 'byte', 'byteorder', |
|
1405 'bytscl', 'caldat', 'calendar', 'call_external', |
|
1406 'call_function', 'call_method', 'call_procedure', 'canny', |
|
1407 'catch', 'cd', 'cdf_[0-9a-za-z_]*', 'ceil', 'chebyshev', |
|
1408 'check_math', |
|
1409 'chisqr_cvf', 'chisqr_pdf', 'choldc', 'cholsol', 'cindgen', |
|
1410 'cir_3pnt', 'close', 'cluster', 'cluster_tree', 'clust_wts', |
|
1411 'cmyk_convert', 'colorbar', 'colorize_sample', |
|
1412 'colormap_applicable', 'colormap_gradient', |
|
1413 'colormap_rotation', 'colortable', 'color_convert', |
|
1414 'color_exchange', 'color_quan', 'color_range_map', 'comfit', |
|
1415 'command_line_args', 'complex', 'complexarr', 'complexround', |
|
1416 'compute_mesh_normals', 'cond', 'congrid', 'conj', |
|
1417 'constrained_min', 'contour', 'convert_coord', 'convol', |
|
1418 'convol_fft', 'coord2to3', 'copy_lun', 'correlate', 'cos', |
|
1419 'cosh', 'cpu', 'cramer', 'create_cursor', 'create_struct', |
|
1420 'create_view', 'crossp', 'crvlength', 'cti_test', |
|
1421 'ct_luminance', 'cursor', 'curvefit', 'cvttobm', 'cv_coord', |
|
1422 'cw_animate', 'cw_animate_getp', 'cw_animate_load', |
|
1423 'cw_animate_run', 'cw_arcball', 'cw_bgroup', 'cw_clr_index', |
|
1424 'cw_colorsel', 'cw_defroi', 'cw_field', 'cw_filesel', |
|
1425 'cw_form', 'cw_fslider', 'cw_light_editor', |
|
1426 'cw_light_editor_get', 'cw_light_editor_set', 'cw_orient', |
|
1427 'cw_palette_editor', 'cw_palette_editor_get', |
|
1428 'cw_palette_editor_set', 'cw_pdmenu', 'cw_rgbslider', |
|
1429 'cw_tmpl', 'cw_zoom', 'c_correlate', 'dblarr', 'db_exists', |
|
1430 'dcindgen', 'dcomplex', 'dcomplexarr', 'define_key', |
|
1431 'define_msgblk', 'define_msgblk_from_file', 'defroi', |
|
1432 'defsysv', 'delvar', 'dendrogram', 'dendro_plot', 'deriv', |
|
1433 'derivsig', 'determ', 'device', 'dfpmin', 'diag_matrix', |
|
1434 'dialog_dbconnect', 'dialog_message', 'dialog_pickfile', |
|
1435 'dialog_printersetup', 'dialog_printjob', |
|
1436 'dialog_read_image', 'dialog_write_image', 'digital_filter', |
|
1437 'dilate', 'dindgen', 'dissolve', 'dist', 'distance_measure', |
|
1438 'dlm_load', 'dlm_register', 'doc_library', 'double', |
|
1439 'draw_roi', 'edge_dog', 'efont', 'eigenql', 'eigenvec', |
|
1440 'ellipse', 'elmhes', 'emboss', 'empty', 'enable_sysrtn', |
|
1441 'eof', 'eos_[0-9a-za-z_]*', 'erase', 'erf', 'erfc', 'erfcx', |
|
1442 'erode', 'errorplot', 'errplot', 'estimator_filter', |
|
1443 'execute', 'exit', 'exp', 'expand', 'expand_path', 'expint', |
|
1444 'extrac', 'extract_slice', 'factorial', 'fft', 'filepath', |
|
1445 'file_basename', 'file_chmod', 'file_copy', 'file_delete', |
|
1446 'file_dirname', 'file_expand_path', 'file_info', |
|
1447 'file_lines', 'file_link', 'file_mkdir', 'file_move', |
|
1448 'file_poll_input', 'file_readlink', 'file_same', |
|
1449 'file_search', 'file_test', 'file_which', 'findgen', |
|
1450 'finite', 'fix', 'flick', 'float', 'floor', 'flow3', |
|
1451 'fltarr', 'flush', 'format_axis_values', 'free_lun', |
|
1452 'fstat', 'fulstr', 'funct', 'fv_test', 'fx_root', |
|
1453 'fz_roots', 'f_cvf', 'f_pdf', 'gamma', 'gamma_ct', |
|
1454 'gauss2dfit', 'gaussfit', 'gaussian_function', 'gaussint', |
|
1455 'gauss_cvf', 'gauss_pdf', 'gauss_smooth', 'getenv', |
|
1456 'getwindows', 'get_drive_list', 'get_dxf_objects', |
|
1457 'get_kbrd', 'get_login_info', 'get_lun', 'get_screen_size', |
|
1458 'greg2jul', 'grib_[0-9a-za-z_]*', 'grid3', 'griddata', |
|
1459 'grid_input', 'grid_tps', 'gs_iter', |
|
1460 'h5[adfgirst]_[0-9a-za-z_]*', 'h5_browser', 'h5_close', |
|
1461 'h5_create', 'h5_get_libversion', 'h5_open', 'h5_parse', |
|
1462 'hanning', 'hash', 'hdf_[0-9a-za-z_]*', 'heap_free', |
|
1463 'heap_gc', 'heap_nosave', 'heap_refcount', 'heap_save', |
|
1464 'help', 'hilbert', 'histogram', 'hist_2d', 'hist_equal', |
|
1465 'hls', 'hough', 'hqr', 'hsv', 'h_eq_ct', 'h_eq_int', |
|
1466 'i18n_multibytetoutf8', 'i18n_multibytetowidechar', |
|
1467 'i18n_utf8tomultibyte', 'i18n_widechartomultibyte', |
|
1468 'ibeta', 'icontour', 'iconvertcoord', 'idelete', 'identity', |
|
1469 'idlexbr_assistant', 'idlitsys_createtool', 'idl_base64', |
|
1470 'idl_validname', 'iellipse', 'igamma', 'igetcurrent', |
|
1471 'igetdata', 'igetid', 'igetproperty', 'iimage', 'image', |
|
1472 'image_cont', 'image_statistics', 'imaginary', 'imap', |
|
1473 'indgen', 'intarr', 'interpol', 'interpolate', |
|
1474 'interval_volume', 'int_2d', 'int_3d', 'int_tabulated', |
|
1475 'invert', 'ioctl', 'iopen', 'iplot', 'ipolygon', |
|
1476 'ipolyline', 'iputdata', 'iregister', 'ireset', 'iresolve', |
|
1477 'irotate', 'ir_filter', 'isa', 'isave', 'iscale', |
|
1478 'isetcurrent', 'isetproperty', 'ishft', 'isocontour', |
|
1479 'isosurface', 'isurface', 'itext', 'itranslate', 'ivector', |
|
1480 'ivolume', 'izoom', 'i_beta', 'journal', 'json_parse', |
|
1481 'json_serialize', 'jul2greg', 'julday', 'keyword_set', |
|
1482 'krig2d', 'kurtosis', 'kw_test', 'l64indgen', 'label_date', |
|
1483 'label_region', 'ladfit', 'laguerre', 'laplacian', |
|
1484 'la_choldc', 'la_cholmprove', 'la_cholsol', 'la_determ', |
|
1485 'la_eigenproblem', 'la_eigenql', 'la_eigenvec', 'la_elmhes', |
|
1486 'la_gm_linear_model', 'la_hqr', 'la_invert', |
|
1487 'la_least_squares', 'la_least_square_equality', |
|
1488 'la_linear_equation', 'la_ludc', 'la_lumprove', 'la_lusol', |
|
1489 'la_svd', 'la_tridc', 'la_trimprove', 'la_triql', |
|
1490 'la_trired', 'la_trisol', 'least_squares_filter', 'leefilt', |
|
1491 'legend', 'legendre', 'linbcg', 'lindgen', 'linfit', |
|
1492 'linkimage', 'list', 'll_arc_distance', 'lmfit', 'lmgr', |
|
1493 'lngamma', 'lnp_test', 'loadct', 'locale_get', |
|
1494 'logical_and', 'logical_or', 'logical_true', 'lon64arr', |
|
1495 'lonarr', 'long', 'long64', 'lsode', 'ludc', 'lumprove', |
|
1496 'lusol', 'lu_complex', 'machar', 'make_array', 'make_dll', |
|
1497 'make_rt', 'map', 'mapcontinents', 'mapgrid', 'map_2points', |
|
1498 'map_continents', 'map_grid', 'map_image', 'map_patch', |
|
1499 'map_proj_forward', 'map_proj_image', 'map_proj_info', |
|
1500 'map_proj_init', 'map_proj_inverse', 'map_set', |
|
1501 'matrix_multiply', 'matrix_power', 'max', 'md_test', |
|
1502 'mean', 'meanabsdev', 'mean_filter', 'median', 'memory', |
|
1503 'mesh_clip', 'mesh_decimate', 'mesh_issolid', 'mesh_merge', |
|
1504 'mesh_numtriangles', 'mesh_obj', 'mesh_smooth', |
|
1505 'mesh_surfacearea', 'mesh_validate', 'mesh_volume', |
|
1506 'message', 'min', 'min_curve_surf', 'mk_html_help', |
|
1507 'modifyct', 'moment', 'morph_close', 'morph_distance', |
|
1508 'morph_gradient', 'morph_hitormiss', 'morph_open', |
|
1509 'morph_thin', 'morph_tophat', 'multi', 'm_correlate', |
|
1510 'ncdf_[0-9a-za-z_]*', 'newton', 'noise_hurl', 'noise_pick', |
|
1511 'noise_scatter', 'noise_slur', 'norm', 'n_elements', |
|
1512 'n_params', 'n_tags', 'objarr', 'obj_class', 'obj_destroy', |
|
1513 'obj_hasmethod', 'obj_isa', 'obj_new', 'obj_valid', |
|
1514 'online_help', 'on_error', 'open', 'oplot', 'oploterr', |
|
1515 'parse_url', 'particle_trace', 'path_cache', 'path_sep', |
|
1516 'pcomp', 'plot', 'plot3d', 'ploterr', 'plots', 'plot_3dbox', |
|
1517 'plot_field', 'pnt_line', 'point_lun', 'polarplot', |
|
1518 'polar_contour', 'polar_surface', 'poly', 'polyfill', |
|
1519 'polyfillv', 'polygon', 'polyline', 'polyshade', 'polywarp', |
|
1520 'poly_2d', 'poly_area', 'poly_fit', 'popd', 'powell', |
|
1521 'pref_commit', 'pref_get', 'pref_set', 'prewitt', 'primes', |
|
1522 'print', 'printd', 'product', 'profile', 'profiler', |
|
1523 'profiles', 'project_vol', 'psafm', 'pseudo', |
|
1524 'ps_show_fonts', 'ptrarr', 'ptr_free', 'ptr_new', |
|
1525 'ptr_valid', 'pushd', 'p_correlate', 'qgrid3', 'qhull', |
|
1526 'qromb', 'qromo', 'qsimp', 'query_ascii', 'query_bmp', |
|
1527 'query_csv', 'query_dicom', 'query_gif', 'query_image', |
|
1528 'query_jpeg', 'query_jpeg2000', 'query_mrsid', 'query_pict', |
|
1529 'query_png', 'query_ppm', 'query_srf', 'query_tiff', |
|
1530 'query_wav', 'radon', 'randomn', 'randomu', 'ranks', |
|
1531 'rdpix', 'read', 'reads', 'readu', 'read_ascii', |
|
1532 'read_binary', 'read_bmp', 'read_csv', 'read_dicom', |
|
1533 'read_gif', 'read_image', 'read_interfile', 'read_jpeg', |
|
1534 'read_jpeg2000', 'read_mrsid', 'read_pict', 'read_png', |
|
1535 'read_ppm', 'read_spr', 'read_srf', 'read_sylk', |
|
1536 'read_tiff', 'read_wav', 'read_wave', 'read_x11_bitmap', |
|
1537 'read_xwd', 'real_part', 'rebin', 'recall_commands', |
|
1538 'recon3', 'reduce_colors', 'reform', 'region_grow', |
|
1539 'register_cursor', 'regress', 'replicate', |
|
1540 'replicate_inplace', 'resolve_all', 'resolve_routine', |
|
1541 'restore', 'retall', 'return', 'reverse', 'rk4', 'roberts', |
|
1542 'rot', 'rotate', 'round', 'routine_filepath', |
|
1543 'routine_info', 'rs_test', 'r_correlate', 'r_test', |
|
1544 'save', 'savgol', 'scale3', 'scale3d', 'scope_level', |
|
1545 'scope_traceback', 'scope_varfetch', 'scope_varname', |
|
1546 'search2d', 'search3d', 'sem_create', 'sem_delete', |
|
1547 'sem_lock', 'sem_release', 'setenv', 'set_plot', |
|
1548 'set_shading', 'sfit', 'shade_surf', 'shade_surf_irr', |
|
1549 'shade_volume', 'shift', 'shift_diff', 'shmdebug', 'shmmap', |
|
1550 'shmunmap', 'shmvar', 'show3', 'showfont', 'simplex', 'sin', |
|
1551 'sindgen', 'sinh', 'size', 'skewness', 'skip_lun', |
|
1552 'slicer3', 'slide_image', 'smooth', 'sobel', 'socket', |
|
1553 'sort', 'spawn', 'spher_harm', 'sph_4pnt', 'sph_scat', |
|
1554 'spline', 'spline_p', 'spl_init', 'spl_interp', 'sprsab', |
|
1555 'sprsax', 'sprsin', 'sprstp', 'sqrt', 'standardize', |
|
1556 'stddev', 'stop', 'strarr', 'strcmp', 'strcompress', |
|
1557 'streamline', 'stregex', 'stretch', 'string', 'strjoin', |
|
1558 'strlen', 'strlowcase', 'strmatch', 'strmessage', 'strmid', |
|
1559 'strpos', 'strput', 'strsplit', 'strtrim', 'struct_assign', |
|
1560 'struct_hide', 'strupcase', 'surface', 'surfr', 'svdc', |
|
1561 'svdfit', 'svsol', 'swap_endian', 'swap_endian_inplace', |
|
1562 'symbol', 'systime', 's_test', 't3d', 'tag_names', 'tan', |
|
1563 'tanh', 'tek_color', 'temporary', 'tetra_clip', |
|
1564 'tetra_surface', 'tetra_volume', 'text', 'thin', 'threed', |
|
1565 'timegen', 'time_test2', 'tm_test', 'total', 'trace', |
|
1566 'transpose', 'triangulate', 'trigrid', 'triql', 'trired', |
|
1567 'trisol', 'tri_surf', 'truncate_lun', 'ts_coef', 'ts_diff', |
|
1568 'ts_fcast', 'ts_smooth', 'tv', 'tvcrs', 'tvlct', 'tvrd', |
|
1569 'tvscl', 'typename', 't_cvt', 't_pdf', 'uindgen', 'uint', |
|
1570 'uintarr', 'ul64indgen', 'ulindgen', 'ulon64arr', 'ulonarr', |
|
1571 'ulong', 'ulong64', 'uniq', 'unsharp_mask', 'usersym', |
|
1572 'value_locate', 'variance', 'vector', 'vector_field', 'vel', |
|
1573 'velovect', 'vert_t3d', 'voigt', 'voronoi', 'voxel_proj', |
|
1574 'wait', 'warp_tri', 'watershed', 'wdelete', 'wf_draw', |
|
1575 'where', 'widget_base', 'widget_button', 'widget_combobox', |
|
1576 'widget_control', 'widget_displaycontextmen', 'widget_draw', |
|
1577 'widget_droplist', 'widget_event', 'widget_info', |
|
1578 'widget_label', 'widget_list', 'widget_propertysheet', |
|
1579 'widget_slider', 'widget_tab', 'widget_table', |
|
1580 'widget_text', 'widget_tree', 'widget_tree_move', |
|
1581 'widget_window', 'wiener_filter', 'window', 'writeu', |
|
1582 'write_bmp', 'write_csv', 'write_gif', 'write_image', |
|
1583 'write_jpeg', 'write_jpeg2000', 'write_nrif', 'write_pict', |
|
1584 'write_png', 'write_ppm', 'write_spr', 'write_srf', |
|
1585 'write_sylk', 'write_tiff', 'write_wav', 'write_wave', |
|
1586 'wset', 'wshow', 'wtn', 'wv_applet', 'wv_cwt', |
|
1587 'wv_cw_wavelet', 'wv_denoise', 'wv_dwt', 'wv_fn_coiflet', |
|
1588 'wv_fn_daubechies', 'wv_fn_gaussian', 'wv_fn_haar', |
|
1589 'wv_fn_morlet', 'wv_fn_paul', 'wv_fn_symlet', |
|
1590 'wv_import_data', 'wv_import_wavelet', 'wv_plot3d_wps', |
|
1591 'wv_plot_multires', 'wv_pwt', 'wv_tool_denoise', |
|
1592 'xbm_edit', 'xdisplayfile', 'xdxf', 'xfont', |
|
1593 'xinteranimate', 'xloadct', 'xmanager', 'xmng_tmpl', |
|
1594 'xmtool', 'xobjview', 'xobjview_rotate', |
|
1595 'xobjview_write_image', 'xpalette', 'xpcolor', 'xplot3d', |
|
1596 'xregistered', 'xroi', 'xsq_test', 'xsurface', 'xvaredit', |
|
1597 'xvolume', 'xvolume_rotate', 'xvolume_write_image', |
|
1598 'xyouts', 'zoom', 'zoom_24'] |
|
1599 """Functions from: http://www.exelisvis.com/docs/routines-1.html""" |
|
1600 |
|
1601 tokens = { |
|
1602 'root': [ |
|
1603 (r'^\s*;.*?\n', Comment.Singleline), |
|
1604 (r'\b(' + '|'.join(_RESERVED) + r')\b', Keyword), |
|
1605 (r'\b(' + '|'.join(_BUILTIN_LIB) + r')\b', Name.Builtin), |
|
1606 (r'\+=|-=|\^=|\*=|/=|#=|##=|<=|>=|=', Operator), |
|
1607 (r'\+\+|--|->|\+|-|##|#|\*|/|<|>|&&|\^|~|\|\|\?|:', Operator), |
|
1608 (r'\b(mod=|lt=|le=|eq=|ne=|ge=|gt=|not=|and=|or=|xor=)', Operator), |
|
1609 (r'\b(mod|lt|le|eq|ne|ge|gt|not|and|or|xor)\b', Operator), |
|
1610 (r'\b[0-9](L|B|S|UL|ULL|LL)?\b', Number), |
|
1611 (r'.', Text), |
|
1612 ] |
|
1613 } |
|
1614 |
|
1615 |
|
1616 class RdLexer(RegexLexer): |
|
1617 """ |
|
1618 Pygments Lexer for R documentation (Rd) files |
|
1619 |
|
1620 This is a very minimal implementation, highlighting little more |
|
1621 than the macros. A description of Rd syntax is found in `Writing R |
|
1622 Extensions <http://cran.r-project.org/doc/manuals/R-exts.html>`_ |
|
1623 and `Parsing Rd files <developer.r-project.org/parseRd.pdf>`_. |
|
1624 |
|
1625 *New in Pygments 1.6.* |
|
1626 """ |
|
1627 name = 'Rd' |
|
1628 aliases = ['rd'] |
|
1629 filenames = ['*.Rd'] |
|
1630 mimetypes = ['text/x-r-doc'] |
|
1631 |
|
1632 # To account for verbatim / LaTeX-like / and R-like areas |
|
1633 # would require parsing. |
|
1634 tokens = { |
|
1635 'root' : [ |
|
1636 # catch escaped brackets and percent sign |
|
1637 (r'\\[\\{}%]', String.Escape), |
|
1638 # comments |
|
1639 (r'%.*$', Comment), |
|
1640 # special macros with no arguments |
|
1641 (r'\\(?:cr|l?dots|R|tab)\b', Keyword.Constant), |
|
1642 # macros |
|
1643 (r'\\[a-zA-Z]+\b', Keyword), |
|
1644 # special preprocessor macros |
|
1645 (r'^\s*#(?:ifn?def|endif).*\b', Comment.Preproc), |
|
1646 # non-escaped brackets |
|
1647 (r'[{}]', Name.Builtin), |
|
1648 # everything else |
|
1649 (r'[^\\%\n{}]+', Text), |
|
1650 (r'.', Text), |
|
1651 ] |
|
1652 } |