Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parse error on array of arrays #455

Open
therontarigo opened this issue Sep 12, 2024 · 1 comment
Open

Parse error on array of arrays #455

therontarigo opened this issue Sep 12, 2024 · 1 comment

Comments

@therontarigo
Copy link
Contributor

therontarigo commented Sep 12, 2024

Input:

#version 450
float arr[5][5];
Parse error: Error in arrayarray.glsl: Ln: 2 Col: 10
float arr[5][5];
         ^
Expecting: '('
@therontarigo
Copy link
Contributor Author

therontarigo commented Sep 12, 2024

Workaround:

#version 450
float[5][5] arr;

...where upon I discover a further bug that unsized arrays fail to parse in this syntax.

Type specification array syntax: array of array parses per many (between (ch '[') (ch ']') expr)

let specifiedTypeGLSL =
let typeSpec = (structSpecifier |>> Ast.TypeBlock) <|> (ident |>> (fun id -> Ast.TypeName id.Name))
let arraySizes = many (between (ch '[') (ch ']') expr)
pipe3 glslQualifier typeSpec arraySizes (fun tyQ name sizes -> Ast.makeType name tyQ sizes)

C array declaration syntax: array of array does not parse per opt bracket

// eg. "int foo[] = exp, bar = 3"
do declRef.Value <- (
let bracket = between (ch '[') (ch ']') (opt expr) |>> (fun size -> defaultArg size (Ast.Int (0, "")))
let init = ch '=' >>. exprNoComma
let var = pipe4 ident (opt bracket) semantics (opt init) Ast.makeDecl
let list = sepBy1 var (ch ',')
tuple2 specifiedType list
)

It is apparently not only a parser deficiency but also a limitation of the AST, where currently any "decl" uses a single option size giving only a choice of singular type or sized array.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant