/*
* @(#)$Id: TREXGrammar.java,v 1.9 2001/10/12 01:36:59 Bear Exp $
*
* Copyright 2001 Sun Microsystems, Inc. All Rights Reserved.
*
* This software is the proprietary information of Sun Microsystems, Inc.
* Use is subject to license terms.
*
*/
package com.sun.msv.grammar.trex;
import com.sun.msv.grammar.*;
import com.sun.msv.reader.datatype.DataTypeVocabularyMap;
/**
* TREX grammar, which is expressed as <grammar> element.
*
* <p>
* The <code>exp</code> field keeps the start pattern.
*
* @author <a href="mailto:kohsuke.kawaguchi@eng.sun.com">Kohsuke KAWAGUCHI</a>
*/
public class TREXGrammar extends ReferenceExp implements Grammar{
static final public class RefContainer extends ReferenceContainer {
public ReferenceExp getOrCreate( String name ) {
return super._getOrCreate(name);
}
protected ReferenceExp createReference( String name ) {
return new ReferenceExp(name);
}
}
/** named patterns which are defined by using <define> element.
*
* this is a map from pattern name to RefPattern object
*/
public final RefContainer namedPatterns = new RefContainer();
/** gets the start pattern.
*
* The pattern defined under <start> element.
* This pattern will be used to verify document element.
*/
public Expression getTopLevel() { return this.exp; }
/** ExpressionPool that is associated with this grammar */
public final ExpressionPool pool;
public ExpressionPool getPool() { return pool; }
/** in case of nested grammar, this variable points to the parent grammar.
* Otherwise null.
*/
protected final TREXGrammar parentGrammar;
/**
* gets a parent TREXGrammar.
*
* In case of nested grammar, the parent grammar will be returned.
* Otherwise, it returns null.
*/
public final TREXGrammar getParentGrammar() { return parentGrammar; }
/**
* data type vocabularies used and defined by this grammar.
*/
public final DataTypeVocabularyMap dataTypes = new DataTypeVocabularyMap();
/**
*
* @param parentGrammar
* this object is used to resolve <ref> element with parent
* attribute.
*/
public TREXGrammar( ExpressionPool pool, TREXGrammar parentGrammar ) {
super(null);
this.pool = pool;
this.parentGrammar = parentGrammar;
}
public TREXGrammar( ExpressionPool pool ) { this(pool,null); }
public TREXGrammar() { this(new ExpressionPool(),null); }
}