rouge 3.14.0 → 3.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d43552856d88e799ffb7f4255d865641bfaafd5dac3945b2646540ff816628c4
4
- data.tar.gz: 5768d921766cf2eb677fc63e783b707ee0f52a7320b73f4bbbc333ee14e79f77
3
+ metadata.gz: 5da5e5d1e737275e6a41550af0aaa6af398cb8517b67717f07d9ad632c13e28a
4
+ data.tar.gz: 4dc38a2b67f0eeb0890143442c411be221e00fc78718c8f404d9dbf6f787b29a
5
5
  SHA512:
6
- metadata.gz: fdfd25582e56396cb78b370372b4587b243c1608fa7d4ee32a9659f13fc8939bba2305b5add8d83569543766eefed1abbb8ff5f0d76593964db2b3624b1d112b
7
- data.tar.gz: 5d2f0526caf091491969d89180fab9a30441ddc5390bbb10c8acb2ea8b9af96b044e91ed32e6db58fa9783a12c530eb3a25d829f031c0ecb7a7e02858592da57
6
+ metadata.gz: 911cf95350e23be5bb1bfedbf178e3872a37d5930f201156fa7daff16a2bad5609043cae7a917a1aa8adf9b863b28538266217271693da8cbfe68aa20a2df82f
7
+ data.tar.gz: 5f363794c19033fd11c3a5360fbcf550536f8f5292962a0ab70e434d1f4f1aa5711c938c19ddf088b4eb76140e54e24029229524321048bc451950a006140f51
@@ -0,0 +1,16 @@
1
+ include "MUMPS"
2
+
3
+ // Parameters
4
+ func f = 1.;
5
+
6
+ // Mesh
7
+ int nn = 25; //Mesh quality
8
+ mesh Th = square(nn, nn);
9
+
10
+ // Fespace
11
+ func Pk = P2;
12
+ fespace Uh(Th, Pk);
13
+ Uh u;
14
+
15
+ // Plot
16
+ plot(u, nbiso=30, fill=true, value=true, cmm="A");
@@ -0,0 +1,26 @@
1
+ Rec {
2
+ -- RHS size: {terms: 24, types: 3, coercions: 0, joins: 0/0}
3
+ Main.fib_fib [Occ=LoopBreaker] :: Integer -> Integer
4
+ [GblId, Arity=1, Str=<S,U>, Unf=OtherCon []]
5
+ Main.fib_fib
6
+ = \ (ds_d2OU :: Integer) ->
7
+ case integer-gmp-1.0.2.0:GHC.Integer.Type.eqInteger#
8
+ ds_d2OU Main.fib1
9
+ of {
10
+ __DEFAULT ->
11
+ case integer-gmp-1.0.2.0:GHC.Integer.Type.eqInteger#
12
+ ds_d2OU Main.fib3
13
+ of {
14
+ __DEFAULT ->
15
+ integer-gmp-1.0.2.0:GHC.Integer.Type.plusInteger
16
+ (Main.fib_fib
17
+ (integer-gmp-1.0.2.0:GHC.Integer.Type.minusInteger
18
+ ds_d2OU Main.fib3))
19
+ (Main.fib_fib
20
+ (integer-gmp-1.0.2.0:GHC.Integer.Type.minusInteger
21
+ ds_d2OU Main.fib2));
22
+ 1# -> Main.fib3
23
+ };
24
+ 1# -> Main.fib1
25
+ }
26
+ end Rec }
@@ -0,0 +1,17 @@
1
+ @import Foundation;
2
+ #import <array>
3
+ #include <vector>
4
+
5
+ @interface IntegerArray : NSObject {
6
+ std::vector<NSUInteger> _numbers;
7
+ }
8
+ @property(readonly) NSUInteger count;
9
+
10
+ - (instancetype)initWithNumbers:(NSUInteger *)numbers count:(NSUInteger)count;
11
+ - (NSUInteger)numberAtIndex:(NSUInteger)index;
12
+ @end
13
+
14
+ int main(int argc, char **argv) {
15
+ auto numbers = std::array<NSUInteger, 3>{1, 2, 3};
16
+ NSLog(@"%@", [[IntegerArray alloc] initWithNumbers:numbers.data() count:numbers.size()]);
17
+ }
@@ -318,7 +318,7 @@ module Rouge
318
318
 
319
319
  def as_bool(val)
320
320
  case val
321
- when nil, false, 0, '0', 'off'
321
+ when nil, false, 0, '0', 'false', 'off'
322
322
  false
323
323
  when Array
324
324
  val.empty? ? true : as_bool(val.last)
@@ -3,6 +3,38 @@
3
3
 
4
4
  module Rouge
5
5
  module Lexers
6
+ # The {ConsoleLexer} class is intended to lex content that represents the
7
+ # text that would display in a console/terminal. As distinct from the
8
+ # {Shell} lexer, {ConsoleLexer} will try to parse out the prompt from each
9
+ # line before passing the remainder of the line to the language lexer for
10
+ # the shell (by default, the {Shell} lexer).
11
+ #
12
+ # The {ConsoleLexer} class accepts four options:
13
+ # 1. **lang**: the shell language to lex (default: `shell`);
14
+ # 2. **output**: the output language (default: `plaintext?token=Generic.Output`);
15
+ # 3. **prompt**: comma-separated list of strings that indicate the end of a
16
+ # prompt (default: `$,#,>,;`);
17
+ # 4. **comments**: whether to enable comments.
18
+ #
19
+ # The comments option, if enabled, will lex lines that begin with a `#` as a
20
+ # comment. Please note that this option will only work if the prompt is
21
+ # either not manually specified or, if manually specified, does not include
22
+ # the `#` character.
23
+ #
24
+ # Most Markdown lexers that recognise GitHub-Flavored Markdown syntax, will
25
+ # pass the language string to Rouge as written in the original document.
26
+ # This allows an end user to pass options to {ConsoleLexer} by passing them
27
+ # as CGI-style parameters as in the example below.
28
+ #
29
+ # @example
30
+ # <pre>Here's some regular text.
31
+ #
32
+ # ```console?comments=true
33
+ # # This is a comment
34
+ # $ cp foo bar
35
+ # ```
36
+ #
37
+ # Some more regular text.</pre>
6
38
  class ConsoleLexer < Lexer
7
39
  tag 'console'
8
40
  aliases 'terminal', 'shell_session', 'shell-session'
@@ -31,6 +63,8 @@ module Rouge
31
63
  def end_chars
32
64
  @end_chars ||= if @prompt.any?
33
65
  @prompt.reject { |c| c.empty? }
66
+ elsif allow_comments?
67
+ %w($ > ;)
34
68
  else
35
69
  %w($ # > ;)
36
70
  end
@@ -100,6 +134,9 @@ module Rouge
100
134
  def process_line(input, &output)
101
135
  input.scan(line_regex)
102
136
 
137
+ # As a nicety, support the use of elisions in input text. A user can
138
+ # write a line with only `<...>` or one or more `.` characters and
139
+ # Rouge will treat it as a comment.
103
140
  if input[0] =~ /\A\s*(?:<[.]+>|[.]+)\s*\z/
104
141
  puts "console: matched snip #{input[0].inspect}" if @debug
105
142
  output_lexer.reset!
@@ -0,0 +1,240 @@
1
+ # -*- coding: utf-8 -*- #
2
+ # frozen_string_literal: true
3
+
4
+ module Rouge
5
+ module Lexers
6
+ load_lexer 'cpp.rb'
7
+
8
+ class FreeFEM < Cpp
9
+ title "FreeFEM"
10
+ desc "The FreeFEM programming language (freefem.org)"
11
+
12
+ tag 'freefem'
13
+ aliases 'ff'
14
+ filenames '*.edp', '*.idp'
15
+ mimetypes 'text/x-ffhdr', 'text/x-ffsrc'
16
+
17
+ # Override C/C++ ones (for example, `do` does not exists)
18
+ def self.keywords
19
+ @keywords ||= Set.new(%w(
20
+ break catch continue else for if return try while
21
+ ))
22
+ end
23
+
24
+ # Override C/C++ ones (for example, `double` does not exists)
25
+ def self.keywords_type
26
+ @keywords_type ||= Set.new(%w(
27
+ bool border complex dmatrix fespace func gslspline ifstream int macro
28
+ matrix mesh mesh3 mpiComm mpiGroup mpiRequest NewMacro EndMacro
29
+ ofstream Pmmap problem Psemaphore real solve string varf
30
+ ))
31
+ end
32
+
33
+ # Override C/C++ ones (totally different)
34
+ def self.reserved
35
+ @reserved ||= Set.new(%w(
36
+ BDM1 BDM1Ortho Edge03d Edge13d Edge23d FEQF HCT P0 P03d P0Edge P1
37
+ P13d P1b P1b3d P1bl P1bl3d P1dc P1Edge P1nc P2 P23d P2b P2BR P2dc
38
+ P2Edge P2h P2Morley P2pnc P3 P3dc P3Edge P4 P4dc P4Edge P5Edge RT0
39
+ RT03d RT0Ortho RT1 RT1Ortho RT2 RT2Ortho
40
+
41
+ qf1pE qf1pElump qf1pT qf1pTlump qfV1 qfV1lump qf2pE qf2pT qf2pT4P1
42
+ qfV2 qf3pE qf4pE qf5pE qf5pT qfV5 qf7pT qf9pT qfnbpE
43
+
44
+ ARGV append area be binary BoundaryEdge bordermeasure CG Cholesky cin
45
+ cout Crout default diag edgeOrientation endl FILE fixed GMRES good
46
+ hTriangle im imax imin InternalEdge l1 l2 label lenEdge length LINE
47
+ linfty LU m max measure min mpiAnySource mpiBAND mpiBXOR mpiCommWorld
48
+ mpiLAND mpiLOR mpiLXOR mpiMAX mpiMIN mpiPROD mpirank mpisize mpiSUM
49
+ mpiUndefined n N nbe ndof ndofK noshowbase noshowpos notaregion nt
50
+ nTonEdge nuEdge nuTriangle nv P pi precision quantile re region
51
+ scientific searchMethod setw showbase showpos sparsesolver sum tellp
52
+ true UMFPACK unused whoinElement verbosity version volume x y z
53
+ ))
54
+ end
55
+
56
+ def self.builtins
57
+ @builtins ||= Set.new(%w(
58
+ abs acos acosh adaptmesh adj AffineCG AffineGMRES arg asin asinh
59
+ assert atan atan2 atanh atof atoi BFGS broadcast buildlayers
60
+ buildmesh ceil chi complexEigenValue copysign change checkmovemesh
61
+ clock cmaes conj convect cos cosh cube d dd dfft diffnp diffpos
62
+ dimKrylov dist dumptable dx dxx dxy dxz dy dyx dyy dyz dz dzx dzy dzz
63
+ EigenValue emptymesh erf erfc exec exit exp fdim ffind find floor
64
+ flush fmax fmin fmod freeyams getARGV getline gmshload gmshload3
65
+ gslcdfugaussianP gslcdfugaussianQ gslcdfugaussianPinv
66
+ gslcdfugaussianQinv gslcdfgaussianP gslcdfgaussianQ
67
+ gslcdfgaussianPinv gslcdfgaussianQinv gslcdfgammaP gslcdfgammaQ
68
+ gslcdfgammaPinv gslcdfgammaQinv gslcdfcauchyP gslcdfcauchyQ
69
+ gslcdfcauchyPinv gslcdfcauchyQinv gslcdflaplaceP gslcdflaplaceQ
70
+ gslcdflaplacePinv gslcdflaplaceQinv gslcdfrayleighP gslcdfrayleighQ
71
+ gslcdfrayleighPinv gslcdfrayleighQinv gslcdfchisqP gslcdfchisqQ
72
+ gslcdfchisqPinv gslcdfchisqQinv gslcdfexponentialP gslcdfexponentialQ
73
+ gslcdfexponentialPinv gslcdfexponentialQinv gslcdfexppowP
74
+ gslcdfexppowQ gslcdftdistP gslcdftdistQ gslcdftdistPinv
75
+ gslcdftdistQinv gslcdffdistP gslcdffdistQ gslcdffdistPinv
76
+ gslcdffdistQinv gslcdfbetaP gslcdfbetaQ gslcdfbetaPinv gslcdfbetaQinv
77
+ gslcdfflatP gslcdfflatQ gslcdfflatPinv gslcdfflatQinv
78
+ gslcdflognormalP gslcdflognormalQ gslcdflognormalPinv
79
+ gslcdflognormalQinv gslcdfgumbel1P gslcdfgumbel1Q gslcdfgumbel1Pinv
80
+ gslcdfgumbel1Qinv gslcdfgumbel2P gslcdfgumbel2Q gslcdfgumbel2Pinv
81
+ gslcdfgumbel2Qinv gslcdfweibullP gslcdfweibullQ gslcdfweibullPinv
82
+ gslcdfweibullQinv gslcdfparetoP gslcdfparetoQ gslcdfparetoPinv
83
+ gslcdfparetoQinv gslcdflogisticP gslcdflogisticQ gslcdflogisticPinv
84
+ gslcdflogisticQinv gslcdfbinomialP gslcdfbinomialQ gslcdfpoissonP
85
+ gslcdfpoissonQ gslcdfgeometricP gslcdfgeometricQ
86
+ gslcdfnegativebinomialP gslcdfnegativebinomialQ gslcdfpascalP
87
+ gslcdfpascalQ gslinterpakima gslinterpakimaperiodic
88
+ gslinterpcsplineperiodic gslinterpcspline gslinterpsteffen
89
+ gslinterplinear gslinterppolynomial gslranbernoullipdf gslranbeta
90
+ gslranbetapdf gslranbinomialpdf gslranexponential
91
+ gslranexponentialpdf gslranexppow gslranexppowpdf gslrancauchy
92
+ gslrancauchypdf gslranchisq gslranchisqpdf gslranerlang
93
+ gslranerlangpdf gslranfdist gslranfdistpdf gslranflat gslranflatpdf
94
+ gslrangamma gslrangammaint gslrangammapdf gslrangammamt
95
+ gslrangammaknuth gslrangaussian gslrangaussianratiomethod
96
+ gslrangaussianziggurat gslrangaussianpdf gslranugaussian
97
+ gslranugaussianratiomethod gslranugaussianpdf gslrangaussiantail
98
+ gslrangaussiantailpdf gslranugaussiantail gslranugaussiantailpdf
99
+ gslranlandau gslranlandaupdf gslrangeometricpdf gslrangumbel1
100
+ gslrangumbel1pdf gslrangumbel2 gslrangumbel2pdf gslranlogistic
101
+ gslranlogisticpdf gslranlognormal gslranlognormalpdf
102
+ gslranlogarithmicpdf gslrannegativebinomialpdf gslranpascalpdf
103
+ gslranpareto gslranparetopdf gslranpoissonpdf gslranrayleigh
104
+ gslranrayleighpdf gslranrayleightail gslranrayleightailpdf
105
+ gslrantdist gslrantdistpdf gslranlaplace gslranlaplacepdf gslranlevy
106
+ gslranweibull gslranweibullpdf gslsfairyAi gslsfairyBi
107
+ gslsfairyAiscaled gslsfairyBiscaled gslsfairyAideriv gslsfairyBideriv
108
+ gslsfairyAiderivscaled gslsfairyBiderivscaled gslsfairyzeroAi
109
+ gslsfairyzeroBi gslsfairyzeroAideriv gslsfairyzeroBideriv
110
+ gslsfbesselJ0 gslsfbesselJ1 gslsfbesselJn gslsfbesselY0 gslsfbesselY1
111
+ gslsfbesselYn gslsfbesselI0 gslsfbesselI1 gslsfbesselIn
112
+ gslsfbesselI0scaled gslsfbesselI1scaled gslsfbesselInscaled
113
+ gslsfbesselK0 gslsfbesselK1 gslsfbesselKn gslsfbesselK0scaled
114
+ gslsfbesselK1scaled gslsfbesselKnscaled gslsfbesselj0 gslsfbesselj1
115
+ gslsfbesselj2 gslsfbesseljl gslsfbessely0 gslsfbessely1 gslsfbessely2
116
+ gslsfbesselyl gslsfbesseli0scaled gslsfbesseli1scaled
117
+ gslsfbesseli2scaled gslsfbesselilscaled gslsfbesselk0scaled
118
+ gslsfbesselk1scaled gslsfbesselk2scaled gslsfbesselklscaled
119
+ gslsfbesselJnu gslsfbesselYnu gslsfbesselInuscaled gslsfbesselInu
120
+ gslsfbesselKnuscaled gslsfbesselKnu gslsfbessellnKnu
121
+ gslsfbesselzeroJ0 gslsfbesselzeroJ1 gslsfbesselzeroJnu gslsfclausen
122
+ gslsfhydrogenicR1 gslsfdawson gslsfdebye1 gslsfdebye2 gslsfdebye3
123
+ gslsfdebye4 gslsfdebye5 gslsfdebye6 gslsfdilog gslsfmultiply
124
+ gslsfellintKcomp gslsfellintEcomp gslsfellintPcomp gslsfellintDcomp
125
+ gslsfellintF gslsfellintE gslsfellintRC gslsferfc gslsflogerfc
126
+ gslsferf gslsferfZ gslsferfQ gslsfhazard gslsfexp gslsfexpmult
127
+ gslsfexpm1 gslsfexprel gslsfexprel2 gslsfexpreln gslsfexpintE1
128
+ gslsfexpintE2 gslsfexpintEn gslsfexpintE1scaled gslsfexpintE2scaled
129
+ gslsfexpintEnscaled gslsfexpintEi gslsfexpintEiscaled gslsfShi
130
+ gslsfChi gslsfexpint3 gslsfSi gslsfCi gslsfatanint gslsffermidiracm1
131
+ gslsffermidirac0 gslsffermidirac1 gslsffermidirac2 gslsffermidiracint
132
+ gslsffermidiracmhalf gslsffermidirachalf gslsffermidirac3half
133
+ gslsffermidiracinc0 gslsflngamma gslsfgamma gslsfgammastar
134
+ gslsfgammainv gslsftaylorcoeff gslsffact gslsfdoublefact gslsflnfact
135
+ gslsflndoublefact gslsflnchoose gslsfchoose gslsflnpoch gslsfpoch
136
+ gslsfpochrel gslsfgammaincQ gslsfgammaincP gslsfgammainc gslsflnbeta
137
+ gslsfbeta gslsfbetainc gslsfgegenpoly1 gslsfgegenpoly2
138
+ gslsfgegenpoly3 gslsfgegenpolyn gslsfhyperg0F1 gslsfhyperg1F1int
139
+ gslsfhyperg1F1 gslsfhypergUint gslsfhypergU gslsfhyperg2F0
140
+ gslsflaguerre1 gslsflaguerre2 gslsflaguerre3 gslsflaguerren
141
+ gslsflambertW0 gslsflambertWm1 gslsflegendrePl gslsflegendreP1
142
+ gslsflegendreP2 gslsflegendreP3 gslsflegendreQ0 gslsflegendreQ1
143
+ gslsflegendreQl gslsflegendrePlm gslsflegendresphPlm
144
+ gslsflegendrearraysize gslsfconicalPhalf gslsfconicalPmhalf
145
+ gslsfconicalP0 gslsfconicalP1 gslsfconicalPsphreg gslsfconicalPcylreg
146
+ gslsflegendreH3d0 gslsflegendreH3d1 gslsflegendreH3d gslsflog
147
+ gslsflogabs gslsflog1plusx gslsflog1plusxmx gslsfpowint gslsfpsiint
148
+ gslsfpsi gslsfpsi1piy gslsfpsi1int gslsfpsi1 gslsfpsin
149
+ gslsfsynchrotron1 gslsfsynchrotron2 gslsftransport2 gslsftransport3
150
+ gslsftransport4 gslsftransport5 gslsfsin gslsfcos gslsfhypot
151
+ gslsfsinc gslsflnsinh gslsflncosh gslsfanglerestrictsymm
152
+ gslsfanglerestrictpos gslsfzetaint gslsfzeta gslsfzetam1
153
+ gslsfzetam1int gslsfhzeta gslsfetaint gslsfeta imag int1d int2d int3d
154
+ intalledges intallfaces interpolate invdiff invdiffnp invdiffpos
155
+ Isend isInf isNaN isoline Irecv j0 j1 jn jump lgamma LinearCG
156
+ LinearGMRES log log10 lrint lround max mean medit min mmg3d movemesh
157
+ movemesh23 mpiAlltoall mpiAlltoallv mpiAllgather mpiAllgatherv
158
+ mpiAllReduce mpiBarrier mpiGather mpiGatherv mpiRank mpiReduce
159
+ mpiScatter mpiScatterv mpiSize mpiWait mpiWaitAny mpiWtick mpiWtime
160
+ mshmet NLCG on plot polar Post pow processor processorblock
161
+ projection randinit randint31 randint32 random randreal1 randreal2
162
+ randreal3 randres53 Read readmesh readmesh3 Recv rfind rint round
163
+ savemesh savesol savevtk seekg Sent set sign signbit sin sinh sort
164
+ splitComm splitmesh sqrt square srandom srandomdev Stringification
165
+ swap system tan tanh tellg tetg tetgconvexhull tetgreconstruction
166
+ tetgtransfo tgamma triangulate trunc Wait Write y0 y1 yn
167
+ ))
168
+ end
169
+
170
+ def self.attributes
171
+ @builtinsParameters ||= Set.new(%w(
172
+ A A1 abserror absolute aniso aspectratio B B1 bb beginend bin
173
+ boundary bw close cmm coef composante cutoff datafilename dataname
174
+ dim distmax displacement doptions dparams eps err errg facemerge
175
+ facetcl factorize file fill fixedborder flabel flags floatmesh
176
+ floatsol fregion gradation grey hmax hmin holelist hsv init inquire
177
+ inside IsMetric iso ivalue keepbackvertices label labeldown labelmid
178
+ labelup levelset loptions lparams maxit maxsubdiv meditff mem memory
179
+ metric mode nbarrow nbiso nbiter nbjacoby nboffacetcl nbofholes
180
+ nbofregions nbregul nbsmooth nbvx ncv nev nomeshgeneration
181
+ normalization omega op optimize option options order orientation
182
+ periodic power precon prev ps ptmerge qfe qforder qft qfV ratio
183
+ rawvector reffacelow reffacemid reffaceup refnum reftet reftri region
184
+ regionlist renumv rescaling ridgeangle save sigma sizeofvolume
185
+ smoothing solver sparams split splitin2 splitpbedge stop strategy
186
+ swap switch sym t tgv thetamax tol tolpivot tolpivotsym transfo U2Vc
187
+ value varrow vector veps viso wait width withsurfacemesh WindowIndex
188
+ which zbound
189
+ ))
190
+ end
191
+
192
+ id = /[a-z_]\w*/i
193
+
194
+ state :expr_bol do
195
+ mixin :inline_whitespace
196
+
197
+ rule %r/include/, Comment::Preproc, :macro
198
+ rule %r/load/, Comment::Preproc, :macro
199
+ rule %r/ENDIFMACRO/, Comment::Preproc, :macro
200
+ rule %r/IFMACRO/, Comment::Preproc, :macro
201
+
202
+ rule(//) { pop! }
203
+ end
204
+
205
+ state :statements do
206
+ mixin :whitespace
207
+ rule %r/(u8|u|U|L)?"/, Str, :string
208
+ rule %r((u8|u|U|L)?'(\\.|\\[0-7]{1,3}|\\x[a-f0-9]{1,2}|[^\\'\n])')i, Str::Char
209
+ rule %r((\d+[.]\d*|[.]?\d+)e[+-]?\d+[lu]*)i, Num::Float
210
+ rule %r(\d+e[+-]?\d+[lu]*)i, Num::Float
211
+ rule %r/0x[0-9a-f]+[lu]*/i, Num::Hex
212
+ rule %r/0[0-7]+[lu]*/i, Num::Oct
213
+ rule %r/\d+[lu]*/i, Num::Integer
214
+ rule %r(\*/), Error
215
+ rule %r([~!%^&*+=\|?:<>/-]), Operator
216
+ rule %r/'/, Operator
217
+ rule %r/[()\[\],.;]/, Punctuation
218
+ rule %r/\bcase\b/, Keyword, :case
219
+ rule %r/(?:true|false|NaN)\b/, Name::Builtin
220
+ rule id do |m|
221
+ name = m[0]
222
+
223
+ if self.class.keywords.include? name
224
+ token Keyword
225
+ elsif self.class.keywords_type.include? name
226
+ token Keyword::Type
227
+ elsif self.class.reserved.include? name
228
+ token Keyword::Reserved
229
+ elsif self.class.builtins.include? name
230
+ token Name::Builtin
231
+ elsif self.class.attributes.include? name
232
+ token Name::Attribute
233
+ else
234
+ token Name
235
+ end
236
+ end
237
+ end
238
+ end
239
+ end
240
+ end
@@ -0,0 +1,151 @@
1
+ # -*- coding: utf-8 -*- #
2
+ # frozen_string_literal: true
3
+
4
+ # See http://www.cs.cmu.edu/afs/andrew/course/15/411/ghc/share/doc/ghc/ext-core/core.pdf for a description of the syntax
5
+ # of the language and https://www.aosabook.org/en/ghc.html for a high level overview.
6
+ module Rouge
7
+ module Lexers
8
+ class GHCCore < RegexLexer
9
+ title "GHC Core"
10
+ desc "Intermediate representation of the GHC Haskell compiler."
11
+ tag 'ghc-core'
12
+
13
+ filenames '*.dump-simpl', '*.dump-cse', '*.dump-ds', '*.dump-spec'
14
+
15
+ state :root do
16
+ # sections
17
+ rule %r/^=====.*=====$/, Generic::Heading
18
+ # timestamps
19
+ rule %r/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\.\d+ UTC$/, Comment::Single
20
+ rule %r/^Result size of .+\s*.*}/, Comment::Multiline
21
+ rule %r/--.*$/, Comment::Single
22
+
23
+ rule %r/\[/, Comment::Special, :annotation
24
+
25
+ mixin :recursive_binding
26
+ mixin :ghc_rule
27
+ mixin :function
28
+
29
+ # rest is Text
30
+ rule %r/\s/m, Text
31
+ rule %r/.*/, Text
32
+ end
33
+
34
+ state :expression do
35
+ rule %r/[\n]+/, Text
36
+ rule %r/(?=^\S)/ do
37
+ pop!
38
+ end
39
+
40
+ rule %r/\s+/, Text, :expression_line
41
+ end
42
+
43
+ state :expression_line do
44
+ rule %r/ /, Text
45
+
46
+ mixin :common
47
+
48
+ rule %r/\n/, Text, :pop!
49
+ end
50
+
51
+ state :annotation do
52
+ rule %r/\]/, Comment::Special, :pop!
53
+ rule %r/\[/, Comment::Special, :annotation
54
+ rule %r/[^\[\]]+/, Comment::Special
55
+ end
56
+
57
+ state :common do
58
+ # array, e.g. '[]' or '[Char]'
59
+ rule %r/\[[^=]*\]/, Keyword::Type
60
+
61
+ rule %r/\[/, Comment::Special, :annotation
62
+
63
+ mixin :literal
64
+ mixin :constants
65
+ mixin :punctuation
66
+ mixin :operator
67
+ mixin :name
68
+ end
69
+
70
+ state :literal do
71
+ rule %r/\d+\.\d+\#{0,2}/, Literal::Number::Float
72
+ rule %r/\d+\#{0,2}/, Literal::Number::Integer
73
+ rule %r/".*"#/, Literal::String
74
+ rule %r/'.'#/, Literal::String::Char
75
+ end
76
+
77
+ state :constants do
78
+ rule %r/__DEFAULT/, Name::Constant
79
+ end
80
+
81
+ state :name do
82
+ rule %r/^([A-Z]\w*)(\.)/ do |m|
83
+ token Name::Namespace, m[0]
84
+ token Punctuation, m[1]
85
+ end
86
+
87
+ rule %r/[A-Z][^\s.,(){}]*/, Keyword::Type
88
+
89
+ # packages, e.g. 'ghc-prim-0.5.3:'
90
+ rule %r/(^[a-z].*?\d+\.\d+\.\d+)(:)(?=\S)/ do |m|
91
+ token Name::Namespace, m[1]
92
+ token Punctuation, m[2]
93
+ end
94
+
95
+ rule %r/\S*\(,\)\S*/, Name::Variable # '(,)' is a name, not punctuation
96
+ rule %r/\S[^\s.,(){}]*/, Name::Variable
97
+ end
98
+
99
+ state :punctuation do
100
+ rule %r/[.,(){};]/, Punctuation
101
+ end
102
+
103
+ state :operator do
104
+ rule %r/=>/, Operator
105
+ rule %r/->/, Operator
106
+ rule %r/::/, Operator
107
+ rule %r/=/, Operator
108
+ rule %r/forall/, Keyword
109
+ rule %r/case/, Keyword
110
+ rule %r/of/, Keyword
111
+ rule %r/letrec/, Keyword
112
+ rule %r/let/, Keyword
113
+ rule %r/join/, Keyword
114
+ rule %r/@/, Operator
115
+ rule %r/\\/, Operator
116
+ end
117
+
118
+ state :recursive_binding do
119
+ rule %r/(Rec)(\s*)({)/ do |m|
120
+ token Keyword, m[1]
121
+ token Text, m[2]
122
+ token Punctuation, m[3]
123
+ end
124
+
125
+ rule %r/^(end)(\s*)(Rec)(\s*)(})/ do |m|
126
+ token Keyword, m[1]
127
+ token Text, m[2]
128
+ token Keyword, m[3]
129
+ token Text, m[4]
130
+ token Punctuation, m[5]
131
+ end
132
+ end
133
+
134
+ state :ghc_rule do
135
+ rule %r/^(".*?")/m do |m|
136
+ token Name::Label, m[0]
137
+
138
+ push :expression
139
+ end
140
+ end
141
+
142
+ state :function do
143
+ rule %r/^(\S+)(?=.*?(=|::))/m do |m|
144
+ token Name::Function, m[0]
145
+
146
+ push :expression
147
+ end
148
+ end
149
+ end
150
+ end
151
+ end
@@ -38,6 +38,7 @@ module Rouge
38
38
  state :root do
39
39
  # Comments
40
40
  rule %r/{#/, Comment, :comment
41
+ rule %r/##.*/, Comment
41
42
 
42
43
  # Statements
43
44
  rule %r/\{\%/ do
@@ -51,13 +52,13 @@ module Rouge
51
52
  push :expression
52
53
  end
53
54
 
54
- rule(/(.+?)(?=\\|{{|{%|{#)/m) { delegate parent }
55
+ rule(/(.+?)(?=\\|{{|{%|{#|##)/m) { delegate parent }
55
56
  rule(/.+/m) { delegate parent }
56
57
  end
57
58
 
58
59
  state :filter do
59
60
  # Filters are called like variable|foo(arg1, ...)
60
- rule %r/(\|)(\w+)/ do
61
+ rule %r/(\|\s*)(\w+)/ do
61
62
  groups Operator, Name::Function
62
63
  end
63
64
  end
@@ -96,8 +97,9 @@ module Rouge
96
97
  end
97
98
 
98
99
  state :comment do
99
- rule(/[^{#]+/m) { token Comment }
100
+ rule %r/[^#]+/m, Comment
100
101
  rule(/#}/) { token Comment; pop! }
102
+ rule %r/#/, Comment
101
103
  end
102
104
 
103
105
  state :expression do
@@ -14,6 +14,48 @@ module Rouge
14
14
  string = /"[^"]*?"/
15
15
  identifier = /([-a-zA-Z$._][-a-zA-Z$._0-9]*|#{string})/
16
16
 
17
+ def self.keywords
18
+ @keywords ||= Set.new %w(
19
+ addrspace addrspacecast alias align alignstack allocsize alwaysinline
20
+ appending arcp argmemonly arm_aapcs_vfpcc arm_aapcscc arm_apcscc asm
21
+ attributes available_externally begin builtin byval c cc ccc cold
22
+ coldcc common constant convergent datalayout dbg declare default
23
+ define dllexport dllimport end eq exact extern_weak external false
24
+ fast fastcc gc global hidden inaccessiblemem_or_argmemonly
25
+ inaccessiblememonly inbounds inlinehint inreg internal jumptable
26
+ landingpad linker_private linkonce linkonce_odr minsize module naked
27
+ ne nest ninf nnan no-jump-tables noalias nobuiltin nocapture
28
+ nocf_check noduplicate noimplicitfloat noinline nonlazybind norecurse
29
+ noredzone noredzone noreturn nounwind nsw nsz null nuw oeq oge ogt
30
+ ole olt one opaque optforfuzzing optnone optsize ord personality
31
+ private protected ptx_device ptx_kernel readnone readonly
32
+ returns_twice safestack sanitize_address sanitize_hwaddress
33
+ sanitize_memory sanitize_thread section sge sgt shadowcallstack
34
+ sideeffect signext sle slt speculatable speculative_load_hardening
35
+ sret ssp sspreq sspstrong strictfp tail target thread_local to triple
36
+ true type ueq uge ugt ule ult undef une unnamed_addr uno uwtable
37
+ volatile weak weak_odr writeonly x x86_fastcallcc x86_stdcallcc
38
+ zeroext zeroinitializer
39
+ )
40
+ end
41
+
42
+ def self.instructions
43
+ @instructions ||= Set.new %w(
44
+ add alloca and ashr bitcast br call catch cleanup extractelement
45
+ extractvalue fadd fcmp fdiv fmul fpext fptosi fptoui fptrunc free
46
+ frem fsub getelementptr getresult icmp insertelement insertvalue
47
+ inttoptr invoke load lshr malloc mul or phi ptrtoint resume ret sdiv
48
+ select sext shl shufflevector sitofp srem store sub switch trunc udiv
49
+ uitofp unreachable unwind urem va_arg xor zext
50
+ )
51
+ end
52
+
53
+ def self.types
54
+ @types ||= Set.new %w(
55
+ double float fp128 half label metadata ppc_fp128 void x86_fp80 x86mmx
56
+ )
57
+ end
58
+
17
59
  state :basic do
18
60
  rule %r/;.*?$/, Comment::Single
19
61
  rule %r/\s+/, Text
@@ -33,55 +75,22 @@ module Rouge
33
75
  rule %r/[=<>{}\[\]()*.,!]|x/, Punctuation
34
76
  end
35
77
 
36
- builtin_types = %w(
37
- void float double half x86_fp80 x86mmx fp128 ppc_fp128 label metadata
38
- )
78
+ state :root do
79
+ mixin :basic
39
80
 
40
- state :types do
41
81
  rule %r/i[1-9]\d*/, Keyword::Type
42
- rule %r/#{builtin_types.join('|')}/, Keyword::Type
43
- end
44
-
45
- builtin_keywords = %w(
46
- begin end true false declare define global constant alignstack private
47
- landingpad linker_private internal available_externally linkonce_odr
48
- linkonce weak weak_odr appending dllimport dllexport common default
49
- hidden protected extern_weak external thread_local zeroinitializer
50
- undef null to tail target triple datalayout volatile nuw nsw nnan ninf
51
- nsz arcp fast exact inbounds align addrspace section alias module asm
52
- sideeffect gc dbg ccc fastcc coldcc x86_stdcallcc x86_fastcallcc
53
- arm_apcscc arm_aapcscc arm_aapcs_vfpcc ptx_device ptx_kernel cc
54
- c signext zeroext inreg sret nounwind noreturn noalias nocapture byval
55
- nest readnone readonly inlinehint noinline alwaysinline optsize ssp
56
- sspreq noredzone noimplicitfloat naked type opaque eq ne slt sgt sle
57
- sge ult ugt ule uge oeq one olt ogt ole oge ord uno unnamed_addr ueq
58
- une uwtable x personality allocsize builtin cold convergent
59
- inaccessiblememonly inaccessiblemem_or_argmemonly jumptable minsize
60
- no-jump-tables nobuiltin noduplicate nonlazybind noredzone norecurse
61
- optforfuzzing optnone writeonly argmemonly returns_twice safestack
62
- sanitize_address sanitize_memory sanitize_thread sanitize_hwaddress
63
- speculative_load_hardening speculatable sspstrong strictfp nocf_check
64
- shadowcallstack attributes
65
- )
66
82
 
67
- builtin_instructions = %w(
68
- add fadd sub fsub mul fmul udiv sdiv fdiv urem srem frem shl lshr ashr
69
- and or xor icmp fcmp phi call catch trunc zext sext fptrunc fpext
70
- uitofp sitofp fptoui fptosi inttoptr ptrtoint bitcast select va_arg ret
71
- br switch invoke unwind unreachable malloc alloca free load store
72
- getelementptr extractelement insertelement shufflevector getresult
73
- extractvalue insertvalue cleanup resume
74
- )
75
-
76
- state :keywords do
77
- rule %r/#{builtin_instructions.join('|')}/, Keyword
78
- rule %r/#{builtin_keywords.join('|')}/, Keyword
79
- end
80
-
81
- state :root do
82
- mixin :basic
83
- mixin :keywords
84
- mixin :types
83
+ rule %r/\w+/ do |m|
84
+ if self.class.types.include? m[0]
85
+ token Keyword::Type
86
+ elsif self.class.instructions.include? m[0]
87
+ token Keyword
88
+ elsif self.class.keywords.include? m[0]
89
+ token Keyword
90
+ else
91
+ token Error
92
+ end
93
+ end
85
94
  end
86
95
  end
87
96
  end
@@ -4,8 +4,11 @@
4
4
  module Rouge
5
5
  module Lexers
6
6
  load_lexer 'c.rb'
7
+ load_lexer 'objective_c/common.rb'
7
8
 
8
9
  class ObjectiveC < C
10
+ extend ObjectiveCCommon
11
+
9
12
  tag 'objective_c'
10
13
  title "Objective-C"
11
14
  desc 'an extension of C commonly used to write Apple software'
@@ -13,178 +16,6 @@ module Rouge
13
16
  filenames '*.m', '*.h'
14
17
 
15
18
  mimetypes 'text/x-objective_c', 'application/x-objective_c'
16
-
17
- def self.at_keywords
18
- @at_keywords ||= %w(
19
- selector private protected public encode synchronized try
20
- throw catch finally end property synthesize dynamic optional
21
- interface implementation import
22
- )
23
- end
24
-
25
- def self.at_builtins
26
- @at_builtins ||= %w(true false YES NO)
27
- end
28
-
29
- def self.builtins
30
- @builtins ||= %w(YES NO nil)
31
- end
32
-
33
- id = /[a-z$_][a-z0-9$_]*/i
34
-
35
- prepend :statements do
36
- rule %r/@"/, Str, :string
37
- rule %r/@'(\\[0-7]{1,3}|\\x[a-fA-F0-9]{1,2}|\\.|[^\\'\n]')/,
38
- Str::Char
39
- rule %r/@(\d+[.]\d*|[.]\d+|\d+)e[+-]?\d+l?/i,
40
- Num::Float
41
- rule %r/@(\d+[.]\d*|[.]\d+|\d+f)f?/i, Num::Float
42
- rule %r/@0x\h+[lL]?/, Num::Hex
43
- rule %r/@0[0-7]+l?/i, Num::Oct
44
- rule %r/@\d+l?/, Num::Integer
45
- rule %r/\bin\b/, Keyword
46
-
47
- rule %r/@(?:interface|implementation)\b/, Keyword, :classname
48
- rule %r/@(?:class|protocol)\b/, Keyword, :forward_classname
49
-
50
- rule %r/@([[:alnum:]]+)/ do |m|
51
- if self.class.at_keywords.include? m[1]
52
- token Keyword
53
- elsif self.class.at_builtins.include? m[1]
54
- token Name::Builtin
55
- else
56
- token Error
57
- end
58
- end
59
-
60
- rule %r/[?]/, Punctuation, :ternary
61
- rule %r/\[/, Punctuation, :message
62
- rule %r/@\[/, Punctuation, :array_literal
63
- rule %r/@\{/, Punctuation, :dictionary_literal
64
- end
65
-
66
- state :ternary do
67
- rule %r/:/, Punctuation, :pop!
68
- mixin :statements
69
- end
70
-
71
- state :message_shared do
72
- rule %r/\]/, Punctuation, :pop!
73
- rule %r/\{/, Punctuation, :pop!
74
- rule %r/;/, Error
75
-
76
- mixin :statements
77
- end
78
-
79
- state :message do
80
- rule %r/(#{id})(\s*)(:)/ do
81
- groups(Name::Function, Text, Punctuation)
82
- goto :message_with_args
83
- end
84
-
85
- rule %r/(#{id})(\s*)(\])/ do
86
- groups(Name::Function, Text, Punctuation)
87
- pop!
88
- end
89
-
90
- mixin :message_shared
91
- end
92
-
93
- state :message_with_args do
94
- rule %r/\{/, Punctuation, :function
95
- rule %r/(#{id})(\s*)(:)/ do
96
- groups(Name::Function, Text, Punctuation)
97
- pop!
98
- end
99
-
100
- mixin :message_shared
101
- end
102
-
103
- state :array_literal do
104
- rule %r/]/, Punctuation, :pop!
105
- rule %r/,/, Punctuation
106
- mixin :statements
107
- end
108
-
109
- state :dictionary_literal do
110
- rule %r/}/, Punctuation, :pop!
111
- rule %r/,/, Punctuation
112
- mixin :statements
113
- end
114
-
115
- state :classname do
116
- mixin :whitespace
117
-
118
- rule %r/(#{id})(\s*)(:)(\s*)(#{id})/ do
119
- groups(Name::Class, Text,
120
- Punctuation, Text,
121
- Name::Class)
122
- pop!
123
- end
124
-
125
- rule %r/(#{id})(\s*)([(])(\s*)(#{id})(\s*)([)])/ do
126
- groups(Name::Class, Text,
127
- Punctuation, Text,
128
- Name::Label, Text,
129
- Punctuation)
130
- pop!
131
- end
132
-
133
- rule id, Name::Class, :pop!
134
- end
135
-
136
- state :forward_classname do
137
- mixin :whitespace
138
-
139
- rule %r/(#{id})(\s*)(,)(\s*)/ do
140
- groups(Name::Class, Text, Punctuation, Text)
141
- push
142
- end
143
-
144
- rule %r/(#{id})(\s*)(;?)/ do
145
- groups(Name::Class, Text, Punctuation)
146
- pop!
147
- end
148
- end
149
-
150
- prepend :root do
151
- rule %r(
152
- ([-+])(\s*)
153
- ([(].*?[)])?(\s*)
154
- (?=#{id}:?)
155
- )ix do |m|
156
- token Keyword, m[1]
157
- token Text, m[2]
158
- recurse(m[3]) if m[3]
159
- token Text, m[4]
160
- push :method_definition
161
- end
162
- end
163
-
164
- state :method_definition do
165
- rule %r/,/, Punctuation
166
- rule %r/[.][.][.]/, Punctuation
167
- rule %r/([(].*?[)])(#{id})/ do |m|
168
- recurse m[1]; token Name::Variable, m[2]
169
- end
170
-
171
- rule %r/(#{id})(\s*)(:)/m do
172
- groups(Name::Function, Text, Punctuation)
173
- end
174
-
175
- rule %r/;/, Punctuation, :pop!
176
-
177
- rule %r/{/ do
178
- token Punctuation
179
- goto :function
180
- end
181
-
182
- mixin :inline_whitespace
183
- rule %r(//.*?\n), Comment::Single
184
- rule %r/\s+/m, Text
185
-
186
- rule(//) { pop! }
187
- end
188
19
  end
189
20
  end
190
21
  end
@@ -0,0 +1,184 @@
1
+ # -*- coding: utf-8 -*- #
2
+ # frozen_string_literal: true
3
+
4
+ module Rouge
5
+ module Lexers
6
+ module ObjectiveCCommon
7
+ id = /[a-z$_][a-z0-9$_]*/i
8
+
9
+ def at_keywords
10
+ @at_keywords ||= %w(
11
+ selector private protected public encode synchronized try
12
+ throw catch finally end property synthesize dynamic optional
13
+ interface implementation import
14
+ )
15
+ end
16
+
17
+ def at_builtins
18
+ @at_builtins ||= %w(true false YES NO)
19
+ end
20
+
21
+ def builtins
22
+ @builtins ||= %w(YES NO nil)
23
+ end
24
+
25
+ def self.extended(base)
26
+ base.prepend :statements do
27
+ rule %r/@"/, base::Str, :string
28
+ rule %r/@'(\\[0-7]{1,3}|\\x[a-fA-F0-9]{1,2}|\\.|[^\\'\n]')/,
29
+ base::Str::Char
30
+ rule %r/@(\d+[.]\d*|[.]\d+|\d+)e[+-]?\d+l?/i,
31
+ base::Num::Float
32
+ rule %r/@(\d+[.]\d*|[.]\d+|\d+f)f?/i, base::Num::Float
33
+ rule %r/@0x\h+[lL]?/, base::Num::Hex
34
+ rule %r/@0[0-7]+l?/i, base::Num::Oct
35
+ rule %r/@\d+l?/, base::Num::Integer
36
+ rule %r/\bin\b/, base::Keyword
37
+
38
+ rule %r/@(?:interface|implementation)\b/, base::Keyword, :objc_classname
39
+ rule %r/@(?:class|protocol)\b/, base::Keyword, :forward_classname
40
+
41
+ rule %r/@([[:alnum:]]+)/ do |m|
42
+ if base.at_keywords.include? m[1]
43
+ token base::Keyword
44
+ elsif base.at_builtins.include? m[1]
45
+ token base::Name::Builtin
46
+ else
47
+ token Error
48
+ end
49
+ end
50
+
51
+ rule %r/[?]/, base::Punctuation, :ternary
52
+ rule %r/\[/, base::Punctuation, :message
53
+ rule %r/@\[/, base::Punctuation, :array_literal
54
+ rule %r/@\{/, base::Punctuation, :dictionary_literal
55
+ end
56
+
57
+ id = /[a-z$_][a-z0-9$_]*/i
58
+
59
+ base.state :ternary do
60
+ rule %r/:/, base::Punctuation, :pop!
61
+ mixin :statements
62
+ end
63
+
64
+ base.state :message_shared do
65
+ rule %r/\]/, base::Punctuation, :pop!
66
+ rule %r/\{/, base::Punctuation, :pop!
67
+ rule %r/;/, base::Error
68
+
69
+ mixin :statements
70
+ end
71
+
72
+ base.state :message do
73
+ rule %r/(#{id})(\s*)(:)/ do
74
+ groups(base::Name::Function, base::Text, base::Punctuation)
75
+ goto :message_with_args
76
+ end
77
+
78
+ rule %r/(#{id})(\s*)(\])/ do
79
+ groups(base::Name::Function, base::Text, base::Punctuation)
80
+ pop!
81
+ end
82
+
83
+ mixin :message_shared
84
+ end
85
+
86
+ base.state :message_with_args do
87
+ rule %r/\{/, base::Punctuation, :function
88
+ rule %r/(#{id})(\s*)(:)/ do
89
+ groups(base::Name::Function, base::Text, base::Punctuation)
90
+ pop!
91
+ end
92
+
93
+ mixin :message_shared
94
+ end
95
+
96
+ base.state :array_literal do
97
+ rule %r/]/, base::Punctuation, :pop!
98
+ rule %r/,/, base::Punctuation
99
+ mixin :statements
100
+ end
101
+
102
+ base.state :dictionary_literal do
103
+ rule %r/}/, base::Punctuation, :pop!
104
+ rule %r/,/, base::Punctuation
105
+ mixin :statements
106
+ end
107
+
108
+ base.state :objc_classname do
109
+ mixin :whitespace
110
+
111
+ rule %r/(#{id})(\s*)(:)(\s*)(#{id})/ do
112
+ groups(base::Name::Class, base::Text,
113
+ base::Punctuation, base::Text,
114
+ base::Name::Class)
115
+ pop!
116
+ end
117
+
118
+ rule %r/(#{id})(\s*)([(])(\s*)(#{id})(\s*)([)])/ do
119
+ groups(base::Name::Class, base::Text,
120
+ base::Punctuation, base::Text,
121
+ base::Name::Label, base::Text,
122
+ base::Punctuation)
123
+ pop!
124
+ end
125
+
126
+ rule id, base::Name::Class, :pop!
127
+ end
128
+
129
+ base.state :forward_classname do
130
+ mixin :whitespace
131
+
132
+ rule %r/(#{id})(\s*)(,)(\s*)/ do
133
+ groups(base::Name::Class, base::Text, base::Punctuation, base::Text)
134
+ push
135
+ end
136
+
137
+ rule %r/(#{id})(\s*)(;?)/ do
138
+ groups(base::Name::Class, base::Text, base::Punctuation)
139
+ pop!
140
+ end
141
+ end
142
+
143
+ base.prepend :root do
144
+ rule %r(
145
+ ([-+])(\s*)
146
+ ([(].*?[)])?(\s*)
147
+ (?=#{id}:?)
148
+ )ix do |m|
149
+ token base::Keyword, m[1]
150
+ token base::Text, m[2]
151
+ recurse(m[3]) if m[3]
152
+ token base::Text, m[4]
153
+ push :method_definition
154
+ end
155
+ end
156
+
157
+ base.state :method_definition do
158
+ rule %r/,/, base::Punctuation
159
+ rule %r/[.][.][.]/, base::Punctuation
160
+ rule %r/([(].*?[)])(#{id})/ do |m|
161
+ recurse m[1]; token base::Name::Variable, m[2]
162
+ end
163
+
164
+ rule %r/(#{id})(\s*)(:)/m do
165
+ groups(base::Name::Function, base::Text, base::Punctuation)
166
+ end
167
+
168
+ rule %r/;/, base::Punctuation, :pop!
169
+
170
+ rule %r/{/ do
171
+ token base::Punctuation
172
+ goto :function
173
+ end
174
+
175
+ mixin :inline_whitespace
176
+ rule %r(//.*?\n), base::Comment::Single
177
+ rule %r/\s+/m, base::Text
178
+
179
+ rule(//) { pop! }
180
+ end
181
+ end
182
+ end
183
+ end
184
+ end
@@ -0,0 +1,31 @@
1
+ # -*- coding: utf-8 -*- #
2
+ # frozen_string_literal: true
3
+
4
+ module Rouge
5
+ module Lexers
6
+ load_lexer 'cpp.rb'
7
+ load_lexer 'objective_c/common.rb'
8
+
9
+ class ObjectiveCpp < Cpp
10
+ extend ObjectiveCCommon
11
+
12
+ tag 'objective_cpp'
13
+ title "Objective-C++"
14
+ desc 'an extension of C++ uncommonly used to write Apple software'
15
+ aliases 'objcpp', 'obj-cpp', 'obj_cpp', 'objectivecpp',
16
+ 'objc++', 'obj-c++', 'obj_c++', 'objectivec++'
17
+ filenames '*.mm', '*.h'
18
+
19
+ mimetypes 'text/x-objective-c++', 'application/x-objective-c++'
20
+
21
+ prepend :statements do
22
+ rule %r/(\.)(class)/ do
23
+ groups(Operator, Name::Builtin::Pseudo)
24
+ end
25
+ rule %r/(@selector)(\()(class)(\))/ do
26
+ groups(Keyword, Punctuation, Name::Builtin::Pseudo, Punctuation)
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
@@ -8,7 +8,8 @@ module Rouge
8
8
  desc "The Python programming language (python.org)"
9
9
  tag 'python'
10
10
  aliases 'py'
11
- filenames '*.py', '*.pyw', '*.sc', 'SConstruct', 'SConscript', '*.tac'
11
+ filenames '*.py', '*.pyw', '*.sc', 'SConstruct', 'SConscript', '*.tac',
12
+ '*.bzl', 'BUCK', 'BUILD', 'BUILD.bazel', 'WORKSPACE'
12
13
  mimetypes 'text/x-python', 'application/x-python'
13
14
 
14
15
  def self.detect?(text)
@@ -96,7 +96,7 @@ module Rouge
96
96
  rule %r([=-]>), Keyword
97
97
  rule %r(<->), Keyword
98
98
  rule %r/[()\[\]{}|,:;]/, Punctuation
99
- rule %r/[*!@~&+%^<>=\?-]|\.{2,3}/, Operator
99
+ rule %r/[*\/!@~&+%^<>=\?-]|\.{2,3}/, Operator
100
100
 
101
101
  rule %r/([.]\s*)?#{id}(?=\s*[(])/m, Name::Function
102
102
  rule %r/[.]\s*#{id}/, Name::Property
@@ -25,7 +25,7 @@ module Rouge
25
25
  )
26
26
 
27
27
  declarations = Set.new %w(
28
- class deinit enum convenience extension final func import init internal lazy let optional private protocol public required static struct subscript typealias var dynamic indirect associatedtype open fileprivate
28
+ class deinit enum convenience extension final func import init internal lazy let optional private protocol public required static struct subscript typealias var dynamic indirect associatedtype open fileprivate some
29
29
  )
30
30
 
31
31
  constants = Set.new %w(
@@ -67,6 +67,7 @@ module Rouge
67
67
 
68
68
  state :root do
69
69
  mixin :whitespace
70
+
70
71
  rule %r/\$(([1-9]\d*)?\d)/, Name::Variable
71
72
 
72
73
  rule %r{[()\[\]{}:;,?\\]}, Punctuation
@@ -3,6 +3,6 @@
3
3
 
4
4
  module Rouge
5
5
  def self.version
6
- "3.14.0"
6
+ "3.15.0"
7
7
  end
8
8
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rouge
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.14.0
4
+ version: 3.15.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeanine Adkisson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-12-10 00:00:00.000000000 Z
11
+ date: 2020-01-14 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Rouge aims to a be a simple, easy-to-extend drop-in replacement for pygments.
14
14
  email:
@@ -73,8 +73,10 @@ files:
73
73
  - lib/rouge/demos/escape
74
74
  - lib/rouge/demos/factor
75
75
  - lib/rouge/demos/fortran
76
+ - lib/rouge/demos/freefem
76
77
  - lib/rouge/demos/fsharp
77
78
  - lib/rouge/demos/gdscript
79
+ - lib/rouge/demos/ghc-core
78
80
  - lib/rouge/demos/gherkin
79
81
  - lib/rouge/demos/glsl
80
82
  - lib/rouge/demos/go
@@ -135,6 +137,7 @@ files:
135
137
  - lib/rouge/demos/nim
136
138
  - lib/rouge/demos/nix
137
139
  - lib/rouge/demos/objective_c
140
+ - lib/rouge/demos/objective_cpp
138
141
  - lib/rouge/demos/ocaml
139
142
  - lib/rouge/demos/openedge
140
143
  - lib/rouge/demos/opentype_feature_file
@@ -272,8 +275,10 @@ files:
272
275
  - lib/rouge/lexers/escape.rb
273
276
  - lib/rouge/lexers/factor.rb
274
277
  - lib/rouge/lexers/fortran.rb
278
+ - lib/rouge/lexers/freefem.rb
275
279
  - lib/rouge/lexers/fsharp.rb
276
280
  - lib/rouge/lexers/gdscript.rb
281
+ - lib/rouge/lexers/ghc_core.rb
277
282
  - lib/rouge/lexers/gherkin.rb
278
283
  - lib/rouge/lexers/gherkin/keywords.rb
279
284
  - lib/rouge/lexers/glsl.rb
@@ -338,6 +343,8 @@ files:
338
343
  - lib/rouge/lexers/nim.rb
339
344
  - lib/rouge/lexers/nix.rb
340
345
  - lib/rouge/lexers/objective_c.rb
346
+ - lib/rouge/lexers/objective_c/common.rb
347
+ - lib/rouge/lexers/objective_cpp.rb
341
348
  - lib/rouge/lexers/ocaml.rb
342
349
  - lib/rouge/lexers/ocaml/common.rb
343
350
  - lib/rouge/lexers/openedge.rb
@@ -457,7 +464,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
457
464
  - !ruby/object:Gem::Version
458
465
  version: '0'
459
466
  requirements: []
460
- rubygems_version: 3.0.3
467
+ rubygems_version: 3.1.2
461
468
  signing_key:
462
469
  specification_version: 4
463
470
  summary: A pure-ruby colorizer based on pygments