|
| 1 | +local L = {} |
| 2 | + |
| 3 | +-- GLSL (OpenGL / Vulkan dialect), as used by Godot compute shaders |
| 4 | +-- (RDShaderFile, with #[compute] section markers) and glslang's stage |
| 5 | +-- extensions. Layout qualifiers that are also common variable names |
| 6 | +-- (offset, index, set, location, component, align) are left out so they |
| 7 | +-- never highlight user identifiers. |
| 8 | +L.lexer = "cpp" |
| 9 | + |
| 10 | +L.singleLineComment = "// " |
| 11 | + |
| 12 | +L.tabSize = 4 |
| 13 | + |
| 14 | +L.first_line = { |
| 15 | + "^#version%s+%d+", |
| 16 | + "^#%[compute%]", |
| 17 | +} |
| 18 | + |
| 19 | +L.extensions = { |
| 20 | + "glsl", |
| 21 | + "vert", |
| 22 | + "frag", |
| 23 | + "geom", |
| 24 | + "comp", |
| 25 | + "tesc", |
| 26 | + "tese", |
| 27 | +} |
| 28 | + |
| 29 | +L.properties = { |
| 30 | + ["fold.cpp.comment.explicit"] = "0", |
| 31 | + ["lexer.cpp.track.preprocessor"] = "0", |
| 32 | +} |
| 33 | + |
| 34 | +L.keywords = { |
| 35 | + -- Declarations, qualifiers, flow control. |
| 36 | + [0] = "attribute break buffer case centroid coherent const continue default discard do else false flat for highp if in inout invariant layout lowp mediump noperspective out patch precise precision readonly restrict return sample shared smooth struct subroutine switch true uniform varying volatile while writeonly", |
| 37 | + -- Data types. |
| 38 | + [1] = "atomic_uint bool bvec2 bvec3 bvec4 double dmat2 dmat2x2 dmat2x3 dmat2x4 dmat3 dmat3x2 dmat3x3 dmat3x4 dmat4 dmat4x2 dmat4x3 dmat4x4 dvec2 dvec3 dvec4 float int ivec2 ivec3 ivec4 mat2 mat2x2 mat2x3 mat2x4 mat3 mat3x2 mat3x3 mat3x4 mat4 mat4x2 mat4x3 mat4x4 uint uvec2 uvec3 uvec4 vec2 vec3 vec4 void " .. |
| 39 | + "sampler sampler1D sampler1DArray sampler1DArrayShadow sampler1DShadow sampler2D sampler2DArray sampler2DArrayShadow sampler2DMS sampler2DMSArray sampler2DRect sampler2DRectShadow sampler2DShadow sampler3D samplerBuffer samplerCube samplerCubeArray samplerCubeArrayShadow samplerCubeShadow samplerShadow " .. |
| 40 | + "isampler1D isampler1DArray isampler2D isampler2DArray isampler2DMS isampler2DMSArray isampler2DRect isampler3D isamplerBuffer isamplerCube isamplerCubeArray usampler1D usampler1DArray usampler2D usampler2DArray usampler2DMS usampler2DMSArray usampler2DRect usampler3D usamplerBuffer usamplerCube usamplerCubeArray " .. |
| 41 | + "image1D image1DArray image2D image2DArray image2DMS image2DMSArray image2DRect image3D imageBuffer imageCube imageCubeArray iimage1D iimage1DArray iimage2D iimage2DArray iimage2DMS iimage2DMSArray iimage2DRect iimage3D iimageBuffer iimageCube iimageCubeArray uimage1D uimage1DArray uimage2D uimage2DArray uimage2DMS uimage2DMSArray uimage2DRect uimage3D uimageBuffer uimageCube uimageCubeArray " .. |
| 42 | + "texture1D texture1DArray texture2D texture2DArray texture2DMS texture2DMSArray texture3D textureBuffer textureCube textureCubeArray subpassInput subpassInputMS isubpassInput isubpassInputMS usubpassInput usubpassInputMS", |
| 43 | + -- Built-in functions and variables, layout qualifiers, image formats. |
| 44 | + [3] = "EmitStreamVertex EmitVertex EndPrimitive EndStreamPrimitive abs acos acosh all any asin asinh atan atanh atomicAdd atomicAnd atomicCompSwap atomicCounter atomicCounterDecrement atomicCounterIncrement atomicExchange atomicMax atomicMin atomicOr atomicXor barrier bitCount bitfieldExtract bitfieldInsert bitfieldReverse ceil clamp cos cosh cross dFdx dFdxCoarse dFdxFine dFdy dFdyCoarse dFdyFine degrees determinant distance dot equal exp exp2 faceforward findLSB findMSB floatBitsToInt floatBitsToUint floor fma fract frexp fwidth fwidthCoarse fwidthFine greaterThan greaterThanEqual groupMemoryBarrier imageAtomicAdd imageAtomicAnd imageAtomicCompSwap imageAtomicExchange imageAtomicMax imageAtomicMin imageAtomicOr imageAtomicXor imageLoad imageSamples imageSize imageStore imulExtended intBitsToFloat interpolateAtCentroid interpolateAtOffset interpolateAtSample inverse inversesqrt isinf isnan ldexp length lessThan lessThanEqual log log2 matrixCompMult max memoryBarrier memoryBarrierAtomicCounter memoryBarrierBuffer memoryBarrierImage memoryBarrierShared min mix mod modf normalize not notEqual outerProduct packDouble2x32 packHalf2x16 packSnorm2x16 packSnorm4x8 packUnorm2x16 packUnorm4x8 pow radians reflect refract round roundEven sign sin sinh smoothstep sqrt step subpassLoad tan tanh texelFetch texelFetchOffset texture textureGather textureGatherOffset textureGatherOffsets textureGrad textureGradOffset textureLod textureLodOffset textureOffset textureProj textureProjGrad textureProjGradOffset textureProjLod textureProjLodOffset textureProjOffset textureQueryLevels textureQueryLod textureSamples textureSize transpose trunc uaddCarry uintBitsToFloat umulExtended unpackDouble2x32 unpackHalf2x16 unpackSnorm2x16 unpackSnorm4x8 unpackUnorm2x16 unpackUnorm4x8 usubBorrow " .. |
| 45 | + "gl_BaseInstance gl_BaseVertex gl_ClipDistance gl_CullDistance gl_DrawID gl_FragColor gl_FragCoord gl_FragData gl_FragDepth gl_FrontFacing gl_GlobalInvocationID gl_HelperInvocation gl_InstanceID gl_InstanceIndex gl_InvocationID gl_Layer gl_LocalInvocationID gl_LocalInvocationIndex gl_NumSubgroups gl_NumWorkGroups gl_PatchVerticesIn gl_PerVertex gl_PointCoord gl_PointSize gl_Position gl_PrimitiveID gl_PrimitiveIDIn gl_SampleID gl_SampleMask gl_SampleMaskIn gl_SamplePosition gl_SubgroupID gl_SubgroupInvocationID gl_SubgroupSize gl_TessCoord gl_TessLevelInner gl_TessLevelOuter gl_VertexID gl_VertexIndex gl_ViewIndex gl_ViewportIndex gl_WorkGroupID gl_WorkGroupSize gl_in gl_out " .. |
| 46 | + "binding column_major constant_id early_fragment_tests equal_spacing fractional_even_spacing fractional_odd_spacing input_attachment_index isolines line_strip lines_adjacency local_size_x local_size_x_id local_size_y local_size_y_id local_size_z local_size_z_id max_vertices origin_upper_left pixel_center_integer point_mode push_constant row_major std140 std430 triangle_strip triangles_adjacency " .. |
| 47 | + "r11f_g11f_b10f r16 r16_snorm r16f r16i r16ui r32f r32i r32ui r8 r8_snorm r8i r8ui rg16 rg16_snorm rg16f rg16i rg16ui rg32f rg32i rg32ui rg8 rg8_snorm rg8i rg8ui rgb10_a2 rgb10_a2ui rgba16 rgba16_snorm rgba16f rgba16i rgba16ui rgba32f rgba32i rgba32ui rgba8 rgba8_snorm rgba8i rgba8ui", |
| 48 | + [5] = "FIXME TODO XXX HACK NOTE", |
| 49 | +} |
| 50 | + |
| 51 | +L.styles = { |
| 52 | + ["PREPROCESSOR"] = { |
| 53 | + id = 9, |
| 54 | + fgColor = rgb(0x804000), |
| 55 | + bgColor = rgb(0xFFFFFF), |
| 56 | + }, |
| 57 | + ["DEFAULT"] = { |
| 58 | + id = 11, |
| 59 | + fgColor = rgb(0x000000), |
| 60 | + bgColor = rgb(0xFFFFFF), |
| 61 | + }, |
| 62 | + ["INSTRUCTION WORD"] = { |
| 63 | + id = 5, |
| 64 | + fgColor = rgb(0x0000FF), |
| 65 | + bgColor = rgb(0xFFFFFF), |
| 66 | + fontStyle = 1, |
| 67 | + }, |
| 68 | + ["TYPE WORD"] = { |
| 69 | + id = 16, |
| 70 | + fgColor = rgb(0x8000FF), |
| 71 | + bgColor = rgb(0xFFFFFF), |
| 72 | + }, |
| 73 | + ["BUILTINS"] = { |
| 74 | + id = 19, |
| 75 | + fgColor = rgb(0x880088), |
| 76 | + bgColor = rgb(0xFFFFFF), |
| 77 | + fontStyle = 1, |
| 78 | + }, |
| 79 | + ["NUMBER"] = { |
| 80 | + id = 4, |
| 81 | + fgColor = rgb(0xFF8000), |
| 82 | + bgColor = rgb(0xFFFFFF), |
| 83 | + }, |
| 84 | + ["STRING"] = { |
| 85 | + id = 6, |
| 86 | + fgColor = rgb(0x808080), |
| 87 | + bgColor = rgb(0xFFFFFF), |
| 88 | + }, |
| 89 | + ["CHARACTER"] = { |
| 90 | + id = 7, |
| 91 | + fgColor = rgb(0x808080), |
| 92 | + bgColor = rgb(0xFFFFFF), |
| 93 | + }, |
| 94 | + ["OPERATOR"] = { |
| 95 | + id = 10, |
| 96 | + fgColor = rgb(0x000080), |
| 97 | + bgColor = rgb(0xFFFFFF), |
| 98 | + fontStyle = 1, |
| 99 | + }, |
| 100 | + ["COMMENT"] = { |
| 101 | + id = 1, |
| 102 | + fgColor = rgb(0x008000), |
| 103 | + bgColor = rgb(0xFFFFFF), |
| 104 | + }, |
| 105 | + ["COMMENT LINE"] = { |
| 106 | + id = 2, |
| 107 | + fgColor = rgb(0x008000), |
| 108 | + bgColor = rgb(0xFFFFFF), |
| 109 | + }, |
| 110 | + ["COMMENT DOC"] = { |
| 111 | + id = 3, |
| 112 | + fgColor = rgb(0x008080), |
| 113 | + bgColor = rgb(0xFFFFFF), |
| 114 | + }, |
| 115 | + ["COMMENT LINE DOC"] = { |
| 116 | + id = 15, |
| 117 | + fgColor = rgb(0x008080), |
| 118 | + bgColor = rgb(0xFFFFFF), |
| 119 | + }, |
| 120 | + ["PREPROCESSOR COMMENT"] = { |
| 121 | + id = 23, |
| 122 | + fgColor = rgb(0x008000), |
| 123 | + bgColor = rgb(0xFFFFFF), |
| 124 | + }, |
| 125 | + ["PREPROCESSOR COMMENT DOC"] = { |
| 126 | + id = 24, |
| 127 | + fgColor = rgb(0x008080), |
| 128 | + bgColor = rgb(0xFFFFFF), |
| 129 | + }, |
| 130 | + ["TASK MARKER"] = { |
| 131 | + id = 26, |
| 132 | + fgColor = rgb(0x008000), |
| 133 | + bgColor = rgb(0xFFFFFF), |
| 134 | + fontStyle = 1, |
| 135 | + }, |
| 136 | +} |
| 137 | +return L |
0 commit comments