Merge: doc: fixed some typos and other misc. corrections
[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 end
29 class PError
30         super EOF
31 end
32 class PLexerError
33         super PError
34 end
35 class PParserError
36         super PError
37 end
38 $ end template
39
40 $ template make_tokens()
41 $ foreach {//token}
42 $ if {@parser_index}
43 redef class @ename
44     redef fun parser_index: Int
45     do
46         return @parser_index
47     end
48
49     init init_tk(loc: Location)
50     do
51                 _location = loc
52     end
53 end
54
55 $ end if
56 $ end foreach
57
58 redef class EOF
59     redef fun parser_index: Int
60     do
61         return ${tokens/eof/@parser_index}
62     end
63 end
64
65 $ end template