lib&src: remove detected warnings
[nit.git] / src / parser / xss / tokens.xss
1 $ // This file is part of NIT ( http://www.nitlanguage.org ).
2 $ //
3 $ // Copyright 2008 Jean Privat <jean@pryen.org>
4 $ // Based on algorithms developped for ( http://www.sablecc.org/ ).
5 $ //
6 $ // Licensed under the Apache License, Version 2.0 (the "License");
7 $ // you may not use this file except in compliance with the License.
8 $ // You may obtain a copy of the License at
9 $ //
10 $ //     http://www.apache.org/licenses/LICENSE-2.0
11 $ //
12 $ // Unless required by applicable law or agreed to in writing, software
13 $ // distributed under the License is distributed on an "AS IS" BASIS,
14 $ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 $ // See the License for the specific language governing permissions and
16 $ // limitations under the License.
17
18 $ template make_abs_tokens()
19 $ foreach {//token}
20 $ if {@parser_index}    
21 class @ename
22         super Token
23 end
24 $ end
25 $ end
26 class EOF
27         super Token
28 private init noinit do end
29 end
30 class PError
31         super EOF
32 private init noinit do end
33 end
34 $ end template
35
36 $ template make_tokens()
37
38 redef class Token
39     redef readable var _text: String
40
41     fun parser_index: Int is abstract
42 end
43
44 $ foreach {//token}
45 $ if {@parser_index}
46 redef class @ename
47     redef fun parser_index: Int
48     do
49         return @parser_index
50     end
51
52 $ if {not(@text)}
53     init init_tk(text: String, loc: Location)
54     do
55         _text = text
56 $ else
57     init init_tk(loc: Location)
58     do
59         _text = once "${sablecc:string2escaped_unicode(@text)}"
60 $ end
61                 _location = loc
62     end
63 end
64
65 $ end if
66 $ end foreach
67
68 redef class EOF
69     redef fun parser_index: Int
70     do
71         return ${tokens/eof/@parser_index}
72     end
73
74     init(loc: Location)
75     do
76         _text = ""
77                 _location = loc
78     end
79 end
80
81 redef class PError
82     readable var _message: String
83
84     init init_error(message: String, loc: Location)
85     do
86                 init(loc)
87                 _message = message
88     end
89 end
90
91 $ end template