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

Subversion Repositories theia_gpu

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

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
"if"            {return Theia::Parser::token::IF;}
56
"else"            {return Theia::Parser::token::ELSE;}
57
"while"          {return Theia::Parser::token::WHILE;}
58
"&"			 {return Theia::Parser::token::BITWISE_AND;}
59
"|"                      {return Theia::Parser::token::BITWISE_OR;}
60
"exit"         {return Theia::Parser::token::EXIT;}
61
"scalar"       {return Theia::Parser::token::SCALAR;}
62
"start"       {return Theia::Parser::token::START;}
63
"copy_data_block"       {return Theia::Parser::token::COPY_DATA_BLOCK;}
64
"copy_code_block"       {return Theia::Parser::token::COPY_CODE_BLOCK;}
65
block_transfer_in_progress"" {return Theia::Parser::token::BLOCK_TRANSFER_IN_PROGRESS;}
66
"("            {return Theia::Parser::token::OPEN_ROUND_BRACE;}
67
")"            {return Theia::Parser::token::CLOSE_ROUND_BRACE;}
68
"{"            {return Theia::Parser::token::OPEN_BRACE;}
69
"}"            {return Theia::Parser::token::CLOSE_BRACE;}
70
"-"          {*yylval = yytext;return Theia::Parser::token::MINUS;   }
71
"=="          {return Theia::Parser::token::EQUAL; }
72
"!="          {return Theia::Parser::token::NOT_EQUAL; }
73
"<="          {return Theia::Parser::token::LESS_OR_EQUAL_THAN; }
74
">="          {return Theia::Parser::token::GREATER_OR_EQUAL_THAN; }
75
"="          {return Theia::Parser::token::ASSIGN; }
76
"<<"        { return Theia::Parser::token::SHL;}
77
">>"         { return Theia::Parser::token::SHR;}
78
">"          {return Theia::Parser::token::GREATER_THAN; }
79
"<"          {return Theia::Parser::token::LESS_THAN; }
80
"+"          {return Theia::Parser::token::ADD;   }
81
";"          {return Theia::Parser::token::EOS;   }
82
","          {return Theia::Parser::token::COMMA;   }
83
 
84
{identifier} {*yylval = yytext; return Theia::Parser::token::IDENTIFIER;}
85
.                    {
86
                                std::ostringstream ret;
87
                                ret << "Unknown Indetifier at line " << LineNumber << " '" << yytext << "'\n";
88
                                throw ret.str();
89
                         };
90
%%

powered by: WebSVN 2.1.0

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