`OsfV1Ancillary.grm`

    // FILE. . . . . /home/hak/hlt/src/hlt/osfv1/apps/v1/sources/OsfV0Ancillary.grm
    // EDIT BY . . . Hassan Ait-Kaci
    // ON MACHINE. . Hak-Laptop
    // STARTED ON. . Sun Sep 08 18:31:47 2013

This file defines ancillary code (global variables and methods) for the OSF V1 language. It is part of its Jacc grammar specification and is included by the main grammar file OsgV1Grammar.grm .
Author: |  | Hassan Aït-Kaci
Copyright: |  | © by the author
Version: |  | Last modified on Mon Sep 16 10:23:29 2013 by hak

    /* ************************************************************************ */
    /* **************************** ANCILLARY CODE **************************** */
    /* ************************************************************************ */

    %{

    /* ************************************************************************ */
    /* *************************** GLOBAL VARIABLES *************************** */
    /* ************************************************************************ */

    /* ************************************************************************ */

This is the OSF execution context.

      static Context context = new Context(1000000,2,3);

    /* ************************************************************************ */

    /* ************************************************************************ */
    /* ************************** TAXONOMY MANAGEMENT ************************* */
    /* ************************************************************************ */

    /* ************************************************************************ */

    void declareIsa (String s1, String s2) throws LockedCodeArrayException
    {
      try
        {
          context.declareIsa(s1,s2,location);
        }
      catch (RuntimeException e)
        {
          logError(new Error().setMsg(e.getMessage()));
        }
    }

    /* ************************************************************************ */

    void processIsaDeclaration (Stack lhs, Stack rhs)
    {
      int lsize = lhs.size();
      int rsize = rhs.size();

      for (int i=0; i<lsize; i++)
        for (int j=0; j<rsize; j++)
          declareIsa((String)lhs.get(i),(String)rhs.get(j));
    }

    /* ************************************************************************ */

    /* ************************************************************************ */
    /* ************************* EXPRESSION PROCESSING ************************ */
    /* ************************************************************************ */

    /* ************************************************************************ */

This builds an uninterpreted ψ-term structure out of the syntactic parts given as arguments as explained in the specification, then interprets its sort expressions in the current context and prints out its interpreted normalized form.

    void processPsiTerm (String tag, SortExpression sort, Stack keys, Stack subterms)
    {
      PsiTerm pst = buildPsiTerm(new HashSet(),Tag.getTag(tag),sort,keys,subterms);
      try
        {
          time = System.currentTimeMillis();
          displayLine("*** "+pst.displayForm(4)); // margin is 4 to account for "*** "
          // Tag.tallyTags();	// show known tags
          Tag.clearKnownTags();	// clear the tags
          time = System.currentTimeMillis() - time;
          if (Context.isTiming())
    	displayLine("*** Processing time = "+time+" ms");
        }
      catch (RuntimeException e)
        {
          logError(new Error().setMsg(e.getMessage()));
        }
    }

Using the given hash set of tags already associated to previously constructed ψ-terms, this builds an uninterpreted ψ-term structure out of the syntactic parts given as arguments.

    PsiTerm buildPsiTerm (HashSet tags, Tag tag, SortExpression sort, Stack keys, Stack subterms)
    {
      // dereference the tag to get to the correct one if needed:
      tag = tag.deref();

      // this is the psiterm to build:
      PsiTerm pst = null;

      // check if this tag has been seen before:
      if (tags.contains(tag))
        // this tag is a reoccurring tag:
        {
          // mark the tag as shared and retrieve its term:
          pst = tag.markAsShared().term();
          // merge the existing term's sort with the given sort:
          pst.mergeSortWith(sort);
        }
      else
        // this tag has not occurred before:
        {
          // add the tag to the tag occurrences:
          tags.add(tag);
          // create a new psiterm with the given sort and tag:
          pst = new PsiTerm(sort).setTag(tag);
        }

      // build the subterms if there are any:
      if (subterms != null) // (then must have keys != null as well)
        {
          // this is to count implicit positions of subterms if any:
          int implicitPosition = 0;

          // this is to hold a subterm to build if any:
          PsiTerm subterm = null;

          // this is to hold an already existing subterm if any:
          PsiTerm existingSubterm = null;

          // build each subterm one at a time:
          while (!subterms.empty())
    	{
    	  // get the current raw subterm to build:
    	  RawPsiTerm rawsub = (RawPsiTerm)subterms.pop();
    	  // build the current subterm
    	  subterm = buildPsiTerm(tags,
    				 Tag.getTag(rawsub.tag),
    				 rawsub.sort,
    				 rawsub.keys,
    				 rawsub.subterms).deref();

    	  // get the current subterm's key
    	  Object key = keys.pop();

    	  if (key == null)
    	    // this is an implicitly contiguous position
    	    {
    	      implicitPosition++;

    	      // retrieve the possibly existing subterm:
    	      existingSubterm = pst.getSubterm(implicitPosition);
    	      if (existingSubterm == null)
    		pst.setSubterm(implicitPosition,subterm.deref());
    	      else
    		existingSubterm.deref().merge(subterm.deref());

    	      continue;
    	    }

    	  if (key instanceof Integer)
    	    // this is an explicitly specified position
    	    {
    	      int position = ((Integer)key).intValue();

    	      existingSubterm = pst.getSubterm(position);
    	      if (existingSubterm == null)
    		pst.setSubterm(position,subterm.deref());
    	      else
    		existingSubterm.deref().merge(subterm.deref());

    	      continue;
    	    }

    	  // this is a feature subterm
    	  Feature feature = Feature.getFeature((String)key);

    	  existingSubterm = pst.getSubterm(feature);
    	  if (existingSubterm == null)
    	    pst.setSubterm(feature,subterm);
    	  else
    	    existingSubterm.merge(subterm.deref());
    	}
        }

      // return dereferenced pst in case its tag was bound by merging subterms
      return pst = pst.deref();
    }

This processes a sort expression in the context of an encoded sort taxonomy. Given the current sort context, it compiles it, evaluates it, and prints out the resulting maximal (possibly disjunctive) sort matching the resulting sort code. If in timing mode, it also reports the processing time in milliseconds.

    void processSortExpression (SortExpression expression)
    {
      try
        {
          time = System.currentTimeMillis();
          displayLine(// "*** " +
    		  (Context.isTracing()
    		   ? (expression.displayForm() +
    		      // " => "+expression.value().toBitString() +
    		      " >= ")
    		   : "") +
    		  // expression.maxLowerBound());
    		  expression.decoded());
          time = System.currentTimeMillis() - time;
          if (Context.isTiming())
    	displayLine("*** Processing time = "+time+" ms");
        }
      catch (RuntimeException e)
        {
          logError(new Error().setMsg(e.getMessage()));
        }
    }

    /* ************************************************************************ */
    /* **************************** PRAGMA PROCESSING ************************* */
    /* ************************************************************************ */

    static boolean isMute, showTree;

    static long time;

    // etc...

    // public final void initialize ()
    // {
    //   Pragmas.AUTOMATIC = false;
    //   // etc ...
    // }

    /* ************************************************************************ */

This calls the method in charge of dispatching which action to take depending on the pragma. If in timing mode, also reports the processing time in milliseconds.

    final void processPragma (String pragma, Stack args)
    {
      time = System.currentTimeMillis();
      executePragma(pragma,args);
      time = System.currentTimeMillis() - time;
      if (Context.isTiming())
        displayLine("*** %"+pragma+" pragma processing time = "+time+" ms");
    }

This is the method in charge of dispatching which action to execute for which pragma.

    final void executePragma (String pragma, Stack args)
    {
      setLocation();

      if (pragma == "exit")
        OsfV1Main.exit();

      if (pragma == "eval")
        {
          PsiTerm.evaluateSorts(true);
          displayLine("*** Sort expression evaluation has been turned on...");
          return;
        }

      if (pragma == "no-eval")
        {
          PsiTerm.evaluateSorts(false);
          displayLine("*** Sort expression evaluation has been turned off...");
          return;
        }

      if (pragma == "toggle-eval")
        {
          PsiTerm.toggleSortEvaluation();
          displayLine("*** Sort expression evaluation has been turned "
    		  +(PsiTerm.evalSorts() ? "on" : "off")+"...");
          return;
        }

      if (pragma == "include")
        { // This has a bug in that an extra dot at the console is needed to
          // get the prompt.  The origin of this comes from IncludeReader
          // that swallows the IO.EOI at the end of the file being included
          // and as a result the tokenizer's promptIsNeeded returns
          // false. There is no easy way to fix that besides a deep and
          // careful analysis of how the read() method in IncludeReader and
          // the nextToken() nextChar() methods in (Abstract)StreamTokenizer
          // work. For now, keep it as it is. However, when we enter:
          // '%include "foo.osf". %encode.' on the same line, this works as
          // expected and we get the prompt.
          includeFiles(args);
          return;
        }

      if (pragma == "encode")
        {
          displaySize();
          encodeSorts();
          return;
        }

      if (pragma == "save")
        {
          saveTaxonomy(args);
          return;
        }

      if (pragma == "load")
        {
          loadTaxonomy(args);
          return;
        }

      if (pragma == "enumsize")
        {
          displayLine("*** Sort enumeration size set to "+Decoded.enumSize());
          return;
        }

      if (pragma == "size")
        {
          displaySize();
          return;
        }

      if (pragma == "sorts")
        {
          displaySorts();
          return;
        }

      if (pragma == "last")
        {
          displayLastExpression();
          return;
        }

      // if (pragma == "height")
      //   {
      //     computeHeight(arg1);
      //     return;
      //   }

      if (pragma == "cleartags")
        {
          Tag.clearKnownTags();
          displayLine("*** Cleared all known tags");
          return;
        }

      if (pragma == "clear")
        {
          Tag.clearKnownTags();
          context.reset();
          displayLine("*** The sort taxonomy has been cleared ("+
    		  (context.taxonomy().size())+" sorts defined)");
          return;
        }

      if (pragma == "parents")
        {
          displayParents((SortExpression)args.get(0));
          return;
        }

      if (pragma == "children")
        {
          displayChildren((SortExpression)args.get(0));
          return;
        }

      if (pragma == "descendants")
        {
          showDescendants((SortExpression)args.get(0));
          return;
        }

      if (pragma == "ancestors")
        {
          showAncestors((SortExpression)args.get(0));
          return;
        }

      if (pragma == "mute")
        {
          isMute = !isMute;
          display("Muted output has been turned "+(isMute ? "on" : "off")+"...\n");
          if (isMute) displayLine("*** ...");
          return;
        }

      if (pragma == "tree")
        {
          parseTreeType = (showTree = !showTree) ? COMPACT_TREE : NO_TREE;
          display("Parse tree display has been turned "+(showTree ? "on" : "off")+"...\n");
          return;
        }

      if (pragma == "time")
        {
          Context.toggleTiming();
          displayLine("*** Processing timing has been turned "+(Context.isTiming() ? "on" : "off")+"...");
          return;
        }

      if (pragma == "trace")
        {
          if (isMute)
    	{
    	  display("Cannot trace evaluation in mute mode; turn mute mode off with '%mute.'");
    	  return;
    	}

          Context.toggleTracing();
          display("Execution tracing has been turned "+(Context.isTracing() ? "on" : "off")+"...\n");
          return;
        }

      if (pragma == "gc")
        {
          display("\n");
          Misc.forceGC(!isMute,dm.getOutputStream());
          return;
        }

      if (pragma == "syntax")
        {
          toggleTrace();
          display("Parser trace has been turned "+(tracingIsOn() ? "on" : "off")+"...\n");
          return;
        }

      if (pragma == "help")
        {
          helpPragma();
          return;
        }

      displayLine("*** Unknown pragma: '%"+pragma+"' (ignored) - type '%help.' for known pragmas.");
    }

    /* ************************************************************************ */

Given a sort expression, this will display its parents in the current taxonomy.

    final void displayParents (SortExpression exp)
    {
      try
        {
          // if this is only a sort symbol, just display its parents:
          if (exp.isSymbol())
    	{
    	  displayParents(context.getSort(((SymbolSortExpression)exp).name()));
    	  return;
    	}

          // otherwise, evaluate the expression, decode the value, and
          // display its least upper bounds:
          displayLine("*** "+displayForm(context.decodedValue(exp.value()).lubs(),true));
        }
      catch (RuntimeException e)
        {
          logError(new Error().setMsg(e.getMessage()));
        }
    }

    /* ************************************************************************ */

    final void displayParents (Sort sort)
    {
      if (sort.isTop())
        displayLine("*** "+dfm.displayTopForm());
      else
        displayLine("*** "+displayForm(sort.parents(),true));
    }

    /* ************************************************************************ */

Given a sort expression, this will display its children in the current taxonomy.

    final void displayChildren (SortExpression exp)
    {
      try
        {
          // if this is only a sort symbol, just display its children:
          if (exp.isSymbol())
    	{
    	  displayChildren(context.getSort(((SymbolSortExpression)exp).name()));
    	  return;
    	}

          // otherwise, evaluate the expression, decode the value, and
          // display its maximal lower bounds:
          displayLine("*** "+displayForm(context.decodedValue(exp.value()).mlbs(),false));
        }
      catch (RuntimeException e)
        {
          logError(new Error().setMsg(e.getMessage()));
        }
    }

    /* ************************************************************************ */

    final void displayChildren (Sort sort)
    {
      if (sort.isBottom())
        displayLine("*** "+dfm.displayBottomForm());
      else
        displayLine("*** "+displayForm(sort.children(),false));
    }

    /* ************************************************************************ */

This loads the stack of files whose names are in the specified stack. Each file should contain OSF V1 declarations or expressions.

    final void includeFiles (Stack files)
    {
      if (files == null || files.isEmpty())
        {
          logError(syntaxError("missing file arguments in %include pragma",location));
          return;
        }

      while (!files.isEmpty())
        {
          String fileName = (String)files.pop();

          try
    	{
    	  displayLine("*** Reading from file: "+fileName);
    	  ((OsfV1Tokenizer)input).include(fileName);
    	}
          catch (FileNotFoundException e)
    	{
    	  logError(syntaxError("file not found: "+fileName,location));
    	}
          catch (CircularInclusionException e)
    	{
    	  logError(syntaxError("circular file inclusion of file: "+fileName,location));
    	}
          catch (RuntimeException e)
    	{
    	  logError(new Error().setMsg(e.getMessage()));
    	}
        }
    }

    /* ************************************************************************ */

This saves the currently encoded taxonomy into the file whose name is in the specified stack.

    final void saveTaxonomy (Stack files)
    {
      if (files == null || files.isEmpty())
        {
          logError(syntaxError("missing file arguments in %save pragma",location));
          return;
        }

      if (!context.taxonomy().isLocked())
        {
          logError(syntaxError("cannot save a non-encoded taxonomy",location));
          return;
        }

      while (!files.isEmpty())
        {
          String fileName = (String)files.pop();
          displayLine("*** Saving encoded taxonomy into file: "+fileName);

          try
    	{
    	  context.taxonomy().save(fileName);
    	}
          catch (FileNotFoundException e)
    	{
    	  logError(syntaxError("file not found: "+fileName,location));
    	}

          displayLine("*** "+(context.taxonomy().size()-1)+" encoded sorts saved into file: "+fileName);
        }
    }

    /* ************************************************************************ */

This loads an encoded taxonomy from the file whose name is in the specified stack.

    final void loadTaxonomy (Stack files)
    {
      if (files == null || files.isEmpty())
        {
          logError(syntaxError("missing file arguments in %load pragma",location));
          return;
        }

      if (context.taxonomy().isLocked())
        {
          logError(syntaxError("there is already an encoded taxonomy - use %clear if you wish to load a new taxonomy",location));
          return;
        }

      while (!files.isEmpty())
        {
          String fileName = (String)files.pop();
          displayLine("*** Loading encoded taxonomy from file: "+fileName);

          try
    	{
    	  context.taxonomy().load(fileName);
    	}
          catch (FileNotFoundException e)
    	{
    	  logError(syntaxError("file not found: "+fileName,location));
    	}
          catch (IOException e)
    	{
    	  logError(syntaxError("IO error while loading: "+fileName,location));
    	}

          displayLine("*** "+(context.taxonomy().size()-1)+" encoded sorts loaded from file: "+fileName);
        }
    }

    /* ************************************************************************ */

    void displayLastExpression ()
    {
      try
        {
          SortExpression expression = context.lastExpression();
          displayLine("*** "+expression.displayForm()+"  ==>  "+expression.maxLowerBound());
        }
      catch (RuntimeException e)
        {
          logError(new Error().setMsg(e.getMessage()));
        }
    }

    /* ************************************************************************ */

    // void computeHeight (String sort)
    // {
    //   try
    //     {
    //       displayLine("*** The height of "+sort+" is "+context.getSort(sort).height());
    //     }
    //   catch (RuntimeException e)
    //     {
    //       logError(new Error().setMsg(e.getMessage()));
    //     }
    // }

    /* ************************************************************************ */

    void showAncestors (SortExpression exp)
    {
      try
        {
          // if this is only a sort symbol, just display its ancestors:
          if (exp.isSymbol())
    	{
    	  Sort sort = context.getSort(((SymbolSortExpression)exp).name());
    	  displayLine("*** "+displayForm(sort.ancestors(),true));
    	  return;
    	}

          // otherwise, evaluate and decode the expression, and get its ancestors:
          HashSet ancestors = context.decodedValue(exp.value()).ancestors(context.taxonomy());

          displayLine("*** "+displayForm(ancestors,true));
        }
      catch (RuntimeException e)
        {
          logError(new Error().setMsg(e.getMessage()));
        }
    }

    /* ************************************************************************ */

    void showDescendants (SortExpression exp)
    {
      try
        {
          // if this is only a sort symbol, just display its descendants:
          if (exp.isSymbol())
    	{
    	  Sort sort = context.getSort(((SymbolSortExpression)exp).name());
    	  displayLine("*** "+displayForm(sort.descendants(),false));
    	  return;
    	}

          // otherwise, evaluate and decode the expression, and get its descendants:
          HashSet descendants = context.decodedValue(exp.value()).descendants(context.taxonomy());

          displayLine("*** "+displayForm(descendants,false));
        }
      catch (RuntimeException e)
        {
          logError(new Error().setMsg(e.getMessage()));
        }
    }

    /* ************************************************************************ */

This encodes the sorts declared thus far and locks the sort taxonomy; (i.e., no new sorts may be declared until this taxononmy has been cleared (see the '`%clear`' pragma).

    void encodeSorts ()
    {
      try
        {
          context.encodeSorts();
          displayLine("*** The sort taxonomy has been encoded ("+
    		  (context.taxonomy().size()-1)+" sorts defined)");
        }
      catch (CyclicSortOrderingException e)
        {
          logError(new Error().setSee("").setMsg(e.getMessage()));
          _criticalError = true;
        }
      catch (RuntimeException e)
        {
          logError(new Error().setMsg(e.getMessage()));
        }
    }

    /* ************************************************************************ */

    final void helpPragma ()
    {
      displayLine("*** Known pragmas (all must be followed by a period - '.'):");
      displayLine("\t------------  ------");
      displayLine("\t      PRAGMA  EFFECT");
      displayLine("\t------------  ------");

      displayLine("\t       %exit  exit session");

      displayLine("\t    %include  read the unclassified ontology from the given file (name specified as a quoted string)");
      displayLine("\t     %encode  classify the current ontology");
      displayLine("\t       %save  save a classified ontology into the given file (name specified as a quoted string)");
      displayLine("\t       %load  read a saved classified ontology from the given file (name specified as a quoted string)");

      displayLine("\t       %size  print the number of symbols in the current sort taxonomy");
      displayLine("\t      %sorts  display the codes of all symbols in current sort taxonomy");
      displayLine("\t    %defined  list all the non-built-in sorts symbols in the current taxonomy");
      displayLine("\t   %builtins  list all the sorts symbols in the current taxonomy");
      displayLine("\t      %clear  erase the codes of all symbols in the current sort taxonomy");

      displayLine("\t%       eval  turn on sort evaluation");
      displayLine("\t%    no-eval  turn off sort evaluation");
      displayLine("\t%toggle-eval  toggle on/off sort evaluation");
      displayLine("\t       %time  toggle on/off execution time reporting");
      displayLine("\t  %automatic  toggle on/off automatic sort encoding");
      displayLine("\t       %mute  toggle on/off intermediate displays");

      displayLine("\t       %last  print the last evaluated sort expression and its maximal lower bound sort(s)");

      displayLine("\t     %height  print the height of the specified sort (size of longest is-a chain from it to {})");
      displayLine("\t      %width  print the size of the widest maximal antichain containing the specified sort");

      displayLine("\t   %children  print the set of maximal strict lower bounds of the specified sort");
      displayLine("\t%descendants  print the set of strict lower bounds of the specified sort");
      displayLine("\t    %parents  print the set of minimal strict upper bounds of the specified sort");
      displayLine("\t  %ancestors  print the set of strinct upper bounds of the specified sort");
      displayLine("\t   %enumsize  set number of symbols to display in sort enumerations");

      displayLine("\t        %isa  check whether the first specified sort is a subsort of the second one");

      displayLine("\t       %tree  toggle on/off graphical display of syntax tree");
      displayLine("\t         %gc  force immediate garbage collection");
      displayLine("\t     %syntax  toggle on/off parser tracing");
      displayLine("\t      %trace  toggle on/off evaluation tracing");
      displayLine("\t       %help  list this information");
      newLine();
    }

    /* ************************************************************************ */
    /* ************************** DISPLAY MANAGEMENT ************************** */
    /* ************************************************************************ */

The display manager.

    static DisplayManager dm = context.displayManager();

The display form manager.

    static DisplayFormManager dfm = dm.displayFormManager();

    /* ************************************************************************ */

Redirect the output to the specified PrintStream.

    public final void setOutputStream (PrintStream stream)
    {
      dm.setOutputStream(stream);
    }

    /* ************************************************************************ */

Returns the display form of the given sort.

    String displayForm (Sort sort)
    {
      return dfm.displaySortForm(sort);
    }

    /* ************************************************************************ */

Returns the display form of set of sorts represented by the specified BitCode.

    String displayForm (BitCode sorts)
    {
      return dfm.displayForm(sorts,context.taxonomy());
    }
    /* ************************************************************************ */

Returns the display form of the given hash set of sorts.

    String displayForm (HashSet sorts, boolean upper)
    {
      return dfm.displayForm(sorts,upper);
    }

    /* ************************************************************************ */

Displays the number of declared sorts on the display manager's output stream.

    void displaySize ()
    {
      try
        {
          displayLine("*** There are "+context.taxonomy().size()+" sorts defined");
        }
      catch (RuntimeException e)
        {
          logError(new Error().setMsg(e.getMessage()));
        }
    }

    /* ************************************************************************ */

Displays the declared sorts on the display manager's output stream.

    void displaySorts ()
    {
      try
        {
          displayLine("*** Declared sorts:");
          context.taxonomy().showSortCodes();
          displayLine("*** "+(context.taxonomy().size()-1)+" sorts defined");
        }
      catch (RuntimeException e)
        {
          logError(new Error().setMsg(e.getMessage()));
        }
    }

    /* ************************************************************************ */

If not in mute mode, displays the specified string on the display manager's output stream.

    final void display (String s)
    {
      if (isMute)
        return;

      dm.print(s);
    }

    /* ************************************************************************ */

If not in mute mode, displays the specified string on the display manager's output stream, and ends it with a newline.

    static final void displayLine (String s)
    {
      if (isMute)
        return;

      dm.println(s);
    }

    /* ************************************************************************ */

Outputs a newline on the display manager's output stream.

    final void newLine ()
    {
      dm.println();
    }

    /* ************************************************************************ */
    /* *************************** ERROR MANAGEMENT *************************** */
    /* ************************************************************************ */

    /* ************************************************************************ */

This parser's error log.

    ErrorLogger errorLogger = context.errorLogger();

Records the specified Error in this parser's error log.

    final void logError (Error error)
    {
      errorLogger.recordError(error);
    }

When this is true, a context reset is called for upon reporting errors.

    private boolean _criticalError = false;

When at top level, displays all the errors recorded in the error log and clears it.

    void reportErrors ()
    {
      if (((OsfV1Tokenizer)input).reader.depth() > 0)
        return;

      int size = errorLogger.size();
      int errorNo = 0;
      int warningNo = 0;

      for (int i=0; i<size; i++)
        {
          Error error = errorLogger.getError(i);
          displayLine(error.toString());
          if (error.isWarning())
    	warningNo++;
          else
    	errorNo++;
        }

      if (warningNo > 0)
        displayLine("*** There "+(warningNo==1 ? "was " : "were ")+warningNo+" warning"+(warningNo>1 ? "s" : ""));
      if (errorNo > 0)
        displayLine("*** There "+(errorNo==1 ? "was " : "were ")+errorNo+" error"+(errorNo>1 ? "s" : ""));

      if (_criticalError)
        {
          displayLine("*** Resetting context...");
          context.reset();
          _criticalError = false;
        }

      errorLogger.clearErrors();
    }

    /* ************************************************************************ */

    /* ************************************************************************ */

This is used for recording the location of syntactic constructs in the input stream in order to locate where potential errors occur.

    Locatable location;

    /* ************************************************************************ */

Returns a syntax error object with specified message.

    final Error syntacticError (String msg)
    {
      return new Error().setLabel("Syntax Error: ").setMsg(msg);
    }

    /* ************************************************************************ */

Returns a syntax error object with specified message, and situated as the specifed `Locatable` extent.

    final Error syntacticError (String msg, Locatable extent)
    {
      return syntacticError(msg).setExtent(extent);
    }

    /* ************************************************************************ */

Returns an evaluation error object with specified message.

    final Error evaluationError (String msg)
    {
      return new Error().setLabel("Evaluation Error: ").setMsg(msg);
    }

    /* ************************************************************************ */

Returns an evaluation error object with specified message, and situated as the specifed `Locatable` extent.

    final Error evaluationError (String msg, Locatable extent)
    {
      return evaluationError(msg).setExtent(extent);
    }

    /* ************************************************************************ */

    // /**
    //  * This method is used to situate an expression's abstract syntax with respect
    //  * to its concrete syntax origin (specified as the given <tt>Locatable</tt>).
    //  */
    // final Expression locate (Expression e, Locatable l)
    // {
    //   return e.setExtent(l);
    // }

    // /**
    //  * This method is used to situate an expression's abstract syntax with the
    //  * extent of the latest <tt>location</tt>.
    //  */
    // final Expression locate (Expression e)
    // {
    //   return e.setExtent(location);
    // }

    // final Expression locateSymbol (ParseNode node)
    // {
    //   return locate(symbol(node.svalue()),node);
    // }

    /* ************************************************************************ */

Prints out a prompt if needed for interactive input.

    final void prompt ()
    {
      ((OsfV1Tokenizer)input).prompt();
    }

Reports errors if any and, if interactive, prompts the user for more input.

    final void commitParse ()
    {
      reportErrors();
      prompt();
    }

    /* ************************************************************************ */

Sets the location to that of the specified `Locatable`.

    final void setLocation (Locatable locatable)
    {
      location = locatable;
    }

    /* ************************************************************************ */

Sets the location to that of the current parse node (i.e., the node currently at the top of the parse stack).

    final void setLocation ()
    {
      setLocation(currentNode());
    }

    /* ************************************************************************ */

    %}

    /* ************************************************************************ */
    /* ************************ END OF ANCILLARY CODE ************************* */
    /* ************************************************************************ */

This file was generated on Thu Oct 03 16:39:07 CEST 2013 from file `OsfV1Ancillary.grm`
by the `hlt.language.tools.Hilite` Java tool written by Hassan Aït-Kaci