01: /*
02: * xtc - The eXTensible Compiler
03: * Copyright (C) 2004-2006 Robert Grimm
04: *
05: * This program is free software; you can redistribute it and/or
06: * modify it under the terms of the GNU General Public License
07: * version 2 as published by the Free Software Foundation.
08: *
09: * This program is distributed in the hope that it will be useful,
10: * but WITHOUT ANY WARRANTY; without even the implied warranty of
11: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12: * GNU General Public License for more details.
13: *
14: * You should have received a copy of the GNU General Public License
15: * along with this program; if not, write to the Free Software
16: * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
17: * USA.
18: */
19: package xtc.parser;
20:
21: /**
22: * Visitor to create the production meta-data. Note that this visitor
23: * only creates the meta-data records, but does not fill in
24: * appropriate values. Further note that this visitor assumes that
25: * the entire grammar is contained in a single module.
26: *
27: * @see DeadProductionEliminator
28: * @see MetaDataSetter
29: *
30: * @author Robert Grimm
31: * @version $Revision: 1.11 $
32: */
33: public class MetaDataCreator extends xtc.tree.Visitor {
34:
35: /** Create a new meta-data creator. */
36: public MetaDataCreator() { /* Nothing to do. */
37: }
38:
39: /** Visit the specified grammar. */
40: public void visit(Module m) {
41: for (Production p : m.productions)
42: dispatch(p);
43: }
44:
45: /** Visit the specified production. */
46: public void visit(Production p) {
47: if (!p.hasProperty(Properties.META_DATA)) {
48: p.setProperty(Properties.META_DATA, new MetaData());
49: }
50: }
51:
52: }
|