From e7e020731bcb49bd816c72b29771dbdcb80b0dd6 Mon Sep 17 00:00:00 2001 From: Andy Ray Date: Fri, 27 Sep 2024 21:47:29 -0700 Subject: [PATCH] Addressing typo in some keywords --- package.json | 2 +- src/parser/glsl-grammar.pegjs | 4 ++-- src/parser/parse.test.ts | 12 ++++++++++++ 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index f2e787e..04fa0b2 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "engines": { "node": ">=16" }, - "version": "5.1.1", + "version": "5.2.0", "type": "module", "description": "A GLSL ES 1.0 and 3.0 parser and preprocessor that can preserve whitespace and comments", "scripts": { diff --git a/src/parser/glsl-grammar.pegjs b/src/parser/glsl-grammar.pegjs index fd60e83..af79257 100644 --- a/src/parser/glsl-grammar.pegjs +++ b/src/parser/glsl-grammar.pegjs @@ -155,7 +155,7 @@ SAMPLERCUBESHADOW = token:"samplerCubeShadow" t:terminal { return node('keyword' SAMPLER1DARRAY = token:"sampler1DArray" t:terminal { return node('keyword', { token, whitespace: t }); } SAMPLER2DARRAY = token:"sampler2DArray" t:terminal { return node('keyword', { token, whitespace: t }); } SAMPLER1DARRAYSHADOW = token:"sampler1DArrayShadow" t:terminal { return node('keyword', { token, whitespace: t }); } -SAMPLER2DARRAYSHADOW = token:"sampler2DArrayshadow" t:terminal { return node('keyword', { token, whitespace: t }); } +SAMPLER2DARRAYSHADOW = token:"sampler2DArrayShadow" t:terminal { return node('keyword', { token, whitespace: t }); } ISAMPLER1D = token:"isampler1D" t:terminal { return node('keyword', { token, whitespace: t }); } ISAMPLER2D = token:"isampler2D" t:terminal { return node('keyword', { token, whitespace: t }); } ISAMPLER3D = token:"isampler3D" t:terminal { return node('keyword', { token, whitespace: t }); } @@ -169,7 +169,7 @@ USAMPLERCUBE = token:"usamplerCube" t:terminal { return node('keyword', { token, USAMPLER1DARRAY = token:"usampler1DArray" t:terminal { return node('keyword', { token, whitespace: t }); } USAMPLER2DARRAY = token:"usampler2DArray" t:terminal { return node('keyword', { token, whitespace: t }); } SAMPLER2DRECT = token:"sampler2DRect" t:terminal { return node('keyword', { token, whitespace: t }); } -SAMPLER2DRECTSHADOW = token:"sampler2DRectshadow" t:terminal { return node('keyword', { token, whitespace: t }); } +SAMPLER2DRECTSHADOW = token:"sampler2DRectShadow" t:terminal { return node('keyword', { token, whitespace: t }); } ISAMPLER2DRECT = token:"isampler2DRect" t:terminal { return node('keyword', { token, whitespace: t }); } USAMPLER2DRECT = token:"usampler2DRect" t:terminal { return node('keyword', { token, whitespace: t }); } SAMPLERBUFFER = token:"samplerBuffer" t:terminal { return node('keyword', { token, whitespace: t }); } diff --git a/src/parser/parse.test.ts b/src/parser/parse.test.ts index e088a31..594b168 100644 --- a/src/parser/parse.test.ts +++ b/src/parser/parse.test.ts @@ -428,3 +428,15 @@ test('fails on error', () => { ) ).toThrow(/duplicate variable declaration: "a"/); }); + +test('exotic precision statements', () => { + // Regression to test for upper/loweracse typos in specific keywords + expect( + c.parse(`precision highp sampler2DArrayShadow;`).program[0].declaration + .specifier.specifier.token + ).toBe('sampler2DArrayShadow'); + expect( + c.parse(`precision highp sampler2DRectShadow;`).program[0].declaration + .specifier.specifier.token + ).toBe('sampler2DRectShadow'); +});