summaryrefslogtreecommitdiffstats
path: root/src/tools/qlalr/examples/qparser/calc.l
blob: 34792d0319a2e6d89834eb8e841fdebea4c3f76c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0

#include "calc_parser.h"
#include <cstdlib>

// Work around flex bug
#include <unistd.h>

#define YY_DECL int CalcParser::nextToken()
%}

%%

[ \t\n]     { /* eat me */ }
[0-9]+      { sym(1) = atoi (yytext); return Token_number; }
"("         { return Token_lparen; }
")"         { return Token_rparen; }
"+"         { return Token_plus; }
"-"         { return Token_minus; }

%%