public class Compiler extends Object
eu.bandm.tools.option.runtime
Model and one
optional from Gui. Both will be in the same package, so that
"protected" fields and methods are mutally accessible.
Model.
In BandM meta-tools one currently finds examples for all important special cases:
| fragmentedLists | xslt/base/Options.xml : sourceRoots, etc. |
| option w/o argument ("switch") | tdom_withOptions : patterns, noCompress, etc. |
| Modifier and Type | Class and Description |
|---|---|
protected class |
Compiler.Phase
Base class for compiler phases.
|
protected class |
Compiler.Phase_enum
Zeroth phase, collect and generate code for enumerations.
|
protected class |
Compiler.Phase_gui
Compile code for the gui class.
|
protected class |
Compiler.Phase_parser
Create a parsing method for each option, and two "switch" methods calling these,
one for short and one for long names.
|
protected class |
Compiler.Phase_pre_enum
Minus-first phase, make crossref in which arguments an enum occurs.
|
protected class |
Compiler.Phase_usage
Common superclass for
Compiler.Phase_usage_enumerations and
Compiler.Phase_usage_options. |
protected class |
Compiler.Phase_usage_enumerations
Deliver the documentation text table for all enumeration types.
|
protected class |
Compiler.Phase_usage_options
Make one default
usage() function and many specials for
each language appearing at least once in the collection of descriptions. |
protected class |
Compiler.Phase1
First and main code generation phase.
Creates code for (1) checks uniqueness and correctness of names and abbrevs. (2) collects documentation into desrcibes_argument_types.(3) makes value fields and getter methods for all option arguments (4) generates code for enabling conditions. (currently only simple "equal()" have been tested. |
| Modifier and Type | Field and Description |
|---|---|
protected GeneratedAnnotation |
annotationDeprecated_has |
protected GeneratedAnnotation |
annotationOverride |
static EnvironmentClass |
CL_ArrayList
Evident
|
static EnvironmentClass |
CL_boolean
Evident
|
static EnvironmentClass |
CL_char
Evident
|
static EnvironmentClass |
CL_Component
Evident
|
static EnvironmentClass |
CL_double
Evident
|
static EnvironmentClass |
CL_EnumSet
Evident
|
static EnvironmentClass |
CL_Function
Evident
|
static EnvironmentClass |
CL_int
Evident
|
static EnvironmentClass |
CL_LinkedList
Evident
|
static EnvironmentClass |
CL_List
Evident
|
static EnvironmentClass |
CL_rational
Evident
|
static EnvironmentClass |
CL_String
Evident
|
protected Map<Element_comment,String> |
comment_name
All comments (=separator lines) are collected in a first visit and used
in subsequent GUI generation.
|
protected CatalogByString |
descriptions
Inter-phase information transfer: all collected multi-lingual description texts.
|
Map<Element_option,String> |
desrcibes_argument_types
Human readable documentation text describing the option.
|
Map<Element_option,String> |
element_conditionUsage |
static String |
ENUM_ITEMS_INLINE_SEPARATOR |
static int |
ENUM_ITEMS_INLINE_THRESHOLD |
Map<String,GeneratedClass> |
enumClasses |
Map<String,List<Element_enumitem>> |
enums
All defined enumeration types.
|
protected Multimap<String,String> |
enums2options |
Set<String> |
enumsWithDocText |
Set<String> |
enumsWithItemDocText |
Map<String,String> |
enumValuesList |
protected Set<String> |
evalforinactive |
protected Map<String,Format> |
formatCache |
protected boolean |
fragmentedLists
Whether lists may come in more than one portions.
|
protected Format |
generationComment
Copy of argument needed only for Phase_enum.
|
protected GeneratedClass |
guiclass
Inter-phase information transfer: the currently defined gui class.
|
protected boolean |
hasRationals
Whether the code for Rationals must be imported.
|
protected boolean |
hexIntegers
Whether integer input may be given in hexdecimal by
0x123. |
protected static int |
LINEWIDTH
Format of the generated java source files.
|
protected static String |
LINGUA_FRANCA
Language selection for generating source comments and for the unparamterized
usage() method. |
protected Set<String> |
maybeinactive |
protected GeneratedMethod |
meth_checkActive |
protected GeneratedMethod |
meth_displayActive |
protected GeneratedClass |
modelclass
Inter-phase information transfer: the currently defined model class.
|
protected SimpleMessage.Generator<XMLDocumentIdentifier> |
msg
Message Generator for all error and warning messages during compilation.
|
protected MessageReceiver<Message> |
msgr |
String |
NAME_OF_DESCRIPTION_CATALOG_CLASS
Must correspond to
eu.bandm.tools.option.runtime |
String |
NAME_OF_DESCRIPTION_CATALOG_FIELD
Must correspond to
eu.bandm.tools.option.runtime |
String |
NAME_OF_MODEL_ACCESS_FUNCTION
Must correspond to
eu.bandm.tools.option.runtime |
static String |
NAME_PROGRAM
Used only as argument to
CommentFormats.generationComment(String,String,int,boolean,String[]). |
protected String |
noDoc
Text used if even the language fallback mechanism fails to find a description.
|
protected Set<String> |
nonEmptyGroups
Lists with "plus" operator (not "star"), finally checked for non-emptyness
|
protected Map<Element_option,GeneratedClass> |
option2tailClass
The class generated to represent the repeting group of arguments.
|
protected boolean |
overall_has_repeting
Whether there is at least one repeting group, requiring import of metaools ops.
|
protected Map<Integer,Element_option> |
positionals
All options which are positional, sorted by their index (short name).
|
static Set<String> |
RESERVED_TYPE_NAMES
Must not appear as names of user-defined enumerations.
|
static String |
VERSION_PROGRAM |
| Constructor and Description |
|---|
Compiler() |
| Modifier and Type | Method and Description |
|---|---|
protected void |
add_comment_for_sourcetext(@Opt Element_desc desc,
GeneratedAnnotationTarget target)
Add the description in the
LINGUA_FRANCA, if any, to the
generated java object "target",
by calling {@link add_comment_for_sourcetext(String,Element_desc, GeneratedAnnotationTarget). |
protected void |
add_comment_for_sourcetext(@Opt String prefix,
@Opt Element_desc desc,
GeneratedAnnotationTarget target)
Adds formatted user-level (=payload) comment to a generated method or field.
|
protected boolean |
argnumberRedundant(Element_option el)
For recognizing an option with at most one argument.
|
void |
compile(Element_optionlist data0,
String packagename0,
String classname_model,
@Opt String classname_gui,
String destdir,
Format genComment,
String inputfilename,
MessageReceiver<Message> msgr)
Create source text for a model, and for a gui, if required.
|
protected Format |
expression(String code) |
protected String |
find_printout_title(Element_optionlist olist,
String lang)
Looks in the header of the option list for the title text of the usage() output.
|
protected Format |
format_dquoted(String s)
Generate a literal format containing a string in double quotes.
|
protected boolean |
listByAbbrev(String enumname)
Decides between different presentation formats in usage().
|
static void |
main(String[] args)
Execute compilation of the dtd to Java sources.
|
protected void |
make_usage(Element_optionlist olist)
Call
Visitor.visit(Element_optionlist) for all languages
appearing at least once in the collection of descriptions. |
protected String |
name2tag(String r)
Prepend the correct number of lead-in minus signs to long name or abbrev name.
|
protected void |
parsePositional()
Generate the parsing method for the positional options/arguments.
|
protected Format |
statement(String code) |
protected Format |
statements(String code) |
protected boolean |
typeNotEmpty(Element_option el)
For recognizing totally empty type (no types nor rep group).
|
protected static void |
usage()
Print the usage information of this tool to stderr.
|
public static final String NAME_PROGRAM
CommentFormats.generationComment(String,String,int,boolean,String[]).
Therefore an html encoding is sensible.public static final String VERSION_PROGRAM
protected static final String LINGUA_FRANCA
usage() method.
Since the lingua franca of the computer area is English,
these documentation texts are taken for program documentation =
API documentation (NOT user documentation like "usage()" and error messages).
It will also be used as the fall-back for usage() if some doc text in
the required language does not exist. If even a text in LINGUA_FRANCA
does not exist, a language will be chosen by random.public final String NAME_OF_DESCRIPTION_CATALOG_CLASS
eu.bandm.tools.option.runtimepublic final String NAME_OF_DESCRIPTION_CATALOG_FIELD
eu.bandm.tools.option.runtimepublic final String NAME_OF_MODEL_ACCESS_FUNCTION
eu.bandm.tools.option.runtimepublic static final Set<String> RESERVED_TYPE_NAMES
public static final int ENUM_ITEMS_INLINE_THRESHOLD
public static final String ENUM_ITEMS_INLINE_SEPARATOR
protected MessageReceiver<Message> msgr
protected SimpleMessage.Generator<XMLDocumentIdentifier> msg
protected Format generationComment
protected GeneratedClass modelclass
protected GeneratedClass guiclass
protected CatalogByString descriptions
Compiler.Phase1 for Element_option and in
Compiler.Phase_enum for Element_enum and Element_enumitem.protected GeneratedAnnotation annotationOverride
protected GeneratedAnnotation annotationDeprecated_has
protected GeneratedMethod meth_checkActive
protected GeneratedMethod meth_displayActive
protected Map<Element_option,GeneratedClass> option2tailClass
public Map<Element_option,String> desrcibes_argument_types
usage(..), etc.public Map<Element_option,String> element_conditionUsage
public Map<String,List<Element_enumitem>> enums
public Map<String,GeneratedClass> enumClasses
protected Map<Element_comment,String> comment_name
protected Map<Integer,Element_option> positionals
protected boolean overall_has_repeting
protected boolean fragmentedLists
protected boolean hexIntegers
0x123.protected boolean hasRationals
protected Set<String> nonEmptyGroups
public static final EnvironmentClass CL_boolean
public static final EnvironmentClass CL_int
public static final EnvironmentClass CL_double
public static final EnvironmentClass CL_rational
public static final EnvironmentClass CL_char
public static final EnvironmentClass CL_String
public static final EnvironmentClass CL_List
public static final EnvironmentClass CL_LinkedList
public static final EnvironmentClass CL_EnumSet
public static final EnvironmentClass CL_Function
public static final EnvironmentClass CL_ArrayList
public static final EnvironmentClass CL_Component
protected final String noDoc
protected static final int LINEWIDTH
public void compile(Element_optionlist data0, String packagename0, String classname_model, @Opt @Opt String classname_gui, String destdir, Format genComment, String inputfilename, MessageReceiver<Message> msgr)
data0 - the top-level element of the option specification filepackagename0 - where to to generate the sourceclassname_model - the name of the generated classclassname_gui - the name of the generated gui class. ==null to suppress code generation.destdir - where the java source hierarchy startsmsgr - for error messages and warningsprotected Format format_dquoted(String s)
protected boolean typeNotEmpty(Element_option el)
protected boolean argnumberRedundant(Element_option el)
protected String name2tag(String r)
protected boolean listByAbbrev(String enumname)
protected String find_printout_title(Element_optionlist olist, String lang)
protected void add_comment_for_sourcetext(@Opt @Opt Element_desc desc, GeneratedAnnotationTarget target)
LINGUA_FRANCA, if any, to the
generated java object "target",
by calling {@link add_comment_for_sourcetext(String,Element_desc, GeneratedAnnotationTarget).protected void add_comment_for_sourcetext(@Opt @Opt String prefix, @Opt @Opt Element_desc desc, GeneratedAnnotationTarget target)
LINGUA_FRANCA (currently English) is output, since all
other text generated by the tool javadoc is in this language.
The text is wrapped in a <span class="bandUser"> xhtml tag for
css style formatting.prefix - prepended to the found text, also contained in the wrapping tag.protected void make_usage(Element_optionlist olist)
Visitor.visit(Element_optionlist) for all languages
appearing at least once in the collection of descriptions.protected void parsePositional()
protected static void usage()
public static void main(String[] args) throws SAXException
args[0] = inputfile
args[1] = packagename
args[2] = classname of the generated model class
args[3] = classname oc the generated gui class (when = empty string "", then no
no gui will be generated)
args[4] = outputroot
SAXExceptionsee also the complete user documentation .