KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > jasmin > ReservedWords


1 /* --- Copyright Jonathan Meyer 1996. All rights reserved. -----------------
2  > File: jasmin/src/jasmin/ReservedWords.java
3  > Purpose: Reserved words for Jasmin
4  > Author: Jonathan Meyer, 10 July 1996
5  */

6
7 package jasmin;
8
9 import java.util.Hashtable JavaDoc;
10 import java_cup.runtime.*;
11
12 abstract class ReservedWords {
13     static Hashtable JavaDoc reserved_words;
14
15     // we can't pull this hashtable trick anymore, no more recycling allowed!
16
public static Symbol get(String JavaDoc name) {
17         Symbol template = (Symbol)reserved_words.get(name);
18         if (template != null)
19             return new Symbol(template.sym);
20         else
21             return null;
22     }
23
24     public static boolean contains(String JavaDoc name) {
25         return reserved_words.get(name) != null;
26     }
27
28     //
29
// scanner initializer - sets up reserved_words table
30
//
31
static {
32         reserved_words = new Hashtable JavaDoc();
33
34         // Jasmin directives
35
reserved_words.put(".catch", new Symbol(sym.DCATCH));
36         reserved_words.put(".class", new Symbol(sym.DCLASS));
37         reserved_words.put(".end", new Symbol(sym.DEND));
38         reserved_words.put(".field", new Symbol(sym.DFIELD));
39         reserved_words.put(".implements", new Symbol(sym.DIMPLEMENTS));
40         reserved_words.put(".interface", new Symbol(sym.DINTERFACE));
41         reserved_words.put(".limit", new Symbol(sym.DLIMIT));
42         reserved_words.put(".line", new Symbol(sym.DLINE));
43         reserved_words.put(".method", new Symbol(sym.DMETHOD));
44         reserved_words.put(".set", new Symbol(sym.DSET));
45         reserved_words.put(".source", new Symbol(sym.DSOURCE));
46         reserved_words.put(".super", new Symbol(sym.DSUPER));
47         reserved_words.put(".no_super", new Symbol(sym.DNOSUPER));
48         reserved_words.put(".throws", new Symbol(sym.DTHROWS));
49         reserved_words.put(".var", new Symbol(sym.DVAR));
50         
51     reserved_words.put(".class_attribute", new Symbol(sym.DCLASS_ATTR));
52         reserved_words.put(".field_attribute", new Symbol(sym.DFIELD_ATTR));
53         reserved_words.put(".method_attribute", new Symbol(sym.DMETHOD_ATTR));
54         reserved_words.put(".code_attribute", new Symbol(sym.DCODE_ATTR));
55         reserved_words.put(".inner_class_attr", new Symbol(sym.DINNER_CLASS_ATTR));
56         reserved_words.put(".inner_class_spec_attr", new Symbol(sym.DINNER_CLASS_SPEC_ATTR));
57         reserved_words.put(".synthetic", new Symbol(sym.DSYNTHETIC));
58         reserved_words.put(".enclosing_method_attr", new Symbol(sym.DENCLOSING_METH));
59         reserved_words.put(".deprecated", new Symbol(sym.DDEPRECATED));
60         reserved_words.put(".signature_attr", new Symbol(sym.DSIG_ATTR));
61         
62         // annotation related directives
63
reserved_words.put(".runtime_visible_annotation", new Symbol(sym.DRUNTIME_VISIBLE));
64         reserved_words.put(".runtime_invisible_annotation", new Symbol(sym.DRUNTIME_INVISIBLE));
65         reserved_words.put(".runtime_param_visible_annotation", new Symbol(sym.DRUNTIME_PARAM_VISIBLE));
66         reserved_words.put(".runtime_param_invisible_annotation", new Symbol(sym.DRUNTIME_PARAM_INVISIBLE));
67         reserved_words.put(".annotation_attr", new Symbol(sym.DANNOTATION_ATTR));
68         reserved_words.put(".param", new Symbol(sym.DPARAM_ANNOT_ATTR));
69         reserved_words.put(".annotation", new Symbol(sym.DANNOTATION));
70         reserved_words.put(".int_kind", new Symbol(sym.INT_KIND));
71         reserved_words.put(".byte_kind", new Symbol(sym.BYTE_KIND));
72         reserved_words.put(".char_kind", new Symbol(sym.CHAR_KIND));
73         reserved_words.put(".short_kind", new Symbol(sym.SHORT_KIND));
74         reserved_words.put(".bool_kind", new Symbol(sym.BOOL_KIND));
75         reserved_words.put(".str_kind", new Symbol(sym.STR_KIND));
76         reserved_words.put(".long_kind", new Symbol(sym.LONG_KIND));
77         reserved_words.put(".doub_kind", new Symbol(sym.DOUB_KIND));
78         reserved_words.put(".float_kind", new Symbol(sym.FLOAT_KIND));
79         reserved_words.put(".enum_kind", new Symbol(sym.ENUM_KIND));
80         reserved_words.put(".ann_kind", new Symbol(sym.ANN_KIND));
81         reserved_words.put(".arr_kind", new Symbol(sym.ARR_KIND));
82         reserved_words.put(".cls_kind", new Symbol(sym.CLS_KIND));
83         reserved_words.put(".arr_elem", new Symbol(sym.DARR_ELEM));
84         reserved_words.put(".annot_elem", new Symbol(sym.DANNOT_ELEM));
85         reserved_words.put(".elem", new Symbol(sym.DELEM));
86         reserved_words.put(".annotation_default", new Symbol(sym.DANNOT_DEFAULT));
87         
88         
89         // reserved_words used in Jasmin directives
90
reserved_words.put("from", new Symbol(sym.FROM));
91         reserved_words.put("method", new Symbol(sym.METHOD));
92         reserved_words.put("to", new Symbol(sym.TO));
93         reserved_words.put("is", new Symbol(sym.IS));
94         reserved_words.put("using", new Symbol(sym.USING));
95
96         // Special-case instructions
97
reserved_words.put("tableswitch", new Symbol(sym.TABLESWITCH));
98         reserved_words.put("lookupswitch", new Symbol(sym.LOOKUPSWITCH));
99         reserved_words.put("default", new Symbol(sym.DEFAULT));
100
101         // Access flags
102
reserved_words.put("public", new Symbol(sym.PUBLIC));
103         reserved_words.put("private", new Symbol(sym.PRIVATE));
104         reserved_words.put("protected", new Symbol(sym.PROTECTED));
105         reserved_words.put("static", new Symbol(sym.STATIC));
106         reserved_words.put("final", new Symbol(sym.FINAL));
107         reserved_words.put("synchronized", new Symbol(sym.SYNCHRONIZED));
108         reserved_words.put("volatile", new Symbol(sym.VOLATILE));
109         reserved_words.put("transient", new Symbol(sym.TRANSIENT));
110         reserved_words.put("native", new Symbol(sym.NATIVE));
111         reserved_words.put("interface", new Symbol(sym.INTERFACE));
112         reserved_words.put("abstract", new Symbol(sym.ABSTRACT));
113         reserved_words.put("strictfp", new Symbol(sym.STRICTFP));
114         reserved_words.put("annotation", new Symbol(sym.ANNOTATION));
115         reserved_words.put("enum", new Symbol(sym.ENUM));
116     }
117 }
118
Popular Tags