public class Generator extends java.lang.Object implements ExpressionVisitorVoid
Modifier and Type | Field and Description |
---|---|
private AttributeExp[] |
attributeDecls
all AttributeExps in the grammar.
|
private int |
depth
current nest level (depth of elements).
|
private org.w3c.dom.Document |
domDoc |
private ElementExp[] |
elementDecls
all ElementExps in the grammar.
|
private boolean |
errorGenerated
this flag is set to true once an error is generated.
|
private java.util.Set |
idrefs
Text nodes of IDREFs that should be "patched" by IDs.
|
private java.util.Set |
ids
ID tokens that are used
|
private org.w3c.dom.Node |
node
current generated node
|
private GeneratorOption |
opts
generation parameters
|
private ExpressionPool |
pool |
Modifier | Constructor and Description |
---|---|
protected |
Generator(Expression exp,
org.w3c.dom.Document emptyDoc,
GeneratorOption opts) |
Modifier and Type | Method and Description |
---|---|
protected boolean |
cutBack()
returns true if generator should cut back.
|
static void |
generate(Expression exp,
org.w3c.dom.Document emptyDoc)
generates instance by using default settings.
|
static void |
generate(Expression exp,
org.w3c.dom.Document emptyDoc,
GeneratorOption opts)
generates instance by custom settings.
|
protected StringPair |
generateTypo(StringPair pair)
generates 'typo'.
|
private java.util.Vector |
getChildren(BinaryExp exp)
enumerates children of BinaryExp into a vector.
|
protected ContextProviderImpl |
getContext() |
private StringPair |
getName(NameClass nc)
generaets a name that satisfies given NameClass
|
private void |
noteError(java.lang.String error)
annotate DOM by adding a comment that an error is generated.
|
void |
onAnyString() |
void |
onAttribute(AttributeExp exp) |
void |
onChoice(ChoiceExp cp) |
void |
onConcur(ConcurExp exp) |
void |
onData(DataExp exp) |
void |
onElement(ElementExp exp) |
void |
onEpsilon() |
void |
onInterleave(InterleaveExp ip) |
void |
onList(ListExp exp) |
void |
onMixed(MixedExp exp) |
void |
onNullSet() |
void |
onOneOrMore(OneOrMoreExp exp) |
void |
onOther(OtherExp exp) |
void |
onRef(ReferenceExp exp) |
void |
onSequence(SequenceExp exp) |
void |
onValue(ValueExp exp) |
void |
onZeroOrMore(OneOrMoreExp exp) |
private final GeneratorOption opts
private final ExpressionPool pool
private final org.w3c.dom.Document domDoc
private org.w3c.dom.Node node
private int depth
private boolean errorGenerated
private final java.util.Set ids
private final java.util.Set idrefs
private final ElementExp[] elementDecls
private final AttributeExp[] attributeDecls
protected Generator(Expression exp, org.w3c.dom.Document emptyDoc, GeneratorOption opts)
protected boolean cutBack()
public static void generate(Expression exp, org.w3c.dom.Document emptyDoc)
public static void generate(Expression exp, org.w3c.dom.Document emptyDoc, GeneratorOption opts)
private void noteError(java.lang.String error)
public void onEpsilon()
onEpsilon
in interface ExpressionVisitorVoid
public void onNullSet()
onNullSet
in interface ExpressionVisitorVoid
public void onSequence(SequenceExp exp)
onSequence
in interface ExpressionVisitorVoid
public void onInterleave(InterleaveExp ip)
onInterleave
in interface ExpressionVisitorVoid
public void onChoice(ChoiceExp cp)
onChoice
in interface ExpressionVisitorVoid
public void onMixed(MixedExp exp)
onMixed
in interface ExpressionVisitorVoid
public void onList(ListExp exp)
onList
in interface ExpressionVisitorVoid
public void onRef(ReferenceExp exp)
onRef
in interface ExpressionVisitorVoid
public void onOther(OtherExp exp)
onOther
in interface ExpressionVisitorVoid
public void onAttribute(AttributeExp exp)
onAttribute
in interface ExpressionVisitorVoid
public void onElement(ElementExp exp)
onElement
in interface ExpressionVisitorVoid
public void onAnyString()
onAnyString
in interface ExpressionVisitorVoid
public void onOneOrMore(OneOrMoreExp exp)
onOneOrMore
in interface ExpressionVisitorVoid
public void onZeroOrMore(OneOrMoreExp exp)
public void onValue(ValueExp exp)
onValue
in interface ExpressionVisitorVoid
public void onData(DataExp exp)
onData
in interface ExpressionVisitorVoid
public void onConcur(ConcurExp exp)
onConcur
in interface ExpressionVisitorVoid
protected ContextProviderImpl getContext()
private StringPair getName(NameClass nc)
private java.util.Vector getChildren(BinaryExp exp)
protected StringPair generateTypo(StringPair pair)