CrossGL / crosstl

Translates native shader languages into CrossGL universal shader language and vice versa.
https://crossgl.net
Apache License 2.0
35 stars 38 forks source link

Syntax Error during parsing of indexes of a matrix #101

Open adarsh2023calc opened 2 weeks ago

adarsh2023calc commented 2 weeks ago

Hello I am Adarsh,

I am pretty much new to this tool but I humbly request to bare with me if I am wrong and consider my request.

I tried converting a cgl file to directx backend file and there was a syntax error during parsing I encountered a syntax error compiling this snippet of code.

Code snippet [input]

// Apply the 3x3 matrix kernel to the noise function
            for (int i = -1; i <= 1; i++) {
                for (int j = -1; j <= 1; j++) {
                    vec2 offset = vec2(float(i), float(j));
                    noise += kernel[i + 1][j + 1] * perlinNoise(vUV + offset);
                }
            }

Actual Output after error

for (int i = -1; i <= 1; i++) {
                for (int j = -1; j <= 1; j++) {
                    vec2 offset = vec2(float(i), float(j));
                    noise += kernel[[]i + 1][j + 1] * perlinNoise(vUV + offset);
                }
            }

The error is kernel[ [] i+1] [j+1] . Is this an active issue? If so, Can i take up this issue?

Error Message:

File "/home/adarsh2023/crosstl/test.py", line 4, in <module>
    metal_code = crosstl.translate('examples/PerlinNoise.cgl',backend='directx')
  File "/home/adarsh2023/crosstl/crosstl/_crosstl.py", line 19, in translate
    lexer = Lexer(shader_code)
  File "/home/adarsh2023/crosstl/crosstl/src/translator/lexer.py", line 106, in __init__
    self.tokenize()
  File "/home/adarsh2023/crosstl/crosstl/src/translator/lexer.py", line 131, in tokenize
    raise SyntaxError(
SyntaxError: Illegal character '[' at position 941

Request

Please assign this issue (If it is genuine )

Thanks in Advance

samthakur587 commented 2 weeks ago

Hi @adarsh2023calc! 😊

Thanks for bringing this up! You're absolutely right—we haven't added array indexing token support in our CrossTL frontend yet. This is an open task #69 that we're excited for contributors to tackle. Feel free to check out the issue here!

If you're interested in working on this, you're more than welcome to assign the issue to yourself and start contributing! Your small contribution can have a big impact and help strengthen our open-source community. 🚀

Looking forward to your contributions! Let's make this project even better together! 💪

adarsh2023calc commented 2 weeks ago

Thanks for the response I will take up this issue