-generic_ctype_full:
- q=ctype_qualif_opt ty=Tchar
- { q (Ast0.wrap(Ast0.BaseType(Ast.CharType,[P.clt2mcode "char" ty]))) }
- | q=ctype_qualif_opt ty=Tshort
- { q (Ast0.wrap(Ast0.BaseType(Ast.ShortType,[P.clt2mcode "short" ty])))}
- | q=ctype_qualif_opt ty=Tint
- { q (Ast0.wrap(Ast0.BaseType(Ast.IntType,[P.clt2mcode "int" ty]))) }
- | t=Tdouble
- { Ast0.wrap(Ast0.BaseType(Ast.DoubleType,[P.clt2mcode "double" t])) }
- | t=Tfloat
- { Ast0.wrap(Ast0.BaseType(Ast.FloatType,[P.clt2mcode "float" t])) }
- | q=ctype_qualif_opt ty=Tlong
- { q (Ast0.wrap(Ast0.BaseType(Ast.LongType,[P.clt2mcode "long" ty]))) }
- | q=ctype_qualif_opt ty=Tlong ty1=Tlong
- { q (Ast0.wrap
- (Ast0.BaseType
- (Ast.LongLongType,
- [P.clt2mcode "long" ty;P.clt2mcode "long" ty1]))) }
- | s=Tenum i=ident
- { Ast0.wrap(Ast0.EnumName(P.clt2mcode "enum" s, i)) }
- | s=struct_or_union i=ident
- { Ast0.wrap(Ast0.StructUnionName(s, Some i)) }
- | s=struct_or_union i=ioption(ident)
- l=TOBrace d=struct_decl_list r=TCBrace
- { (if i = None && !Data.in_iso
- then failwith "structures must be named in the iso file");
- Ast0.wrap(Ast0.StructUnionDef(Ast0.wrap(Ast0.StructUnionName(s, i)),
- P.clt2mcode "{" l,
- d, P.clt2mcode "}" r)) }
- | s=TMetaType l=TOBrace d=struct_decl_list r=TCBrace
- { let (nm,pure,clt) = s in
- let ty =
- Ast0.wrap(Ast0.MetaType(P.clt2mcode nm clt,pure)) in
- Ast0.wrap
- (Ast0.StructUnionDef(ty,P.clt2mcode "{" l,d,P.clt2mcode "}" r)) }
- | r=TRuleName TDot p=TIdent
- { let nm = (r,P.id2name p) in
- (* this is only possible when we are in a metavar decl. Otherwise,
- it will be represented already as a MetaType *)
- let _ = P.check_meta(Ast.MetaTypeDecl(Ast.NONE,nm)) in
- Ast0.wrap(Ast0.MetaType(P.clt2mcode nm (P.id2clt p),
- Ast0.Impure (*will be ignored*))) }
- | p=TTypeId
- { Ast0.wrap(Ast0.TypeName(P.id2mcode p)) }
- | q=ctype_qualif_opt p=TMetaType
- { let (nm,pure,clt) = p in
- q (Ast0.wrap(Ast0.MetaType(P.clt2mcode nm clt,pure))) }
-
-generic_ctype:
- q=ctype_qualif { q None }
- | generic_ctype_full { $1 }
+/* ---------------------------------------------------------------------- */
+
+%inline
+signable_types:
+ ty=Tchar
+ { Ast0.wrap(Ast0.BaseType(Ast.CharType,[P.clt2mcode "char" ty])) }
+| ty=Tshort
+ { Ast0.wrap(Ast0.BaseType(Ast.ShortType,[P.clt2mcode "short" ty])) }
+| ty=Tint
+ { Ast0.wrap(Ast0.BaseType(Ast.IntType,[P.clt2mcode "int" ty])) }
+| p=TMetaType
+ { let (nm,pure,clt) = p in
+ Ast0.wrap(Ast0.MetaType(P.clt2mcode nm clt,pure)) }
+| r=TRuleName TDot p=TIdent
+ { let nm = (r,P.id2name p) in
+ (* this is only possible when we are in a metavar decl. Otherwise,
+ it will be represented already as a MetaType *)
+ let _ = P.check_meta(Ast.MetaTypeDecl(Ast.NONE,nm)) in
+ Ast0.wrap(Ast0.MetaType(P.clt2mcode nm (P.id2clt p),
+ Ast0.Impure (*will be ignored*))) }
+| ty=Tlong
+ { Ast0.wrap(Ast0.BaseType(Ast.LongType,[P.clt2mcode "long" ty])) }
+| ty1=Tlong ty2=Tlong
+ { Ast0.wrap
+ (Ast0.BaseType
+ (Ast.LongLongType,
+ [P.clt2mcode "long" ty1;P.clt2mcode "long" ty2])) }
+
+%inline
+non_signable_types:
+ ty=Tvoid
+ { Ast0.wrap(Ast0.BaseType(Ast.VoidType,[P.clt2mcode "void" ty])) }
+| ty=Tdouble
+ { Ast0.wrap(Ast0.BaseType(Ast.DoubleType,[P.clt2mcode "double" ty])) }
+| ty=Tfloat
+ { Ast0.wrap(Ast0.BaseType(Ast.FloatType,[P.clt2mcode "float" ty])) }
+| ty=Tsize_t
+ { Ast0.wrap(Ast0.BaseType(Ast.SizeType,[P.clt2mcode "size_t" ty])) }
+| ty=Tssize_t
+ { Ast0.wrap(Ast0.BaseType(Ast.SSizeType,[P.clt2mcode "ssize_t" ty])) }
+| ty=Tptrdiff_t
+ { Ast0.wrap(Ast0.BaseType(Ast.PtrDiffType,[P.clt2mcode "ptrdiff_t" ty])) }
+| s=Tenum i=ident
+ { Ast0.wrap(Ast0.EnumName(P.clt2mcode "enum" s, Some i)) }
+| s=Tenum i=ioption(ident) l=TOBrace ids=enum_decl_list r=TCBrace
+ { (if i = None && !Data.in_iso
+ then failwith "enums must be named in the iso file");
+ Ast0.wrap(Ast0.EnumDef(Ast0.wrap(Ast0.EnumName(P.clt2mcode "enum" s, i)),
+ P.clt2mcode "{" l, ids, P.clt2mcode "}" r)) }
+| s=struct_or_union i=ident
+ { Ast0.wrap(Ast0.StructUnionName(s, Some i)) }
+| s=struct_or_union i=ioption(ident)
+ l=TOBrace d=struct_decl_list r=TCBrace
+ { (if i = None && !Data.in_iso
+ then failwith "structures must be named in the iso file");
+ Ast0.wrap(Ast0.StructUnionDef(Ast0.wrap(Ast0.StructUnionName(s, i)),
+ P.clt2mcode "{" l,
+ d, P.clt2mcode "}" r)) }
+| s=TMetaType l=TOBrace d=struct_decl_list r=TCBrace
+ { let (nm,pure,clt) = s in
+ let ty = Ast0.wrap(Ast0.MetaType(P.clt2mcode nm clt,pure)) in
+ Ast0.wrap(Ast0.StructUnionDef(ty,P.clt2mcode "{" l,d,P.clt2mcode "}" r)) }
+| p=TTypeId
+ { Ast0.wrap(Ast0.TypeName(P.id2mcode p)) }
+
+%inline
+all_basic_types:
+ r=Tsigned ty=signable_types
+ { Ast0.wrap(Ast0.Signed(P.clt2mcode Ast.Signed r,Some ty)) }
+| r=Tunsigned ty=signable_types
+ { Ast0.wrap(Ast0.Signed(P.clt2mcode Ast.Unsigned r,Some ty)) }
+| ty=signable_types { ty }
+| ty=non_signable_types { ty }
+
+ctype:
+ cv=ioption(const_vol) ty=all_basic_types m=list(TMul)
+ { P.pointerify (P.make_cv cv ty) m }
+| r=Tsigned
+ { Ast0.wrap(Ast0.Signed(P.clt2mcode Ast.Signed r,None)) }
+| r=Tunsigned
+ { Ast0.wrap(Ast0.Signed(P.clt2mcode Ast.Unsigned r,None)) }
+| lp=TOPar0 t=midzero_list(ctype,ctype) rp=TCPar0
+ { let (mids,code) = t in
+ Ast0.wrap
+ (Ast0.DisjType(P.clt2mcode "(" lp,code,mids, P.clt2mcode ")" rp)) }
+
+/* signed, unsigned alone not allowed */
+typedef_ctype:
+ cv=ioption(const_vol) ty=all_basic_types m=list(TMul)
+ { P.pointerify (P.make_cv cv ty) m }
+| lp=TOPar0 t=midzero_list(ctype,ctype) rp=TCPar0
+ { let (mids,code) = t in
+ Ast0.wrap
+ (Ast0.DisjType(P.clt2mcode "(" lp,code,mids, P.clt2mcode ")" rp)) }
+
+/* ---------------------------------------------------------------------- */