logo

oasis-root

Compiled tree of Oasis Linux based on own branch at <https://hacktivis.me/git/oasis/> git clone https://anongit.hacktivis.me/git/oasis-root.git

glsl.lua (7936B)


  1. -- Copyright 2006-2024 Mitchell. See LICENSE.
  2. -- GLSL LPeg lexer.
  3. local lexer = lexer
  4. local P, S = lpeg.P, lpeg.S
  5. local lex = lexer.new(..., {inherit = lexer.load('ansi_c')})
  6. -- Word lists.
  7. lex:set_word_list(lexer.KEYWORD, {
  8. 'attribute', 'const', 'uniform', 'varying', 'buffer', 'shared', 'coherent', 'volatile',
  9. 'restrict', 'readonly', 'writeonly', 'layout', 'centroid', 'flat', 'smooth', 'noperspective',
  10. 'patch', 'sample', 'break', 'continue', 'do', 'for', 'while', 'switch', 'case', 'default', 'if',
  11. 'else', 'subroutine', 'in', 'inout', 'out', 'true', 'false', 'invariant', 'precise', 'discard',
  12. 'return', 'lowp', 'mediump', 'highp', 'precision', 'struct', --
  13. -- Reserved.
  14. 'common', 'partition', 'active', 'asm', 'class', 'union', 'enum', 'typedef', 'template', 'this',
  15. 'resource', 'goto', 'inline', 'noinline', 'public', 'static', 'extern', 'external', 'interface',
  16. 'superp', 'input', 'output', 'filter', 'sizeof', 'cast', 'namespace', 'using'
  17. })
  18. lex:set_word_list(lexer.TYPE, {
  19. 'atomic_uint', 'float', 'double', 'int', 'void', 'bool', 'mat2', 'mat3', 'mat4', 'dmat2', 'dmat3',
  20. 'dmat4', 'mat2x2', 'mat2x3', 'mat2x4', 'dmat2x2', 'dmat2x3', 'dmat2x4', 'mat3x2', 'mat3x3',
  21. 'mat3x4', 'dmat3x2', 'dmat3x3', 'dmat3x4', 'mat4x2', 'mat4x3', 'mat4x4', 'dmat4x2', 'dmat4x3',
  22. 'dmat4x4', 'vec2', 'vec3', 'vec4', 'ivec2', 'ivec3', 'ivec4', 'bvec2', 'bvec3', 'bvec4', 'dvec2',
  23. 'dvec3', 'dvec4', 'uint', 'uvec2', 'uvec3', 'uvec4', 'sampler1D', 'sampler2D', 'sampler3D',
  24. 'samplerCube', 'sampler1DShadow', 'sampler2DShadow', 'samplerCubeShadow', 'sampler1DArray',
  25. 'sampler2DArray', 'sampler1DArrayShadow', 'sampler2DArrayShadow', 'isampler1D', 'isampler2D',
  26. 'isampler3D', 'isamplerCube', 'isampler1DArray', 'isampler2DArray', 'usampler1D', 'usampler2D',
  27. 'usampler3D', 'usamplerCube', 'usampler1DArray', 'usampler2DArray', 'sampler2DRect',
  28. 'sampler2DRectShadow', 'isampler2DRect', 'usampler2DRect', 'samplerBuffer', 'isamplerBuffer',
  29. 'usamplerBuffer', 'sampler2DMS', 'isampler2DMS', 'usampler2DMS', 'sampler2DMSArray',
  30. 'isampler2DMSArray', 'usampler2DMSArray', 'samplerCubeArray', 'samplerCubeArrayShadow',
  31. 'isamplerCubeArray', 'usamplerCubeArray', 'image1D', 'iimage1D', 'uimage1D', 'image2D',
  32. 'iimage2D', 'uimage2D', 'image3D', 'iimage3D', 'uimage3D', 'image2DRect', 'iimage2DRect',
  33. 'uimage2DRect', 'imageCube', 'iimageCube', 'uimageCube', 'imageBuffer', 'iimageBuffer',
  34. 'uimageBuffer', 'image1DArray', 'iimage1DArray', 'uimage1DArray', 'image2DArray', 'iimage2DArray',
  35. 'uimage2DArray', 'imageCubeArray', 'iimageCubeArray', 'uimageCubeArray', 'image2DMS',
  36. 'iimage2DMS', 'uimage2DMS', 'image2DMSArray', 'iimage2DMSArray', 'uimage2DMSArray',
  37. -- Reserved.
  38. 'long', 'short', 'half', 'fixed', 'unsigned', 'hvec2', 'hvec3', 'hvec4', 'fvec2', 'fvec3',
  39. 'fvec4', 'sampler3DRect'
  40. })
  41. lex:set_word_list(lexer.FUNCTION_BUILTIN, {
  42. 'radians', 'degrees', 'sin', 'cos', 'tan', 'asin', 'acos', 'atan', 'sinh', 'cosh', 'tanh',
  43. 'asinh', 'acosh', 'atanh', 'pow', 'exp', 'log', 'exp2', 'log2', 'sqrt', 'inversesqrt', 'abs',
  44. 'sign', 'floor', 'trunc', 'round', 'roundEven', 'ceil', 'fract', 'mod', 'modf', 'min', 'max',
  45. 'clamp', 'mix', 'step', 'smoothstep', 'isnan', 'isinf', 'floatBitsToInt', 'floatBitsToUint',
  46. 'intBitsToFloat', 'uintBitsToFloat', 'fma', 'frexp', 'ldexp', 'packUnorm2x16', 'packUnorm4x8',
  47. 'packSnorm4x8', 'unpackUnorm2x16', 'unpackUnorm4x8', 'unpackSnorm4x8', 'packDouble2x32',
  48. 'unpackDouble2x32', 'length', 'distance', 'dot', 'cross', 'normalize', 'ftransform',
  49. 'faceforward', 'reflect', 'refract', 'matrixCompMult', 'outerProduct', 'transpose', 'determinant',
  50. 'inverse', 'lessThan', 'lessThanEqual', 'greaterThan', 'greaterThanEqual', 'equal', 'notEqual',
  51. 'any', 'all', 'not', 'uaddCarry', 'usubBorrow', 'umulExtended', 'imulExtended', 'bitfieldExtract',
  52. 'bitfildInsert', 'bitfieldReverse', 'bitCount', 'findLSB', 'findMSB', 'textureSize',
  53. 'textureQueryLOD', 'texture', 'textureProj', 'textureLod', 'textureOffset', 'texelFetch',
  54. 'texelFetchOffset', 'textureProjOffset', 'textureLodOffset', 'textureProjLod',
  55. 'textureProjLodOffset', 'textureGrad', 'textureGradOffset', 'textureProjGrad',
  56. 'textureProjGradOffset', 'textureGather', 'textureGatherOffset', 'texture1D', 'texture2D',
  57. 'texture3D', 'texture1DProj', 'texture2DProj', 'texture3DProj', 'texture1DLod', 'texture2DLod',
  58. 'texture3DLod', 'texture1DProjLod', 'texture2DProjLod', 'texture3DProjLod', 'textureCube',
  59. 'textureCubeLod', 'shadow1D', 'shadow2D', 'shadow1DProj', 'shadow2DProj', 'shadow1DLod',
  60. 'shadow2DLod', 'shadow1DProjLod', 'shadow2DProjLod', 'dFdx', 'dFdy', 'fwidth',
  61. 'interpolateAtCentroid', 'interpolateAtSample', 'interpolateAtOffset', 'noise1', 'noise2',
  62. 'noise3', 'noise4', 'EmitStreamVertex', 'EndStreamPrimitive', 'EmitVertex', 'EndPrimitive',
  63. 'barrier'
  64. })
  65. lex:set_word_list(lexer.VARIABLE, {
  66. 'gl_VertexID', 'gl_InstanceID', 'gl_Position', 'gl_PointSize', 'gl_ClipDistance',
  67. 'gl_PrimitiveIDIn', 'gl_InvocationID', 'gl_PrimitiveID', 'gl_Layer', 'gl_PatchVerticesIn',
  68. 'gl_TessLevelOuter', 'gl_TessLevelInner', 'gl_TessCoord', 'gl_FragCoord', 'gl_FrontFacing',
  69. 'gl_PointCoord', 'gl_SampleID', 'gl_SamplePosition', 'gl_FragColor', 'gl_FragData',
  70. 'gl_FragDepth', 'gl_SampleMask', 'gl_ClipVertex', 'gl_FrontColor', 'gl_BackColor',
  71. 'gl_FrontSecondaryColor', 'gl_BackSecondaryColor', 'gl_TexCoord', 'gl_FogFragCoord', 'gl_Color',
  72. 'gl_SecondaryColor', 'gl_Normal', 'gl_Vertex', 'gl_MultiTexCoord0', 'gl_MultiTexCoord1',
  73. 'gl_MultiTexCoord2', 'gl_MultiTexCoord3', 'gl_MultiTexCoord4', 'gl_MultiTexCoord5',
  74. 'gl_MultiTexCoord6', 'gl_MultiTexCoord7', 'gl_FogCoord'
  75. })
  76. lex:set_word_list(lexer.CONSTANT_BUILTIN, {
  77. '__LINE__', '__FILE__', '__VERSION__', --
  78. 'gl_MaxVertexAttribs', 'gl_MaxVertexUniformComponents', 'gl_MaxVaryingFloats',
  79. 'gl_MaxVaryingComponents', 'gl_MaxVertexOutputComponents', 'gl_MaxGeometryInputComponents',
  80. 'gl_MaxGeometryOutputComponents', 'gl_MaxFragmentInputComponents',
  81. 'gl_MaxVertexTextureImageUnits', 'gl_MaxCombinedTextureImageUnits', 'gl_MaxTextureImageUnits',
  82. 'gl_MaxFragmentUniformComponents', 'gl_MaxDrawBuffers', 'gl_MaxClipDistances',
  83. 'gl_MaxGeometryTextureImageUnits', 'gl_MaxGeometryOutputVertices',
  84. 'gl_MaxGeometryTotalOutputComponents', 'gl_MaxGeometryUniformComponents',
  85. 'gl_MaxGeometryVaryingComponents', 'gl_MaxTessControlInputComponents',
  86. 'gl_MaxTessControlOutputComponents', 'gl_MaxTessControlTextureImageUnits',
  87. 'gl_MaxTessControlUniformComponents', 'gl_MaxTessControlTotalOutputComponents',
  88. 'gl_MaxTessEvaluationInputComponents', 'gl_MaxTessEvaluationOutputComponents',
  89. 'gl_MaxTessEvaluationTextureImageUnits', 'gl_MaxTessEvaluationUniformComponents',
  90. 'gl_MaxTessPatchComponents', 'gl_MaxPatchVertices', 'gl_MaxTessGenLevel', 'gl_MaxTextureUnits',
  91. 'gl_MaxTextureCoords', 'gl_MaxClipPlanes', --
  92. 'gl_DepthRange', 'gl_ModelViewMatrix', 'gl_ProjectionMatrix', 'gl_ModelViewProjectionMatrix',
  93. 'gl_TextureMatrix', 'gl_NormalMatrix', 'gl_ModelViewMatrixInverse', 'gl_ProjectionMatrixInverse',
  94. 'gl_ModelViewProjectionMatrixInverse', 'gl_TextureMatrixInverse', 'gl_ModelViewMatrixTranspose',
  95. 'gl_ProjectionMatrixTranspose', 'gl_ModelViewProjectionMatrixTranspose',
  96. 'gl_TextureMatrixTranspose', 'gl_ModelViewMatrixInverseTranspose',
  97. 'gl_ProjectionMatrixInverseTranspose', 'gl_ModelViewProjectionMatrixInverseTranspose',
  98. 'gl_TextureMatrixInverseTranspose', 'gl_NormalScale', 'gl_ClipPlane', 'gl_Point',
  99. 'gl_FrontMaterial', 'gl_BackMaterial', 'gl_LightSource', 'gl_LightModel',
  100. 'gl_FrontLightModelProduct', 'gl_BackLightModelProduct', 'gl_FrontLightProduct',
  101. 'gl_BackLightProduct', 'gl_TextureEnvColor', 'gl_EyePlaneS', 'gl_EyePlaneT', 'gl_EyePlaneR',
  102. 'gl_EyePlaneQ', 'gl_ObjectPlaneS', 'gl_ObjectPlaneT', 'gl_ObjectPlaneR', 'gl_ObjectPlaneQ',
  103. 'gl_Fog'
  104. })
  105. lex:set_word_list(lexer.PREPROCESSOR, 'extension version', true)
  106. lexer.property['scintillua.comment'] = '//'
  107. return lex