Class CharParserPrepare

java.lang.Object
eu.bandm.tools.d2d2.base.CharParserPrepare

public class CharParserPrepare extends Object
Collects all parser particles from character parsers and joins them to a content model which is DTD compatible. There are two situations: without and with an explicit element definition. In both cases the definitions of the parse particles (e.g. "p") must be collected from the different character parser definitions (which may be recursive!). All variants must be joined into one disjunction, and this must be normalized into a content model for later DTD generation and result write-out.
Case without element definition:
     chars a = ..... [p ..... [q..][q..] [p ..... ] .... ]
     chars b = ..... [p ..... ] ...
  
In this case NO definition in the module may have the name "p".

or

     chars a = ..... [p ..... [q..][q..] [p ..... ] .... ]
     chars b = ..... [p ..... ] ...
     chars p = #distributed with xmlrep el = "x:y", postprocessor "a.b"
  
In this case a char parser is defined as "#distributed" and will be assigned the collected content model of the parse particles in the same module with the name. Then additional features can be specified, like xml tag and namespace, Java class as postprocessor, etc.

     chars p = #distributed with xmlrep data ...
  
The keyword "data" means that the sequential order of the input is not significant and will be re-ordered. The top-level expression will be a permutation "..&.." of the contained elements (coming from character parsers or parse particles in the collected regexps).

Usage: create one instance (anew for each instantiated module) and call resolve(eu.bandm.tools.d2d2.model.ResolvedModule).

(Please note that there is a general problem with more than one instantiations of the same module, which will result in more than one parser definitions bound to the saem XML tag !)
  • Field Details

  • Constructor Details

  • Method Details

    • error

      protected void error(Location<XMLDocumentIdentifier> loc, String txt, Object... obj)
    • SEQ

      static Expression SEQ(Expression... exp)
    • ALT

      static Alt ALT(Expression... exp)
    • isEmptyAlt

      static boolean isEmptyAlt(Expression exp)
    • PLUS

      static Expression PLUS(Expression exp)
    • rawDef

      protected Definition rawDef(Definition def)
    • rawMod

      protected Module rawMod(Definition def)
    • representingKey

      final String representingKey(DefInstance defI, Module rawMod)
      ATTENTION ParseParticles are unified w.r.t. the UN-instatiated, raw modules. Therefore one instantiated module is chosen arbitrarily, and the "collector" is instantiated/created with that import prefix in its name.
    • resolve

      public void resolve(ResolvedModule resolvedModule)
      MAIN OPERATIVE ENTRY METHOD:
      1. Collect all ParseParticles in resolvedModule and link together all those from the same raw module, with the same name.
      2. Link these to a "Collector", either a fresh CharsRegExp, or one in the same module with the with the same name, declared as "#distributed".
      3. Collect the "linear content models" (as an Expression) of all CharParsers and all ParseParticles, thereby reducing "flattened recursion" = "x=..@x.." to repetition.
      4. Construct the unified expr (for DTD-generation and writing-out) either as a conjunction of the distributed expressions (may crash due to violation of (1)unabmig.) or as a permutation expression, reflecting cardinalities only, iff the Collector has been declared as xmlrep data.
    • resolveOnePpName

      protected void resolveOnePpName(String ppName)
      ppName is built from one (arbitrarily chosen) module expansion of the raw origin module, plus the name of a ParseParticle. This call triggers the unification of all ParseParticle with this name in ALL instantiated definitions coming from this raw module, as already stored in allParseParticles.
    • testParse

      public static Expression testParse(String data)
    • toRegExp

      public static Expression toRegExp(String s, Expression exp)
    • testE

      public static void testE(String data)
    • testF

      public static void testF(String data)
    • main

      public static void main(String[] cmd)