Docs GODI Archive
Projects Blog Link DB

Search GODI:


More options
File doc/godi-frontc/html/Cabs.html GODI Package godi-frontc
 
   Cabs.html    cabs.cmi_pretty    Sources  

Module Cabs


module Cabs: sig .. end
Thrown when an unconsistent C abstract syntax is found.

val version : string
exception UnconsistentDef
Thrown when an unconsistent C abstract syntax is found.

type size =
| NO_SIZE (*No size modifier*)
| SHORT (*"short" modifier*)
| LONG (*"long" modifier*)
| LONG_LONG (*GNU "long long" modifier*)
Size of int

type sign =
| NO_SIGN (*No sign modifier*)
| SIGNED (*"signed" modifier*)
| UNSIGNED (*"unsigned" modifier*)
Signess of int and bitfields

type storage =
| NO_STORAGE (*No storage modifier*)
| AUTO (*"auto" modifier*)
| STATIC (*"static" modifier*)
| EXTERN (*"extern" modifier*)
| REGISTER (*"register" modifier*)
Storage of names

type base_type =
| NO_TYPE (*Old K&R declaration without type*)
| VOID (*"void" type*)
| CHAR of sign (*"char" type with sign modifier*)
| INT of size * sign (*"int" type with size and sign modifiers*)
| BITFIELD of sign * expression (*Bitfield with sign modifier and size expression*)
| FLOAT of bool (*"float" type with long (true) modifier*)
| DOUBLE of bool (*"doubl" type with long (true) modifier*)
| PTR of base_type (*Pointer "*" to the given type*)
| ARRAY of base_type * expression (*Array of the given type with the given expression size (may be NOTHING)*)
| STRUCT of string * name_group list (*"struct" of the given name (may be empty) with given fields (may also be empty)*)
| UNION of string * name_group list (*"union" of the given name (may be empty) with given fields (may also be empty)*)
| PROTO of proto (*Prototype of a function*)
| OLD_PROTO of old_proto (*Old-style K&R prototype*)
| NAMED_TYPE of string (*Named type coming from typedef*)
| ENUM of string * enum_item list (*"union" of the given name (may be empty) with given values (may also be empty)*)
| CONST of base_type (*"const" modifier*)
| VOLATILE of base_type (*"volatile" modifier*)
Base type
type name = string * base_type * attributes * expression 
A name in a declaration with identifier, full type, GNU attributes and initialization expression.
type name_group = base_type * storage * name list 
A name group, that is, a simple type following by many name declaration as int v, *p, t[256];.
type single_name = base_type * storage * name 
A single name, as above, but with only one declaration.
type enum_item = string * expression 
Definition of an enumerated value.
type proto = base_type * single_name list * bool 
Prototype of a function with return type, function declaration and variable argument "..." boolean.
type old_proto = base_type * string list * bool 
Old-C K&R function prototype with root type, list of arguments and variable argument "..." boolean.

type definition =
| FUNDEF of single_name * body (*Definition of a function.*)
| OLDFUNDEF of single_name * name_group list * body (*Definition of an old-C K&R style function.*)
| DECDEF of name_group (*Declaration of function or definition of a variable.*)
| TYPEDEF of name_group (*Definition of a typedef.*)
| ONLYTYPEDEF of name_group (*Definition of lonely "struct", "union" or "enum".*)
Definitions found in a C file.
type file = definition list 
A C files is composed of C definitions
type body = definition list * statement 
The body of a function is composed as a list of variable declaration and of a statement.

type statement =
| NOP (*No operation. Useful for empty else-part in condition.*)
| COMPUTATION of expression (*A simple expression, usually an assignment.*)
| BLOCK of body (*A block between braces*)
| SEQUENCE of statement * statement (*Two statement separated by ";"*)
| IF of expression * statement * statement (*"if" statement with or without else-part.*)
| WHILE of expression * statement (*"while" statement.*)
| DOWHILE of expression * statement (*"do ... while" statement*)
| FOR of expression * expression * expression * statement (*"for" statement.*)
| BREAK (*"break" statement.*)
| CONTINUE (*"continue" statement.*)
| RETURN of expression (*"return" statement with an expression or with NOTHING.*)
| SWITCH of expression * statement (*"switch" statement. Cases are put in the sub-statement as labels.*)
| CASE of expression * statement (*"case" statement as a label.*)
| DEFAULT of statement (*"default" statement as a label.*)
| LABEL of string * statement (*"label" statement whose sub-statement follows colon ":".*)
| GOTO of string (*"goto" statement.*)
Statement changes the flow of control.

type binary_operator =
| ADD (*"+" operator.*)
| SUB (*"-" operator.*)
| MUL (*"*" operator.*)
| DIV (*"/" operator.*)
| MOD (*"%" operator.*)
| AND (*"&&" operator.*)
| OR (*"||" operator.*)
| BAND (*"&" operator.*)
| BOR (*"|" operator.*)
| XOR (*"^" operator.*)
| SHL (*"<<" operator.*)
| SHR (*">>" operator.*)
| EQ (*"==" operator.*)
| NE (*"!=" operator.*)
| LT (*"<" operator.*)
| GT (*">" operator.*)
| LE (*"<=" operator.*)
| GE (*">=" operator.*)
| ASSIGN (*"=" operator.*)
| ADD_ASSIGN (*"+=" operator.*)
| SUB_ASSIGN (*"-=" operator.*)
| MUL_ASSIGN (*"*=" operator.*)
| DIV_ASSIGN (*"/=" operator.*)
| MOD_ASSIGN (*"%=" operator.*)
| BAND_ASSIGN (*"&=" operator.*)
| BOR_ASSIGN (*"|=" operator.*)
| XOR_ASSIGN (*"^=" operator.*)
| SHL_ASSIGN (*"<<=" operator.*)
| SHR_ASSIGN (*">>=" operator.*)

type unary_operator =
| MINUS (*"-" operator.*)
| PLUS (*"+" operator.*)
| NOT (*"!" operator.*)
| BNOT (*"~" operator.*)
| MEMOF (*"*" operator.*)
| ADDROF (*"&" operator.*)
| PREINCR (*"++" pre-incrementation.*)
| PREDECR (*"--" pre-decrementation.*)
| POSINCR (*"++" post-incrementation.*)
| POSDECR (*"--" post-decrementation.*)
Unary operators identifiers.

type expression =
| NOTHING (*Null-expression. Useful for return with no value or table declaration without size.*)
| UNARY of unary_operator * expression (*Unary operator use.*)
| BINARY of binary_operator * expression * expression (*Binary operator use.*)
| QUESTION of expression * expression * expression (*"condition ? then-expression : else-expression" operator.*)
| CAST of base_type * expression (*"(type)expresson" type casting.*)
| CALL of expression * expression list (*Function call.*)
| COMMA of expression list (*Sequence of expression separated with ",".*)
| CONSTANT of constant (*Constant value.*)
| VARIABLE of string (*Access to an identifier.*)
| EXPR_SIZEOF of expression (*"sizeof" with expression.*)
| TYPE_SIZEOF of base_type (*"sizeof" with type.*)
| INDEX of expression * expression (*Access to an array item;*)
| MEMBEROF of expression * string (*Indirection through ".".*)
| MEMBEROFPTR of expression * string (*Pointer indirection through "->".*)
| GNU_BODY of body (*GNU braces inside an expression.*)
Expressions.

type constant =
| CONST_INT of string (*Integer constant.*)
| CONST_FLOAT of string (*Float constant.*)
| CONST_CHAR of string (*Character constant with escapes resolved.*)
| CONST_STRING of string (*String constant with escapes resolved.*)
| CONST_COMPOUND of expression list (*Compound values between braces. Only valid for variable initialization.*)
Constant values.
type attributes = attribute list 
GNU special attribute list.

type attribute =
| NO_ATTR (*No attribute "()".*)
| ATTR_LIST of attribute list (*Attribute list between parentheses.*)
| ATTR_ID of string (*Attribute identifier.*)
GNU special attribute.
This web site is published by Informatikbüro Gerd Stolpmann
Powered by Caml