ix.util.xml
Class BNFSyntax

java.lang.Object
  extended by ix.util.xml.XMLSyntax
      extended by ix.util.xml.BNFSyntax

public class BNFSyntax
extends XMLSyntax

Describes the (XML) syntax of data objects in a BNF-like style.


Nested Class Summary
(package private)  class BNFSyntax.Alternatives
          A RHS that represents a disjunction of BNFSyntax.Instances.
(package private)  class BNFSyntax.CollectionInstance
          Represents an instance of a collection class.
(package private)  class BNFSyntax.ConstraintTemplate
          A TemplateInstance based on a Constraint.
(package private)  class BNFSyntax.Instance
          A RHS that describes an instance of a class.
(package private)  class BNFSyntax.InstanceField
          Represents a field of a structure class.
(package private)  class BNFSyntax.ListInstance
           
(package private)  class BNFSyntax.Literal
          An instance used when only a (simple) literal value shoud appear.
(package private)  class BNFSyntax.MapEntryInstance
           
(package private)  class BNFSyntax.MapInstance
           
(package private)  class BNFSyntax.Nonterminal
          An Instance used when only the name of a nonterminal should appear.
(package private)  class BNFSyntax.RHS
          The right-hand side of a syntax rule.
(package private)  class BNFSyntax.Rule
          A syntax rule.
(package private)  class BNFSyntax.RuleList
          Represents the grammar that is being produced.
(package private)  class BNFSyntax.SetInstance
           
(package private)  class BNFSyntax.SimpleInstance
          Represents an instance of a primitve or atomic class.
(package private)  class BNFSyntax.StructInstance
          Represents an instance of a structure class.
(package private)  class BNFSyntax.TemplateInstance
          An instance that's already XML in the form of a JDOM Element.
 
Field Summary
protected  XMLTranslator noNamespaceXmlt
           
 
Fields inherited from class ix.util.xml.XMLSyntax
attributeFieldP, classSyntax, inheritance, xmlt
 
Constructor Summary
BNFSyntax()
           
BNFSyntax(XMLTranslator xmlt)
           
 
Method Summary
 void describeClass(java.lang.String className, java.io.PrintStream out)
          Prints the syntax for the indicated class and for any related classes that can be found.
static void main(java.lang.String[] argv)
          Test loop that repeatedly asks the user for a class name and prints a description of the syntax for objects of that class.
(package private)  BNFSyntax.Instance makeClassInstance(ClassDescr cd)
          Makes a description of an instance of a class.
(package private)  void printAlternatives(BNFSyntax.Alternatives alts, java.io.PrintStream out)
          Prints the BNF for a RHS that is an Alternatives.
(package private)  void printIndented(java.io.PrintStream out, int indent, java.lang.String text)
          Utility that breaks text into lines and prints them with the specified indentation.
(package private)  void printInstance(BNFSyntax.Instance inst, java.io.PrintStream out)
          Prints the BNF for a RHS that is an Instance -- a description of an instance of a class.
(package private)  void printRuleSyntax(BNFSyntax.RuleList list, java.io.PrintStream out)
          Prints the the BNF that corresponds to each rule.
(package private)  void printRuleSyntax(BNFSyntax.Rule rule, java.io.PrintStream out)
          Prints the BNF that corresponds to an individual rule.
(package private)  java.lang.String tagged(java.lang.String tag, java.lang.String contents)
          Returns a string representing an XML element.
 
Methods inherited from class ix.util.xml.XMLSyntax
attributeFields, collectListofClasses, elementFields, getClassDescr, getConstraintSyntaxList, getElementName, getElementName, getElementName, getEnumerationValues, getNTName, getNTName, getUpperName, getUpperName, relevantClasses, structTextDescription, walkStructFields
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

noNamespaceXmlt

protected XMLTranslator noNamespaceXmlt
Constructor Detail

BNFSyntax

public BNFSyntax()

BNFSyntax

public BNFSyntax(XMLTranslator xmlt)
Method Detail

describeClass

public void describeClass(java.lang.String className,
                          java.io.PrintStream out)
Prints the syntax for the indicated class and for any related classes that can be found. Related classes are the types of fields, subclasses if known, and some special cases. This method is the main entry point when a BNFSyntax is used to produce syntax descriptions.

Overrides:
describeClass in class XMLSyntax

printRuleSyntax

void printRuleSyntax(BNFSyntax.RuleList list,
                     java.io.PrintStream out)
Prints the the BNF that corresponds to each rule.


printRuleSyntax

void printRuleSyntax(BNFSyntax.Rule rule,
                     java.io.PrintStream out)
Prints the BNF that corresponds to an individual rule.


printAlternatives

void printAlternatives(BNFSyntax.Alternatives alts,
                       java.io.PrintStream out)
Prints the BNF for a RHS that is an Alternatives.


printInstance

void printInstance(BNFSyntax.Instance inst,
                   java.io.PrintStream out)
Prints the BNF for a RHS that is an Instance -- a description of an instance of a class.


printIndented

void printIndented(java.io.PrintStream out,
                   int indent,
                   java.lang.String text)
Utility that breaks text into lines and prints them with the specified indentation.


makeClassInstance

BNFSyntax.Instance makeClassInstance(ClassDescr cd)
Makes a description of an instance of a class.


tagged

java.lang.String tagged(java.lang.String tag,
                        java.lang.String contents)
Returns a string representing an XML element.


main

public static void main(java.lang.String[] argv)
Test loop that repeatedly asks the user for a class name and prints a description of the syntax for objects of that class.