License New BSD license
Lines 368
Keywords
fortran (1) lexer (6) numpy (3) pygments (6) xslt (1)
Included in this Library
Permissions
Owner: Stou S.
Viewable by Everyone
Editable by All Siafoo Users
Hide
Writing an article is easy - try our reStructured Text demo Join Siafoo Now or Learn More

Various pygments lexers Atom Feed 0

In Brief Some lexers I wrote for Siafoo.... more
# 's
  1"""
2Copyright 2007 (c) Siafoo.net
3
4Some lexers based on code from Pygments project, by Georg Brandl, Tim Hatch
5
6Custom Siafoo Lexers, or Lexers not implemented in Pygments
7"""
8
9import re
10
11from pygments.lexer import RegexLexer, include, bygroups, using, this
12from pygments.lexers.agile import PythonLexer
13from pygments.lexers.web import XmlLexer
14from pygments.token import Error, Punctuation, Text, Comment, Operator, Keyword, Name, String, Number
15from pygments.util import shebang_matches
16
17
18class FortranLexer(RegexLexer):
19 '''
20 A FORTRAN lexer
21 '''
22 name = 'Fortran'
23 aliases = ['fortran']
24 filenames = ['*.f']
25 mimetypes = []
26 flags = re.IGNORECASE
27
28 # Data Types: INTEGER, REAL, COMPLEX, LOGICAL, CHARACTER and DOUBLE PRECISION
29 # Operators: **, *, +, -, /, <, >, <=, >=, ==, /=
30 # Logical (?): NOT, AND, OR, EQV, NEQV
31
32 # Builtins: http://gcc.gnu.org/onlinedocs/gcc-3.4.6/g77/Table-of-Intrinsic-Functions.html
33
34 tokens = {
35 'root': [
36 (r'!.*\n', Comment),
37 include('strings'),
38 include('core'),
39 (r'[a-z][a-z0-9_]*', Name.Variable),
40 include('nums'),
41 (r'[\s]+', Text)
42 ],
43 'core':[ # Statements
44 (r'\b(ACCEPT|ALLOCATABLE|ALLOCATE|ARRAY|ASSIGN|BACKSPACE|BLOCK DATA|BYTE|CALL|CASE|'
45 r'CLOSE|COMMON|CONTAINS|CONTINUE|CYCLE|DATA|DEALLOCATE|DECODE|DIMENSION|DO|ENCODE|END|'
46 r'END FILE|ENDIF|ENTRY|EQUIVALENCE|EXIT|EXTERNAL|EXTRINSIC|FORALL|FORMAT|FUNCTION|GOTO|'
47 r'IF|IMPLICIT|INCLUDE|INQUIRE|INTENT|INTERFACE|INTRINSIC|MODULE|NAMELIST|NULLIFY|NONE|'
48 r'OPEN|OPTIONAL|OPTIONS|PARAMETER|PAUSE|POINTER|PRINT|PRIVATE|PROGRAM|PUBLIC|PURE|READ|'
49 r'RECURSIVE|RETURN|REWIND|SAVE|SELECT|SEQUENCE|STOP|SUBROUTINE|TARGET|TYPE|USE|VOLATILE|'
50 r'WHERE|WRITE|WHILE|THEN|ELSE|ENDIF)\s*\b',
51 Keyword),
52
53 # Data Types
54 (r'\b(CHARACTER|COMPLEX|DOUBLE PRECISION|DOUBLE COMPLEX|INTEGER|LOGICAL|REAL)\s*\b',
55 Keyword.Type),
56
57 # Operators
58 (r'(\*\*|\*|\+|-|\/|<|>|<=|>=|==|\/=|=)',
59 Operator),
60
61 (r'(\(|\)|\,)',
62 Punctuation),
63
64 (r'(::)',
65 Keyword.Declaration),
66
67 # Intrinsics
68 (r'\b(Abort|Abs|Access|AChar|ACos|AdjustL|AdjustR|AImag|AInt|Alarm|'
69 r'All|Allocated|ALog|ALog|AMax|AMax|AMin|AMin|AMod|And|ANInt|Any|'
70 r'ASin|Associated|ATan|ATan|BesJ|BesJ|BesJN|BesY|BesY|BesYN|Bit_Size|'
71 r'BTest|CAbs|CCos|Ceiling|CExp|Char|ChDir|ChMod|CLog|Cmplx|Complex|Conjg|'
72 r'Cos|CosH|Count|CPU_Time|CShift|CSin|CSqRt|CTime|CTime|DAbs|DACos|DASin|'
73 r'DATan|DATan|Date_and_Time|DbesJ|DbesJ|DbesJN|DbesY|DbesY|DbesYN|Dble|DCos|'
74 r'DCosH|DDiM|DErF|DErFC|DExp|Digits|DiM|DInt|DLog|DLog|DMax|DMin|DMod|DNInt|'
75 r'Dot_Product|DProd|DSign|DSin|DSinH|DSqRt|DTan|DTanH|DTime|EOShift|Epsilon|'
76 r'ErF|ErFC|ETime|ETime|Exit|Exp|Exponent|FDate|yyyy|FDate|yyyy|FGet|FGetC|'
77 r'Float|Floor|Flush|FNum|FPut|FPutC|Fraction|FSeek|FStat|FStat|FTell|FTell|'
78 r'GError|GetArg|GetCWD|GetCWD|GetEnv|GetGId|GetLog|GetPId|GetUId|GMTime|'
79 r'HostNm|HostNm|Huge|IAbs|IAChar|IAnd|IArgC|IBClr|IBits|IBSet|IChar|'
80 r'IDate|IDiM|IDInt|IDNInt|number|IEOr|IErrNo|IFix|Imag|ImagPart|Index|Int|'
81 r'Int|number|Int|number|IOr|IRand|IsaTty|IShft|IShftC|ISign|ITime|Kill|Kind|'
82 r'LBound|Len|Len_Trim|LGe|LGt|Link|LLe|LLt|LnBlnk|Loc|Log|Log|Logical|Long|'
83 r'LShift|LStat|LStat|LTime|MatMul|Max|Max|Max|MaxExponent|MaxLoc|MaxVal|MClock|'
84 r'MClock|Merge|Min|Min|Min|MinExponent|MinLoc|MinVal|Mod|Modulo|MvBits|Nearest|'
85 r'NInt|number|Not|Or|Pack|PError|Precision|Present|Product|Radix|Rand|Random_Number|'
86 r'Random_Seed|Range|Real|RealPart|Rename|Repeat|Reshape|RRSpacing|RShift|Scale|Scan|'
87 r'Second|Second|Selected_Int_Kind|Selected_Real_Kind|Set_Exponent|Shape|Short|number|'
88 r'Sign|Signal|Sin|SinH|Sleep|Sngl|Spacing|Spread|SqRt|SRand|Stat|Stat|Sum|SymLnk|'
89 r'System|System_Clock|Tan|TanH|Time|Time|Tiny|Transfer|Transpose|Trim|TtyNam|TtyNam|'
90 r'UBound|UMask|Unlink|Unpack|Verify|XOr|ZAbs|ZCos|ZExp|ZLog|ZSin|ZSqRt)\s*\b',
91 Name.Builtin)
92 ],
93
94 'strings': [
95 (r'"(\\\\|\\[0-7]+|\\.|[^"])*"', String.Double),
96 (r"'(\\\\|\\[0-7]+|\\.|[^'])*'", String.Single),
97 ],
98
99 'nums': [
100 (r'\d+(?![.Ee])', Number.Integer),
101 (r'[+-]?\d*\.\d+([eE][-+]?\d+)?', Number.Float),
102 (r'[+-]?\d+\.\d*([eE][-+]?\d+)?', Number.Float)
103 ],
104 }
105
106class MatLabLexer(RegexLexer):
107 name = 'MatLab'
108 aliases = ['matlab']
109 filenames = ['*.m']
110 mimetypes = []
111 #flags = re.DOTALL
112
113 # List of builtins were taken from:
114 #http://www.mathworks.com/access/helpdesk/help/techdoc/index.html?/access/helpdesk/help/techdoc/ref/funcalpha.html
115
116 tokens = {
117 'root': [
118 (r'\%\{[\w\W\n]*?\%\}', Comment.Multiline),
119 (r'%.*\n', Comment.Single),
120
121 include('strings'),
122 include('core'),
123 (r'[a-zA-Z][a-zA-Z0-9_]*', Name.Variable),
124 include('nums'),
125 (r'[\s]+', Text)
126 ],
127 'core':[ # Statements
128 (r'\b(break|case|catch|continue|else|elseif|end|error|for|if|otherwise|return|switch|try|while)\s*\b',
129 Keyword),
130
131 # Operators
132 (r'(\+|\-|\*|\^|\\|\/|\.\*|\.\^|\.\\|\.\/|\.|\=|\^|\'|\.\'|' # Mathematical
133 r'<|<=|>|>=|==|~=|' # Comparison
134 r'&&|\|\||\&|\||\~|' # Logical
135 r'\]|\[|\{|\}|\.|\!|\@|\:)', # Other
136 Operator),
137
138 (r'(\(|\)|\,|\;)',
139 Punctuation),
140
141 (r'\b(ColorSpec|Execute|Feval|GetCharArray|GetFullMatrix|GetVariable|GetWorkspaceData|Inf|MException|NaN|PutCharArray|PutFullMatrix|PutWorkspaceData|Quit|'
142 r'abs|accumarray|acos|acosd|acosh|acot|acotd|acoth|acsc|acscd|acsch|actxGetRunningServer|actxcontrol|actxcontrollist|'
143 r'actxcontrolselect|actxserver|addCause|addOptional|addParamValue|addRequired|addevent|addframe|addpath|addpref|'
144 r'addproperty|addsample|addsampletocollection|addtodate|addts|airy|align|alim|all|allchild|alpha|alphamap|amd|'
145 r'ancestor|and|angle|annotation|ans|any|area|arrayfun|ascii|asec|asecd|asech|asin|asind|asinh|assert|assignin|atan|atan2|'
146 r'atand|atanh|audioplayer|audiorecorder|aufinfo|auread|auwrite|avifile|aviinfo|aviread|axes|axis|balance|bar|bar3|'
147 r'bar3h|barh|base2dec|beep|besselh|besseli|besselj|besselk|bessely|beta|betainc|betaln|bicg|bicgstab|bin2dec|binary|'
148 r'bitand|bitcmp|bitget|bitmax|bitor|bitset|bitshift|bitxor|blanks|blkdiag|box|brighten|bsxfun|builtin|bvp4c|bvp5c|'
149 r'bvpget|bvpinit|bvpset|bvpxtend|calendar|callSoapService|calllib|camdolly|cameratoolbar|camlight|camlookat|'
150 r'camorbit|campan|campos|camproj|camroll|camtarget|camup|camva|camzoom|cart2pol|cart2sph|cast|cat|catch|caxis|cd|'
151 r'cdf2rdf|cdfepoch|cdfinfo|cdfread|cdfwrite|ceil|cell|cell2mat|cell2struct|celldisp|cellfun|cellplot|cellstr|cgs|'
152 r'char|checkin|checkout|chol|cholinc|cholupdate|circshift|cla|clabel|class|clc|clear|clf|clipboard|clock|close|'
153 r'closereq|cmopts|colamd|colorbar|colordef|colormap|colormapeditor|colperm|comet|comet3|commandhistory|'
154 r'commandwindow|compan|compass|complex|computer|cond|condeig|condest|coneplot|conj|contour3|contourc|contourf|'
155 r'contourslice|contrast|conv|conv2|convhull|convhulln|convn|copyfile|copyobj|corrcoef|cos|cosd|cosh|cot|cotd|coth|cov|'
156 r'cplxpair|cputime|createClassFromWsdl|createCopy|createSoapMessage|cross|csc|cscd|csch|csvread|csvwrite|'
157 r'ctranspose|cumprod|cumsum|cumtrapz|curl|customverctrl|cylinder|daqread|daspect|datacursormode|datatipinfo|date|'
158 r'datenum|datestr|datetick|datevec|dbclear|dbcont|dbdown|dblquad|dbmex|dbquit|dbstack|dbstatus|dbstep|dbstop|dbtype|'
159 r'dbup|dde23|ddeget|ddesd|ddeset|deal|deblank|debug|dec2base|dec2bin|dec2hex|decic|deconv|del2|delaunay|delaunay3|'
160 r'delaunayn|delete|deleteproperty|delevent|delsample|delsamplefromcollection|demo|depdir|depfun|det|detrend|deval|'
161 r'diag|dialog|diary|diff|diffuse|dir|disp|display|divergence|dlmread|dlmwrite|dmperm|doc|docopt|docsearch|dos|dot|'
162 r'double|dragrect|drawnow|dsearch|dsearchn|echo|echodemo|edit|eig|eigs|ellipj|ellipke|ellipsoid|enableservice|end|'
163 r'eomday|eps|eq|erf|erfc|erfcinv|erfcx|erfinv|error|errorbar|errordlg|etime|etree|etreeplot|eval|evalc|evalin|'
164 r'eventlisteners|events|exifread|exist|exit|exp|expint|expm|expm1|export2wsdlg|eye|ezcontour|ezcontourf|ezmesh|'
165 r'ezmeshc|ezplot|ezplot3|ezpolar|ezsurf|ezsurfc|factor|factorial|false|fclose|feather|feof|ferror|feval|fft|fft2|fftn|'
166 r'fftshift|fftw|fgetl|fgets|fieldnames|figure|figurepalette|fileattrib|filebrowser|filehandle|filemarker|'
167 r'fileparts|filesep|fill|fill3|filter|filter2|find|findall|findfigs|findobj|findstr|finish|fitsinfo|fitsread|fix|'
168 r'flipdim|fliplr|flipud|floor|flow|fminbnd|fminsearch|fopen|format|fplot|fprintf|frame2im|frameedit|fread|freqspace|'
169 r'frewind|fscanf|fseek|ftell|ftp|full|fullfile|func2str|function|function_handle|functions|funm|fwrite|fzero|gallery|'
170 r'gamma|gammainc|gammaln|gca|gcbf|gcbo|gcd|gcf|gco|ge|genpath|genvarname|get|getReport|getabstime|getappdata|'
171 r'getdatasamplesize|getenv|getfield|getframe|getinterpmethod|getpixelposition|getpref|getqualitydesc|'
172 r'getsampleusingtime|gettimeseriesnames|gettsafteratevent|gettsafterevent|gettsatevent|gettsbeforeatevent|'
173 r'gettsbeforeevent|gettsbetweenevents|ginput|global|gmres|gplot|grabcode|gradient|graymon|grid|griddata|griddata3|'
174 r'griddatan|gsvd|gt|gtext|guidata|guide|guihandles|gunzip|gzip|hadamard|hankel|hdf|hdf5|hdf5info|hdf5read|hdf5write|'
175 r'hdfinfo|hdfread|hdftool|help|helpbrowser|helpdlg|helpwin|hess|hex2dec|hex2num|hgexport|hggroup|hgload|hgsave|'
176 r'hgtransform|hidden|hilb|hist|histc|hold|home|horzcat|hostid|hsv2rgb|hypot|i|idealfilter|idivide|ifft|ifft2|ifftn|'
177 r'ifftshift|ilu|im2frame|im2java|imag|image|imagesc|imfinfo|imformats|import|importdata|imread|imwrite|ind2rgb|'
178 r'ind2sub|inferiorto|info|inline|inmem|inpolygon|input|inputParser|inputdlg|inputname|inspect|instrcallback|'
179 r'instrfind|instrfindall|int16|int2str|int32|int64|int8|interfaces|interp1|interp1q|interp2|interp3|interpft|'
180 r'interpn|interpstreamspeed|intersect|intmax|intmin|intwarning|inv|invhilb|invoke|ipermute|iqr|isa|isappdata|iscell|'
181 r'iscellstr|ischar|iscom|isdir|isempty|isequal|isequalwithequalnans|isevent|isfield|isfinite|isfloat|isglobal|'
182 r'ishandle|ishold|isinf|isinteger|isinterface|isjava|iskeyword|isletter|islogical|ismac|ismember|ismethod|isnan|'
183 r'isnumeric|isobject|isocaps|isocolors|isonormals|isosurface|ispc|ispref|isprime|isprop|isreal|isscalar|issorted|'
184 r'isspace|issparse|isstr|isstrprop|isstruct|isstudent|isunix|isvalid|isvarname|isvector|j|javaArray|javaMethod|'
185 r'javaObject|javaaddpath|javachk|javaclasspath|javarmpath|keyboard|kron|last|lasterr|lasterror|lastwarn|lcm|ldl|le|'
186 r'legend|legendre|length|libfunctions|libfunctionsview|libisloaded|libpointer|libstruct|license|light|lightangle|'
187 r'lighting|lin2mu|line|linkaxes|linkprop|linsolve|linspace|listdlg|listfonts|load|loadlibrary|loadobj|log|log10|'
188 r'log1p|log2|logical|loglog|logm|logspace|lookfor|lower|ls|lscov|lsqnonneg|lsqr|lt|lu|luinc|magic|makehgtform|mat2cell|'
189 r'mat2str|material|matlab|matlabcolon|matlabrc|matlabroot|max|maxNumCompThreads|mean|median|memmapfile|memory|menu|'
190 r'mesh|meshc|meshgrid|meshz|methods|methodsview|mex|mexext|mfilename|mget|min|minres|mislocked|mkdir|mkpp|mldivide|'
191 r'mlint|mlintrpt|mlock|mmfileinfo|mmreader|mod|mode|more|move|movefile|movegui|movie|movie2avi|mput|msgbox|mu2lin|'
192 r'multibandread|multibandwrite|munlock|namelengthmax|nargchk|nargin|nargout|nargoutchk|native2unicode|nchoosek|'
193 r'ndgrid|ndims|ne|newplot|nextpow2|nnz|noanimate|nonzeros|norm|normest|not|notebook|now|nthroot|null|num2cell|num2hex|'
194 r'num2str|numel|nzmax|ode113|ode15i|ode15s|ode23|ode23s|ode23t|ode23tb|ode45|odefile|odeget|odeset|odextend|ones|open|'
195 r'openfig|opengl|openvar|optimget|optimset|or|ordeig|orderfields|ordqz|ordschur|orient|orth|pack|padecoef|pan|pareto|'
196 r'parse|parseSoapResponse|partialpath|pascal|patch|path|path2rc|pathdef|pathsep|pathtool|pause|pbaspect|pcg|pchip|'
197 r'pcode|pcolor|pdepe|pdeval|peaks|perl|perms|permute|persistent|pi|pie|pie3|pinv|planerot|playshow|plot|plot3|'
198 r'plotbrowser|plotedit|plotmatrix|plottools|plotyy|pol2cart|polar|poly|polyarea|polyder|polyeig|polyfit|polyint|'
199 r'polyval|polyvalm|pow2|ppval|prefdir|preferences|primes|print|printdlg|printopt|printpreview|prod|profile|profsave|'
200 r'propedit|propertyeditor|psi|publish|pwd|qmr|qr|qrdelete|qrinsert|qrupdate|quad|quadgk|quadl|quadv|questdlg|quit|'
201 r'quiver|quiver3|rand|randn|randperm|rank|rat|rats|rbbox|rcond|read|readasync|real|reallog|realmax|realmin|realpow|'
202 r'realsqrt|record|rectangle|rectint|recycle|reducepatch|reducevolume|refresh|refreshdata|regexp|regexpi|regexprep|'
203 r'regexptranslate|registerevent|rehash|release|rem|removets|rename|repmat|resample|reset|reshape|residue|'
204 r'restoredefaultpath|rethrow|rgb2hsv|rgbplot|ribbon|rmappdata|rmdir|rmfield|rmpath|rmpref|root|roots|rose|rosser|'
205 r'rot90|rotate|rotate3d|round|rref|rsf2csf|run|save|saveas|saveobj|savepath|scatter|scatter3|schur|script|sec|secd|sech|'
206 r'selectmoveresize|semilogx|semilogy|sendmail|serial|serialbreak|set|setabstime|setappdata|setdiff|setenv|'
207 r'setfield|setinterpmethod|setpixelposition|setpref|settimeseriesnames|setxor|shading|shiftdim|showplottool|'
208 r'shrinkfaces|sign|sin|sind|single|sinh|size|slice|smooth3|sort|sortrows|sound|soundsc|spalloc|sparse|spaugment|'
209 r'spconvert|spdiags|specular|speye|spfun|sph2cart|sphere|spinmap|spline|spones|spparms|sprand|sprandn|sprandsym|'
210 r'sprank|sprintf|spy|sqrt|sqrtm|squeeze|ss2tf|sscanf|stairs|start|startat|startup|std|stem|stem3|stop|stopasync|'
211 r'str2double|str2func|str2mat|str2num|strcat|strcmp|strcmpi|stream2|stream3|streamline|streamparticles|'
212 r'streamribbon|streamslice|streamtube|strfind|strings|strjust|strmatch|strncmp|strncmpi|strread|strrep|strtok|'
213 r'strtrim|struct|struct2cell|structfun|strvcat|sub2ind|subplot|subsasgn|subsindex|subspace|subsref|substruct|'
214 r'subvolume|sum|superiorto|support|surf|surf2patch|surface|surfc|surfl|surfnorm|svd|svds|swapbytes|symamd|symbfact|'
215 r'symmlq|symrcm|symvar|synchronize|syntax|system|tan|tand|tanh|tar|tempdir|tempname|tetramesh|texlabel|text|textread|'
216 r'textscan|textwrap|throw|tic|timer|timerfind|timerfindall|timeseries|title|toc|todatenum|toeplitz|toolboxdir|trace|'
217 r'transpose|trapz|treelayout|treeplot|tril|trimesh|triplequad|triplot|trisurf|triu|true|try|tscollection|'
218 r'tsdata.event|tsearch|tsearchn|tsprops|tstool|type|typecast|uibuttongroup|uicontextmenu|uicontrol|uigetdir|'
219 r'uigetfile|uigetpref|uiimport|uimenu|uint16|uint32|uint64|uint8|uiopen|uipanel|uipushtool|uiputfile|uiresume|'
220 r'uisave|uisetcolor|uisetfont|uisetpref|uistack|uitoggletool|uitoolbar|uiwait|undocheckout|unicode2native|union|'
221 r'unique|unix|unloadlibrary|unmkpp|unregisterallevents|unregisterevent|untar|unwrap|unzip|upper|urlread|urlwrite|'
222 r'usejava|validateattributes|validatestring|vander|var|varargin|varargout|vectorize|ver|verLessThan|verctrl|'
223 r'version|vertcat|view|viewmtx|volumebounds|voronoi|voronoin|wait|waitbar|waitfor|waitforbuttonpress|warndlg|'
224 r'warning|waterfall|wavfinfo|wavplay|wavread|wavrecord|wavwrite|web|weekday|what|whatsnew|which|whitebg|who|whos|'
225 r'wilkinson|winopen|winqueryreg|wk1finfo|wk1read|wk1write|workspace|xlabel|xlim|xlsfinfo|xlsread|xlswrite|xmlread|'
226 r'xmlwrite|xor|xslt|ylabel|ylim|zeros|zip|zlabel|zlim|zoom)\s*\b',
227 Name.Builtin)
228 ],
229
230 'strings': [
231 (r"'(\\\\|\\[0-7]+|\\.|[^'])*'", String.Single),
232 ],
233
234 'nums': [
235 (r'\d+(?![.Ee])', Number.Integer),
236 (r'[+-]?\d*\.\d+([eE][-+]?\d+)?', Number.Float),
237 (r'[+-]?\d+\.\d*([eE][-+]?\d+)?', Number.Float)
238 ],
239 }
240
241class NumPyLexer(PythonLexer):
242 '''
243 A lexer for Numerical Python builtins
244
245 Unimplemented: '...', 'T'
246 '''
247
248 name = 'NumPy'
249 aliases = ['numpy']
250
251 EXTRA_KEYWORDS = ['abs', 'absolute', 'accumulate', 'add', 'alen', 'all', 'allclose', 'alltrue', 'alterdot',
252 'amax', 'amin', 'angle', 'any', 'append', 'apply_along_axis', 'apply_over_axes', 'arange',
253 'arccos', 'arccosh', 'arcsin', 'arcsinh', 'arctan', 'arctan2', 'arctanh', 'argmax', 'argmin',
254 'argsort', 'argwhere', 'around', 'array', 'array2string', 'array_equal', 'array_equiv',
255 'array_repr', 'array_split', 'array_str', 'arrayrange', 'asanyarray', 'asarray',
256 'asarray_chkfinite', 'ascontiguousarray', 'asfarray', 'asfortranarray', 'asmatrix',
257 'asscalar', 'astype', 'atleast_1d', 'atleast_2d', 'atleast_3d', 'average', 'bartlett',
258 'base_repr', 'beta', 'binary_repr', 'bincount', 'binomial', 'bitwise_and', 'bitwise_not',
259 'bitwise_or', 'bitwise_xor', 'blackman', 'bmat', 'broadcast', 'byte_bounds', 'bytes',
260 'byteswap', 'c_', 'can_cast', 'ceil', 'choose', 'clip', 'column_stack', 'common_type',
261 'compare_chararrays', 'compress', 'concatenate', 'conj', 'conjugate', 'convolve', 'copy',
262 'corrcoef', 'correlate', 'cos', 'cosh', 'cov', 'cross', 'cumprod', 'cumproduct', 'cumsum',
263 'delete', 'deprecate', 'diag', 'diagflat', 'diagonal', 'diff', 'digitize', 'disp', 'divide',
264 'dot', 'dsplit', 'dstack', 'dtype', 'dump', 'dumps', 'ediff1d', 'empty', 'empty_like', 'equal',
265 'exp', 'expand_dims', 'expm1', 'extract', 'eye', 'fabs', 'fastCopyAndTranspose', 'fft',
266 'fftfreq', 'fftshift', 'fill', 'finfo', 'fix', 'flat', 'flatnonzero', 'flatten', 'fliplr',
267 'flipud', 'floor', 'floor_divide', 'fmod', 'frexp', 'fromarrays', 'frombuffer', 'fromfile',
268 'fromfunction', 'fromiter', 'frompyfunc', 'fromstring', 'generic', 'get_array_wrap',
269 'get_include', 'get_numarray_include', 'get_numpy_include', 'get_printoptions', 'getbuffer',
270 'getbufsize', 'geterr', 'geterrcall', 'geterrobj', 'getfield', 'gradient', 'greater',
271 'greater_equal', 'gumbel', 'hamming', 'hanning', 'histogram', 'histogram2d', 'histogramdd',
272 'hsplit', 'hstack', 'hypot', 'i0', 'identity', 'ifft', 'imag', 'index_exp', 'indices', 'inf',
273 'info', 'inner', 'insert', 'int_asbuffer', 'interp', 'intersect1d', 'intersect1d_nu', 'inv',
274 'invert', 'iscomplex', 'iscomplexobj', 'isfinite', 'isfortran', 'isinf', 'isnan', 'isneginf',
275 'isposinf', 'isreal', 'isrealobj', 'isscalar', 'issctype', 'issubclass_', 'issubdtype',
276 'issubsctype', 'item', 'itemset', 'iterable', 'ix_', 'kaiser', 'kron', 'ldexp', 'left_shift',
277 'less', 'less_equal', 'lexsort', 'linspace', 'load', 'loads', 'loadtxt', 'log', 'log10',
278 'log1p', 'log2', 'logical_and', 'logical_not', 'logical_or', 'logical_xor', 'logspace',
279 'lstsq', 'mat', 'matrix', 'max', 'maximum', 'maximum_sctype', 'may_share_memory', 'mean',
280 'median', 'meshgrid', 'mgrid', 'min', 'minimum', 'mintypecode', 'mod', 'modf', 'msort',
281 'multiply', 'nan', 'nan_to_num', 'nanargmax', 'nanargmin', 'nanmax', 'nanmin', 'nansum',
282 'ndenumerate', 'ndim', 'ndindex', 'negative', 'newaxis', 'newbuffer', 'newbyteorder',
283 'nonzero', 'not_equal', 'obj2sctype', 'ogrid', 'ones', 'ones_like', 'outer', 'permutation',
284 'piecewise', 'pinv', 'pkgload', 'place', 'poisson', 'poly', 'poly1d', 'polyadd', 'polyder',
285 'polydiv', 'polyfit', 'polyint', 'polymul', 'polysub', 'polyval', 'power', 'prod', 'product',
286 'ptp', 'put', 'putmask', 'r_', 'randint', 'random_integers', 'random_sample', 'ranf', 'rank',
287 'ravel', 'real', 'real_if_close', 'recarray', 'reciprocal', 'reduce', 'remainder', 'repeat',
288 'require', 'reshape', 'resize', 'restoredot', 'right_shift', 'rint', 'roll', 'rollaxis',
289 'roots', 'rot90', 'round', 'round_', 'row_stack', 's_', 'sample', 'savetxt', 'sctype2char',
290 'searchsorted', 'seed', 'select', 'set_numeric_ops', 'set_printoptions', 'set_string_function',
291 'setbufsize', 'setdiff1d', 'seterr', 'seterrcall', 'seterrobj', 'setfield', 'setflags',
292 'setmember1d', 'setxor1d', 'shape', 'show_config', 'shuffle', 'sign', 'signbit', 'sin', 'sinc',
293 'sinh', 'size', 'slice', 'solve', 'sometrue', 'sort', 'sort_complex', 'source', 'split', 'sqrt',
294 'square', 'squeeze', 'standard_normal', 'std', 'subtract', 'sum', 'svd', 'swapaxes', 'take',
295 'tan', 'tanh', 'tensordot', 'test', 'tile', 'tofile', 'tolist', 'tostring', 'trace', 'transpose',
296 'trapz', 'tri', 'tril', 'trim_zeros', 'triu', 'true_divide', 'typeDict', 'typename', 'uniform',
297 'union1d', 'unique', 'unique1d', 'unravel_index', 'unwrap', 'vander', 'var', 'vdot', 'vectorize',
298 'view', 'vonmises', 'vsplit', 'vstack', 'weibull', 'where', 'who', 'zeros', 'zeros_like']
299
300 def get_tokens_unprocessed(self, text):
301 for index, token, value in PythonLexer.get_tokens_unprocessed(self, text):
302 if token is Name and value in self.EXTRA_KEYWORDS:
303 yield index, Keyword.Pseudo, value
304 else:
305 yield index, token, value
306
307class TcshLexer(RegexLexer):
308 """
309 Lexer for tcsh scripts
310
311 A modification of BashLexer from: pygments.lexers.other
312
313 Lexers for other languages.
314
315 :copyright: 2006-2007 by Georg Brandl, Tim Hatch <tim@timhatch.com>.
316 :license: BSD, see LICENSE for more details.
317
318 """
319
320 name = 'Tcsh'
321 aliases = ['tcsh', 'sh']
322 filenames = ['*.csh']
323 mimetypes = ['application/x-sh', 'application/x-shellscript']
324
325 tokens = {
326 'root': [
327 include('basic'),
328 (r'\$\(', Keyword, 'paren'),
329 (r'\${#?', Keyword, 'curly'),
330 (r'`', String.Backtick, 'backticks'),
331 include('data'),
332 ],
333 'basic': [
334 (r'\b(if|endif|else|while|then|foreach|case|default|'
335 r'continue|goto|breaksw|end|switch|endsw)\s*\b',
336 Keyword),
337 (r'\b(alias|alloc|bg|bindkey|break|builtins|bye|caller|cd|chdir|'
338 r'complete|dirs|echo|echotc|eval|exec|exit|'
339 r'fg|filetest|getxvers|glob|getspath|hashstat|history|hup|inlib|jobs|kill|'
340 r'limit|log|login|logout|ls-F|migrate|newgrp|nice|nohup|notify|'
341 r'onintr|popd|printenv|pushd|rehash|repeat|rootnode|popd|pushd|set|shift|'
342 r'sched|setenv|setpath|settc|setty|setxvers|shift|source|stop|suspend|'
343 r'source|suspend|telltc|time|'
344 r'umask|unalias|uncomplete|unhash|universe|unlimit|unset|unsetenv|ver|wait|warp|watchlog|where|which)\s*\b',
345 Name.Builtin),
346 (r'#.*\n', Comment),
347 (r'\\[\w\W]', String.Escape),
348 (r'(\b\w+)(\s*)(=)', bygroups(Name.Variable, Text, Operator)),
349 (r'[\[\]{}()=]+', Operator),
350 (r'<<\s*(\'?)\\?(\w+)[\w\W]+?\2', String),
351 ],
352 'data': [
353 (r'"(\\\\|\\[0-7]+|\\.|[^"])*"', String.Double),
354 (r"'(\\\\|\\[0-7]+|\\.|[^'])*'", String.Single),
355 (r'\s+', Text),
356 (r'[^=\s\n\[\]{}()$"\'`\\]+', Text),
357 (r'\d+(?= |\Z)', Number),
358 (r'\$#?(\w+|.)', Name.Variable),
359 ],
360 'curly': [
361 (r'}', Keyword, '#pop'),
362 (r':-', Keyword),
363 (r'[a-zA-Z0-9_]+', Name.Variable),
364 (r'[^}:"\'`$]+', Punctuation),
365 (r':', Punctuation),
366 include('root'),
367 ],
368 'paren': [
369 (r'\)', Keyword, '#pop'),
370 include('root'),
371 ],
372 'backticks': [
373 (r'`', String.Backtick, '#pop'),
374 include('root'),
375 ],
376 }
377
378class XsltLexer(XmlLexer):
379 '''
380 A lexer for XSLT
381 '''
382
383 name = 'XSLT'
384 aliases = ['xslt']
385 filenames = ['*.xsl', '*.xslt']
386
387 EXTRA_KEYWORDS = ['apply-imports', 'apply-templates', 'attribute',
388 'attribute-set', 'call-template', 'choose', 'comment',
389 'copy', 'copy-of', 'decimal-format', 'element', 'fallback',
390 'for-each', 'if', 'import', 'include', 'key', 'message',
391 'namespace-alias', 'number', 'otherwise', 'output', 'param',
392 'preserve-space', 'processing-instruction', 'sort',
393 'strip-space', 'stylesheet', 'template', 'text', 'transform',
394 'value-of', 'variable', 'when', 'with-param',]
395
396 def get_tokens_unprocessed(self, text):
397 for index, token, value in XmlLexer.get_tokens_unprocessed(self, text):
398
399 m = re.match('</?xsl:([^>]*)/?>?', value)
400
401 if token is Name.Tag and m and m.group(1) in self.EXTRA_KEYWORDS:
402 yield index, Keyword, value
403 else:
404 yield index, token, value

Some lexers I wrote for Siafoo.

The Fortran and Matlab lexers could use some work since they don't take into account variable / function definitions and highlight them as plain "names", instead of "variable name" / "function name".

Note

All but the Matlab lexers are included in the Pygments 1.0 release, a release that already includes a set of Matlab lexers (of no doubt higher quality than the one here).