2 ** Splint - annotation-assisted static program checker
3 ** Copyright (C) 1994-2003 University of Virginia,
4 ** Massachusetts Institute of Technology
6 ** This program is free software; you can redistribute it and/or modify it
7 ** under the terms of the GNU General Public License as published by the
8 ** Free Software Foundation; either version 2 of the License, or (at your
9 ** option) any later version.
11 ** This program is distributed in the hope that it will be useful, but
12 ** WITHOUT ANY WARRANTY; without even the implied warranty of
13 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 ** General Public License for more details.
16 ** The GNU General Public License is available from http://www.gnu.org/ or
17 ** the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
18 ** MA 02111-1307, USA.
20 ** For information on splint: info@splint.org
21 ** To report a bug: splint-bug@splint.org
22 ** For more information: http://www.splint.org
28 # include "splintMacros.nf"
31 # include "cgrammar.h"
34 lltok_isSemi (lltok tok
)
36 return (tok
->tok
== TSEMI
);
40 lltok_isMult (lltok tok
)
42 return (tok
->tok
== TMULT
);
45 bool lltok_isIncOp (lltok tok
)
47 return (tok
->tok
== INC_OP
);
50 bool lltok_isDecOp (lltok tok
)
52 return (tok
->tok
== DEC_OP
);
56 /* DRL added this function 10/23/2000 for boolean stuff */
57 bool lltok_isEqOp (lltok tok
)
59 return (tok
->tok
== EQ_OP
);
62 bool lltok_isNotEqOp (lltok tok
)
64 return (tok
->tok
== NE_OP
);
67 /* DRL added this function 10/25/2000 for boolean stuff */
68 bool lltok_isAndOp (lltok tok
)
70 return (tok
->tok
== AND_OP
);
73 bool lltok_isOrOp (lltok tok
)
75 return (tok
->tok
== OR_OP
);
78 bool lltok_isNotOp (lltok tok
)
80 return (tok
->tok
== TEXCL
);
82 /*drl7x added this function 11/20/00 */
84 bool lltok_isLt_Op (lltok tok
)
86 return (tok
->tok
== TLT
);
89 bool lltok_isGt_Op (lltok tok
)
91 return (tok
->tok
== TGT
);
94 bool lltok_isGe_Op (lltok tok
)
96 return (tok
->tok
== GE_OP
);
99 bool lltok_isLe_Op (lltok tok
)
101 return (tok
->tok
== LE_OP
);
104 /* end drl7x added */
107 /*drl7x added 11 30 2000*/
108 bool lltok_isPlus_Op (lltok tok
)
110 return (tok
->tok
== TPLUS
);
113 bool lltok_isMinus_Op (lltok tok
)
115 return (tok
->tok
== TMINUS
);
118 /*drl7x added 6 6 2001 */
121 bool lltok_isAmpersand_Op (lltok tok
)
123 return (tok
->tok
== TAMPERSAND
);
128 /*drl7x added 6 15 2001 */
130 bool lltok_isExcl_Op (lltok tok
)
132 return (tok
->tok
== TEXCL
);
135 bool lltok_isTilde_Op (lltok tok
)
137 return (tok
->tok
== TTILDE
);
142 bool lltok_isEnsures (lltok tok
)
144 return (tok
->tok
== QPOSTCLAUSE
);
147 bool lltok_isRequires (lltok tok
)
149 return (tok
->tok
== QPRECLAUSE
);
153 lltok_unparse (lltok tok
)
159 case BREAK
: lit
= "break"; break;
160 case CASE
: lit
= "case"; break;
161 case CONTINUE
: lit
= "continue"; break;
162 case DEFAULT
: lit
= "default"; break;
163 case DO
: lit
= "do"; break;
164 case CDOUBLE
: lit
= "double"; break;
165 case CELSE
: lit
= "else"; break;
166 case CFOR
: lit
= "for"; break;
167 case GOTO
: lit
= "goto"; break;
168 case CIF
: lit
= "if"; break;
169 case RETURN
: lit
= "return"; break;
170 case CSIZEOF
: lit
= "sizeof"; break;
171 case SWITCH
: lit
= "switch"; break;
172 case WHILE
: lit
= "while"; break;
173 case CSTRUCT
: lit
= "struct"; break;
174 case CTYPEDEF
: lit
= "typedef"; break;
175 case CUNION
: lit
= "union"; break;
176 case CENUM
: lit
= "enum"; break;
177 case QEXTERN
: lit
= "extern"; break;
178 case QAUTO
: lit
= "auto"; break;
179 case QSTATIC
: lit
= "static"; break;
180 case RIGHT_ASSIGN
: lit
= ">>="; break;
181 case LEFT_ASSIGN
: lit
= "<<="; break;
182 case ADD_ASSIGN
: lit
= "+="; break;
183 case SUB_ASSIGN
: lit
= "-="; break;
184 case MUL_ASSIGN
: lit
= "*="; break;
185 case DIV_ASSIGN
: lit
= "/="; break;
186 case MOD_ASSIGN
: lit
= "%="; break;
187 case AND_ASSIGN
: lit
= "&="; break;
188 case XOR_ASSIGN
: lit
= "^="; break;
189 case OR_ASSIGN
: lit
= "|="; break;
190 case RIGHT_OP
: lit
= ">>"; break;
191 case LEFT_OP
: lit
= "<<"; break;
192 case INC_OP
: lit
= "++"; break;
193 case DEC_OP
: lit
= "--"; break;
194 case ARROW_OP
: lit
= "->"; break;
195 case AND_OP
: lit
= "&&"; break;
196 case OR_OP
: lit
= "||"; break;
197 case LE_OP
: lit
= "<="; break;
198 case GE_OP
: lit
= ">="; break;
199 case EQ_OP
: lit
= "=="; break;
200 case NE_OP
: lit
= "!="; break;
201 case TSEMI
: lit
= ";"; break;
202 case TLBRACE
: lit
= "{"; break;
203 case TRBRACE
: lit
= "}"; break;
204 case TCOMMA
: lit
= ","; break;
205 case TCOLON
: lit
= ":"; break;
206 case TASSIGN
: lit
= "="; break;
207 case TLPAREN
: lit
= "("; break;
208 case TRPAREN
: lit
= ")"; break;
209 case TLSQBR
: lit
= "["; break;
210 case TRSQBR
: lit
= "]"; break;
211 case TDOT
: lit
= "."; break; /* evans 2003-05-31: Fix reported by psanzani. */
212 case TAMPERSAND
: lit
= "&"; break;
213 case TEXCL
: lit
= "!"; break;
214 case TTILDE
: lit
= "~"; break;
215 case TMINUS
: lit
= "-"; break;
216 case TPLUS
: lit
= "+"; break;
217 case TMULT
: lit
= "*"; break;
218 case TDIV
: lit
= "/"; break;
219 case TPERCENT
: lit
= "%"; break;
220 case TLT
: lit
= "<"; break;
221 case TGT
: lit
= ">"; break;
222 case TCIRC
: lit
= "^"; break;
223 case TBAR
: lit
= "|"; break;
224 case TQUEST
: lit
= "?"; break;
225 case QOUT
: lit
= "out"; break;
226 case QONLY
: lit
= "only"; break;
227 case QKEEP
: lit
= "keep"; break;
228 case QKEPT
: lit
= "kept"; break;
229 case QTEMP
: lit
= "temp"; break;
230 case QSHARED
: lit
= "shared"; break;
231 case QUNIQUE
: lit
= "unique"; break;
232 case QREF
: lit
= "ref"; break;
233 case QCHECKED
: lit
= "checked"; break;
234 case QCHECKEDSTRICT
: lit
= "checkedstrict"; break;
235 case QCHECKMOD
: lit
= "checkmod"; break;
236 case QUNCHECKED
: lit
= "unchecked"; break;
237 case QPRECLAUSE
: lit
= "requires"; break;
238 case QPOSTCLAUSE
: lit
= "ensures"; break;
239 case QTRUENULL
: lit
= "truenull"; break;
240 case QFALSENULL
: lit
= "falsenull"; break;
241 case QRETURNED
: lit
= "returned"; break;
242 case QEXPOSED
: lit
= "exposed"; break;
243 case QNULL
: lit
= "null"; break;
244 case QRELNULL
: lit
= "refnull"; break;
245 case QOBSERVER
: lit
= "observer"; break;
246 case QPARTIAL
: lit
= "partial"; break;
247 case QSPECIAL
: lit
= "special"; break;
248 case QUSES
: lit
= "uses"; break;
249 case QDEFINES
: lit
= "defines"; break;
250 case QALLOCATES
: lit
= "allocates"; break;
251 case QSETS
: lit
= "sets"; break;
252 case QRELEASES
: lit
= "releases"; break;
256 return cstring_makeLiteralTemp (lit
);
260 lltok_create (int tok
, fileloc loc
)
262 lltok l
= (lltok
) dmalloc (sizeof (*l
));
266 DPRINTF (("Create: %s [%p]", lltok_unparse (l
), loc
));
270 void lltok_free (lltok t
)
272 fileloc_free (t
->loc
);
276 void lltok_free2 (lltok t1
, lltok t2
)
282 void lltok_free3 (lltok t1
, lltok t2
, lltok t3
)