Package eu.bandm.tools.option
Class Compiler.Phase1
java.lang.Object
eu.bandm.tools.tdom.runtime.BaseVisitor
eu.bandm.tools.option.absy.Visitor
eu.bandm.tools.option.Compiler.Phase
eu.bandm.tools.option.Compiler.Phase1
- All Implemented Interfaces:
PCDataVisitor
- Enclosing class:
Compiler
First and main code generation phase.
Creates code for
(1) checks uniqueness and correctness of names and abbrevs.
(2) collects documentation into
(3) makes value fields and getter methods for all option arguments
(4) generates code for enabling conditions.
(currently only simple "equal()" have been tested. More to come)
(5) collects serialization/unparsing code in
(6) collect multi-lingual doc text into
All this by adding to visitor's registers, from the "visit option" and the "visit field" level.
Creates code for
(1) checks uniqueness and correctness of names and abbrevs.
(2) collects documentation into
Compiler.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. More to come)
(5) collects serialization/unparsing code in
serializeText (6) collect multi-lingual doc text into
Compiler.descriptions
(Only for options, not enums)All this by adding to visitor's registers, from the "visit option" and the "visit field" level.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Map<String, Element_option> Lists option definitions by their short naes.(package private) intGlobar register for the argument number which is currently processed.protected StringAccumulator for generated java code to check the activity of the visited option.protected StringBuilderAccumulator for the user documentation of the argument types sequecen of the visited option.(package private) intRunning counter of comment fields.(package private) intTHe number of arguments on top level or in repting group, needed only to synthesize documentation text.(package private) @Opt GeneratedMethodThe pars-pro-toto meth which gets the user-level documentation of the whole option.protected Map<String, Element_option> Lists option definitions by their long naes.protected Map<Integer, Element_option> Lists option definitions iff their short name is a decimal digit.(package private) @Opt GeneratedClassCurrently processed repeting group, or null when on top-level.(package private) Element_repCurrently processed repeting group, or null when on top-level.protected StringAccumulator for the generated java code for the serialization of the visited option.protected StringAccumulator for the user documentation of the activity condition of the visited option.Fields inherited from class eu.bandm.tools.option.Compiler.Phase
abbrev, currentOptionElement, name, option_qualifierFields inherited from class eu.bandm.tools.tdom.runtime.BaseVisitor
validating -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidFor the first call, put the (English) documentation text and arguments' regExp to that method, as a pars-pro-toto; later put references to that first method.protected voidPut the (English) documentation text which leads the user to the pars-pro-totodocumentedMeth.protected voidaddLinkCommentEXT(GeneratedAnnotationTarget gm, String name) Put the (English) documentation text which leads the user to the pars-pro-totodocumentedMethcontained in a diffrent class.voidMake a special boolean value field plus methods plus usage() documentation for a "switch type" / "flag type" option.protected voidmakeValueField(MetaType cl, @Opt TypedAttribute<String> userdef, String defdef) Convenience method to prcess one single position of an option's type structure which is neither String nor enumeratin nor switch.protected voidmakeValueField(MetaType cl, @Opt TypedAttribute<String> userdef, String defdef, boolean isString, @Opt String enumname, boolean isSwitch, boolean hexOut) Central method for processing one single position of an options's type signature.voidvisit(Element_and el) Stores Java source and user documentation for the "and" combinator in an enabling condition.voidvisit(Element_bool el) Make value field plus methods plus usage() documentation for a boolean type argument.voidvisit(Element_comment element) Here only the text translations are collected and stored under a dedicated key, which all are entered inCompiler.descriptions.voidStores Java source and user documentation for a constant in an enabling condition.voidvisit(Element_enum el) Make value field plus methods plus usage() documentation for an enumeration type argument.voidvisit(Element_enumeration element) Do nothing and DO NOT descend.voidvisit(Element_enumset el) Make value field plus methods plus usage() documentation for an enum set type argument.voidStores Java source and user documentation for the reference to an option's arguemt in an enabling condition.voidvisit(Element_float el) Make value field plus methods plus usage() documentation for a float type argument.voidvisit(Element_int el) Make value field plus methods plus usage() documentation for an int type argument.voidvisit(Element_not el) Stores Java source and user documentation for the "not" combinator in an enabling condition.voidvisit(Element_optarg el) Stores Java source and user documentation for the reference to an option's arguemt in an enabling condition.voidvisit(Element_option element) See description of containing classCompiler.Phase1voidvisit(Element_optionlist element) Entry point; initialize the global data to collect and on return compiles some of it into generated source.voidvisit(Element_or el) Stores Java source and user documentation for the "or" combinator in an enabling condition.voidvisit(Element_rat el) Make value field plus methods plus usage() documentation for a rational type argument.voidvisit(Element_rep el) Generate a class representing the repeting goup and fill this with field and method definitions using the same methods as implied for the top-levelModel.voidvisit(Element_string el) Make value field plus methods plus usage() documentation for a String type argument.voidStores Java source and user documentation for the equality test in an enabling condition.voidStores Java source and user documentation for the "is grater" combinator in an enabling condition.voidvisit(Element_text el) Memorize description text for gui tool-tips.voidvisit(Element_uri el) Make value field plus methods plus usage() documentation for an URI / file path type argument.Methods inherited from class eu.bandm.tools.option.Compiler.Phase
bothtags, bothtags_formatted, ERROR, longestname, longesttag, shortestname, shortesttag, WARNING, WARNINGMethods inherited from class eu.bandm.tools.option.absy.Visitor
visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visitMethods inherited from class eu.bandm.tools.tdom.runtime.BaseVisitor
visit
-
Field Details
-
argnum
int argnumGlobar register for the argument number which is currently processed. May refer to a top-level argument or part of a repeting group. -
currentlen
int currentlenTHe number of arguments on top level or in repting group, needed only to synthesize documentation text. -
commentfields
int commentfieldsRunning counter of comment fields. Used to synthesize a name, if necessary. -
repetingValueClass
Currently processed repeting group, or null when on top-level. -
repetingValueElement
Element_rep repetingValueElementCurrently processed repeting group, or null when on top-level. -
documentedMeth
The pars-pro-toto meth which gets the user-level documentation of the whole option. -
cmd_usage
Accumulator for the user documentation of the argument types sequecen of the visited option. -
cmd_checkActive
Accumulator for generated java code to check the activity of the visited option. -
usage_checkActive
Accumulator for the user documentation of the activity condition of the visited option. -
serializeText
Accumulator for the generated java code for the serialization of the visited option. -
name2el
Lists option definitions by their long naes. -
abbrev2el
Lists option definitions by their short naes. -
pos
Lists option definitions iff their short name is a decimal digit.
-
-
Constructor Details
-
Phase1
protected Phase1()
-
-
Method Details
-
visit
Do nothing and DO NOT descend. -
visit
Here only the text translations are collected and stored under a dedicated key, which all are entered inCompiler.descriptions. This must be done this early, so that a language appearing ONLY in a comment (a rare case, probably erronuous) will correctly be considered! -
visit
Entry point; initialize the global data to collect and on return compiles some of it into generated source. -
visit
See description of containing classCompiler.Phase1- Overrides:
visitin classCompiler.Phase
-
visit
Memorize description text for gui tool-tips. Store it in global mapCompiler.descriptions.Element_commentandElement_enumerationare pruned by this visitor code, so we come here only viaElement_optionand thenElement_desc. -
addFullCommentOrCrossRef
For the first call, put the (English) documentation text and arguments' regExp to that method, as a pars-pro-toto; later put references to that first method. -
addLinkComment
Put the (English) documentation text which leads the user to the pars-pro-totodocumentedMeth. -
addLinkCommentEXT
Put the (English) documentation text which leads the user to the pars-pro-totodocumentedMethcontained in a diffrent class. Currently only used from the repeting-group class to its containingModelclass. -
makeValueField
Convenience method to prcess one single position of an option's type structure which is neither String nor enumeratin nor switch. -
makeValueField
protected void makeValueField(MetaType cl, @Opt @Opt TypedAttribute<String> userdef, String defdef, boolean isString, @Opt @Opt String enumname, boolean isSwitch, boolean hexOut) Central method for processing one single position of an options's type signature. It is called for every position of the top-level type sequence or of the trailing repetition sequence. It creates the metajava field object in the currentmodelclass, including its initializer and its getter method. It extends the serialization (un-parsing) method and the signature documentation text.- Parameters:
cl- the class of the model field to generate.userdef- (maybe null) the attribute carrying the default from the xml input.defdef- the default for the default value, if no default is specified in the xml input.isString- the default value is inserted in the generated code literally, so it must be additionally escaped iff it is a String.enumname- needed only as prefix for the default value / initializerisSwitch- is a argument-less option which only acts by mere presence.hexOut- that an integer value shall be serialized in hex format
-
makeNoArgSwitch
public void makeNoArgSwitch()Make a special boolean value field plus methods plus usage() documentation for a "switch type" / "flag type" option. -
visit
Make value field plus methods plus usage() documentation for an int type argument. -
visit
Make value field plus methods plus usage() documentation for a float type argument. -
visit
Make value field plus methods plus usage() documentation for a rational type argument. -
visit
Make value field plus methods plus usage() documentation for a boolean type argument. -
visit
Make value field plus methods plus usage() documentation for a String type argument. ATTENTION: The default value of a String field is not Java source, but the argument's value, as typed on an command line. -
visit
Make value field plus methods plus usage() documentation for an URI / file path type argument. ATTENTION: The default value of a String field (and a string-like field as this) is not Java source, but directly the argument's value, as typed on an command line. -
visit
Make value field plus methods plus usage() documentation for an enumeration type argument. -
visit
Make value field plus methods plus usage() documentation for an enum set type argument. -
visit
Generate a class representing the repeting goup and fill this with field and method definitions using the same methods as implied for the top-levelModel. -
visit
Stores Java source and user documentation for the "and" combinator in an enabling condition. -
visit
Stores Java source and user documentation for the "or" combinator in an enabling condition. -
visit
Stores Java source and user documentation for the "not" combinator in an enabling condition. -
visit
Stores Java source and user documentation for the equality test in an enabling condition.
ATTENTION uses ".equals()" iff one of the arguments is a string constant starting with a double quotes or a call to "Rational" appears in one of the texts. Otherwise use "==". -
visit
Stores Java source and user documentation for the "is grater" combinator in an enabling condition. -
visit
Stores Java source and user documentation for a constant in an enabling condition. Each such constant (a) must be verbatim valid Java source and (b) shows up in the usage() documentation. -
visit
Stores Java source and user documentation for the reference to an option's arguemt in an enabling condition. -
visit
Stores Java source and user documentation for the reference to an option's arguemt in an enabling condition.
-