Newer
Older
/**************************************************************************/
/* */
/* This file is part of Frama-Clang */
/* */
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
101
102
103
104
105
106
/* CEA (Commissariat à l'énergie atomique et aux énergies */
/* alternatives) */
/* */
/* you can redistribute it and/or modify it under the terms of the GNU */
/* Lesser General Public License as published by the Free Software */
/* Foundation, version 2.1. */
/* */
/* It is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* GNU Lesser General Public License for more details. */
/* */
/* See the GNU Lesser General Public License version 2.1 */
/* for more details (enclosed in the file LICENSE). */
/* */
/**************************************************************************/
//
// Description:
// Definition of the ACSL function contracts.
//
#ifndef ACSL_FunctionContractH
#define ACSL_FunctionContractH
#include "ACSLParser.h"
// #include "DescentParse.h"
extern "C" {
#include "intermediate_format.h"
} // end of extern "C"
#include "ACSLLogicType.h"
#include "ACSLTermOrPredicate.h"
namespace Acsl {
/*! @class FunctionContract
* @brief Component that parses a function contract.
*
* The state is defined by the Parser::State::point() method and has
* additional information within the fields _state.
*/
class FunctionContract: public ::Parser::Base {
private:
function_contract _spec;
ForwardReferenceList _currentBehavior;
ForwardReferenceList _currentRequires;
ForwardReferenceList _currentAssumes;
ForwardReferenceList _currentPostCond;
ForwardList _currentAssigns;
ForwardList _currentFrees;
ForwardList _currentAllocates;
ForwardReferenceList _complete;
ForwardReferenceList _disjoint;
ForwardReferenceList _currentSetOfBehaviors;
termination_kind _postCondKind;
enum { ALLOCATES, FREES } _allocClauseKind;
bool _isStatementContract;
enum { START, TERMINATES, BHV, ASSUMES, REQUIRES, POST_COND,
VARIANT, COMPLETE } _state;
std::string _behaviorName;
std::string _additionalMsg;
ReadResult error_empty_behavior(Parser::Arguments& arguments);
ReadResult check_bhv_position (Parser::Arguments& arguments);
ReadResult check_terminates_position(Parser::Arguments& arguments);
ReadResult check_assumes_position(Parser::Arguments& arguments);
ReadResult check_requires_position(Parser::Arguments& arguments);
ReadResult check_post_cond_position(Parser::Arguments& arguments);
ReadResult check_variant_position(Parser::Arguments& arguments);
ReadResult check_complete_position(Parser::Arguments& arguments);
ReadResult parseSemiColumn(Parser::Arguments&, const std::string& );
void add_behavior(const std::string&);
public:
location _loc;
public:
FunctionContract(location loc)
: _spec(function_contract_cons(NULL,opt_none(),opt_none(),NULL,NULL)),
_currentBehavior(_spec->behavior), _complete(_spec->complete_behaviors),
_disjoint(_spec->disjoint_behaviors), _loc(loc)
{ _isStatementContract = false;
_state = START;
}
~FunctionContract() { if (_loc) { free(_loc); _loc=NULL; }; }
void setStatementContract() { _isStatementContract = true; }
ReadResult readToken(Parser::State& state, Parser::Arguments& arguments);
function_contract getAnnot() const { return _spec; }
};
} // end of namespace Acsl
#endif // ACSL_FunctionContractH