diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 7dedf28..9e313e3 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -25,9 +25,9 @@ jobs: uses: actions/checkout@v2 - name: Use OCaml ${{ matrix.ocaml-version }} - uses: avsm/setup-ocaml@v1 + uses: ocaml/setup-ocaml@v2 with: - ocaml-version: ${{ matrix.ocaml-version }} + ocaml-compiler: ${{ matrix.ocaml-version }} - run: opam pin add FrontC . --no-action - run: opam install FrontC --deps-only diff --git a/FrontC.opam b/FrontC.opam index ac2195d..d6dda0a 100644 --- a/FrontC.opam +++ b/FrontC.opam @@ -1,6 +1,6 @@ # This file is generated by dune, edit dune-project instead opam-version: "2.0" -version: "4.0.0" +version: "4.1.0" synopsis: "Parses C programs to an abstract syntax tree" description: "FrontC provides a C parser and an OCaml definition of an abstract syntax treee for the C language. It also includes AST pretty-printers in plain and XML formats." diff --git a/calipso.opam b/calipso.opam index e4742ed..21e18c4 100644 --- a/calipso.opam +++ b/calipso.opam @@ -1,6 +1,6 @@ # This file is generated by dune, edit dune-project instead opam-version: "2.0" -version: "4.0.0" +version: "4.1.0" synopsis: "Rewrites C programs to remove non-structured control-flow" description: "Calipso analyzes programs in order to replace all nonstructured instructions (i.e., break, return, switch...) by branches and, then, remove all branches. See https://dblp.org/rec/journals/tsi/CasseFRS02 for more details" @@ -12,7 +12,7 @@ homepage: "https://github.com/BinaryAnalysisPlatform/FrontC" bug-reports: "https://github.com/BinaryAnalysisPlatform/FrontC/issues" depends: [ "dune" {>= "2.7"} - "FrontC" {>= "4.0.0"} + "FrontC" {>= "4.1.0"} "odoc" {with-doc} ] build: [ diff --git a/calipso/calipso.ml b/calipso/calipso.ml index 64da4eb..c978d04 100644 --- a/calipso/calipso.ml +++ b/calipso/calipso.ml @@ -2,7 +2,7 @@ exception ParsingError (* Useful Data *) -let version = "Calipso V4.0 Hugues Cassé." +let version = "Calipso v4.1 Hugues Cassé." let help = version ^ "\n" ^ "calipso [-hmPtsVv] [-r[bcfgkrs]] [-s[lrw]] [-p preprocessor] [-o ]" exception InternalError diff --git a/calipso/stat.ml b/calipso/stat.ml index ac3e247..810c153 100644 --- a/calipso/stat.ml +++ b/calipso/stat.ml @@ -64,7 +64,7 @@ let display_stats _ = (* Useful Data *) -let version = "stat V4.0 Hugues Cassé et al." +let version = "stat v4.1 Hugues Cassé et al." let help = version ^ "\n" ^ "stat [-hPtVv] [-r[bcfgkrs]] [-p preprocessor] " exception InternalError diff --git a/ctoxml.opam b/ctoxml.opam index 3b1f724..853637a 100644 --- a/ctoxml.opam +++ b/ctoxml.opam @@ -1,6 +1,6 @@ # This file is generated by dune, edit dune-project instead opam-version: "2.0" -version: "4.0.0" +version: "4.1.0" synopsis: "Parses a C program into Cabs AST and dumps as an XML document" maintainer: ["Ivan Gotovchits "] authors: ["Hugues Cassé et al"] @@ -10,7 +10,7 @@ homepage: "https://github.com/BinaryAnalysisPlatform/FrontC" bug-reports: "https://github.com/BinaryAnalysisPlatform/FrontC/issues" depends: [ "dune" {>= "2.7"} - "FrontC" {>= "4.0.0"} + "FrontC" {>= "4.1.0"} "odoc" {with-doc} ] build: [ diff --git a/ctoxml/ctoxml_bin.ml b/ctoxml/ctoxml_bin.ml index 80adf42..909aaec 100644 --- a/ctoxml/ctoxml_bin.ml +++ b/ctoxml/ctoxml_bin.ml @@ -1,4 +1,4 @@ -(* +(* * $Id$ * Copyright (c) 2003, Hugues Cassé * @@ -10,10 +10,10 @@ open Frontc (* Options *) let banner = - "ctoxml V1.0 (02/14/04)\n" ^ - "Copyright (c) 2004, Hugues Cassé \n\n" ^ - "SYNTAX:\tctoxml [options] files...\n" ^ - "\tctoxml [options] --\n" + "ctoxml v4.1\n" ^ + "Copyright (c) 2004-2021, Hugues Cassé et al\n\n" ^ + "SYNTAX:\tctoxml [options] files...\n" ^ + "\tctoxml [options] --\n" let args: parsing_arg list ref = ref [] let files: string list ref = ref [] let out_file = ref "" @@ -22,55 +22,53 @@ let from_stdin = ref false (* Options scanning *) let opts = [ - ("-o", Arg.Set_string out_file, - "Output to the given file."); - ("-pp", Arg.Unit (fun _ -> args := USE_CPP :: !args), - "Preprocess the input files."); - ("-nogcc", Arg.Unit (fun _ -> args := (GCC_SUPPORT false) :: !args), - "Do not use the GCC extensions."); - ("-proc", Arg.String (fun cpp -> args := (PREPROC cpp) :: !args), - "Use the given preprocessor"); - ("-i", Arg.String (fun file -> args := (INCLUDE file) :: !args), - "Include the given file."); - ("-I", Arg.String (fun dir -> args := (INCLUDE_DIR dir) :: !args), - "Include retrieval directory"); - ("-D", Arg.String (fun def -> args := (DEF def) :: !args), - "Pass this definition to the preprocessor."); - ("-U", Arg.String (fun undef -> args := (UNDEF undef) :: !args), - "Pass this undefinition to the preprocessor."); - ("--", Arg.Set from_stdin, - "Takes input from standard input."); + ("-o", Arg.Set_string out_file, + "Output to the given file."); + ("-pp", Arg.Unit (fun _ -> args := USE_CPP :: !args), + "Preprocess the input files."); + ("-nogcc", Arg.Unit (fun _ -> args := (GCC_SUPPORT false) :: !args), + "Do not use the GCC extensions."); + ("-proc", Arg.String (fun cpp -> args := (PREPROC cpp) :: !args), + "Use the given preprocessor"); + ("-i", Arg.String (fun file -> args := (INCLUDE file) :: !args), + "Include the given file."); + ("-I", Arg.String (fun dir -> args := (INCLUDE_DIR dir) :: !args), + "Include retrieval directory"); + ("-D", Arg.String (fun def -> args := (DEF def) :: !args), + "Pass this definition to the preprocessor."); + ("-U", Arg.String (fun undef -> args := (UNDEF undef) :: !args), + "Pass this undefinition to the preprocessor."); + ("--", Arg.Set from_stdin, + "Takes input from standard input."); ] (* Main Program *) let _ = - (* Parse arguments *) - Arg.parse opts (fun file -> files := file :: !files) banner; + (* Parse arguments *) + Arg.parse opts (fun file -> files := file :: !files) banner; - (* Get the output *) - let (output, close) = - if !out_file = "" then (stdout,false) - else ((open_out !out_file), true) in - + (* Get the output *) + let (output, close) = + if !out_file = "" then (stdout,false) + else ((open_out !out_file), true) in - (* Process the input *) - let process opts = - match Frontc.parse opts with - PARSING_ERROR -> () - | PARSING_OK file -> - let doc = Frontc.convert_to_xml file in - Cxml.output_doc output doc in - (* Process the inputs *) - let _ = - if !from_stdin || !files = [] - then process !args - else - List.iter (fun file -> process ((FROM_FILE file) :: !args)) !files in + (* Process the input *) + let process opts = + match Frontc.parse opts with + PARSING_ERROR -> () + | PARSING_OK file -> + let doc = Frontc.convert_to_xml file in + Cxml.output_doc output doc in - (* Close the output if needed *) - if close then close_out output + (* Process the inputs *) + let _ = + if !from_stdin || !files = [] + then process !args + else + List.iter (fun file -> process ((FROM_FILE file) :: !args)) !files in - + (* Close the output if needed *) + if close then close_out output diff --git a/dune-project b/dune-project index 663d573..accf8fe 100644 --- a/dune-project +++ b/dune-project @@ -1,7 +1,7 @@ (lang dune 2.7) (using menhir 2.0) (cram enable) -(version 4.0.0) +(version 4.1.0) (name FrontC) (license LGPL-2.0-only) @@ -28,13 +28,13 @@ nonstructured instructions (i.e., break, return, switch...) \ by branches and, then, remove all branches. \ See https://dblp.org/rec/journals/tsi/CasseFRS02 for more details" ) - (depends (FrontC (>= 4.0.0))) + (depends (FrontC (>= 4.1.0))) (tags (FrontC C analysis))) (package (name ctoxml) (synopsis "Parses a C program into Cabs AST and dumps as an XML document") - (depends (FrontC (>= 4.0.0))) + (depends (FrontC (>= 4.1.0))) (tags (FrontC C parser XML))) (generate_opam_files true) diff --git a/frontc/clexer.mll b/frontc/clexer.mll index 9a351b8..f6ac89a 100644 --- a/frontc/clexer.mll +++ b/frontc/clexer.mll @@ -2,23 +2,8 @@ ** ** Project: FrontC ** File: frontc.mll - ** Version: 1.0e - ** Date: 9.1.99 - ** Author: Hugues Cassé - ** - ** 1.0 3.22.99 Hugues Cassé First version. - ** a 4.19.99 Hugues Cassé Now accept floating notation `.'. - ** b 4.26.99 Hugues Cassé Correctly handle the # ... - ** directive. Previous bug was taking last - ** integer of the line as line number. - ** c 6.4.99 Hugues Cassé Added context handling to manage local variables - ** and type definition with the same name. - ** d 8.26.99 Hugues Cassé Now, manage escape sequences in string and - ** characters. - ** e 9.1.99 Hugues Cassé Fix, '\0' now recognized. - ** f 10.8.99 Hugues Cassé Understand "__const" GCC. - ** 1.1 04.150.05 Hugues Cassé Added support for __XXX__ GNU attributes. - ** Added "restrict" keyword. + ** Version: 4.1 + ** Author: Hugues Cassé et al *) { open Ctokens diff --git a/printc/printc_bin.ml b/printc/printc_bin.ml index 32ec110..6c1fd24 100644 --- a/printc/printc_bin.ml +++ b/printc/printc_bin.ml @@ -10,8 +10,8 @@ open Frontc (* Options *) let banner = - "printc V4.0\n" ^ - "Copyright (c) 2007, Hugues Cassé et al.\n\n" ^ + "printc v4.1\n" ^ + "Copyright (c) 2007-2021, Hugues Cassé et al.\n\n" ^ "SYNTAX:\tprintc [options] files...\n" ^ "\tprintc [options] --\n" let args: parsing_arg list ref = ref []