From fa25ac98dbc28e413b5c4547ef70f696d14f30cf Mon Sep 17 00:00:00 2001 From: ivg Date: Mon, 24 May 2021 15:17:08 -0400 Subject: [PATCH 1/3] updates versions and switches to new setup-ocaml action --- .github/workflows/test.yml | 2 +- calipso/calipso.ml | 2 +- calipso/stat.ml | 2 +- ctoxml/ctoxml_bin.ml | 90 +++++++++++++++++++------------------- frontc/clexer.mll | 19 +------- printc/printc_bin.ml | 4 +- 6 files changed, 51 insertions(+), 68 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 7dedf28..a0cff50 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -25,7 +25,7 @@ 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 }} 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/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/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 [] From 523343bc6c6625d4d1366164bc66650451589cc8 Mon Sep 17 00:00:00 2001 From: ivg Date: Mon, 24 May 2021 15:19:43 -0400 Subject: [PATCH 2/3] bumps the package versions --- FrontC.opam | 2 +- calipso.opam | 4 ++-- ctoxml.opam | 4 ++-- dune-project | 6 +++--- 4 files changed, 8 insertions(+), 8 deletions(-) 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/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/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) From 72e30934bb09324a75f8056e19c5d1ff01c01efe Mon Sep 17 00:00:00 2001 From: ivg Date: Mon, 24 May 2021 15:25:54 -0400 Subject: [PATCH 3/3] uses the new option to specify the compiler version --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a0cff50..9e313e3 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -27,7 +27,7 @@ jobs: - name: Use OCaml ${{ matrix.ocaml-version }} 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