001: /*
002: * xtc - The eXTensible Compiler
003: * Copyright (C) 2004-2006 Robert Grimm
004: *
005: * This program is free software; you can redistribute it and/or
006: * modify it under the terms of the GNU General Public License
007: * version 2 as published by the Free Software Foundation.
008: *
009: * This program is distributed in the hope that it will be useful,
010: * but WITHOUT ANY WARRANTY; without even the implied warranty of
011: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
012: * GNU General Public License for more details.
013: *
014: * You should have received a copy of the GNU General Public License
015: * along with this program; if not, write to the Free Software
016: * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
017: * USA.
018: */
019: package xtc.parser;
020:
021: import java.util.ArrayList;
022: import java.util.List;
023:
024: import xtc.type.Type;
025:
026: /**
027: * The meta-data for a production necessary for code generation.
028: *
029: * @author Robert Grimm
030: * @version $Revision: 1.25 $
031: */
032: public class MetaData {
033:
034: /** Flag for whether the production requires a character variable. */
035: public boolean requiresChar = false;
036:
037: /** Flag for whether the production requires an index variable. */
038: public boolean requiresIndex = false;
039:
040: /** Flag for whether the production requires a result variable. */
041: public boolean requiresResult = false;
042:
043: /** Flag for whether the production requires a predicate index variable. */
044: public boolean requiresPredIndex = false;
045:
046: /** Flag for whether the production requires a predicate result variable. */
047: public boolean requiresPredResult = false;
048:
049: /** Flag for whether the production requires a predicate matched variable. */
050: public boolean requiresPredMatch = false;
051:
052: /** Flag for whether the production requires a base index variable. */
053: public boolean requiresBaseIndex = false;
054:
055: /** The number of times this production is referenced within the grammar. */
056: public int usageCount = 0;
057:
058: /** The number of times this production references itself. */
059: public int selfCount = 0;
060:
061: /**
062: * The structure of repetitions for this production. The length of
063: * the list indicates the maximum depth of nested repetitions. Each
064: * list element is a <code>Boolean</code>, which is
065: * <code>true</code> if any of the repetitions at that level has its
066: * {@link Repetition#once} flag set.
067: */
068: public List<Boolean> repetitions;
069:
070: /**
071: * The structure of bound repetitions for this production. The
072: * length of the list indicates the maximum depth of nested
073: * repetitions. Each list element is the (unified) type of all
074: * lists at that level; it is <code>null</code> if none of the
075: * repetitions has a bound semantic value.
076: */
077: public List<Type> boundRepetitions;
078:
079: /**
080: * The structure of options for this production. The length of the
081: * list indicates the maximum depth of nested options. Each list
082: * element is the (unified) type of all bound options at that level;
083: * it is <code>null</code> if none of the options has a bound
084: * semantic value.
085: */
086: public List<Type> options;
087:
088: /**
089: * Create a new meta-data record.
090: *
091: * <p />Note that the constructor allocates a new list for the
092: * {@link #repetitions}, {@link #boundRepetitions} and {@link
093: * #options} fields.
094: */
095: public MetaData() {
096: repetitions = new ArrayList<Boolean>();
097: boundRepetitions = new ArrayList<Type>();
098: options = new ArrayList<Type>();
099: }
100:
101: }
|