/usr/share/gtk-doc/html/ctpl/ctpl-CtplLexerExpr.html is in libctpl-doc 0.3.3.dfsg-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 | <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>CtplLexerExpr</title>
<meta name="generator" content="DocBook XSL Stylesheets V1.75.2">
<link rel="home" href="index.html" title="CTPL Reference Manual">
<link rel="up" href="ch02.html" title="API reference">
<link rel="prev" href="ctpl-CtplLexer.html" title="CtplLexer">
<link rel="next" href="ctpl-CtplParser.html" title="CtplParser">
<meta name="generator" content="GTK-Doc V1.17 (XML mode)">
<link rel="stylesheet" href="style.css" type="text/css">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="2">
<tr valign="middle">
<td><a accesskey="p" href="ctpl-CtplLexer.html"><img src="left.png" width="24" height="24" border="0" alt="Prev"></a></td>
<td><a accesskey="u" href="ch02.html"><img src="up.png" width="24" height="24" border="0" alt="Up"></a></td>
<td><a accesskey="h" href="index.html"><img src="home.png" width="24" height="24" border="0" alt="Home"></a></td>
<th width="100%" align="center">CTPL Reference Manual</th>
<td><a accesskey="n" href="ctpl-CtplParser.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td>
</tr>
<tr><td colspan="5" class="shortcuts">
<a href="#ctpl-CtplLexerExpr.synopsis" class="shortcut">Top</a>
|
<a href="#ctpl-CtplLexerExpr.description" class="shortcut">Description</a>
</td></tr>
</table>
<div class="refentry">
<a name="ctpl-CtplLexerExpr"></a><div class="titlepage"></div>
<div class="refnamediv"><table width="100%"><tr>
<td valign="top">
<h2><span class="refentrytitle"><a name="ctpl-CtplLexerExpr.top_of_page"></a>CtplLexerExpr</span></h2>
<p>CtplLexerExpr — Syntax analyser for mathematical/test expressions</p>
</td>
<td valign="top" align="right"></td>
</tr></table></div>
<div class="refsynopsisdiv">
<a name="ctpl-CtplLexerExpr.synopsis"></a><h2>Synopsis</h2>
<pre class="synopsis">
#include <ctpl/ctpl.h>
#define <a class="link" href="ctpl-CtplLexerExpr.html#CTPL-LEXER-EXPR-ERROR:CAPS" title="CTPL_LEXER_EXPR_ERROR">CTPL_LEXER_EXPR_ERROR</a>
enum <a class="link" href="ctpl-CtplLexerExpr.html#CtplLexerExprError" title="enum CtplLexerExprError">CtplLexerExprError</a>;
<a class="link" href="ctpl-CtplToken.html#CtplTokenExpr" title="CtplTokenExpr"><span class="returnvalue">CtplTokenExpr</span></a> * <a class="link" href="ctpl-CtplLexerExpr.html#ctpl-lexer-expr-lex" title="ctpl_lexer_expr_lex ()">ctpl_lexer_expr_lex</a> (<em class="parameter"><code><a class="link" href="ctpl-CtplInputStream.html#CtplInputStream" title="CtplInputStream"><span class="type">CtplInputStream</span></a> *stream</code></em>,
<em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-Error-Reporting.html#GError"><span class="type">GError</span></a> **error</code></em>);
<a class="link" href="ctpl-CtplToken.html#CtplTokenExpr" title="CtplTokenExpr"><span class="returnvalue">CtplTokenExpr</span></a> * <a class="link" href="ctpl-CtplLexerExpr.html#ctpl-lexer-expr-lex-full" title="ctpl_lexer_expr_lex_full ()">ctpl_lexer_expr_lex_full</a> (<em class="parameter"><code><a class="link" href="ctpl-CtplInputStream.html#CtplInputStream" title="CtplInputStream"><span class="type">CtplInputStream</span></a> *stream</code></em>,
<em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gboolean"><span class="type">gboolean</span></a> lex_all</code></em>,
<em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-Error-Reporting.html#GError"><span class="type">GError</span></a> **error</code></em>);
<a class="link" href="ctpl-CtplToken.html#CtplTokenExpr" title="CtplTokenExpr"><span class="returnvalue">CtplTokenExpr</span></a> * <a class="link" href="ctpl-CtplLexerExpr.html#ctpl-lexer-expr-lex-string" title="ctpl_lexer_expr_lex_string ()">ctpl_lexer_expr_lex_string</a> (<em class="parameter"><code>const <a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gchar"><span class="type">gchar</span></a> *expr</code></em>,
<em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gssize"><span class="type">gssize</span></a> len</code></em>,
<em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-Error-Reporting.html#GError"><span class="type">GError</span></a> **error</code></em>);
</pre>
</div>
<div class="refsect1">
<a name="ctpl-CtplLexerExpr.description"></a><h2>Description</h2>
<p>
Syntax analyser for mathematical or test expressions creating a token tree
from an expression.
</p>
<p>
To analyse an expression, use <a class="link" href="ctpl-CtplLexerExpr.html#ctpl-lexer-expr-lex" title="ctpl_lexer_expr_lex ()"><code class="function">ctpl_lexer_expr_lex()</code></a>. The resulting expression
should be freed with <a class="link" href="ctpl-CtplToken.html#ctpl-token-expr-free" title="ctpl_token_expr_free ()"><code class="function">ctpl_token_expr_free()</code></a> when no longer needed.
</p>
<p>
An expression is something like a mathematical expression that can include
references to variables. The allowed things are:
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term">Binary operators</span></p></td>
<td>
<p>
addition (<code class="code">+</code>),
subtraction (<code class="code">-</code>),
multiplication (<code class="code">*</code>),
division (<code class="code">/</code>),
modulo (<code class="code">%</code>),
and the boolean
equality (<code class="code">==</code>),
non-equality (<code class="code">!=</code>),
inferiority (<code class="code"><</code>),
inferiority-or-equality (<code class="code"><=</code>),
superiority (<code class="code">></code>),
superiority-or-equality (<code class="code">>=</code>),
AND (<code class="code">&&</code>),
and
OR (<code class="code">||</code>).
</p>
<p>
The boolean operators results to the integer 0 if their expression
evaluates to false, or to the positive integer 1 if their expression
evaluates to true.
This result might be used as a plain integer.
</p>
<p>
The operators' priority is very common: boolean operators have the
higher priority, followed by division, modulo and multiplication, and
finally addition and subtraction which have the lower priority.
When two operators have the same priority, the left one is prior over
the right one.
</p>
</td>
</tr>
<tr>
<td><p><span class="term">Unary operators</span></p></td>
<td><p>
The unary operators plus (<code class="code">+</code>) and minus (<code class="code">-</code>),
that may precede any numeric operand.
</p></td>
</tr>
<tr>
<td><p><span class="term">Operands</span></p></td>
<td><p>
Any numeric constant that <a class="link" href="ctpl-CtplInputStream.html#ctpl-input-stream-read-number" title="ctpl_input_stream_read_number ()"><code class="function">ctpl_input_stream_read_number()</code></a> supports,
any reference to any
<a class="link" href="ctpl-CtplEnviron.html" title="CtplEnviron">environment</a> variable,
or any string literal that <a class="link" href="ctpl-CtplInputStream.html#ctpl-input-stream-read-string-literal" title="ctpl_input_stream_read_string_literal ()"><code class="function">ctpl_input_stream_read_string_literal()</code></a>
supports.
An operand may be suffixed with an index of the form
<code class="code">[<expression>]</code>.
</p></td>
</tr>
<tr>
<td><p><span class="term">Parentheses</span></p></td>
<td><p>
Parentheses may be placed to delimit sub-expressions, allowing a fine
control over operator priority.
</p></td>
</tr>
</tbody>
</table></div>
<p>
</p>
<p>
</p>
<div class="example">
<a name="idp8943168"></a><p class="title"><b>Example 12. A simple expression</b></p>
<div class="example-contents">
<table class="listing_frame" border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td class="listing_lines" align="right"><pre>1</pre></td>
<td class="listing_code"><pre class="programlisting"><span class="number">42</span> <span class="gtkdoc opt">*</span> <span class="number">2</span></pre></td>
</tr>
</tbody>
</table>
</div>
</div>
<p><br class="example-break">
</p>
<div class="example">
<a name="idp6663856"></a><p class="title"><b>Example 13. A more complicated expression</b></p>
<div class="example-contents">
<table class="listing_frame" border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td class="listing_lines" align="right"><pre>1</pre></td>
<td class="listing_code"><pre class="programlisting"><span class="gtkdoc opt">(</span>foo <span class="gtkdoc opt">+</span> <span class="number">1</span><span class="gtkdoc opt">) *</span> <span class="number">3</span> <span class="gtkdoc opt">-</span> <span class="number">2</span> <span class="gtkdoc opt">*</span> bar</pre></td>
</tr>
</tbody>
</table>
</div>
</div>
<p><br class="example-break">
</p>
<div class="example">
<a name="idp11555488"></a><p class="title"><b>Example 14. An expression with indexes</b></p>
<div class="example-contents">
<table class="listing_frame" border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td class="listing_lines" align="right"><pre>1</pre></td>
<td class="listing_code"><pre class="programlisting">array<span class="gtkdoc opt">[</span>array<span class="gtkdoc opt">[</span>idx <span class="gtkdoc opt">+</span> <span class="number">1</span><span class="gtkdoc opt">]] *</span> array<span class="gtkdoc opt">[</span>idx<span class="gtkdoc opt">]</span></pre></td>
</tr>
</tbody>
</table>
</div>
</div>
<p><br class="example-break">
Of course, the latter examples supposes that the environment contains the
variables <em class="parameter"><code>foo</code></em>, <em class="parameter"><code>bar</code></em>, <em class="parameter"><code>array</code></em> and <em class="parameter"><code>idx</code></em>, and that they contains appropriate
values for latter evaluation.
</p>
</div>
<div class="refsect1">
<a name="ctpl-CtplLexerExpr.details"></a><h2>Details</h2>
<div class="refsect2">
<a name="CTPL-LEXER-EXPR-ERROR:CAPS"></a><h3>CTPL_LEXER_EXPR_ERROR</h3>
<pre class="programlisting">#define CTPL_LEXER_EXPR_ERROR (ctpl_lexer_expr_error_quark ())
</pre>
<p>
Error domain of <a class="link" href="ctpl-CtplLexerExpr.html#CtplLexerExprError" title="enum CtplLexerExprError"><span class="type">CtplLexerExprError</span></a>.
</p>
</div>
<hr>
<div class="refsect2">
<a name="CtplLexerExprError"></a><h3>enum CtplLexerExprError</h3>
<pre class="programlisting">typedef enum _CtplLexerExprError
{
CTPL_LEXER_EXPR_ERROR_MISSING_OPERAND,
CTPL_LEXER_EXPR_ERROR_MISSING_OPERATOR,
CTPL_LEXER_EXPR_ERROR_SYNTAX_ERROR,
CTPL_LEXER_EXPR_ERROR_FAILED
} CtplLexerExprError;
</pre>
<p>
Error codes that lexing functions can throw, from the <a class="link" href="ctpl-CtplLexerExpr.html#CTPL-LEXER-EXPR-ERROR:CAPS" title="CTPL_LEXER_EXPR_ERROR"><code class="literal">CTPL_LEXER_EXPR_ERROR</code></a>
domain.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><a name="CTPL-LEXER-EXPR-ERROR-MISSING-OPERAND:CAPS"></a><span class="term"><code class="literal">CTPL_LEXER_EXPR_ERROR_MISSING_OPERAND</code></span></p></td>
<td>An operand is missing
</td>
</tr>
<tr>
<td><p><a name="CTPL-LEXER-EXPR-ERROR-MISSING-OPERATOR:CAPS"></a><span class="term"><code class="literal">CTPL_LEXER_EXPR_ERROR_MISSING_OPERATOR</code></span></p></td>
<td>An operator is missing
</td>
</tr>
<tr>
<td><p><a name="CTPL-LEXER-EXPR-ERROR-SYNTAX-ERROR:CAPS"></a><span class="term"><code class="literal">CTPL_LEXER_EXPR_ERROR_SYNTAX_ERROR</code></span></p></td>
<td>The expression has invalid syntax
</td>
</tr>
<tr>
<td><p><a name="CTPL-LEXER-EXPR-ERROR-FAILED:CAPS"></a><span class="term"><code class="literal">CTPL_LEXER_EXPR_ERROR_FAILED</code></span></p></td>
<td>An error occurred without any
precision on what failed.
</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2">
<a name="ctpl-lexer-expr-lex"></a><h3>ctpl_lexer_expr_lex ()</h3>
<pre class="programlisting"><a class="link" href="ctpl-CtplToken.html#CtplTokenExpr" title="CtplTokenExpr"><span class="returnvalue">CtplTokenExpr</span></a> * ctpl_lexer_expr_lex (<em class="parameter"><code><a class="link" href="ctpl-CtplInputStream.html#CtplInputStream" title="CtplInputStream"><span class="type">CtplInputStream</span></a> *stream</code></em>,
<em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-Error-Reporting.html#GError"><span class="type">GError</span></a> **error</code></em>);</pre>
<p>
Tries to lex the expression in <em class="parameter"><code>stream</code></em>.
If you want to lex a <a class="link" href="ctpl-CtplInputStream.html#CtplInputStream" title="CtplInputStream"><span class="type">CtplInputStream</span></a> that (may) hold other data after the
expression, see <a class="link" href="ctpl-CtplLexerExpr.html#ctpl-lexer-expr-lex-full" title="ctpl_lexer_expr_lex_full ()"><code class="function">ctpl_lexer_expr_lex_full()</code></a>.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>stream</code></em> :</span></p></td>
<td>A <a class="link" href="ctpl-CtplInputStream.html#CtplInputStream" title="CtplInputStream"><span class="type">CtplInputStream</span></a> from where read the expression</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>error</code></em> :</span></p></td>
<td>Return location for errors, or <a href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> to ignore them.</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td>A new <a class="link" href="ctpl-CtplToken.html#CtplTokenExpr" title="CtplTokenExpr"><span class="type">CtplTokenExpr</span></a> or <a href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> on error.</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2">
<a name="ctpl-lexer-expr-lex-full"></a><h3>ctpl_lexer_expr_lex_full ()</h3>
<pre class="programlisting"><a class="link" href="ctpl-CtplToken.html#CtplTokenExpr" title="CtplTokenExpr"><span class="returnvalue">CtplTokenExpr</span></a> * ctpl_lexer_expr_lex_full (<em class="parameter"><code><a class="link" href="ctpl-CtplInputStream.html#CtplInputStream" title="CtplInputStream"><span class="type">CtplInputStream</span></a> *stream</code></em>,
<em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gboolean"><span class="type">gboolean</span></a> lex_all</code></em>,
<em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-Error-Reporting.html#GError"><span class="type">GError</span></a> **error</code></em>);</pre>
<p>
Tries to lex the expression in <em class="parameter"><code>stream</code></em>.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>stream</code></em> :</span></p></td>
<td>A <a class="link" href="ctpl-CtplInputStream.html#CtplInputStream" title="CtplInputStream"><span class="type">CtplInputStream</span></a>
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>lex_all</code></em> :</span></p></td>
<td>Whether to lex <em class="parameter"><code>stream</code></em> until EOF or until the end of a valid
expression. This is useful for expressions inside other data.</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>error</code></em> :</span></p></td>
<td>Return location for errors, or <a href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> to ignore them.</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td>A new <a class="link" href="ctpl-CtplToken.html#CtplTokenExpr" title="CtplTokenExpr"><span class="type">CtplTokenExpr</span></a> or <a href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> on error.</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2">
<a name="ctpl-lexer-expr-lex-string"></a><h3>ctpl_lexer_expr_lex_string ()</h3>
<pre class="programlisting"><a class="link" href="ctpl-CtplToken.html#CtplTokenExpr" title="CtplTokenExpr"><span class="returnvalue">CtplTokenExpr</span></a> * ctpl_lexer_expr_lex_string (<em class="parameter"><code>const <a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gchar"><span class="type">gchar</span></a> *expr</code></em>,
<em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gssize"><span class="type">gssize</span></a> len</code></em>,
<em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-Error-Reporting.html#GError"><span class="type">GError</span></a> **error</code></em>);</pre>
<p>
Tries to lex the expression in <em class="parameter"><code>expr</code></em>.
See <a class="link" href="ctpl-CtplLexerExpr.html#ctpl-lexer-expr-lex" title="ctpl_lexer_expr_lex ()"><code class="function">ctpl_lexer_expr_lex()</code></a>.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>expr</code></em> :</span></p></td>
<td>An expression</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>len</code></em> :</span></p></td>
<td>Length of <em class="parameter"><code>expr</code></em> or -1 to read the whole string</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>error</code></em> :</span></p></td>
<td>Return location for errors, or <a href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> to ignore them</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td>A new <a class="link" href="ctpl-CtplToken.html#CtplTokenExpr" title="CtplTokenExpr"><span class="type">CtplTokenExpr</span></a> or <a href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> on error.</td>
</tr>
</tbody>
</table></div>
</div>
</div>
</div>
<div class="footer">
<hr>
Generated by GTK-Doc V1.17</div>
</body>
</html>
|