source: trunk/orbital/gun.l @ 1416

Last change on this file since 1416 was 1416, checked in by sam, 8 years ago

orbital: parser for the gun commands... fails to link because of flex.

File size: 1.4 KB
Line 
1/*
2 * Orbital
3 *
4 * Copyright: (c) 2012 Various People
5 */
6
7%option reentrant
8%option extra-type="char const **"
9%option noyywrap
10%option nounput
11%option batch
12
13%{
14#include "generated/gun-parser.hpp"
15
16#define yyterminate(yyscanner) return token::T_END
17
18#undef YY_INPUT
19#define YY_INPUT(buf, result, max_size) \
20    do { \
21        if ((*yyg->yyextra_r)[0]) \
22        { \
23            buf[0] = (*yyg->yyextra_r)[0]; \
24            (*yyg->yyextra_r)++; \
25            result = 1; \
26        } \
27        else \
28        { \
29            result = YY_NULL; \
30        } \
31    } while(0)
32%}
33
34%%
35
36%{
37    typedef yy::GunParser::token token;
38    typedef yy::GunParser::token_type token_type;
39%}
40
41ai    { return token::T_AI; }
42pai   { return token::T_PAI; }
43ca    { return token::T_CA; }
44sa    { return token::T_SA; }
45tim   { return token::T_TIM; }
46so    { return token::T_SO; }
47rd    { return token::T_RD; }
48spd   { return token::T_SPD; }
49moda  { return token::T_MODA; }
50modb  { return token::T_MODB; }
51ffb   { return token::T_FFB; }
52ffp   { return token::T_FFP; }
53fb    { return token::T_FB; }
54fp    { return token::T_FP; }
55sk    { return token::T_SK; }
56loop  { return token::T_LOOP; }
57
58[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)? {
59               yylval->fval = atof(yytext); return token::NUMBER; }
60-            { return token_type('-'); }
61,            { return token_type(','); }
62[.\n]        { /* ignore everything else */ }
63
64%%
65
Note: See TracBrowser for help on using the repository browser.