rouge 1.1.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (54) hide show
  1. data/Gemfile +2 -0
  2. data/lib/rouge/cli.rb +15 -0
  3. data/lib/rouge/demos/matlab +6 -0
  4. data/lib/rouge/demos/ocaml +12 -0
  5. data/lib/rouge/demos/scala +3 -0
  6. data/lib/rouge/demos/sml +4 -0
  7. data/lib/rouge/demos/vb +4 -0
  8. data/lib/rouge/formatters/html.rb +13 -17
  9. data/lib/rouge/formatters/terminal256.rb +2 -2
  10. data/lib/rouge/lexer.rb +12 -14
  11. data/lib/rouge/lexers/coffeescript.rb +2 -4
  12. data/lib/rouge/lexers/common_lisp.rb +2 -4
  13. data/lib/rouge/lexers/erlang.rb +4 -13
  14. data/lib/rouge/lexers/factor.rb +25 -24
  15. data/lib/rouge/lexers/gherkin.rb +6 -6
  16. data/lib/rouge/lexers/groovy.rb +1 -2
  17. data/lib/rouge/lexers/haml.rb +2 -2
  18. data/lib/rouge/lexers/haskell.rb +18 -20
  19. data/lib/rouge/lexers/http.rb +13 -12
  20. data/lib/rouge/lexers/ini.rb +1 -2
  21. data/lib/rouge/lexers/java.rb +1 -2
  22. data/lib/rouge/lexers/lua.rb +1 -1
  23. data/lib/rouge/lexers/make.rb +4 -5
  24. data/lib/rouge/lexers/markdown.rb +4 -12
  25. data/lib/rouge/lexers/matlab.rb +71 -0
  26. data/lib/rouge/lexers/matlab/builtins.rb +10 -0
  27. data/lib/rouge/lexers/nginx.rb +3 -4
  28. data/lib/rouge/lexers/objective_c.rb +1 -1
  29. data/lib/rouge/lexers/ocaml.rb +109 -0
  30. data/lib/rouge/lexers/perl.rb +2 -5
  31. data/lib/rouge/lexers/php.rb +5 -5
  32. data/lib/rouge/lexers/php/builtins.rb +4 -2
  33. data/lib/rouge/lexers/puppet.rb +1 -2
  34. data/lib/rouge/lexers/python.rb +5 -11
  35. data/lib/rouge/lexers/racket.rb +1 -3
  36. data/lib/rouge/lexers/ruby.rb +8 -8
  37. data/lib/rouge/lexers/rust.rb +3 -3
  38. data/lib/rouge/lexers/sass/common.rb +4 -4
  39. data/lib/rouge/lexers/scala.rb +141 -0
  40. data/lib/rouge/lexers/scheme.rb +1 -3
  41. data/lib/rouge/lexers/sed.rb +4 -4
  42. data/lib/rouge/lexers/shell.rb +1 -2
  43. data/lib/rouge/lexers/smalltalk.rb +6 -7
  44. data/lib/rouge/lexers/sml.rb +236 -6
  45. data/lib/rouge/lexers/tex.rb +1 -4
  46. data/lib/rouge/lexers/toml.rb +1 -2
  47. data/lib/rouge/lexers/vb.rb +162 -0
  48. data/lib/rouge/lexers/viml.rb +1 -1
  49. data/lib/rouge/lexers/yaml.rb +10 -11
  50. data/lib/rouge/regex_lexer.rb +77 -92
  51. data/lib/rouge/token.rb +3 -3
  52. data/lib/rouge/util.rb +4 -4
  53. data/lib/rouge/version.rb +1 -1
  54. metadata +13 -4
@@ -25,10 +25,12 @@ module Rouge
25
25
  ([^ ]+)([ ]+) # path
26
26
  (HTTPS?)(/)(1[.][01])(\r?\n|$) # http version
27
27
  )ox do
28
- group Name::Function; group Text
29
- group Name::Namespace; group Text
30
- group Keyword; group Operator
31
- group Num; group Text
28
+ groups(
29
+ Name::Function, Text,
30
+ Name::Namespace, Text,
31
+ Keyword, Operator, Num, Text
32
+ )
33
+
32
34
  push :headers
33
35
  end
34
36
 
@@ -38,10 +40,11 @@ module Rouge
38
40
  (\d{3})([ ]+) # status
39
41
  ([^\r\n]+)(\r?\n|$) # status message
40
42
  )x do
41
- group Keyword; group Operator
42
- group Num; group Text
43
- group Num; group Text
44
- group Name::Exception; group Text
43
+ groups(
44
+ Keyword, Operator, Num, Text,
45
+ Num, Text,
46
+ Name::Exception, Text
47
+ )
45
48
  push :headers
46
49
  end
47
50
  end
@@ -54,13 +57,11 @@ module Rouge
54
57
  @content_type = value.split(';')[0].downcase
55
58
  end
56
59
 
57
- group Name::Attribute; group Text
58
- group Punctuation; group Text
59
- group Str; group Text
60
+ groups Name::Attribute, Text, Punctuation, Text, Str, Text
60
61
  end
61
62
 
62
63
  rule /([^\r\n]+)(\r?\n|$)/ do
63
- group Str; group Text
64
+ groups Str, Text
64
65
  end
65
66
 
66
67
  rule /\r?\n/, Text, :content
@@ -24,8 +24,7 @@ module Rouge
24
24
  mixin :basic
25
25
 
26
26
  rule /(#{identifier})(\s*)(=)/ do
27
- group Name::Property; group Text
28
- group Punctuation
27
+ groups Name::Property, Text, Punctuation
29
28
  push :value
30
29
  end
31
30
 
@@ -48,8 +48,7 @@ module Rouge
48
48
  rule /"(\\\\|\\"|[^"])*"/, Str
49
49
  rule /'(?:\\.|[^\\]|\\u[0-9a-f]{4})'/, Str::Char
50
50
  rule /(\.)(#{id})/ do
51
- group Operator
52
- group Name::Attribute
51
+ groups Operator, Name::Attribute
53
52
  end
54
53
  rule /#{id}:/, Name::Label
55
54
  rule /\$?#{id}/, Name
@@ -86,7 +86,7 @@ module Rouge
86
86
  state :function_name do
87
87
  rule /\s+/, Text
88
88
  rule %r((?:([A-Za-z_][A-Za-z0-9_]*)(\.))?([A-Za-z_][A-Za-z0-9_]*)) do
89
- group Name::Class; group Punctuation; group Name::Function
89
+ groups Name::Class, Punctuation, Name::Function
90
90
  pop!
91
91
  end
92
92
  # inline function
@@ -34,7 +34,7 @@ module Rouge
34
34
  rule /#.*?\n/, Comment
35
35
 
36
36
  rule /(export)(\s+)(?=[a-zA-Z0-9_\${}\t -]+\n)/ do
37
- group Keyword; group Text
37
+ groups Keyword, Text
38
38
  push :export
39
39
  end
40
40
 
@@ -51,7 +51,7 @@ module Rouge
51
51
  rule /"(\\\\|\\.|[^"\\])*"/, Str::Double
52
52
  rule /'(\\\\|\\.|[^'\\])*'/, Str::Single
53
53
  rule /([^\n:]+)(:+)([ \t]*)/ do
54
- group Name::Label; group Operator; group Text
54
+ groups Name::Label, Operator, Text
55
55
  push :block_header
56
56
  end
57
57
  end
@@ -76,7 +76,7 @@ module Rouge
76
76
 
77
77
  state :block_body do
78
78
  rule /(\t[\t ]*)([@-]?)/ do |m|
79
- group Text; group Punctuation
79
+ groups Text, Punctuation
80
80
  push :shell_line
81
81
  end
82
82
 
@@ -88,8 +88,7 @@ module Rouge
88
88
  rule /\$\(\s*[a-z_]\w*\s*\)/i, Name::Variable
89
89
  # $(shell ...)
90
90
  rule /(\$\()(\s*)(shell)(\s+)/m do
91
- group Name::Function; group Text
92
- group Name::Builtin; group Text
91
+ groups Name::Function, Text, Name::Builtin, Text
93
92
  push :shell_expr
94
93
  end
95
94
 
@@ -66,9 +66,7 @@ module Rouge
66
66
  (\[) (#{edot}+?) (\]) # the reference
67
67
  (\s*) (:) # colon
68
68
  )x do
69
- group Text
70
- group Punctuation; group Str::Symbol; group Punctuation
71
- group Text; group Punctuation
69
+ groups Text, Punctuation, Str::Symbol, Punctuation, Text, Punctuation
72
70
 
73
71
  push :title
74
72
  push :url
@@ -76,9 +74,7 @@ module Rouge
76
74
 
77
75
  # links and images
78
76
  rule /(!?\[)(#{edot}+?)(\])/ do
79
- group Punctuation
80
- group Name::Variable
81
- group Punctuation
77
+ groups Punctuation, Name::Variable, Punctuation
82
78
  push :link
83
79
  end
84
80
 
@@ -105,9 +101,7 @@ module Rouge
105
101
 
106
102
  state :link do
107
103
  rule /(\[)(#{edot}*?)(\])/ do
108
- group Punctuation
109
- group Str::Symbol
110
- group Punctuation
104
+ groups Punctuation, Str::Symbol, Punctuation
111
105
  pop!
112
106
  end
113
107
 
@@ -127,9 +121,7 @@ module Rouge
127
121
 
128
122
  # the url
129
123
  rule /(<)(#{edot}*?)(>)/ do
130
- group Name::Tag
131
- group Str::Other
132
- group Name::Tag
124
+ groups Name::Tag, Str::Other, Name::Tag
133
125
  pop!
134
126
  end
135
127
 
@@ -0,0 +1,71 @@
1
+ module Rouge
2
+ module Lexers
3
+ class Matlab < RegexLexer
4
+ desc "Matlab"
5
+ tag 'matlab'
6
+ aliases 'm'
7
+ filenames '*.m'
8
+ mimetypes 'text/x-matlab', 'application/x-matlab'
9
+
10
+ def self.analyze_text(text)
11
+ return 0.4 if text.match(/^\s*% /) # % comments are a dead giveaway
12
+ end
13
+
14
+ def self.keywords
15
+ @keywords = Set.new %w(
16
+ break case catch classdef continue else elseif end for function
17
+ global if otherwise parfor persistent return spmd switch try while
18
+ )
19
+ end
20
+
21
+ def self.builtins
22
+ load Pathname.new(__FILE__).dirname.join('matlab/builtins.rb')
23
+ self.builtins
24
+ end
25
+
26
+ state :root do
27
+ rule /\s+/m, Text # Whitespace
28
+ rule %r([{]%.*?%[}])m, Comment::Multiline
29
+ rule /%.*$/, Comment::Single
30
+ rule /([.][.][.])(.*?)$/ do
31
+ groups(Keyword, Comment)
32
+ end
33
+
34
+ rule /^(!)(.*?)(?=%|$)/ do |m|
35
+ token Keyword, m[1]
36
+ delegate Shell, m[2]
37
+ end
38
+
39
+
40
+ rule /[a-zA-Z][_a-zA-Z0-9]*/m do |m|
41
+ match = m[0]
42
+ if self.class.keywords.include? match
43
+ token Keyword
44
+ elsif self.class.builtins.include? match
45
+ token Name::Builtin
46
+ else
47
+ token Name
48
+ end
49
+ end
50
+
51
+ rule %r{[(){};:,\/\\\]\[]}, Punctuation
52
+
53
+ rule /~=|==|<<|>>|[-~+\/*%=<>&^|.]/, Operator
54
+
55
+
56
+ rule /(\d+\.\d*|\d*\.\d+)(e[+-]?[0-9]+)?/i, Num::Float
57
+ rule /\d+e[+-]?[0-9]+/i, Num::Float
58
+ rule /\d+L/, Num::Integer::Long
59
+ rule /\d+/, Num::Integer
60
+
61
+ rule /'/, Str::Single, :string
62
+ end
63
+
64
+ state :string do
65
+ rule /[^']+/, Str::Single
66
+ rule /''/, Str::Escape
67
+ rule /'/, Str::Single, :pop!
68
+ end
69
+ end
70
+ end
71
+ end
@@ -0,0 +1,10 @@
1
+ # automatically generated by `rake builtins:matlab`
2
+ module Rouge
3
+ module Lexers
4
+ class Matlab
5
+ def self.builtins
6
+ @builtins ||= Set.new %w(ans clc diary format home iskeyword more commandhistory commandwindow accumarray blkdiag diag eye false freqspace linspace logspace meshgrid ndgrid ones rand true zeros cat horzcat vertcat colon end ind2sub sub2ind length ndims numel size height width iscolumn isempty ismatrix isrow isscalar isvector blkdiag circshift ctranspose diag flip flipdim fliplr flipud ipermute permute repmat reshape rot90 shiftdim issorted sort sortrows squeeze transpose vectorize plus uplus minus uminus times rdivide ldivide power mtimes mrdivide mldivide mpower cumprod cumsum diff prod sum ceil fix floor idivide mod rem round relationaloperators eq ge gt le lt ne isequal isequaln logicaloperatorselementwise logicaloperatorsshortcircuit and not or xor all any false find islogical logical true intersect ismember issorted setdiff setxor union unique join innerjoin outerjoin bitand bitcmp bitget bitor bitset bitshift bitxor swapbytes specialcharacters colon double single int8 int16 int32 int64 uint8 uint16 uint32 uint64 cast typecast isinteger isfloat isnumeric isreal isfinite isinf isnan eps flintmax inf intmax intmin nan realmax realmin blanks cellstr char iscellstr ischar sprintf strcat strjoin ischar isletter isspace isstrprop sscanf strfind strrep strsplit strtok validatestring symvar regexp regexpi regexprep regexptranslate strcmp strcmpi strncmp strncmpi blanks deblank strtrim lower upper strjust categorical iscategorical categories iscategory isordinal isprotected addcats mergecats removecats renamecats reordercats summary countcats isundefined table array2table cell2table struct2table table2array table2cell table2struct readtable writetable istable height width summary intersect ismember setdiff setxor unique union join innerjoin outerjoin sortrows stack unstack ismissing standardizemissing varfun rowfun struct fieldnames getfield isfield isstruct orderfields rmfield setfield arrayfun structfun cell2struct struct2cell cell cell2mat cell2struct celldisp cellfun cellplot cellstr iscell iscellstr mat2cell num2cell strjoin strsplit struct2cell function_handle feval func2str str2func localfunctions functions timeseriesclass addevent delevent gettsafteratevent gettsafterevent gettsatevent gettsbeforeatevent gettsbeforeevent gettsbetweenevents gettscollection isemptytscollection lengthtscollection settscollection sizetscollection tscollection addsampletocollection addts delsamplefromcollection getabstimetscollection getsampleusingtimetscollection gettimeseriesnames horzcattscollection removets resampletscollection setabstimetscollection settimeseriesnames vertcattscollection is isa iscategorical iscell iscellstr ischar isfield isfloat ishghandle isinteger isjava islogical isnumeric isobject isreal isscalar isstr isstruct istable isvector class validateattributes whos char int2str mat2str num2str str2double str2num native2unicode unicode2native base2dec bin2dec dec2base dec2bin dec2hex hex2dec hex2num num2hex table2array table2cell table2struct array2table cell2table struct2table cell2mat cell2struct cellstr mat2cell num2cell struct2cell datenum datevec datestr now clock date calendar eomday weekday addtodate etime plus uplus minus uminus times rdivide ldivide power mtimes mrdivide mldivide mpower cumprod cumsum diff prod sum ceil fix floor idivide mod rem round sin sind asin asind sinh asinh cos cosd acos acosd cosh acosh tan tand atan atand atan2 atan2d tanh atanh csc cscd acsc acscd csch acsch sec secd asec asecd sech asech cot cotd acot acotd coth acoth hypot exp expm1 log log10 log1p log2 nextpow2 nthroot pow2 reallog realpow realsqrt sqrt abs angle complex conj cplxpair i imag isreal j real sign unwrap factor factorial gcd isprime lcm nchoosek perms primes rat poly polyder polyeig polyfit polyint polyval polyvalm residue roots airy besselh besseli besselj besselk bessely beta betainc betaincinv betaln ellipj ellipke erf erfc erfcinv erfcx erfinv expint gamma gammainc gammaincinv gammaln legendre psi cart2pol cart2sph pol2cart sph2cart eps flintmax i j inf pi nan isfinite isinf isnan compan gallery hadamard hankel hilb invhilb magic pascal rosser toeplitz vander wilkinson cross dot kron surfnorm tril triu transpose cond condest funm inv linsolve lscov lsqnonneg pinv rcond mldivide mrdivide chol ichol cholupdate ilu lu qr qrdelete qrinsert qrupdate planerot ldl cdf2rdf rsf2csf gsvd svd balance cdf2rdf condeig eig eigs gsvd hess ordeig ordqz ordschur poly polyeig qz rsf2csf schur sqrtm ss2tf svd svds cond condeig det norm normest null orth rank rcond rref subspace trace expm logm sqrtm bsxfun arrayfun accumarray mpower corrcoef cov max mean median min mode std var rand randn randi randperm rng interp1 griddedinterpolantclass pchip spline ppval mkpp unmkpp padecoef interpft interp2 interp3 interpn griddedinterpolantclass ndgrid meshgrid griddata griddatan scatteredinterpolantclass fminbnd fminsearch fzero lsqnonneg optimget optimset ode45 ode15s ode23 ode113 ode23t ode23tb ode23s ode15i decic odextend odeget odeset deval bvp4c bvp5c bvpinit bvpxtend bvpget bvpset deval dde23 ddesd ddensd ddeget ddeset deval pdepe pdeval integral integral2 integral3 quadgk quad2d cumtrapz trapz polyint del2 diff gradient polyder abs angle cplxpair fft fft2 fftn fftshift fftw ifft ifft2 ifftn ifftshift nextpow2 unwrap conv conv2 convn deconv detrend filter filter2 spdiags speye sprand sprandn sprandsym sparse spconvert issparse nnz nonzeros nzmax spalloc spfun spones spparms spy find full amd colamd colperm dmperm randperm symamd symrcm condest eigs ichol ilu normest spaugment sprank svds bicg bicgstab bicgstabl cgs gmres lsqr minres pcg qmr symmlq tfqmr etree etreeplot gplot symbfact treelayout treeplot unmesh triangulationclass tetramesh trimesh triplot trisurf delaunaytriangulationclass delaunay delaunayn tetramesh trimesh triplot trisurf triangulationclass delaunaytriangulationclass dsearchn tsearchn delaunay delaunayn convhull convhulln patch trisurf patch voronoi voronoin polyarea inpolygon rectint plot plotyy plot3 loglog semilogx semilogy errorbar fplot ezplot ezplot3 linespec colorspec bar bar3 barh bar3h hist histc rose pareto area pie pie3 stem stairs stem3 scatter scatter3 spy plotmatrix polar rose compass ezpolar linespec colorspec contour contourf contourc contour3 contourslice ezcontour ezcontourf feather quiver compass quiver3 streamslice streamline surf surfc surface surfl surfnorm mesh meshc meshz waterfall ribbon contour3 peaks cylinder ellipsoid sphere pcolor surf2patch ezsurf ezsurfc ezmesh ezmeshc contourslice flow isocaps isocolors isonormals isosurface reducepatch reducevolume shrinkfaces slice smooth3 subvolume volumebounds coneplot curl divergence interpstreamspeed stream2 stream3 streamline streamparticles streamribbon streamslice streamtube fill fill3 patch surf2patch movie noanimate drawnow refreshdata frame2im getframe im2frame comet comet3 title xlabel ylabel zlabel clabel datetick texlabel legend colorbar xlim ylim zlim box grid daspect pbaspect axes axis subplot hold gca cla annotation text legend title xlabel ylabel zlabel datacursormode ginput gtext colormap colormapeditor colorbar brighten contrast shading graymon caxis hsv2rgb rgb2hsv rgbplot spinmap colordef whitebg hidden pan reset rotate rotate3d selectmoveresize zoom datacursormode figurepalette plotbrowser plotedit plottools propertyeditor showplottool brush datacursormode linkdata refreshdata view makehgtform viewmtx cameratoolbar campan camzoom camdolly camlookat camorbit campos camproj camroll camtarget camup camva camlight light lightangle lighting diffuse material specular alim alpha alphamap image imagesc imread imwrite imfinfo imformats frame2im im2frame im2java ind2rgb rgb2ind imapprox dither cmpermute cmunique print printopt printdlg printpreview orient savefig openfig hgexport hgsave hgload saveas gca gcf gcbf gcbo gco ancestor allchild findall findfigs findobj gobjects ishghandle copyobj delete get set propedit rootobject figure axes image light line patch rectangle surface text annotation set get hggroup hgtransform makehgtform figure gcf close clf refresh newplot shg closereq dragrect drawnow rbbox opengl axes hold ishold newplot linkaxes linkprop refreshdata waitfor get set if for parfor switch try while break continue end pause return edit input publish notebook grabcode snapnow function nargin nargout varargin varargout narginchk nargoutchk validateattributes validatestring inputparserclass inputname persistent genvarname isvarname namelengthmax assignin global isglobal try error warning lastwarn assert oncleanup dbclear dbcont dbdown dbquit dbstack dbstatus dbstep dbstop dbtype dbup checkcode keyboard mlintrpt edit echo eval evalc evalin feval run builtin depdir depfun mfilename pcode timerclass clear clearvars disp openvar who whos load save matfile workspace importdata uiimport csvread csvwrite dlmread dlmwrite fileread textread textscan readtable writetable type xlsfinfo xlsread xlswrite readtable writetable fclose feof ferror fgetl fgets fopen fprintf fread frewind fscanf fseek ftell fwrite exifread im2java imfinfo imread imwrite tiffclass nccreate ncdisp ncinfo ncread ncreadatt ncwrite ncwriteatt ncwriteschema netcdf h5create h5disp h5info h5read h5readatt h5write h5writeatt hdfinfo hdfread hdf fitsdisp fitsinfo fitsread fitswrite multibandread multibandwrite cdfepoch cdfinfo cdfread cdfwrite todatenum cdflib audioinfo audioread audiowrite mmfileinfo movie2avi videoreaderclass videowriterclass audiodevinfo audioplayer audiorecorder sound soundsc beep lin2mu mu2lin xmlread xmlwrite xslt dispmemmapfile getmemmapfile memmapfile dir ls pwd fileattrib exist isdir type visdiff what which cd copyfile delete recycle mkdir movefile rmdir open winopen filebrowser fileparts fullfile filemarker filesep tempdir tempname matlabroot toolboxdir gunzip gzip tar untar unzip zip addpath rmpath path savepath userpath genpath pathsep pathtool restoredefaultpath clipboard computer dos getenv perl setenv system unix winqueryreg ftpclass sendmail urlread urlwrite web instrcallback instrfind instrfindall readasync record serial serialbreak stopasync guide figure axes uicontrol uitable uipanel uibuttongroup actxcontrol uimenu uicontextmenu uitoolbar uipushtool uitoggletool dialog errordlg helpdlg msgbox questdlg uigetpref uisetpref waitbar warndlg export2wsdlg inputdlg listdlg uisetcolor uisetfont printdlg printpreview uigetdir uigetfile uiopen uiputfile uisave align movegui getpixelposition setpixelposition listfonts textwrap uistack guidata guihandles openfig getappdata isappdata rmappdata setappdata uiresume uiwait waitfor waitforbuttonpress addpref getpref ispref rmpref setpref classdef class isa isequal isobject enumeration events methods properties classdef import properties isprop dynamicprops methods ismethod handle hgsetget dynamicprops isa events empty superclasses enumeration save load saveobj loadobj cat horzcat vertcat empty disp display numel size end subsref subsasgn subsindex substruct metaclass try addcausemexception getreportmexception lastmexception rethrowmexception throwmexception throwascallermexception mexception bench cputime memory profile profsave tic timeit toc clear inmem memory pack whos functiontests runtests builddocsearchdb javaarray javaclasspath javaaddpath javarmpath javachk isjava usejava javamethod javamethodedt javaobject javaobjectedt cell class clear depfun exist fieldnames im2java import inmem inspect isa methods methodsview which net enablenetfromnetworkdrive cell begininvoke endinvoke combine remove removeall bitand bitor bitxor bitnot mexext inmem actxserver actxcontrol actxcontrollist actxcontrolselect iscom addproperty deleteproperty inspect fieldnames methods methodsview invoke isevent eventlisteners registerevent unregisterallevents unregisterevent isinterface interfaces release move execute getchararray putchararray getfullmatrix putfullmatrix getvariable getworkspacedata putworkspacedata maximizecommandwindow minimizecommandwindow actxgetrunningserver enableservice callsoapservice createclassfromwsdl createsoapmessage parsesoapresponse loadlibrary unloadlibrary libisloaded calllib libfunctions libfunctionsview libstruct libpointer mexext inmem mex dbmex mex dbmex ver computer mexext dbmex inmem mex mexext checkin checkout cmopts customverctrl undocheckout verctrl matlabwindows matlabunix exit quit matlabrc startup finish prefdir preferences ismac ispc isstudent isunix javachk license usejava ver verlessthan version doc help docsearch lookfor demo echodemo)
7
+ end
8
+ end
9
+ end
10
+ end
@@ -10,7 +10,7 @@ module Rouge
10
10
 
11
11
  state :root do
12
12
  rule /(include)(\s+)([^\s;]+)/ do
13
- group Keyword; group Text; group Name
13
+ groups Keyword, Text, Name
14
14
  end
15
15
 
16
16
  rule id, Keyword, :statement
@@ -43,8 +43,7 @@ module Rouge
43
43
 
44
44
  # host/port
45
45
  rule /([a-z0-9.-]+)(:)([0-9]+)/i do
46
- group Name::Function; group Punctuation
47
- group Num::Integer
46
+ groups Name::Function, Punctuation, Num::Integer
48
47
  end
49
48
 
50
49
  # mimetype
@@ -52,7 +51,7 @@ module Rouge
52
51
 
53
52
  rule /[0-9]+[kmg]?\b/i, Num::Integer
54
53
  rule /(~)(\s*)([^\s{]+)/ do
55
- group Punctuation; group Text; group Str::Regex
54
+ groups Punctuation, Text, Str::Regex
56
55
  end
57
56
 
58
57
  rule /[:=~]/, Punctuation
@@ -27,7 +27,7 @@ module Rouge
27
27
  end
28
28
 
29
29
  def self.analyze_text(text)
30
- return 1 if text =~ /@(end|implementation|protocol)\b/
30
+ return 1 if text =~ /@(end|implementation|protocol|property)\b/
31
31
 
32
32
  id = /[a-z$_][a-z0-9$_]*/i
33
33
  return 0.4 if text =~ %r(
@@ -0,0 +1,109 @@
1
+ module Rouge
2
+ module Lexers
3
+ class OCaml < RegexLexer
4
+ desc 'Objective CAML (ocaml.org)'
5
+ tag 'ocaml'
6
+ filenames '*.ml', '*.mli', '*.mll', '*.mly'
7
+ mimetypes 'text/x-ocaml'
8
+
9
+ def self.keywords
10
+ @keywords ||= Set.new %w(
11
+ as assert begin class constraint do done downto else end
12
+ exception external false for fun function functor if in include
13
+ inherit initializer lazy let match method module mutable new
14
+ object of open private raise rec sig struct then to true try
15
+ type value val virtual when while with
16
+ )
17
+ end
18
+
19
+ def self.keyopts
20
+ @keyopts ||= Set.new %w(
21
+ != # & && ( ) * \+ , - -. -> . .. : :: := :> ; ;; < <- =
22
+ > >] >} ? ?? [ [< [> [| ] _ ` { {< | |] } ~
23
+ )
24
+ end
25
+
26
+ def self.word_operators
27
+ @word_operators ||= Set.new %w(and asr land lor lsl lxor mod or)
28
+ end
29
+
30
+ def self.primitives
31
+ @primitives ||= Set.new %w(unit int float bool string char list array)
32
+ end
33
+
34
+ operator = %r([\[\];,{}_()!$%&*+./:<=>?@^|~-]+)
35
+ id = /[a-z][\w']*/i
36
+ upper_id = /[A-Z][\w']*/
37
+
38
+ state :root do
39
+ rule /\s+/m, Text
40
+ rule /false|true|[(][)]|\[\]/, Name::Builtin::Pseudo
41
+ rule /#{upper_id}(?=\s*[.])/, Name::Namespace, :dotted
42
+ rule upper_id, Name::Class
43
+ rule /[(][*](?![)])/, Comment, :comment
44
+ rule id do |m|
45
+ match = m[0]
46
+ if self.class.keywords.include? match
47
+ token Keyword
48
+ elsif self.class.word_operators.include? match
49
+ token Operator::Word
50
+ elsif self.class.primitives.include? match
51
+ token Keyword::Type
52
+ else
53
+ token Name
54
+ end
55
+ end
56
+
57
+ rule operator do |m|
58
+ match = m[0]
59
+ if self.class.keyopts.include? match
60
+ token Punctuation
61
+ else
62
+ token Operator
63
+ end
64
+ end
65
+
66
+ rule /-?\d[\d_]*(.[\d_]*)?(e[+-]?\d[\d_]*)/i, Num::Float
67
+ rule /0x\h[\h_]*/i, Num::Hex
68
+ rule /0o[0-7][0-7_]*/i, Num::Oct
69
+ rule /0b[01][01_]*/i, Num::Bin
70
+ rule /\d[\d_]*/, Num::Integer
71
+
72
+ rule /'(?:(\\[\\"'ntbr ])|(\\[0-9]{3})|(\\x\h{2}))'/, Str::Char
73
+ rule /'[.]'/, Str::Char
74
+ rule /'/, Keyword
75
+ rule /"/, Str::Double, :string
76
+ rule /[~?]#{id}/, Name::Variable
77
+ end
78
+
79
+ state :comment do
80
+ rule /[^(*)]+/, Comment
81
+ rule(/[(][*]/) { token Comment; push }
82
+ rule /[*][)]/, Comment, :pop!
83
+ rule /[(*)]/, Comment
84
+ end
85
+
86
+ state :string do
87
+ rule /[^\\"]+/, Str::Double
88
+ mixin :escape_sequence
89
+ rule /\\\n/, Str::Double
90
+ rule /"/, Str::Double, :pop!
91
+ end
92
+
93
+ state :escape_sequence do
94
+ rule /\\[\\"'ntbr]/, Str::Escape
95
+ rule /\\\d{3}/, Str::Escape
96
+ rule /\\x\h{2}/, Str::Escape
97
+ end
98
+
99
+ state :dotted do
100
+ rule /\s+/m, Text
101
+ rule /[.]/, Punctuation
102
+ rule /#{upper_id}(?=\s*[.])/, Name::Namespace
103
+ rule upper_id, Name::Class, :pop!
104
+ rule id, Name, :pop!
105
+ end
106
+ end
107
+ end
108
+ end
109
+
@@ -67,9 +67,7 @@ module Rouge
67
67
  rule /(?:#{keywords.join('|')})\b/, Keyword
68
68
 
69
69
  rule /(format)(\s+)([a-zA-Z0-9_]+)(\s*)(=)(\s*\n)/ do
70
- group Keyword; group Text
71
- group Name; group Text
72
- group Punctuation; group Text
70
+ groups Keyword, Text, Name, Text, Punctuation, Text
73
71
 
74
72
  push :format
75
73
  end
@@ -166,8 +164,7 @@ module Rouge
166
164
 
167
165
  # argument declaration
168
166
  rule /(\([$@%]*\))(\s*)/ do
169
- group Punctuation
170
- group Text
167
+ groups Punctuation, Text
171
168
  end
172
169
 
173
170
  rule /.*?{/, Punctuation, :pop!
@@ -74,7 +74,7 @@ module Rouge
74
74
  rule %r(/\*\*.*?\*/)m, Str::Doc
75
75
  rule %r(/\*.*?\*/)m, Comment::Multiline
76
76
  rule /(->|::)(\s*)([a-zA-Z_][a-zA-Z0-9_]*)/ do
77
- group Operator; group Text; group Name::Attribute
77
+ groups Operator, Text, Name::Attribute
78
78
  end
79
79
 
80
80
  rule /[~!%^&*+=\|:.<>\/?@-]+/, Operator
@@ -82,17 +82,17 @@ module Rouge
82
82
  rule /class\b/, Keyword, :classname
83
83
  # anonymous functions
84
84
  rule /(function)(\s*)(?=\()/ do
85
- group Keyword; group Text
85
+ groups Keyword, Text
86
86
  end
87
87
 
88
88
  # named functions
89
89
  rule /(function)(\s+)(&?)(\s*)/ do
90
- group Keyword; group Text; group Operator; group Text
90
+ groups Keyword, Text, Operator, Text
91
91
  push :funcname
92
92
  end
93
93
 
94
94
  rule /(const)(\s+)([a-zA-Z_]\w*)/i do
95
- group Keyword; group Text; group Name::Constant
95
+ groups Keyword, Text, Name::Constant
96
96
  end
97
97
 
98
98
  rule /(true|false|null)\b/, Keyword::Constant
@@ -141,7 +141,7 @@ module Rouge
141
141
  rule /\{\$\{/, Str::Interpol, :interp_double
142
142
  rule /\{(?=\$)/, Str::Interpol, :interp_single
143
143
  rule /(\{)(\S+)(\})/ do
144
- group Str::Interpol; group Name::Variable; group Str::Interpol
144
+ groups Str::Interpol, Name::Variable, Str::Interpol
145
145
  end
146
146
 
147
147
  rule /[${\\]+/, Str::Double