allow array struct fields

This commit is contained in:
Zachary Snow 2019-10-13 23:59:21 -04:00
parent a1cd6941ae
commit 8e8d44f421
1 changed files with 12 additions and 1 deletions

View File

@ -496,7 +496,13 @@ StructItems :: { [(Type, Identifier)] }
: StructItem { $1 }
| StructItems StructItem { $1 ++ $2 }
StructItem :: { [(Type, Identifier)] }
: Type Identifiers ";" { map (\a -> ($1, a)) $2 }
: Type FieldDecls ";" { map (fieldDecl $1) $2 }
FieldDecls :: { [(Identifier, [Range])] }
: FieldDecl { [$1] }
| FieldDecls "," FieldDecl { $1 ++ [$3] }
FieldDecl :: { (Identifier, [Range]) }
: Identifier Dimensions { ($1, $2) }
Packing :: { Packing }
: "packed" OptSigning { Packed $2 }
@ -1321,4 +1327,9 @@ makeParamDecls s t items =
(tf, rs) = typeRanges t
mapper (x, e, a) = Param s (tf $ a ++ rs) x e
fieldDecl :: Type -> (Identifier, [Range]) -> (Type, Identifier)
fieldDecl t (x, rs2) =
(tf $ rs2 ++ rs1, x)
where (tf, rs1) = typeRanges t
}