rouge 3.19.0 → 3.20.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: 31311a77cd2c1bbe0bd0eb402b7b5d0e08c46a91fb9ae7614310b5c022f7707c
4
- data.tar.gz: daa405b54f1c0a249a57d6f5044e52a08a861aece022df92ee311492cfd6d553
3
+ metadata.gz: a0ad085dddf353cc95e795e5f556b4f2d9821068cceeeaab4cb34cb11f3ad776
4
+ data.tar.gz: f70271022198b1d7e95df35d856274234720d54d4ef3f1a42c782246e2cf4c47
5
5
  SHA512:
6
- metadata.gz: 27a79b06908ec8791d6e743817c35dae531e0b171cd35efa43190b384fbb87c74a72fbf5226b233ce8f96e57e2dc31596d91f5bb43307628c41da901544f649f
7
- data.tar.gz: 2bdf4c0aa72e72944e28428ac4c5eea314b01fd3314f037f107f80e43f125471cab7dc1d82ff055337015e231495fa781c6fd0a80db2c6a702346bea915b38af
6
+ metadata.gz: 473cfdc4ce0c458d0a7b0c3b1e6684723ceb7c15dea4d1080baf201786ecd149e9d21cd25f65735edbbf4b4f763a5d7d1854a4d909bef6902b7d609d30ebcc2b
7
+ data.tar.gz: 579d31241b2fe8d4f2b9471dd6bb97b5621051811260d02b21a012e9e35ccf34d83e0e998981e959aa0ce6a1b00932c06f7ed8b8b093fde95d53c7a8ebbb67ce
@@ -0,0 +1,16 @@
1
+ (*
2
+ This is a comment
3
+ *)
4
+ module Foo =
5
+ autoload xfm
6
+
7
+ let a = b | c . d
8
+
9
+ let lns = a*
10
+
11
+ let filter = incl "/path/to/file"
12
+ . incl "/path/to/other_file"
13
+ . Util.stdexcl
14
+
15
+ (* xmf is the transform *)
16
+ let xmf = transform lns filter
@@ -0,0 +1,12 @@
1
+ @article{Witten:1988hf,
2
+ author = "Witten, Edward",
3
+ title = "{Quantum Field Theory and the Jones Polynomial}",
4
+ journal = "Commun. Math. Phys.",
5
+ volume = "121",
6
+ year = "1989",
7
+ pages = "351-399",
8
+ doi = "10.1007/BF01217730",
9
+ note = "[,233(1988)]",
10
+ reportNumber = "IASSNS-HEP-88-33",
11
+ SLACcitation = "%%CITATION = CMPHA,121,351;%%"
12
+ }
@@ -0,0 +1,20 @@
1
+ struct PSInput
2
+ {
3
+ float4 position : SV_POSITION;
4
+ float4 color : COLOR;
5
+ };
6
+
7
+ // Vertex shader
8
+ PSInput VSMain(float4 position : POSITION, float4 color : COLOR)
9
+ {
10
+ PSInput result;
11
+ result.position = position;
12
+ result.color = color;
13
+ return result;
14
+ }
15
+
16
+ // Pixel shader
17
+ float4 PSMain(PSInput input) : SV_TARGET
18
+ {
19
+ return input.color;
20
+ }
@@ -0,0 +1,15 @@
1
+ mitch =
2
+ age: 21
3
+ height: 180cm
4
+ pets: [\dog, \goldfish]
5
+
6
+ phile = {}
7
+ phile{height, pets} = mitch
8
+ phile.height #=> 180
9
+ phile.pets #=> ['dog', 'goldfish']
10
+
11
+ a = [2 7 1 8]
12
+ ..push 3
13
+ ..shift!
14
+ ..sort!
15
+ a #=> [1,3,7,8]
@@ -0,0 +1,9 @@
1
+ #*
2
+ There is multi-line comment.
3
+ see this text because the Velocity Templating Engine will ignore it.
4
+ *#
5
+ <h3>List</h3>
6
+ ## This is a single line comment.
7
+ #if( $allProducts )
8
+ <p>not found.</p>
9
+ #end
@@ -0,0 +1,6 @@
1
+ const std = @import("std");
2
+ const warn = std.debug.warn;
3
+
4
+ fn add_floats(x: f16, y: f16) f16 {
5
+ return x + y;
6
+ }
@@ -0,0 +1,93 @@
1
+ # -*- coding: utf-8 -*- #
2
+ # frozen_string_literal: true
3
+
4
+ module Rouge
5
+ module Lexers
6
+ class Augeas < RegexLexer
7
+ title "Augeas"
8
+ desc "The Augeas programming language (augeas.net)"
9
+
10
+ tag 'augeas'
11
+ aliases 'aug'
12
+ filenames '*.aug'
13
+ mimetypes 'text/x-augeas'
14
+
15
+ def self.reserved
16
+ @reserved ||= Set.new %w(
17
+ _ let del store value counter seq key label autoload incl excl
18
+ transform test get put in after set clear insa insb print_string
19
+ print_regexp print_endline print_tree lens_ctype lens_atype
20
+ lens_ktype lens_vtype lens_format_atype regexp_match
21
+ )
22
+ end
23
+
24
+ state :basic do
25
+ rule %r/\s+/m, Text
26
+ rule %r/\(\*/, Comment::Multiline, :comment
27
+ end
28
+
29
+ state :comment do
30
+ rule %r/\*\)/, Comment::Multiline, :pop!
31
+ rule %r/\(\*/, Comment::Multiline, :comment
32
+ rule %r/[^*)]+/, Comment::Multiline
33
+ rule %r/[*)]/, Comment::Multiline
34
+ end
35
+
36
+ state :root do
37
+ mixin :basic
38
+
39
+ rule %r/(:)(\w\w*)/ do
40
+ groups Punctuation, Keyword::Type
41
+ end
42
+
43
+ rule %r/\w[\w']*/ do |m|
44
+ name = m[0]
45
+ if name == "module"
46
+ token Keyword::Reserved
47
+ push :module
48
+ elsif self.class.reserved.include? name
49
+ token Keyword::Reserved
50
+ elsif name =~ /\A[A-Z]/
51
+ token Keyword::Namespace
52
+ else
53
+ token Name
54
+ end
55
+ end
56
+
57
+ rule %r/"/, Str, :string
58
+ rule %r/\//, Str, :regexp
59
+
60
+ rule %r([-*+.=?\|]+), Operator
61
+ rule %r/[\[\](){}:;]/, Punctuation
62
+ end
63
+
64
+ state :module do
65
+ rule %r/\s+/, Text
66
+ rule %r/[A-Z][a-zA-Z0-9_.]*/, Name::Namespace, :pop!
67
+ end
68
+
69
+ state :regexp do
70
+ rule %r/\//, Str::Regex, :pop!
71
+ rule %r/[^\\\/]+/, Str::Regex
72
+ rule %r/\\[\\\/]/, Str::Regex
73
+ rule %r/\\/, Str::Regex
74
+ end
75
+
76
+ state :string do
77
+ rule %r/"/, Str, :pop!
78
+ rule %r/\\/, Str::Escape, :escape
79
+ rule %r/[^\\"]+/, Str
80
+ end
81
+
82
+ state :escape do
83
+ rule %r/[abfnrtv"'&\\]/, Str::Escape, :pop!
84
+ rule %r/\^[\]\[A-Z@\^_]/, Str::Escape, :pop!
85
+ rule %r/o[0-7]+/i, Str::Escape, :pop!
86
+ rule %r/x[\da-f]+/i, Str::Escape, :pop!
87
+ rule %r/\d+/, Str::Escape, :pop!
88
+ rule %r/\s+/, Str::Escape, :pop!
89
+ rule %r/./, Str, :pop!
90
+ end
91
+ end
92
+ end
93
+ end
@@ -0,0 +1,115 @@
1
+ # -*- coding: utf-8 -*- #
2
+ # frozen_string_literal: true
3
+
4
+ # Regular expressions based on https://github.com/SaswatPadhi/prismjs-bibtex
5
+ # and https://github.com/alecthomas/chroma/blob/master/lexers/b/bibtex.go
6
+
7
+ module Rouge
8
+ module Lexers
9
+ class BibTeX < RegexLexer
10
+ title 'BibTeX'
11
+ desc "BibTeX"
12
+ tag 'bibtex'
13
+ aliases 'bib'
14
+ filenames '*.bib'
15
+
16
+ valid_punctuation = Regexp.quote("@!$&.\\:;<>?[]^`|~*/+-")
17
+ valid_name = /[a-z_#{valid_punctuation}][\w#{valid_punctuation}]*/io
18
+
19
+ state :root do
20
+ mixin :whitespace
21
+
22
+ rule %r/@(#{valid_name})/o do |m|
23
+ match = m[1].downcase
24
+
25
+ if match == "comment"
26
+ token Comment
27
+ elsif match == "preamble"
28
+ token Name::Class
29
+ push :closing_brace
30
+ push :value
31
+ push :opening_brace
32
+ elsif match == "string"
33
+ token Name::Class
34
+ push :closing_brace
35
+ push :field
36
+ push :opening_brace
37
+ else
38
+ token Name::Class
39
+ push :closing_brace
40
+ push :command_body
41
+ push :opening_brace
42
+ end
43
+ end
44
+
45
+ rule %r/.+/, Comment
46
+ end
47
+
48
+ state :opening_brace do
49
+ mixin :whitespace
50
+ rule %r/[{(]/, Punctuation, :pop!
51
+ end
52
+
53
+ state :closing_brace do
54
+ mixin :whitespace
55
+ rule %r/[})]/, Punctuation, :pop!
56
+ end
57
+
58
+ state :command_body do
59
+ mixin :whitespace
60
+ rule %r/[^\s\,\}]+/ do
61
+ token Name::Label
62
+ pop!
63
+ push :fields
64
+ end
65
+ end
66
+
67
+ state :fields do
68
+ mixin :whitespace
69
+ rule %r/,/, Punctuation, :field
70
+ rule(//) { pop! }
71
+ end
72
+
73
+ state :field do
74
+ mixin :whitespace
75
+ rule valid_name do
76
+ token Name::Attribute
77
+ push :value
78
+ push :equal_sign
79
+ end
80
+ rule(//) { pop! }
81
+ end
82
+
83
+ state :equal_sign do
84
+ mixin :whitespace
85
+ rule %r/=/, Punctuation, :pop!
86
+ end
87
+
88
+ state :value do
89
+ mixin :whitespace
90
+ rule valid_name, Name::Variable
91
+ rule %r/"/, Literal::String, :quoted_string
92
+ rule %r/\{/, Literal::String, :braced_string
93
+ rule %r/\d+/, Literal::Number
94
+ rule %r/#/, Punctuation
95
+ rule(//) { pop! }
96
+ end
97
+
98
+ state :quoted_string do
99
+ rule %r/\{/, Literal::String, :braced_string
100
+ rule %r/"/, Literal::String, :pop!
101
+ rule %r/[^\{\"]+/, Literal::String
102
+ end
103
+
104
+ state :braced_string do
105
+ rule %r/\{/, Literal::String, :braced_string
106
+ rule %r/\}/, Literal::String, :pop!
107
+ rule %r/[^\{\}]+/, Literal::String
108
+ end
109
+
110
+ state :whitespace do
111
+ rule %r/\s+/, Text
112
+ end
113
+ end
114
+ end
115
+ end
@@ -68,6 +68,7 @@ module Rouge
68
68
  rule %r/#{dq}[lu]*/i, Num::Integer
69
69
  rule %r/\bnullptr\b/, Name::Builtin
70
70
  rule %r/(?:u8|u|U|L)?R"([a-zA-Z0-9_{}\[\]#<>%:;.?*\+\-\/\^&|~!=,"']{,16})\(.*?\)\1"/m, Str
71
+ rule %r/::/, Operator
71
72
  end
72
73
 
73
74
  state :classname do
@@ -84,6 +85,11 @@ module Rouge
84
85
  rule %r/typename\b/, Keyword, :classname
85
86
  mixin :root
86
87
  end
88
+
89
+ state :case do
90
+ rule %r/:(?!:)/, Punctuation, :pop!
91
+ mixin :statements
92
+ end
87
93
  end
88
94
  end
89
95
  end
@@ -14,7 +14,7 @@ module Rouge
14
14
  def self.detect?(text)
15
15
  return true if text.start_with?('Index: ')
16
16
  return true if text =~ %r(\Adiff[^\n]*?\ba/[^\n]*\bb/)
17
- return true if text =~ /(---|[+][+][+]).*?\n(---|[+][+][+])/
17
+ return true if text =~ /---.*?\n[+][+][+]/ || text =~ /[+][+][+].*?\n---/
18
18
  end
19
19
 
20
20
  state :root do
@@ -17,8 +17,8 @@ module Rouge
17
17
  end
18
18
 
19
19
  reserved = %w(
20
- _ case class data default deriving do else if in
21
- infix[lr]? instance let newtype of then type where
20
+ _ case class data default deriving do else if in infix infixl infixr
21
+ instance let newtype of then type where
22
22
  )
23
23
 
24
24
  ascii = %w(
@@ -54,14 +54,31 @@ module Rouge
54
54
  state :root do
55
55
  mixin :basic
56
56
 
57
- rule %r/\bimport\b/, Keyword::Reserved, :import
58
- rule %r/\bmodule\b/, Keyword::Reserved, :module
59
- rule %r/\b(?:#{reserved.join('|')})\b/, Keyword::Reserved
60
- # not sure why, but ^ doesn't work here
61
- # rule %r/^[_a-z][\w']*/, Name::Function
62
- rule %r/[_a-z][\w']*/, Name
63
- rule %r/[A-Z][\w']*/, Keyword::Type
64
- rule %r/'[A-Z]\w+'?/, Keyword::Type # promoted data constructor
57
+ rule %r/'(?=(?:.|\\\S+)')/, Str::Char, :character
58
+ rule %r/"/, Str, :string
59
+
60
+ rule %r/\d+e[+-]?\d+/i, Num::Float
61
+ rule %r/\d+\.\d+(e[+-]?\d+)?/i, Num::Float
62
+ rule %r/0o[0-7]+/i, Num::Oct
63
+ rule %r/0x[\da-f]+/i, Num::Hex
64
+ rule %r/\d+/, Num::Integer
65
+
66
+ rule %r/[\w']+/ do |m|
67
+ match = m[0]
68
+ if match == "import"
69
+ token Keyword::Reserved
70
+ push :import
71
+ elsif match == "module"
72
+ token Keyword::Reserved
73
+ push :module
74
+ elsif reserved.include?(match)
75
+ token Keyword::Reserved
76
+ elsif match =~ /\A'?[A-Z]/
77
+ token Keyword::Type
78
+ else
79
+ token Name
80
+ end
81
+ end
65
82
 
66
83
  # lambda operator
67
84
  rule %r(\\(?![:!#\$\%&*+.\\/<=>?@^\|~-]+)), Name::Function
@@ -72,15 +89,6 @@ module Rouge
72
89
  # other operators
73
90
  rule %r([:!#\$\%&*+.\\/<=>?@^\|~-]+), Operator
74
91
 
75
- rule %r/\d+e[+-]?\d+/i, Num::Float
76
- rule %r/\d+\.\d+(e[+-]?\d+)?/i, Num::Float
77
- rule %r/0o[0-7]+/i, Num::Oct
78
- rule %r/0x[\da-f]+/i, Num::Hex
79
- rule %r/\d+/, Num::Integer
80
-
81
- rule %r/'/, Str::Char, :character
82
- rule %r/"/, Str, :string
83
-
84
92
  rule %r/\[\s*\]/, Keyword::Type
85
93
  rule %r/\(\s*\)/, Name::Builtin
86
94
 
@@ -0,0 +1,166 @@
1
+ # -*- coding: utf-8 -*- #
2
+ # frozen_string_literal: true
3
+
4
+ module Rouge
5
+ module Lexers
6
+ load_lexer 'c.rb'
7
+
8
+ class HLSL < C
9
+ title "HLSL"
10
+ desc "HLSL, the High Level Shading Language for DirectX (docs.microsoft.com/en-us/windows/win32/direct3dhlsl/dx-graphics-hlsl)"
11
+ tag 'hlsl'
12
+ filenames '*.hlsl', '*.hlsli'
13
+ mimetypes 'text/x-hlsl'
14
+
15
+ def self.keywords
16
+ @keywords ||= Set.new %w(
17
+ asm asm_fragment break case cbuffer centroid class column_major
18
+ compile compile_fragment const continue default discard do else export
19
+ extern for fxgroup globallycoherent groupshared if in inline inout
20
+ interface line lineadj linear namespace nointerpolation noperspective
21
+ NULL out packoffset pass pixelfragment point precise return register
22
+ row_major sample sampler shared stateblock stateblock_state static
23
+ struct switch tbuffer technique technique10 technique11 texture
24
+ typedef triangle uniform vertexfragment volatile while
25
+ )
26
+ end
27
+
28
+ def self.keywords_type
29
+ @keywords_type ||= Set.new %w(
30
+ dword matrix snorm string unorm unsigned void vector BlendState Buffer
31
+ ByteAddressBuffer ComputeShader DepthStencilState DepthStencilView
32
+ DomainShader GeometryShader HullShader InputPatch LineStream
33
+ OutputPatch PixelShader PointStream RasterizerState RenderTargetView
34
+ RasterizerOrderedBuffer RasterizerOrderedByteAddressBuffer
35
+ RasterizerOrderedStructuredBuffer RasterizerOrderedTexture1D
36
+ RasterizerOrderedTexture1DArray RasterizerOrderedTexture2D
37
+ RasterizerOrderedTexture2DArray RasterizerOrderedTexture3D RWBuffer
38
+ RWByteAddressBuffer RWStructuredBuffer RWTexture1D RWTexture1DArray
39
+ RWTexture2D RWTexture2DArray RWTexture3D SamplerState
40
+ SamplerComparisonState StructuredBuffer Texture1D Texture1DArray
41
+ Texture2D Texture2DArray Texture2DMS Texture2DMSArray Texture3D
42
+ TextureCube TextureCubeArray TriangleStream VertexShader
43
+
44
+ bool1 bool2 bool3 bool4 BOOL1 BOOL2 BOOL3 BOOL4
45
+ int1 int2 int3 int4
46
+ half1 half2 half3 half4
47
+ float1 float2 float3 float4
48
+ double1 double2 double3 double4
49
+
50
+ bool1x1 bool1x2 bool1x3 bool1x4 bool2x1 bool2x2 bool2x3 bool2x4
51
+ bool3x1 bool3x2 bool3x3 bool3x4 bool4x1 bool4x2 bool4x3 bool4x4
52
+ BOOL1x1 BOOL1x2 BOOL1x3 BOOL1x4 BOOL2x1 BOOL2x2 BOOL2x3 BOOL2x4
53
+ BOOL3x1 BOOL3x2 BOOL3x3 BOOL3x4 BOOL4x1 BOOL4x2 BOOL4x3 BOOL4x4
54
+ half1x1 half1x2 half1x3 half1x4 half2x1 half2x2 half2x3 half2x4
55
+ half3x1 half3x2 half3x3 half3x4 half4x1 half4x2 half4x3 half4x4
56
+ int1x1 int1x2 int1x3 int1x4 int2x1 int2x2 int2x3 int2x4
57
+ int3x1 int3x2 int3x3 int3x4 int4x1 int4x2 int4x3 int4x4
58
+ float1x1 float1x2 float1x3 float1x4 float2x1 float2x2 float2x3 float2x4
59
+ float3x1 float3x2 float3x3 float3x4 float4x1 float4x2 float4x3 float4x4
60
+ double1x1 double1x2 double1x3 double1x4 double2x1 double2x2 double2x3 double2x4
61
+ double3x1 double3x2 double3x3 double3x4 double4x1 double4x2 double4x3 double4x4
62
+ )
63
+ end
64
+
65
+ def self.reserved
66
+ @reserved ||= Set.new %w(
67
+ auto catch char const_cast delete dynamic_cast enum explicit friend
68
+ goto long mutable new operator private protected public
69
+ reinterpret_cast short signed sizeof static_cast template this throw
70
+ try typename union unsigned using virtual
71
+ )
72
+ end
73
+
74
+ def self.builtins
75
+ @builtins ||= Set.new %w(
76
+ abort abs acos all AllMemoryBarrier AllMemoryBarrierWithGroupSync any
77
+ AppendStructuredBuffer asdouble asfloat asin asint asuint asuint atan
78
+ atan2 ceil CheckAccessFullyMapped clamp clip CompileShader
79
+ ConsumeStructuredBuffer cos cosh countbits cross D3DCOLORtoUBYTE4 ddx
80
+ ddx_coarse ddx_fine ddy ddy_coarse ddy_fine degrees determinant
81
+ DeviceMemoryBarrier DeviceMemoryBarrierWithGroupSync distance dot dst
82
+ errorf EvaluateAttributeAtCentroid EvaluateAttributeAtSample
83
+ EvaluateAttributeSnapped exp exp2 f16tof32 f32tof16 faceforward
84
+ firstbithigh firstbitlow floor fma fmod frac frexp fwidth
85
+ GetRenderTargetSampleCount GetRenderTargetSamplePosition
86
+ GlobalOrderedCountIncrement GroupMemoryBarrier
87
+ GroupMemoryBarrierWithGroupSync InterlockedAdd InterlockedAnd
88
+ InterlockedCompareExchange InterlockedCompareStore InterlockedExchange
89
+ InterlockedMax InterlockedMin InterlockedOr InterlockedXor isfinite
90
+ isinf isnan ldexp length lerp lit log log10 log2 mad max min modf
91
+ msad4 mul noise normalize pow printf Process2DQuadTessFactorsAvg
92
+ Process2DQuadTessFactorsMax Process2DQuadTessFactorsMin
93
+ ProcessIsolineTessFactors ProcessQuadTessFactorsAvg
94
+ ProcessQuadTessFactorsMax ProcessQuadTessFactorsMin
95
+ ProcessTriTessFactorsAvg ProcessTriTessFactorsMax
96
+ ProcessTriTessFactorsMin QuadReadLaneAt QuadSwapX QuadSwapY radians
97
+ rcp reflect refract reversebits round rsqrt saturate sign sin sincos
98
+ sinh smoothstep sqrt step tan tanh tex1D tex1D tex1Dbias tex1Dgrad
99
+ tex1Dlod tex1Dproj tex2D tex2D tex2Dbias tex2Dgrad tex2Dlod tex2Dproj
100
+ tex3D tex3D tex3Dbias tex3Dgrad tex3Dlod tex3Dproj texCUBE texCUBE
101
+ texCUBEbias texCUBEgrad texCUBElod texCUBEproj transpose trunc
102
+ WaveAllBitAnd WaveAllMax WaveAllMin WaveAllBitOr WaveAllBitXor
103
+ WaveAllEqual WaveAllProduct WaveAllSum WaveAllTrue WaveAnyTrue
104
+ WaveBallot WaveGetLaneCount WaveGetLaneIndex WaveGetOrderedIndex
105
+ WaveIsHelperLane WaveOnce WavePrefixProduct WavePrefixSum
106
+ WaveReadFirstLane WaveReadLaneAt
107
+
108
+ SV_CLIPDISTANCE SV_CLIPDISTANCE0 SV_CLIPDISTANCE1 SV_CULLDISTANCE
109
+ SV_CULLDISTANCE0 SV_CULLDISTANCE1 SV_COVERAGE SV_DEPTH
110
+ SV_DEPTHGREATEREQUAL SV_DEPTHLESSEQUAL SV_DISPATCHTHREADID
111
+ SV_DOMAINLOCATION SV_GROUPID SV_GROUPINDEX SV_GROUPTHREADID
112
+ SV_GSINSTANCEID SV_INNERCOVERAGE SV_INSIDETESSFACTOR SV_INSTANCEID
113
+ SV_ISFRONTFACE SV_OUTPUTCONTROLPOINTID SV_POSITION SV_PRIMITIVEID
114
+ SV_RENDERTARGETARRAYINDEX SV_SAMPLEINDEX SV_STENCILREF SV_TESSFACTOR
115
+ SV_VERTEXID SV_VIEWPORTARRAYINDEX
116
+
117
+ allow_uav_condition branch call domain earlydepthstencil fastopt
118
+ flatten forcecase instance loop maxtessfactor numthreads
119
+ outputcontrolpoints outputtopology partitioning patchconstantfunc
120
+ unroll
121
+
122
+ BINORMAL BINORMAL0 BINORMAL1 BINORMAL2 BINORMAL3 BINORMAL4
123
+ BLENDINDICES0 BLENDINDICES1 BLENDINDICES2 BLENDINDICES3 BLENDINDICES4
124
+ BLENDWEIGHT0 BLENDWEIGHT1 BLENDWEIGHT2 BLENDWEIGHT3 BLENDWEIGHT4 COLOR
125
+ COLOR0 COLOR1 COLOR2 COLOR3 COLOR4 NORMAL NORMAL0 NORMAL1 NORMAL2
126
+ NORMAL3 NORMAL4 POSITION POSITION0 POSITION1 POSITION2 POSITION3
127
+ POSITION4 POSITIONT PSIZE0 PSIZE1 PSIZE2 PSIZE3 PSIZE4 TANGENT
128
+ TANGENT0 TANGENT1 TANGENT2 TANGENT3 TANGENT4 TESSFACTOR0 TESSFACTOR1
129
+ TESSFACTOR2 TESSFACTOR3 TESSFACTOR4 TEXCOORD0 TEXCOORD1 TEXCOORD2
130
+ TEXCOORD3 TEXCOORD4
131
+
132
+ FOG PSIZE
133
+
134
+ VFACE VPOS
135
+
136
+ DEPTH0 DEPTH1 DEPTH2 DEPTH3 DEPTH4
137
+ )
138
+ end
139
+
140
+ ws = %r((?:\s|//.*?\n|/[*].*?[*]/)+)
141
+ id = /[a-zA-Z_][a-zA-Z0-9_]*/
142
+
143
+ state :root do
144
+ mixin :expr_whitespace
145
+ rule %r(
146
+ ([\w*\s]+?[\s*]) # return arguments
147
+ (#{id}) # function name
148
+ (\s*\([^;]*?\)(?:\s*:\s+#{id})?) # signature
149
+ (#{ws}?)({|;) # open brace or semicolon
150
+ )mx do |m|
151
+ # This is copied from the C lexer
152
+ recurse m[1]
153
+ token Name::Function, m[2]
154
+ recurse m[3]
155
+ recurse m[4]
156
+ token Punctuation, m[5]
157
+ if m[5] == ?{
158
+ push :function
159
+ end
160
+ end
161
+ rule %r/\{/, Punctuation, :function
162
+ mixin :statements
163
+ end
164
+ end
165
+ end
166
+ end