forked from potassco/potassco.github.io
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ast_8c-example.html
95 lines (93 loc) · 25.2 KB
/
ast_8c-example.html
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
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.11"/>
<title>Clingo C API: ast.c</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
$(document).ready(function() { init_search(); });
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="clingo.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
<tbody>
<tr style="height: 56px;">
<td id="projectalign" style="padding-left: 0.5em;">
<div id="projectname">Clingo C API
</div>
<div id="projectbrief">C API for clingo providing high level functions to control grounding and solving.</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.11 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
<div id="navrow1" class="tabs">
<ul class="tablist">
<li><a href="index.html"><span>Main Page</span></a></li>
<li><a href="modules.html"><span>Modules</span></a></li>
<li><a href="annotated.html"><span>Classes</span></a></li>
<li><a href="files.html"><span>Files</span></a></li>
<li><a href="examples.html"><span>Examples</span></a></li>
<li>
<div id="MSearchBox" class="MSearchBoxInactive">
<span class="left">
<img id="MSearchSelect" src="search/mag_sel.png"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
alt=""/>
<input type="text" id="MSearchField" value="Search" accesskey="S"
onfocus="searchBox.OnSearchFieldFocus(true)"
onblur="searchBox.OnSearchFieldFocus(false)"
onkeyup="searchBox.OnSearchFieldChange(event)"/>
</span><span class="right">
<a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
</span>
</div>
</li>
</ul>
</div>
</div><!-- top -->
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>
<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0"
name="MSearchResults" id="MSearchResults">
</iframe>
</div>
<div class="header">
<div class="headertitle">
<div class="title">ast.c</div> </div>
</div><!--header-->
<div class="contents">
<p>The example shows how to rewrite a non-ground logic program.</p><h2>Output</h2>
<div class="fragment"><div class="line">./ast 0</div><div class="line">Solving with enable = <span class="keyword">false</span>...</div><div class="line">Model:</div><div class="line">Solving with enable = <span class="keyword">true</span>...</div><div class="line">Model: enable a</div><div class="line">Model: enable b</div><div class="line">Solving with enable = <span class="keyword">false</span>...</div><div class="line">Model:</div></div><!-- fragment --><h2>Code</h2>
<div class="fragment"><div class="line"><span class="preprocessor">#include <<a class="code" href="clingo_8h.html">clingo.h</a>></span></div><div class="line"><span class="preprocessor">#include <stdlib.h></span></div><div class="line"><span class="preprocessor">#include <stdio.h></span></div><div class="line"></div><div class="line"><span class="keywordtype">bool</span> on_model(<a class="code" href="group__Model.html#gaaf9a93819f023f3cb8aa80598c46556b">clingo_model_t</a> *model, <span class="keywordtype">void</span> *data, <span class="keywordtype">bool</span> *goon) {</div><div class="line"> (void)data;</div><div class="line"> <span class="keywordtype">bool</span> ret = <span class="keyword">true</span>;</div><div class="line"> <a class="code" href="group__Symbols.html#ga6c75c60fa57c3b97505265ff08f6f951">clingo_symbol_t</a> *atoms = NULL;</div><div class="line"> <span class="keywordtype">size_t</span> atoms_n;</div><div class="line"> <a class="code" href="group__Symbols.html#ga6c75c60fa57c3b97505265ff08f6f951">clingo_symbol_t</a> <span class="keyword">const</span> *it, *ie;</div><div class="line"> <span class="keywordtype">char</span> *str = NULL;</div><div class="line"> <span class="keywordtype">size_t</span> str_n = 0;</div><div class="line"></div><div class="line"> <span class="comment">// determine the number of (shown) symbols in the model</span></div><div class="line"> <span class="keywordflow">if</span> (!<a name="a0"></a><a class="code" href="group__Model.html#ga6fd012a9b6deb0d743701ceba35b65ec">clingo_model_symbols_size</a>(model, <a name="a1"></a><a class="code" href="group__Model.html#ggaa943fe81f0874ea63820b627bc19845ca82a698ef41cd919cb370d22fc0b44826">clingo_show_type_shown</a>, &atoms_n)) { <span class="keywordflow">goto</span> error; }</div><div class="line"></div><div class="line"> <span class="comment">// allocate required memory to hold all the symbols</span></div><div class="line"> <span class="keywordflow">if</span> (!(atoms = (<a class="code" href="group__Symbols.html#ga6c75c60fa57c3b97505265ff08f6f951">clingo_symbol_t</a>*)malloc(<span class="keyword">sizeof</span>(*atoms) * atoms_n))) {</div><div class="line"> <a name="a2"></a><a class="code" href="group__BasicTypes.html#ga861bc86ccee813d744920ac0de35ee11">clingo_set_error</a>(<a name="a3"></a><a class="code" href="group__BasicTypes.html#gga5adba1f5e366e7489ac4a3fb5266dba6aa14a0926eb3e653fcc13299b33d8d348">clingo_error_bad_alloc</a>, <span class="stringliteral">"could not allocate memory for atoms"</span>);</div><div class="line"> <span class="keywordflow">goto</span> error;</div><div class="line"> }</div><div class="line"></div><div class="line"> <span class="comment">// retrieve the symbols in the model</span></div><div class="line"> <span class="keywordflow">if</span> (!<a name="a4"></a><a class="code" href="group__Model.html#gaa32137ad8fa747f5fa5dae3345ddf982">clingo_model_symbols</a>(model, <a class="code" href="group__Model.html#ggaa943fe81f0874ea63820b627bc19845ca82a698ef41cd919cb370d22fc0b44826">clingo_show_type_shown</a>, atoms, atoms_n)) { <span class="keywordflow">goto</span> error; }</div><div class="line"></div><div class="line"> printf(<span class="stringliteral">"Model:"</span>);</div><div class="line"></div><div class="line"> <span class="keywordflow">for</span> (it = atoms, ie = atoms + atoms_n; it != ie; ++it) {</div><div class="line"> <span class="keywordtype">size_t</span> n;</div><div class="line"> <span class="keywordtype">char</span> *str_new;</div><div class="line"></div><div class="line"> <span class="comment">// determine size of the string representation of the next symbol in the model</span></div><div class="line"> <span class="keywordflow">if</span> (!<a name="a5"></a><a class="code" href="group__Symbols.html#gafba05ee305c698c687390ed2ee4f1562">clingo_symbol_to_string_size</a>(*it, &n)) { <span class="keywordflow">goto</span> error; }</div><div class="line"></div><div class="line"> <span class="keywordflow">if</span> (str_n < n) {</div><div class="line"> <span class="comment">// allocate required memory to hold the symbol's string</span></div><div class="line"> <span class="keywordflow">if</span> (!(str_new = (<span class="keywordtype">char</span>*)realloc(str, <span class="keyword">sizeof</span>(*str) * n))) {</div><div class="line"> <a class="code" href="group__BasicTypes.html#ga861bc86ccee813d744920ac0de35ee11">clingo_set_error</a>(<a class="code" href="group__BasicTypes.html#gga5adba1f5e366e7489ac4a3fb5266dba6aa14a0926eb3e653fcc13299b33d8d348">clingo_error_bad_alloc</a>, <span class="stringliteral">"could not allocate memory for symbol's string"</span>);</div><div class="line"> <span class="keywordflow">goto</span> error;</div><div class="line"> }</div><div class="line"></div><div class="line"> str = str_new;</div><div class="line"> str_n = n;</div><div class="line"> }</div><div class="line"></div><div class="line"> <span class="comment">// retrieve the symbol's string</span></div><div class="line"> <span class="keywordflow">if</span> (!<a name="a6"></a><a class="code" href="group__Symbols.html#ga7990b41b229320ac158fc428fa366000">clingo_symbol_to_string</a>(*it, str, n)) { <span class="keywordflow">goto</span> error; }</div><div class="line"></div><div class="line"> printf(<span class="stringliteral">" %s"</span>, str);</div><div class="line"> }</div><div class="line"></div><div class="line"> printf(<span class="stringliteral">"\n"</span>);</div><div class="line"> *goon = <span class="keyword">true</span>;</div><div class="line"> <span class="keywordflow">goto</span> out;</div><div class="line"></div><div class="line">error:</div><div class="line"> ret = <span class="keyword">false</span>;</div><div class="line"></div><div class="line">out:</div><div class="line"> <span class="keywordflow">if</span> (atoms) { free(atoms); }</div><div class="line"> <span class="keywordflow">if</span> (str) { free(str); }</div><div class="line"></div><div class="line"> <span class="keywordflow">return</span> ret;</div><div class="line">}</div><div class="line"></div><div class="line"><span class="keyword">typedef</span> <span class="keyword">struct </span>{</div><div class="line"> <a name="_a7"></a><a class="code" href="structclingo__ast__term.html">clingo_ast_term_t</a> atom;</div><div class="line"> <a class="code" href="group__ProgramBuilder.html#gaf3ea2b021e93cdcc0f6c7b4219e4a06d">clingo_program_builder_t</a> *builder;</div><div class="line">} on_statement_data;</div><div class="line"></div><div class="line"><span class="comment">// adds atom enable to all rule bodies</span></div><div class="line"><span class="keywordtype">bool</span> on_statement (<a name="_a8"></a><a class="code" href="structclingo__ast__statement.html">clingo_ast_statement_t</a> <span class="keyword">const</span> *stm, on_statement_data *data) {</div><div class="line"> <span class="keywordtype">bool</span> ret = <span class="keyword">true</span>;</div><div class="line"> <a name="_a9"></a><a class="code" href="structclingo__ast__rule.html">clingo_ast_rule_t</a> rule;</div><div class="line"> <a name="_a10"></a><a class="code" href="structclingo__ast__body__literal.html">clingo_ast_body_literal_t</a> *body = NULL;</div><div class="line"> <a name="_a11"></a><a class="code" href="structclingo__ast__literal.html">clingo_ast_literal_t</a> lit;</div><div class="line"> <a class="code" href="structclingo__ast__statement.html">clingo_ast_statement_t</a> stm2;</div><div class="line"></div><div class="line"> <span class="comment">// pass through all statements that are not rules</span></div><div class="line"> <span class="keywordflow">if</span> (stm-><a name="a12"></a>type != clingo_ast_statement_type_rule) {</div><div class="line"> <span class="keywordflow">if</span> (!<a name="a13"></a><a class="code" href="group__ProgramBuilder.html#gaadbcca73d63e8b1a7652e687bba1b595">clingo_program_builder_add</a>(data->builder, stm)) { <span class="keywordflow">goto</span> error; }</div><div class="line"> <span class="keywordflow">goto</span> out;</div><div class="line"> }</div><div class="line"></div><div class="line"> <span class="comment">// allocate space to hold the current rule body + one literal</span></div><div class="line"> body = (<a class="code" href="structclingo__ast__body__literal.html">clingo_ast_body_literal_t</a>*)malloc(<span class="keyword">sizeof</span>(<a class="code" href="structclingo__ast__body__literal.html">clingo_ast_body_literal_t</a>) * (stm-><a name="a14"></a>rule-><a name="a15"></a>size + 1));</div><div class="line"> <span class="keywordflow">if</span> (!body) {</div><div class="line"> <a class="code" href="group__BasicTypes.html#ga861bc86ccee813d744920ac0de35ee11">clingo_set_error</a>(<a class="code" href="group__BasicTypes.html#gga5adba1f5e366e7489ac4a3fb5266dba6aa14a0926eb3e653fcc13299b33d8d348">clingo_error_bad_alloc</a>, <span class="stringliteral">"could not allocate memory for rule body"</span>);</div><div class="line"> <span class="keywordflow">goto</span> error;</div><div class="line"> }</div><div class="line"></div><div class="line"> <span class="comment">// copy the current rule body</span></div><div class="line"> <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> i = 0; i < stm->rule->size; ++i) {</div><div class="line"> body[i] = stm->rule-><a name="a16"></a>body[i];</div><div class="line"> }</div><div class="line"></div><div class="line"> <span class="comment">// create atom enable</span></div><div class="line"> lit.<a name="a17"></a>symbol = &data->atom;</div><div class="line"> lit.<a name="a18"></a>location = data->atom.location;</div><div class="line"> lit.<a name="a19"></a>type = clingo_ast_literal_type_symbolic;</div><div class="line"> lit.<a name="a20"></a>sign = clingo_ast_sign_none;</div><div class="line"></div><div class="line"> <span class="comment">// add atom enable to the rule body</span></div><div class="line"> body[stm->rule->size].<a name="a21"></a>location = data->atom.location;</div><div class="line"> body[stm->rule->size].<a name="a22"></a>type = clingo_ast_body_literal_type_literal;</div><div class="line"> body[stm->rule->size].<a name="a23"></a>sign = clingo_ast_sign_none;</div><div class="line"> body[stm->rule->size].<a name="a24"></a>literal = &lit;</div><div class="line"></div><div class="line"> <span class="comment">// initialize the rule</span></div><div class="line"> rule.<a name="a25"></a>head = stm->rule->head;</div><div class="line"> rule.size = stm->rule->size + 1;</div><div class="line"> rule.body = body;</div><div class="line"></div><div class="line"> <span class="comment">// initialize the statement</span></div><div class="line"> stm2.<a name="a26"></a>location = stm->location;</div><div class="line"> stm2.type = stm->type;</div><div class="line"> stm2.rule = &rule;</div><div class="line"></div><div class="line"> <span class="comment">// add the rewritten statement to the program</span></div><div class="line"> <span class="keywordflow">if</span> (!<a class="code" href="group__ProgramBuilder.html#gaadbcca73d63e8b1a7652e687bba1b595">clingo_program_builder_add</a>(data->builder, &stm2)) { <span class="keywordflow">goto</span> error; }</div><div class="line"></div><div class="line"> <span class="keywordflow">goto</span> out;</div><div class="line">error:</div><div class="line"> ret = <span class="keyword">false</span>;</div><div class="line">out:</div><div class="line"> <span class="keywordflow">if</span> (body) { free(body); }</div><div class="line"></div><div class="line"> <span class="keywordflow">return</span> ret;</div><div class="line">}</div><div class="line"></div><div class="line"><span class="keywordtype">int</span> main(<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span> <span class="keyword">const</span> **argv) {</div><div class="line"> <span class="keywordtype">char</span> <span class="keyword">const</span> *error_message;</div><div class="line"> <span class="keywordtype">int</span> ret = 0;</div><div class="line"> <a class="code" href="group__Control.html#gae917a23b0591d181004ec88c4e3291c1">clingo_solve_result_bitset_t</a> solve_ret;</div><div class="line"> <a class="code" href="group__Control.html#gaf008e9db9dbb37b0b7ef039bb9d582f0">clingo_control_t</a> *ctl = NULL;</div><div class="line"> <a class="code" href="group__Symbols.html#ga6c75c60fa57c3b97505265ff08f6f951">clingo_symbol_t</a> sym;</div><div class="line"> <a name="_a27"></a><a class="code" href="structclingo__location.html">clingo_location_t</a> location;</div><div class="line"> <a class="code" href="structclingo__ast__statement.html">clingo_ast_statement_t</a> stm;</div><div class="line"> <a name="_a28"></a><a class="code" href="structclingo__ast__external.html">clingo_ast_external_t</a> ext;</div><div class="line"> on_statement_data data;</div><div class="line"> <a name="_a29"></a><a class="code" href="structclingo__part.html">clingo_part_t</a> parts[] = {{ <span class="stringliteral">"base"</span>, NULL, 0 }};</div><div class="line"></div><div class="line"> <span class="comment">// create a control object and pass command line arguments</span></div><div class="line"> <span class="keywordflow">if</span> (!<a name="a30"></a><a class="code" href="group__Control.html#ga46254f92ddf864a5214cf1572402e2bc">clingo_control_new</a>(argv+1, argc-1, NULL, NULL, 20, &ctl) != 0) { <span class="keywordflow">goto</span> error; }</div><div class="line"></div><div class="line"> <span class="comment">// get the program builder</span></div><div class="line"> <span class="keywordflow">if</span> (!<a name="a31"></a><a class="code" href="group__Control.html#gaa3df82717137933584acfbbc80219b97">clingo_control_program_builder</a>(ctl, &data.builder)) { <span class="keywordflow">goto</span> error; }</div><div class="line"></div><div class="line"> <span class="comment">// initialize the location</span></div><div class="line"> location.<a name="a32"></a><a class="code" href="structclingo__location.html#a7e1cc6f6d6086bded33e3f9adbb16b90">begin_line</a> = location.<a name="a33"></a><a class="code" href="structclingo__location.html#a8fe7fd90b5eb6ae1885abc55ae40a6b0">end_line</a> = 0;</div><div class="line"> location.<a name="a34"></a><a class="code" href="structclingo__location.html#afe5db4636f00e6f9ee2bdb371591b4d6">begin_column</a> = location.<a name="a35"></a><a class="code" href="structclingo__location.html#a69787609f3a62fb6156c01f72bcddab2">end_column</a> = 0;</div><div class="line"> location.<a name="a36"></a><a class="code" href="structclingo__location.html#af09373d7b6ffdec84a27787724500697">begin_file</a> = location.<a name="a37"></a><a class="code" href="structclingo__location.html#a3dabe65d33b291ed9c289ab618612d47">end_file</a> = <span class="stringliteral">"<rewrite>"</span>;</div><div class="line"></div><div class="line"> <span class="comment">// initilize atom to add</span></div><div class="line"> <span class="keywordflow">if</span> (!<a name="a38"></a><a class="code" href="group__Symbols.html#ga17bb0c81e3d6e0bf1422dd969b0b9b9b">clingo_symbol_create_id</a>(<span class="stringliteral">"enable"</span>, <span class="keyword">true</span>, &sym)) { <span class="keywordflow">goto</span> error; }</div><div class="line"> data.atom.location = location;</div><div class="line"> data.atom.type = clingo_ast_term_type_symbol;</div><div class="line"> data.atom.symbol = sym;</div><div class="line"></div><div class="line"> <span class="comment">// begin building a program</span></div><div class="line"> <span class="keywordflow">if</span> (!<a name="a39"></a><a class="code" href="group__ProgramBuilder.html#ga36b68815b8ee4cf612985feea8118065">clingo_program_builder_begin</a>(data.builder)) { <span class="keywordflow">goto</span> error; }</div><div class="line"></div><div class="line"> <span class="comment">// get the AST of the program</span></div><div class="line"> <span class="keywordflow">if</span> (!<a name="a40"></a><a class="code" href="group__AST.html#ga810b671c0f4ae50fd828044f5f40dee2">clingo_parse_program</a>(<span class="stringliteral">"a :- not b. b :- not a."</span>, (clingo_ast_callback_t*)on_statement, &data, NULL, NULL, 20)) { <span class="keywordflow">goto</span> error; }</div><div class="line"></div><div class="line"> <span class="comment">// add the external statement: #external enable.</span></div><div class="line"> ext.<a name="a41"></a>atom = data.atom;</div><div class="line"> ext.<a name="a42"></a>body = NULL;</div><div class="line"> ext.<a name="a43"></a>size = 0;</div><div class="line"> stm.location = location;</div><div class="line"> stm.type = clingo_ast_statement_type_external;</div><div class="line"> stm.<a name="a44"></a>external = &ext;</div><div class="line"> <span class="keywordflow">if</span> (!<a class="code" href="group__ProgramBuilder.html#gaadbcca73d63e8b1a7652e687bba1b595">clingo_program_builder_add</a>(data.builder, &stm)) { <span class="keywordflow">goto</span> error; }</div><div class="line"></div><div class="line"> <span class="comment">// finish building a program</span></div><div class="line"> <span class="keywordflow">if</span> (!<a name="a45"></a><a class="code" href="group__ProgramBuilder.html#ga5e165aec527a8843c54790d3ef1b0eee">clingo_program_builder_end</a>(data.builder)) { <span class="keywordflow">goto</span> error; }</div><div class="line"></div><div class="line"> <span class="comment">// ground the base part</span></div><div class="line"> <span class="keywordflow">if</span> (!<a name="a46"></a><a class="code" href="group__Control.html#gad0d95c5766649ff2f00e4ee3507a679f">clingo_control_ground</a>(ctl, parts, 1, NULL, NULL)) { <span class="keywordflow">goto</span> error; }</div><div class="line"></div><div class="line"> <span class="comment">// solve with external enable = false</span></div><div class="line"> printf(<span class="stringliteral">"Solving with enable = false...\n"</span>);</div><div class="line"> <span class="keywordflow">if</span> (!<a name="a47"></a><a class="code" href="group__Control.html#ga32ecc4f42257562dde343621597a596d">clingo_control_solve</a>(ctl, on_model, NULL, NULL, 0, &solve_ret)) { <span class="keywordflow">goto</span> error; }</div><div class="line"> <span class="comment">// solve with external enable = true</span></div><div class="line"> printf(<span class="stringliteral">"Solving with enable = true...\n"</span>);</div><div class="line"> <span class="keywordflow">if</span> (!<a name="a48"></a><a class="code" href="group__Control.html#ga6399db2e472e3b94c02654aabe17bf4e">clingo_control_assign_external</a>(ctl, sym, <a name="a49"></a><a class="code" href="group__BasicTypes.html#gga6847b34622ab224c5867a84ef9c08126a304e39ab32ecb495a7a13626a3125276">clingo_truth_value_true</a>)) { <span class="keywordflow">goto</span> error; }</div><div class="line"> <span class="keywordflow">if</span> (!<a class="code" href="group__Control.html#ga32ecc4f42257562dde343621597a596d">clingo_control_solve</a>(ctl, on_model, NULL, NULL, 0, &solve_ret)) { <span class="keywordflow">goto</span> error; }</div><div class="line"> <span class="comment">// solve with external enable = false</span></div><div class="line"> printf(<span class="stringliteral">"Solving with enable = false...\n"</span>);</div><div class="line"> <span class="keywordflow">if</span> (!<a class="code" href="group__Control.html#ga6399db2e472e3b94c02654aabe17bf4e">clingo_control_assign_external</a>(ctl, sym, <a name="a50"></a><a class="code" href="group__BasicTypes.html#gga6847b34622ab224c5867a84ef9c08126a2ac4886c8ca9dfd7f0d70cd24e07cf52">clingo_truth_value_false</a>)) { <span class="keywordflow">goto</span> error; }</div><div class="line"> <span class="keywordflow">if</span> (!<a class="code" href="group__Control.html#ga32ecc4f42257562dde343621597a596d">clingo_control_solve</a>(ctl, on_model, NULL, NULL, 0, &solve_ret)) { <span class="keywordflow">goto</span> error; }</div><div class="line"></div><div class="line"> <span class="keywordflow">goto</span> out;</div><div class="line"></div><div class="line">error:</div><div class="line"> <span class="keywordflow">if</span> (!(error_message = <a name="a51"></a><a class="code" href="group__BasicTypes.html#ga9732caf39396e15e7a2eb0e01d1a71b0">clingo_error_message</a>())) { error_message = <span class="stringliteral">"error"</span>; }</div><div class="line"></div><div class="line"> printf(<span class="stringliteral">"%s\n"</span>, error_message);</div><div class="line"> ret = <a name="a52"></a><a class="code" href="group__BasicTypes.html#ga94ce73fd010c0dbad708901a472f2c7a">clingo_error_code</a>();</div><div class="line"></div><div class="line">out:</div><div class="line"> <span class="keywordflow">if</span> (ctl) { <a name="a53"></a><a class="code" href="group__Control.html#gad1c4e8f6be76e1d3d8e34d71363dd067">clingo_control_free</a>(ctl); }</div><div class="line"></div><div class="line"> <span class="keywordflow">return</span> ret;</div><div class="line">}</div><div class="line"></div></div><!-- fragment --> </div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated on Thu Aug 18 2016 13:19:52 for Clingo C API by  <a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.11
</small></address>
</body>
</html>