Repository navigation
Expand file tree
/
Copy pathcprint.ml
More file actions
101 lines (90 loc) · 3.23 KB
/
Copy pathcprint.ml
File metadata and controls
101 lines (90 loc) · 3.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
(*
*
* Copyright (c) 2001-2003,
* George C. Necula <necula@cs.berkeley.edu>
* Scott McPeak <smcpeak@cs.berkeley.edu>
* Wes Weimer <weimer@cs.berkeley.edu>
* Ben Liblit <liblit@cs.berkeley.edu>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* 3. The names of the contributors may not be used to endorse or promote
* products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*)
(* cprint -- pretty printer of C program from abstract syntax
**
** Project: FrontC
** File: cprint.ml
** Version: 2.1e
** Date: 9.1.99
** Author: Hugues Cassé
**
** 1.0 2.22.99 Hugues Cassé First version.
** 2.0 3.18.99 Hugues Cassé Compatible with Frontc 2.1, use of CAML
** pretty printer.
** 2.1 3.22.99 Hugues Cassé More efficient custom pretty printer used.
** 2.1a 4.12.99 Hugues Cassé Correctly handle:
** char *m, *m, *p; m + (n - p)
** 2.1b 4.15.99 Hugues Cassé x + (y + z) stays x + (y + z) for
** keeping computation order.
** 2.1c 7.23.99 Hugues Cassé Improvement of case and default display.
** 2.1d 8.25.99 Hugues Cassé Rebuild escape sequences in string and
** characters.
** 2.1e 9.1.99 Hugues Cassé Fix, recognize and correctly display '\0'.
*)
(* George Necula: I changed this pretty dramatically since CABS changed *)
open Cabs
open Escape
open Whitetrack
let version = "Cprint 2.1e 9.1.99 Hugues Cassé"
type loc = { line : int; file : string }
let lu = {line = -1; file = "loc unknown";}
let cabslu = {lineno = -10;
filename = "cabs loc unknown";
byteno = -10;
ident = 0;
lineOffsetStart = 0;
}
let curLoc = ref cabslu
let msvcMode = ref false
let printLn = ref true
let printLnComment = ref false
let printCounters = ref false
(*
** FrontC Pretty printer
*)
let out = ref stdout
let width = ref 80
let tab = ref 2
let max_indent = ref 60
let line = ref ""
let line_len = ref 0
let current = ref ""
let current_len = ref 0
let spaces = ref 0
let follow = ref 0
let roll = ref 0