Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
89 changes: 83 additions & 6 deletions LanguageDefinitions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -534,16 +534,93 @@ const TextEditor::LanguageDefinition& TextEditor::LanguageDefinition::Glsl()
if (!inited)
{
static const char* const keywords[] = {
"auto", "break", "case", "char", "const", "continue", "default", "do", "double", "else", "enum", "extern", "float", "for", "goto", "if", "inline", "int", "long", "register", "restrict", "return", "short",
"signed", "sizeof", "static", "struct", "switch", "typedef", "union", "unsigned", "void", "volatile", "while", "_Alignas", "_Alignof", "_Atomic", "_Bool", "_Complex", "_Generic", "_Imaginary",
"_Noreturn", "_Static_assert", "_Thread_local"
// Types
"bool", "true", "false", "int", "uint", "float", "double",
"bvec2", "bvec3", "bvec4", "ivec2", "ivec3", "ivec4", "uvec2", "uvec3", "uvec4", "vec2", "vec3", "vec4", "dvec2", "dvec3", "dvec4",
"mat2", "mat3", "mat4", "mat2x2", "mat3x2", "mat4x2", "mat2x3", "mat3x3", "mat4x3", "mat2x4", "mat3x4", "mat4x4",
"dmat2", "dmat3", "dmat4", "dmat2x2", "dmat3x2", "dmat4x2", "dmat2x3", "dmat3x3", "dmat4x3", "dmat2x4", "dmat3x4", "dmat4x4",
// Samplers
"sampler1D","isampler1D", "usampler1D",
"sampler2D","isampler2D", "usampler2D",
"sampler3D","isampler3D", "usampler3D",
"samplerCube","isamplerCube", "usamplerCube",
"sampler2DRect","isampler2DRect", "usampler2DRect",
"sampler1DArray","isampler1DArray", "usampler1DArray",
"sampler2DArray","isampler2DArray", "usampler2DArray",
"samplerCubeArray","isamplerCubeArray", "usamplerCubeArray",
"samplerBuffer","isamplerBuffer", "usamplerBuffer",
"sampler2DMS","isampler2DMS", "usampler2DMS",
"sampler2DMSArray","isampler2DMSArray", "usampler2DMSArray",
"sampler1DShadow", "sampler2DShadow", "samplerCubeShadow", "sampler2DRectShadow", "sampler1DArrayShadow", "sampler2DArrayShadow", "samplerCubeArrayShadow",
// Images
"image1D", "iimage1D", "uimage1D",
"image2D", "iimage2D", "uimage2D",
"image3D", "iimage3D", "uimage3D",
"imageCube", "iimageCube", "uimageCube",
"image2DRect", "iimage2DRect", "uimage2DRect",
"image1DArray", "iimage1DArray", "uimage1DArray",
"image2DArray", "iimage2DArray", "uimage2DArray",
"imageCubeArray", "iimageCubeArray", "uimageCubeArray",
"imageBuffer", "iimageBuffer", "uimageBuffer",
"image2DMS", "iimage2DMS", "uimage2DMS",
"image2DMSArray", "iimage2DMSArray", "uimage2DMSArray",
// Memory Qualifiers
"coherent", "volatile", "restrict", "readonly", "writeonly",
// Format Qualifiers
"rgba32f", "rgba32ui", "rgba16f", "rgba16ui", "rg32f", "rgb10_a2ui", "rg16f", "rgba8ui", "r11f_g11f_b10f", "rg32ui",
"r32f", "rg16ui", "r16f", "rg8ui", "rgba16", "r32ui", "rgb10_a2", "r16ui", "rgba8", "r8ui", "rg16", "rgba32i", "rg8", "rgba16i",
"r16", "rgba8i", "r8", "rg32i", "rgba16_snorm", "rg16i", "rgba8_snorm", "rg8i", "rg16_snorm", "r32i", "rg8_snorm", "r16i", "r16_snorm", "r8i",
// Interpolation Qualifiers
"flat", "noperspective", "smooth", "centroid", "sample",
// Precision Qualifiers
"highp", "mediump", "lowp",
// Others
"enum", // GLSL doesnt have enum types but still reserves the keyword
"const", "in", "out", "inout", "discard", "shared", "invariant", "precise",
"uniform", "layout", "binding", "const", "break", "case", "continue", "default", "do", "return", "void", "while", "location",
"enum", "extern", "for", "goto", "if",
"sizeof", "static", "struct", "switch", "typedef", "union",
// Deprecated as of GLSL 1.30 (OpenGL 3.0) and removed from GLSL 1.40 and above
"attribute", "varying",
};
for (auto& k : keywords)
langDef.mKeywords.insert(k);

static const char* const identifiers[] = {
"abort", "abs", "acos", "asin", "atan", "atexit", "atof", "atoi", "atol", "ceil", "clock", "cosh", "ctime", "div", "exit", "fabs", "floor", "fmod", "getchar", "getenv", "isalnum", "isalpha", "isdigit", "isgraph",
"ispunct", "isspace", "isupper", "kbhit", "log10", "log2", "log", "memcmp", "modf", "pow", "putchar", "putenv", "puts", "rand", "remove", "rename", "sinh", "sqrt", "srand", "strcat", "strcmp", "strerror", "time", "tolower", "toupper"
// Trigonometry
"acos", "acosh", "asin", "asinh", "atan", "atanh", "cos", "cosh", "degrees", "radians", "sin", "sinh", "tan", "tanh",
// Mathematics
"abs", "ceil", "clamp", "dFdx", "dFdy", "exp", "exp2", "floor", "fma", "fract", "fwidth", "inversesqrt", "isinf", "isnan",
"log", "log2", "max", "min", "mix", "mod", "modf", "noise", "pow", "round", "roundEven", "sign", "smoothstep", "sqrt", "step", "trunc",
// Floating-Point
"floatBitsToInt", "frexp", "intBitsToFloat", "ldexp", "packDouble2x32", "packHalf2x16", "packUnorm", "unpackDouble2x32", "unpackHalf2x16", "unpackUnorm",
// Built-In Variables
"gl_ClipDistance", "gl_CullDistance", "gl_FragCoord", "gl_FragDepth", "gl_FrontFacing", "gl_GlobalInvocationID", "gl_HelperInvocation", "gl_InstanceID",
"gl_InvocationID", "gl_Layer", "gl_LocalInvocationID", "gl_LocalInvocationIndex", "gl_NumSamples", "gl_NumWorkGroups", "gl_PatchVerticesIn", "gl_PointCoord",
"gl_PointSize", "gl_Position", "gl_PrimitiveID", "gl_PrimitiveIDIn", "gl_SampleID", "gl_SampleMask", "gl_SampleMaskIn", "gl_SamplePosition", "gl_TessCoord",
"gl_TessLevelInner", "gl_TessLevelOuter", "gl_VertexID", "gl_ViewportIndex", "gl_WorkGroupID", "gl_WorkGroupSize",
// Vector
"cross", "distance", "dot", "equal", "faceforward", "length", "normalize", "notEqual", "reflect", "refract",
// Component Comparison
"all", "any", "greaterThan", "greaterThanEqual", "lessThan", "lessThanEqual", "not",
// Geometry Shader
"EmitStreamVertex", "EmitVertex", "EndPrimitive", "EndStreamPrimitive",
// Texture Sampling
"interpolateAtCentroid", "interpolateAtOffset", "interpolateAtSample", "texelFetch", "texelFetchOffset", "texture", "textureGather", "textureGatherOffset",
"textureGatherOffsets", "textureGrad", "textureGradOffset", "textureLod", "textureLodOffset", "textureOffset", "textureProj", "textureProjGrad",
"textureProjGradOffset", "textureProjLod", "textureProjLodOffset", "textureProjOffset", "textureQueryLevels", "textureQueryLod", "textureSamples", "textureSize",
// Matrix
"determinant", "groupMemoryBarrier", "inverse", "matrixCompMult", "outerProduct", "transpose",
// Integer
"bitCount", "bitfieldExtract", "bitfieldInsert", "bitfieldReverse", "findLSB", "findMSB", "uaddCarry", "umulExtended", "usubBorrow",
// Image
"imageAtomicAdd", "imageAtomicAnd", "imageAtomicCompSwap", "imageAtomicExchange", "imageAtomicMax", "imageAtomicMin", "imageAtomicOr", "imageAtomicXor",
"imageLoad", "imageSamples", "imageSize", "imageStore",
// Atomic
"atomicAdd", "atomicAnd", "atomicCompSwap", "atomicCounter", "atomicCounterDecrement", "atomicCounterIncrement", "atomicExchange", "atomicMax",
"atomicMin", "atomicOr", "atomicXor",
// Memory Barrier
"barrier", "groupMemoryBarrier", "memoryBarrier", "memoryBarrierAtomicCounter", "memoryBarrierBuffer", "memoryBarrierImage", "memoryBarrierShared",
};
for (auto& k : identifiers)
{
Expand Down Expand Up @@ -934,4 +1011,4 @@ const TextEditor::LanguageDefinition& TextEditor::LanguageDefinition::Json()
inited = true;
}
return langDef;
}
}