source: trunk/orbital/gun-scanner.l @ 1519

Last change on this file since 1519 was 1512, checked in by sam, 11 years ago

build: fix the PS3 port by using our trig.h everywhere instead of stdlib
functions; also remove a lot of idiotic "using namespace std" from the
codebase.

File size: 2.2 KB
Line 
1%{
2//
3// Orbital
4//
5// Copyright: (c) 2009-2012 Cédric Lecacheur <jordx@free.fr>
6//            (c) 2009-2012 Benjamin Huet <huet.benjamin@gmail.com>
7//            (c) 2012 Sam Hocevar <sam@hocevar.net>
8//
9
10#if defined HAVE_CONFIG_H
11#   include "config.h"
12#endif
13
14#include <cstdlib>
15using std::exit;
16using std::malloc;
17using std::realloc;
18using std::free;
19
20#include "core.h"
21#include "loldebug.h"
22
23using namespace lol;
24
25#include "../gun-compiler.h"
26
27typedef orbital::GunParser::token token;
28typedef orbital::GunParser::token_type token_type;
29
30#ifndef YY_DECL
31#   define YY_DECL orbital::GunParser::token_type \
32        orbital::GunScanner::lex(orbital::GunParser::semantic_type* yylval, \
33                                 orbital::GunParser::location_type* yylloc)
34#endif
35
36#define yyterminate() return token::T_END
37#define YY_NO_UNISTD_H
38#define YY_USER_ACTION yylloc->columns(yyleng);
39%}
40
41%option c++ prefix="Gun"
42%option batch yywrap nounput stack
43
44%%
45
46%{
47    /* reset location at the beginning of yylex() */
48    yylloc->step();
49%}
50
51ai    { return token::T_AI; }
52pai   { return token::T_PAI; }
53ca    { return token::T_CA; }
54sa    { return token::T_SA; }
55tim   { return token::T_TIM; }
56so    { return token::T_SO; }
57rd    { return token::T_RD; }
58spd   { return token::T_SPD; }
59moda  { return token::T_MODA; }
60modb  { return token::T_MODB; }
61ffb   { return token::T_FFB; }
62ffp   { return token::T_FFP; }
63fb    { return token::T_FB; }
64fp    { return token::T_FP; }
65sk    { return token::T_SK; }
66loop  { return token::T_LOOP; }
67
68[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)? {
69        yylval->fval = std::atof(yytext); return token::NUMBER; }
70-     { return token_type('-'); }
71,     { return token_type(','); }
72[.\n] { /* ignore everything else */ }
73
74%%
75
76orbital::GunScanner::GunScanner(char const *command)
77    : GunFlexLexer(0, 0),
78      m_input(command)
79{
80}
81
82orbital::GunScanner::~GunScanner()
83{
84}
85
86int orbital::GunScanner::LexerInput(char* buf, int max_size)
87{
88    buf[0] = m_input[0];
89    if (buf[0])
90        ++m_input;
91    return buf[0] ? 1 : 0;
92}
93
94#ifdef yylex
95#undef yylex
96#endif
97int GunFlexLexer::yylex()
98{
99    std::cerr << "in GunFlexLexer::yylex() !" << std::endl;
100    return 0;
101}
102
103int GunFlexLexer::yywrap()
104{
105    return 1;
106}
107
Note: See TracBrowser for help on using the repository browser.