Class FirstCalculator


public class FirstCalculator extends Navigate.VisitReachable<Object>
Sets up constants in each Expression, which cache structural properties of the syntax for later parsing.
  • The ".firsts : String -> (Expression+int)" director map (this points to sub-expressions of an ALT or PERM or to starting position numbers of a SEQU!)
  • whether character data is accepted
  • whether epsilon accepted (Expression.canProduceEpsilon is initialized to false and overwritten here to true, if appropriate.)
During this, LL(1) violations are detected. They are reported as errors or warnings, depending on lenient (lenient=true is used in xslt mode, so that target elements are simply not recognized when tag-synonym to an xslt element.)

Visiting starts with the (externally requested) top-level module and follows ONLY references (to declarations contained anywhere!)

ATTENTION: Does NOT visit the expressions X in "import _ from _ ^ ( X / _)"

The "result" mechanism of VisitReachable is not used.

  • Field Details

  • Constructor Details

  • Method Details

    • error

      protected void error(Location<XMLDocumentIdentifier> loc, String txt, Object... args)
      Evident
    • warning

      protected void warning(Location<XMLDocumentIdentifier> loc, String txt, Object... args)
      Evident
    • hint

      protected void hint(Location<XMLDocumentIdentifier> loc, String txt, Object... args)
      Evident
    • action

      public void action(TagsRegExp def)
      Memorize location (for messages) and descend into the expression.
      Overrides:
      action in class SinglePhase
    • action

      public void action(CharsRegExp def)
      No operation necessary.
      Overrides:
      action in class SinglePhase
    • action

      public void action(Enumeration def)
      No operation necessary.
      Overrides:
      action in class SinglePhase
    • isDone

      boolean isDone(Expression exp)
      If not yet visited, create the director map objects.
      Returns:
      whether visited before.
    • action

      public void action(Empty x)
      Only mark as visited.
      Overrides:
      action in class SinglePhase
    • action

      public void action(Pcdata x)
      Mark as visited and set the director maps.
      Overrides:
      action in class SinglePhase
    • action

      public void action(Insertion x)
      Mark as visited and set the director maps. Insertions can only be in ResolvedModule as synthetic ones, containing only one Reference
      Overrides:
      action in class SinglePhase
    • makeGenericHints

      protected void makeGenericHints(Module module, List<String> names)
      Emit a sequence of hints pointing to the sequence of import commands, when (erroneously) a definition is referred which is marked with "#GENERIC".
    • action

      public void action(Reference ref)
      Put "tag->expr" into the directors map for later parsing. References can refer to Tags, Chars and Enumerations definitions.

      Attention: Use the name of the referred to declaration object, which is a kind of "d2d-tag" with possibly local scope. Do not use the referring source text, which already has been normalized to module level scope.

      Overrides:
      action in class SinglePhase
    • copyMult

      protected void copyMult(GrUnary x, boolean canEps)
      Copy the directors into a compound expression "x" from its component.
    • action

      public void action(Opt x)
      Copy the directors into the compound expression "x" from its component.
      Overrides:
      action in class SinglePhase
    • action

      public void action(Star x)
      Copy the directors into the compound expression "x" from its component.
      Overrides:
      action in class SinglePhase
    • action

      public void action(Plus x)
      Copy the directors into the compound expression "x" from its component.
      Overrides:
      action in class SinglePhase
    • LL1_violation

      protected void LL1_violation(String s, Expression from, Expression to)
      Signal the fact that a tag is already contained in the domain of the (non-weak) director map.
    • addFromTo

      protected void addFromTo(Expression from, Expression to, boolean isalt)
      "From" is the component expression FROM which the director map is copied inTO the map ruling the compond expression called "to".d
    • action

      public void action(Alt alt)
      Fill the director maps to the disjunction of all directors of the components.
      Overrides:
      action in class SinglePhase
    • action

      public void action(Perm x)
      Fill the director maps to the disjunction of all directors of the components.
      Overrides:
      action in class SinglePhase
    • action

      public void action(Seq x)
      Fill the director maps of a sequence expression, depending on the possible epsilon-results of its components.
      Overrides:
      action in class SinglePhase
    • liftFirstsToSeq

      public static void liftFirstsToSeq(Expression exp, Seq ns)
      All directors from "exp" are lifted into the directory maps of "ns", to point to the "exp"-expression.