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

Subversion Repositories theia_gpu

[/] [theia_gpu/] [branches/] [beta_2.0/] [compiler/] [src/] [vp_compiler/] [scanner.l] - Blame information for rev 216

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

Line No. Rev Author Line
1 216 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
"while"          {return Theia::Parser::token::WHILE;}
59
"&"			 {return Theia::Parser::token::BITWISE_AND;}
60
"|"                      {return Theia::Parser::token::BITWISE_OR;}
61
"function"   {return Theia::Parser::token::FUNCTION;}
62
"jmp"        {return Theia::Parser::token::JMP;}
63
"return"          {return Theia::Parser::token::RETURN;}
64
"exit"         {return Theia::Parser::token::EXIT;}
65
"vector"         {return Theia::Parser::token::AUTO;}
66
"thread"       {return Theia::Parser::token::THREAD;}
67
"start"       {return Theia::Parser::token::START;}
68
"("            {return Theia::Parser::token::OPEN_ROUND_BRACE;}
69
")"            {return Theia::Parser::token::CLOSE_ROUND_BRACE;}
70
"{"            {return Theia::Parser::token::OPEN_BRACE;}
71
"}"            {return Theia::Parser::token::CLOSE_BRACE;}
72
"-"          {*yylval = yytext;return Theia::Parser::token::MINUS;   }
73
"=="          {return Theia::Parser::token::EQUAL; }
74
"!="          {return Theia::Parser::token::NOT_EQUAL; }
75
"scale"           {return Theia::Parser::token::SCALE; }
76
"unscale"         {return Theia::Parser::token::UNSCALE; }
77
"using"           {return Theia::Parser::token::USING; }
78
"out"         {return Theia::Parser::token::OUT; }
79
"fixed_point_arithmetic" {return Theia::Parser::token::FIXED_POINT; }
80
"<="          {return Theia::Parser::token::LESS_OR_EQUAL_THAN; }
81
">="          {return Theia::Parser::token::GREATER_OR_EQUAL_THAN; }
82
"="          {return Theia::Parser::token::ASSIGN; }
83
">"          {return Theia::Parser::token::GREATER_THAN; }
84
"<"          {return Theia::Parser::token::LESS_THAN; }
85
"["                      {return Theia::Parser::token::OPEN_SQUARE_BRACE; }
86
"]"          {return Theia::Parser::token::CLOSE_SQUARE_BRACE; }
87
"*"           {return Theia::Parser::token::MUL;   }
88
"/"          {return Theia::Parser::token::DIV;   }
89
"+="         {return Theia::Parser::token::ADD_EQ; }
90
"+"          {return Theia::Parser::token::ADD;   }
91
";"          {return Theia::Parser::token::EOS;   }
92
","          {return Theia::Parser::token::COMMA;   }
93
"."          {return Theia::Parser::token::DOT;   }
94
x                {*yylval = yytext;return Theia::Parser::token::TK_X;  }
95
y            {*yylval = yytext;return Theia::Parser::token::TK_Y;  }
96
z            {*yylval = yytext;return Theia::Parser::token::TK_Z;  }
97
"n"              {*yylval = yytext;return Theia::Parser::token::TK_N;  }
98
{registry} { *yylval = yytext; return Theia::Parser::token::REG;}
99
{identifier} {*yylval = yytext; return Theia::Parser::token::IDENTIFIER;}
100
.                    {
101
                                std::ostringstream ret;
102
                                ret << "Unknown Indetifier at line " << LineNumber << " '" << yytext << "'\n";
103
                                throw ret.str();
104
                         };
105
%%

powered by: WebSVN 2.1.0

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