val version : string
FrontC is an OCAML library providing facilities for parsing source file
in C language.
Although it is designed for parsing ANSI C, it provides also support for
old K&R C style and for some GCC extensions.
It provides also a limited degraded mode allowing to parse file although
all type information is not available and preprocessor directives are still
in the source.
type parsing_arg =
| |
FROM_STDIN |
| |
FROM_CHANNEL of Pervasives.in_channel |
| |
FROM_FILE of string |
| |
USE_CPP |
| |
PREPROC of string |
| |
DEF of string |
| |
UNDEF of string |
| |
INCLUDE of string |
| |
INCLUDE_DIR of string |
| |
OPTION of string |
| |
ERROR of Pervasives.out_channel |
| |
INTERACTIVE of bool |
Parameters for building the reader handler.
type parsing_result =
Result of a parsing.
val trans_old_fun_def : Cabs.single_name * Cabs.name_group list * Cabs.body -> Cabs.definition
Transform an old K&R C function definition into a new ANSI one.
Raises UnconsistentDef Raised when an undeclared parameter is found
in the function definition.
Returns New function definition.
def : Old function definition.
val trans_old_fun_defs : Cabs.definition list -> Cabs.definition list
Transform all old function definition into new ones.
Raises UnconsistentDef Raised if some old function definition does not
define the type of a parameter.
Returns Definitions with all old function definitions transformed.
defs : Defs to transform.
val convert_to_xml : Cabs.definition list -> Cxml.document
Convert the given C file abstract repersentation into XML.
Raises UnconsistentDef Raised if the file contains some old function
definition whose one parameter is not defined.
Returns XML document result of conversion.
file : C file to convert.
val parse : parsing_arg list -> parsing_result
val parse_interactive : Pervasives.in_channel -> Pervasives.out_channel -> parsing_result
Parse the input channel in interactive way, that is, as coming from the
console. Error are displayed in a specific way.
Returns Read C definitions.
inp : Input to read the C source from.
out : For outputting errors.
val parse_console : 'a -> parsing_result
Parse the C source from the console. It exactly equals to
"parse_interactive stdin stderr".
Returns Read C definitions.
val parse_channel : Pervasives.in_channel -> Pervasives.out_channel -> parsing_result
Parse the C source from a non-interactive channel. It may be useful when
the source come from a piped channel from the C preprocessor, for example.*
Returns Read C definitions.
input : Input channel to read the source from.
out : Output channel to display errors.
val parse_file : string -> Pervasives.out_channel -> parsing_result
Parse a C source passed as a file path.
Returns Read C definitions.
NOTE: an error during the read of the file returned as a parse failure.
file_name : Path of the file to read.
out : Channel used for displaying errors.