commit b473792a33fe86991d6ada1f0686d25ef5aaf388
parent 362a2e62e5310ba21fad74fdabebf8636fe1b9e1
Author: Robert Russell <robert@rr3.xyz>
Date: Sun, 12 Jan 2025 19:13:06 -0800
Sync glsl vis lexers
I had made the same lexer on two different computers.
This commit combines them (basically no change).
Diffstat:
1 file changed, 17 insertions(+), 13 deletions(-)
diff --git a/vis/lexers/glsl.lua b/vis/lexers/glsl.lua
@@ -1,4 +1,6 @@
-local M = {_NAME = "ansi_c"}
+-- TODO: Hack: This is just a copy of the ansi_c lexer with some additions.
+
+local M = {_NAME = "glsl"}
local l = require("lexer")
local P, R, S = lpeg.P, lpeg.R, lpeg.S
@@ -135,9 +137,10 @@ local keyword = T("keyword", l.word_match{
"unreachable",
-- GLSL
- "layout", "in", "out", "inout",
- "uniform", "shared", "buffer",
- "coherent","readonly", "writeonly",
+ "in", "out", "inout", "layout",
+ "uniform", "buffer", "shared",
+ "lowp", "mediump", "highp", "precision",
+ "coherent", "readonly", "writeonly",
})
local constant = T("constant", l.word_match{
@@ -167,16 +170,17 @@ local type_nice = P"__"^-1 * (P"v" * dec^1)^-1 * S"usifc" * dec^1 * (P"a" * dec^
}
local type_rcx = (S"iu" * (P"max" + P"ptr" + P"size") + P"rune" + P"maxalign") * #(any - letter)
local type_glsl = (
- S"biud"^-1 * P"vec" * S"234" +
- S"d"^-1 * P"mat" * S"234" * (P"x" * S"243")^-1 +
- S"iu"^-1 * (P"image" + P"sampler") * (
- P"1D" + P"2D" + P"3D" + P"Cube" + P"2DRect" + P"1DArray" +
- P"2DArray" + P"CubeArray" + P"Buffer" + P"2DMS" + P"2DMSArray"
- ) +
+ S"buid"^-1 * P"vec" * R"24" +
+ S"d"^-1 * P"mat" * R"24" * (P"x" * R"24")^-1 +
+ (S"ui"^-1 * (P"sampler" + P"image") + P"image") * (
+ P"1D" + P"2D" + P"3D" + P"Cube" + P"2DRect" + P"1DArray" +
+ P"2DArray" + P"CubeArray" + P"Buffer" + P"2DMS" + P"2DMSArray"
+ ) +
P"sampler" * (
- P"1D" + P"2D" + P"Cube" + P"2DRect" + P"1DArray" +
- P"2DArray" + P"CubeArray"
- ) * P"Shadow"
+ P"1D" + P"2D" + P"Cube" + P"2DRect" +
+ P"1DArray" + P"2DArray" + P"CubeArray"
+ ) * P"Shadow" +
+ P"atomic_uint"
) * #(any - letter)
local type_ = T("type", type_builtin + type_std + type_stdint + type_nice + type_rcx + type_glsl)