slicc: removed unused atomics code from StateMachine
[gem5.git] / src / mem / slicc / parser / lexer.ll
1
2 /*
3 * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are
8 * met: redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer;
10 * redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution;
13 * neither the name of the copyright holders nor the names of its
14 * contributors may be used to endorse or promote products derived from
15 * this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 */
29
30 /*
31 * $Id$
32 */
33
34 %{
35
36 #include <assert.h>
37 #include "mem/slicc/ast/ASTs.hh"
38 #include "parser.hh"
39 #include <string>
40
41 extern "C" int yylex();
42 extern "C" void yyerror();
43 extern "C" int yywrap()
44 {
45 return 1;
46 }
47
48 %}
49 %x CMNT
50 %x IMBEDED
51 %%
52
53 [\t ]+ /* Ignore whitespace */
54 [\n] { g_line_number++; }
55 "//".*[\n] { g_line_number++; } /* C++ style comments */
56
57 "/*" BEGIN CMNT;
58 <CMNT>. ;
59 <CMNT>\n { g_line_number++; }
60 <CMNT>"*/" { BEGIN INITIAL; }
61
62 true { yylval.str_ptr = new string(yytext); return LIT_BOOL; }
63 false { yylval.str_ptr = new string(yytext); return LIT_BOOL; }
64 global { return GLOBAL_DECL; }
65 machine { return MACHINE_DECL; }
66 in_port { return IN_PORT_DECL; }
67 out_port { return OUT_PORT_DECL; }
68 action { return ACTION_DECL; }
69 transition { return TRANSITION_DECL; }
70 structure { return STRUCT_DECL; }
71 external_type { return EXTERN_TYPE_DECL; }
72 enumeration { return ENUM_DECL; }
73 peek { return PEEK; }
74 enqueue { return ENQUEUE; }
75 copy_head { return COPY_HEAD; }
76 check_allocate { return CHECK_ALLOCATE; }
77 check_stop_slots { return CHECK_STOP_SLOTS; }
78 if { return IF; }
79 else { return ELSE; }
80 return { return RETURN; }
81 THIS { return THIS; }
82 CHIP { return CHIP; }
83 void { yylval.str_ptr = new string(yytext); return VOID; }
84 new { return NEW; }
85
86 == { yylval.str_ptr = new string(yytext); return EQ; }
87 != { yylval.str_ptr = new string(yytext); return NE; }
88 [<] { yylval.str_ptr = new string(yytext); return '<'; }
89 [>] { yylval.str_ptr = new string(yytext); return '>'; }
90 [<][<] { yylval.str_ptr = new string(yytext); return LEFTSHIFT; }
91 [>][>] { yylval.str_ptr = new string(yytext); return RIGHTSHIFT; }
92 [<][=] { yylval.str_ptr = new string(yytext); return LE; }
93 [>][=] { yylval.str_ptr = new string(yytext); return GE; }
94 [!] { yylval.str_ptr = new string(yytext); return NOT; }
95 [&][&] { yylval.str_ptr = new string(yytext); return AND; }
96 [|][|] { yylval.str_ptr = new string(yytext); return OR; }
97 [+] { yylval.str_ptr = new string(yytext); return PLUS; }
98 [-] { yylval.str_ptr = new string(yytext); return DASH; }
99 [*] { yylval.str_ptr = new string(yytext); return STAR; }
100 [/] { yylval.str_ptr = new string(yytext); return SLASH; }
101 :: { return DOUBLE_COLON; }
102 [:] { return ':'; }
103 [;] { return SEMICOLON; }
104 [[] { return '['; }
105 []] { return ']'; }
106 [{] { return '{'; }
107 [}] { return '}'; }
108 [(] { return '('; }
109 [)] { return ')'; }
110 [,] { return ','; }
111 [=] { return '='; }
112 := { return ASSIGN; }
113 [.] { return DOT; }
114
115 [0-9]*[.][0-9]* { yylval.str_ptr = new string(yytext); return FLOATNUMBER; }
116 [0-9]* { yylval.str_ptr = new string(yytext); return NUMBER; }
117
118 [a-zA-Z_][a-zA-Z_0-9]{0,50} { yylval.str_ptr = new string(yytext); return IDENT; }
119 \"[^"\n]*\" { yytext[strlen(yytext)-1] = '\0'; yylval.str_ptr = new string(yytext+1); return STRING; }
120 \'[^'\n]*\' { yytext[strlen(yytext)-1] = '\0'; yylval.str_ptr = new string(yytext+1); return STRING; }
121
122 . { return OTHER; } /* Need so that we handle all characters */
123
124 %%
125