Debian Codegraph @

src/tools/qlalr/examples/qparser/calc.l

raw
1
2 %option noyywrap
3
4 %{
5 /****************************************************************************
6 **
7 ** Copyright (C) 2016 The Qt Company Ltd.
8 ** Contact: https://www.qt.io/licensing/
9 **
10 ** This file is part of the QLALR tool of the Qt Toolkit.
11 **
12 ** $QT_BEGIN_LICENSE:GPL-EXCEPT$
13 ** Commercial License Usage
14 ** Licensees holding valid commercial Qt licenses may use this file in
15 ** accordance with the commercial license agreement provided with the
16 ** Software or, alternatively, in accordance with the terms contained in
17 ** a written agreement between you and The Qt Company. For licensing terms
18 ** and conditions see https://www.qt.io/terms-conditions. For further
19 ** information use the contact form at https://www.qt.io/contact-us.
20 **
21 ** GNU General Public License Usage
22 ** Alternatively, this file may be used under the terms of the GNU
23 ** General Public License version 3 as published by the Free Software
24 ** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
25 ** included in the packaging of this file. Please review the following
26 ** information to ensure the GNU General Public License requirements will
27 ** be met: https://www.gnu.org/licenses/gpl-3.0.html.
28 **
29 ** $QT_END_LICENSE$
30 **
31 ****************************************************************************/
32
33 #include "calc_parser.h"
34 #include <cstdlib>
35
36 // Work around flex bug
37 #include <unistd.h>
38
39 #define YY_DECL int CalcParser::nextToken()
40 %}
41
42 %%
43
44 [ \t\n] { /* eat me */ }
45 [0-9]+ { sym(1) = atoi (yytext); return Token_number; }
46 "(" { return Token_lparen; }
47 ")" { return Token_rparen; }
48 "+" { return Token_plus; }
49 "-" { return Token_minus; }
50
51 %%