OpenCores
URL https://opencores.org/ocsvn/theia_gpu/theia_gpu/trunk

Subversion Repositories theia_gpu

[/] [theia_gpu/] [branches/] [new_compiler/] [scanner.l] - Blame information for rev 220

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 207 diegovalve
%{
2
 
3
/**********************************************************************************
4
Theia, Ray Cast Programable graphic Processing Unit.
5
Copyright (C) 2012  Diego Valverde (diego.valverde.g@gmail.com)
6
 
7
This program is free software; you can redistribute it and/or
8
modify it under the terms of the GNU General Public License
9
as published by the Free Software Foundation; either version 2
10
of the License, or (at your option) any later version.
11
 
12
This program is distributed in the hope that it will be useful,
13
but WITHOUT ANY WARRANTY; without even the implied warranty of
14
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
GNU General Public License for more details.
16
 
17
You should have received a copy of the GNU General Public License
18
along with this program; if not, write to the Free Software
19
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
20
 
21
***********************************************************************************/
22
 
23
        #include "Scanner.h"
24
        // used to keep track of location
25
        #define YY_USER_ACTION yylloc->columns(yyleng);
26
        int LineNumber = 1;
27
%}
28
 
29
%option nodefault yyclass="Scanner" noyywrap c++
30
 
31
comment     "//"(.*)*\n
32
separator   ([ \t""])+
33
character   [a-zA-Z]
34
hexchar     [a-fA-F]
35
digit       [0-9]
36
decconstant    {digit}({digit})*
37
hexconstant 0x({digit}|{hexchar})+
38
binconstant 0b(1|0)+
39
registry    (r|R)({digit})+
40
identifier ([a-wA-Z])({character}|{digit})*
41
 
42
 
43
%%
44
 
45
%{
46
        yylloc->step();
47
%}
48
 
49
{comment}    {yylloc->lines(); ;LineNumber++; ;}
50
"\n"         {yylloc->lines(); ;LineNumber++;}
51
{separator}  {/* do nothing */}
52
{decconstant}   { *yylval = yytext; return Theia::Parser::token::DECCONST; }
53
{hexconstant}   { *yylval = yytext; return Theia::Parser::token::HEXCONST; }
54
{binconstant}   { *yylval = yytext; return Theia::Parser::token::BINCONST; }
55
"sqrt"                  {return Theia::Parser::token::SQRT;}
56
"if"            {return Theia::Parser::token::IF;}
57
"else"            {return Theia::Parser::token::ELSE;}
58
"function"   {return Theia::Parser::token::FUNCTION;}
59
"jmp"        {return Theia::Parser::token::JMP;}
60
"return"          {return Theia::Parser::token::RETURN;}
61
"exit"         {return Theia::Parser::token::EXIT;}
62
"vector"         {return Theia::Parser::token::AUTO;}
63
"("            {return Theia::Parser::token::OPEN_ROUND_BRACE;}
64
")"            {return Theia::Parser::token::CLOSE_ROUND_BRACE;}
65
"{"            {return Theia::Parser::token::OPEN_BRACE;}
66
"}"            {return Theia::Parser::token::CLOSE_BRACE;}
67
"-"          {*yylval = yytext;return Theia::Parser::token::MINUS;   }
68
"=="          {return Theia::Parser::token::EQUAL; }
69
"!="          {return Theia::Parser::token::NOT_EQUAL; }
70
"scale"           {return Theia::Parser::token::SCALE; }
71
"unscale"         {return Theia::Parser::token::UNSCALE; }
72
"using"           {return Theia::Parser::token::USING; }
73
"fixed_point_arithmetic" {return Theia::Parser::token::FIXED_POINT; }
74
"<="          {return Theia::Parser::token::LESS_OR_EQUAL_THAN; }
75
">="          {return Theia::Parser::token::GREATER_OR_EQUAL_THAN; }
76
"="          {return Theia::Parser::token::ASSIGN; }
77
">"          {return Theia::Parser::token::GREATER_THAN; }
78
"<"          {return Theia::Parser::token::LESS_THAN; }
79
"["                      {return Theia::Parser::token::OPEN_SQUARE_BRACE; }
80
"]"          {return Theia::Parser::token::CLOSE_SQUARE_BRACE; }
81
"*"           {return Theia::Parser::token::MUL;   }
82
"/"          {return Theia::Parser::token::DIV;   }
83
"+"          {return Theia::Parser::token::ADD;   }
84
";"          {return Theia::Parser::token::EOS;   }
85
","          {return Theia::Parser::token::COMMA;   }
86
"."          {return Theia::Parser::token::DOT;   }
87
x                {*yylval = yytext;return Theia::Parser::token::TK_X;  }
88
y            {*yylval = yytext;return Theia::Parser::token::TK_Y;  }
89
z            {*yylval = yytext;return Theia::Parser::token::TK_Z;  }
90
"n"              {*yylval = yytext;return Theia::Parser::token::TK_N;  }
91
{registry} { *yylval = yytext; return Theia::Parser::token::REG;}
92
{identifier} {*yylval = yytext; return Theia::Parser::token::IDENTIFIER;}
93
.                    {
94
                                std::ostringstream ret;
95
                                ret << "Unknown Indetifier at line " << LineNumber << " '" << yytext << "'\n";
96
                                throw ret.str();
97
                         };
98
%%

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.