// *******************************************************************
// This file has been automatically generated from the grammar in file
// OsfV1.grm by hlt.language.syntax.ParserGenerator on
// Fri Sep 06 08:49:34 CEST 2013 --- !!! PLEASE DO NO EDIT !!!
// *******************************************************************

package hlt.osf.v1;

import java.io.Reader;
import java.io.StringReader;
import java.io.IOException;
import hlt.language.syntax.*;
import hlt.language.tools.Misc;
import hlt.language.tools.Debug;
import hlt.language.util.Stack;
import hlt.language.util.ArrayList;
import hlt.language.util.IntIterator;
import hlt.language.util.Error;
import hlt.language.util.Span;
import hlt.language.util.Locatable;
import hlt.osf.io.*;
import hlt.osf.base.*;
import hlt.osf.util.*;
import hlt.osf.exec.*;
import hlt.language.io.CircularInclusionException;
import java.util.HashMap;
import java.util.HashSet;
import java.io.PrintStream;
import java.io.FileNotFoundException;


/* ************ */
/* PARSER CLASS */
/* ************ */

public class OsfV1Parser extends StaticParser
{
  /* ************************ */
  /* PARSER CLASS CONSTRUCTOR */
  /* ************************ */

  public OsfV1Parser (Tokenizer t)
    {
      input = t;
      xmlroot = "OsfV1Program";
    }

  /* ************************* */
  /* PARSER CLASS DECLARATIONS */
  /* ************************* */


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

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

/**
 * This is OSF execution context.
 */
  static Context context = new Context(1000000,2,3);

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

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

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

void processIsaDeclaration (ArrayList lhs, ArrayList 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));
}

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

void declareIsa (String s1, String s2) throws LockedCodeArrayException
{
  context.declareIsa(s1,s2,location);
}

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

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

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

/**
 * This builds an uninterpreted &psi;-term structure out of the
 * syntactic parts given as arguments as explained in the <a
 * href="#pstconstruc">specification</a>, 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());
      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 &psi;-terms, this builds an uninterpreted &psi;-term
 * structure out of the syntactic parts given as arguments as explained
 * in the <a href="#pstconstruc">specification</a>.
 */
PsiTerm buildPsiTerm (HashSet tags, Tag tag, SortExpression sort, Stack keys, Stack subterms)
{
  tag = tag.deref();	// dereference the tag to get to the correct one if needed
  
  PsiTerm pst = null;	// this is the new psiterm to build and return

  // if the tag is a reoccurring tag
  if (tags.contains(tag))	
    {
      // build this term with a new anonymous tag:
      pst = buildPsiTerm(tags,
			 Tag.getTag(null),
			 sort,
			 keys,
			 subterms);
      // // update the tag to its reference (due to possible mergings building pst)
      // tag = tag.deref();
      // retrieve the tag's term, marking the tag as shared (due to the reoccurrence):
      PsiTerm previous = tag.markAsShared().term();
      // merge the two terms and return:
      previous.merge(pst);
      return previous;
    }

  // the tag has not occurred before
  pst = new PsiTerm(tag).setSort(sort);	// construct a new psiterm with the given tag and sort
  tags.add(tag);			// and add the tag to the tag occurrences

  // if there are any subterms
  if (subterms != null) // then keys != null as well
    while (!subterms.empty())
      {
	// get the current raw subterm to build:
	RawPsiTerm sub = (RawPsiTerm)subterms.pop();
	// build the current subterm
	PsiTerm subterm = buildPsiTerm(tags,
				       Tag.getTag(sub.tag),
				       sub.sort,
				       sub.keys,
				       sub.subterms);

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

	// the possibly existing subterm for this key
	PsiTerm existingSubterm = null;

	if (key == null)
	  // this is an implicitly contiguous position
	  {
	    // retrieve the dereferenced possibly existing subterm:
	    existingSubterm = pst.getNextContiguousPositionSubterm();
	    if (existingSubterm == null)
	      pst.addContiguousPositionSubterm(subterm);
	    else
	      subterm.merge(existingSubterm.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);
	    else
	      subterm.merge(existingSubterm.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
	  subterm.merge(existingSubterm.deref());
      }
  
  return pst;    
}

/**
 * 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 of the pragma.  If in timing mode, also reports the
 * processing time in milliseconds.
 */
final void processPragma (String pragma, ArrayList 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, ArrayList args)
{
  setLocation();

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

  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((Stack)args);
      return;
    }

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

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

  if (pragma == "load")
    {
      loadTaxonomy((Stack)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 == "evaluate")
    {
      PsiTerm.toggleSortEvaluation();
      if (!isMute)
	display("Sort expression evaluation has been turned "
	       +(PsiTerm.evaluateSorts() ? "on" : "off")+"...\n");
      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));
	}
    }
}

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

/**
 * 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>i.e.</i>, no new sorts may be declared until this taxononmy has
 * been cleared (see the '<tt>%clear</tt>' 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   %evaluate  toggle on/off automatic 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.displaySortsForm(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 <tt>Locatable</tt> 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 <tt>Locatable</tt> 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 <tt>Locatable</tt>.
 */
final void setLocation (Locatable locatable)
{
  location = locatable;
}

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

/**
 * Sets the location to that of the current parse node (<i>i.e.</i>, the node
 * currently at the top of the parse stack).
 */
final void setLocation ()
{
  setLocation(currentNode());
}

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



  /* ********************** */
  /* STATIC INITIALIZATIONS */
  /* ********************** */

  static
    {
      initializeTerminals();
      initializeNonTerminals();
      initializeRules();
      initializeParserActions();
      initializeParserStates();
      initializeActionTables();
      initializeGotoTables();
      initializeStateTables();
    }

  /* ********************* */
  /* PARTIAL PARSE METHODS */
  /* ********************* */

  final static ParseNode $OSFV1PROGRAM_SWITCH$ = new ParseNode(terminals[3]);

  public final void parseOsfV1Program (String s) throws IOException
    {
      parseOsfV1Program(new StringReader(s));
    }

  public final void parseOsfV1Program (Reader r) throws IOException
    {
      input.setReader(r);
      errorManager().recoverFromErrors(false);
      setSwitchToken($OSFV1PROGRAM_SWITCH$);
      parse();
    }

  final static ParseNode $SORTEXPRESSION_SWITCH$ = new ParseNode(terminals[4]);

  public final void parseSortExpression (String s) throws IOException
    {
      parseSortExpression(new StringReader(s));
    }

  public final void parseSortExpression (Reader r) throws IOException
    {
      input.setReader(r);
      errorManager().recoverFromErrors(false);
      setSwitchToken($SORTEXPRESSION_SWITCH$);
      parse();
    }

  /* **************** */
  /* SEMANTIC ACTIONS */
  /* **************** */

  protected ParseNode semanticAction(ParserRule $rule$) throws IOException
    {
      ParseNode $head$ = new ParseNode($rule$.head);

      switch($rule$.index())
        {
          case 2:
            {
            $head$ = $head$.copy(node($rule$,2));
            break;
            }
          case 3:
            {
            $head$ = $head$.copy(node($rule$,2));
            break;
            }
          case 8:
            {
            commitParse();
            break;
            }
          case 11:
            {
            OsfV1PragmaArguments_opt $node2$;
                if (node($rule$,2) instanceof OsfV1PragmaArguments_opt)
                   $node2$ = (OsfV1PragmaArguments_opt)node($rule$,2);
                 else
                 {
                     $node2$ = new OsfV1PragmaArguments_opt(node($rule$,2));
                     replaceStackNode($rule$,2,$node2$);
                   }

        processPragma(node($rule$,1).svalue().intern(),$node2$.args);
            break;
            }
          case 15:
            {
            OsfV1IsaDeclarationStatement $node1$;
                if (node($rule$,1) instanceof OsfV1IsaDeclarationStatement)
                   $node1$ = (OsfV1IsaDeclarationStatement)node($rule$,1);
                 else
                 {
                     $node1$ = new OsfV1IsaDeclarationStatement(node($rule$,1));
                     replaceStackNode($rule$,1,$node1$);
                   }

        setLocation();
        processIsaDeclaration($node1$.lhs,$node1$.rhs);
            break;
            }
          case 16:
            {
            OsfV1IsaDeclarationStatement $node0$ = new OsfV1IsaDeclarationStatement($head$);
                 $head$ = (OsfV1IsaDeclarationStatement)$node0$;
    OsfV1SortSymbols $node1$;
                if (node($rule$,1) instanceof OsfV1SortSymbols)
                   $node1$ = (OsfV1SortSymbols)node($rule$,1);
                 else
                 {
                     $node1$ = new OsfV1SortSymbols(node($rule$,1));
                     replaceStackNode($rule$,1,$node1$);
                   }
    OsfV1SortSymbols $node3$;
                if (node($rule$,3) instanceof OsfV1SortSymbols)
                   $node3$ = (OsfV1SortSymbols)node($rule$,3);
                 else
                 {
                     $node3$ = new OsfV1SortSymbols(node($rule$,3));
                     replaceStackNode($rule$,3,$node3$);
                   }

        $node0$.lhs = $node1$.symbols;
        $node0$.rhs = $node3$.symbols;
            break;
            }
          case 18:
            {
            OsfV1SortSymbols $node0$ = new OsfV1SortSymbols($head$);
                 $head$ = (OsfV1SortSymbols)$node0$;

        $node0$.symbols = new Stack();
        $node0$.symbols.push(node($rule$,1).svalue());
            break;
            }
          case 19:
            {
            OsfV1SortSymbols $node0$ = new OsfV1SortSymbols($head$);
                 $head$ = (OsfV1SortSymbols)$node0$;
    OsfV1SortSymbols $node3$;
                if (node($rule$,3) instanceof OsfV1SortSymbols)
                   $node3$ = (OsfV1SortSymbols)node($rule$,3);
                 else
                 {
                     $node3$ = new OsfV1SortSymbols(node($rule$,3));
                     replaceStackNode($rule$,3,$node3$);
                   }

        ($node0$.symbols = $node3$.symbols).push(node($rule$,1).svalue());
            break;
            }
          case 20:
            {
            OsfV1SortExpression $node1$;
                if (node($rule$,1) instanceof OsfV1SortExpression)
                   $node1$ = (OsfV1SortExpression)node($rule$,1);
                 else
                 {
                     $node1$ = new OsfV1SortExpression(node($rule$,1));
                     replaceStackNode($rule$,1,$node1$);
                   }

        processSortExpression($node1$.expression);
            break;
            }
          case 21:
            {
            OsfV1PsiTerm $node1$;
                if (node($rule$,1) instanceof OsfV1PsiTerm)
                   $node1$ = (OsfV1PsiTerm)node($rule$,1);
                 else
                 {
                     $node1$ = new OsfV1PsiTerm(node($rule$,1));
                     replaceStackNode($rule$,1,$node1$);
                   }

        processPsiTerm($node1$.tag,$node1$.sort,$node1$.keys,$node1$.subterms);
            break;
            }
          case 22:
            {
            OsfV1PsiTerm $node0$ = new OsfV1PsiTerm($head$);
                 $head$ = (OsfV1PsiTerm)$node0$;

        $node0$.tag = node($rule$,1).svalue();
        $node0$.sort = new SymbolSortExpression("@",context);
            break;
            }
          case 23:
            {
            OsfV1PsiTerm $node0$ = new OsfV1PsiTerm($head$);
                 $head$ = (OsfV1PsiTerm)$node0$;
    OsfV1UntaggedPsiTerm $node1$;
                if (node($rule$,1) instanceof OsfV1UntaggedPsiTerm)
                   $node1$ = (OsfV1UntaggedPsiTerm)node($rule$,1);
                 else
                 {
                     $node1$ = new OsfV1UntaggedPsiTerm(node($rule$,1));
                     replaceStackNode($rule$,1,$node1$);
                   }

        $node0$.sort = $node1$.sort;
        $node0$.keys = $node1$.keys;
        $node0$.subterms = $node1$.subterms;
            break;
            }
          case 24:
            {
            OsfV1PsiTerm $node0$ = new OsfV1PsiTerm($head$);
                 $head$ = (OsfV1PsiTerm)$node0$;
    OsfV1UntaggedPsiTerm $node3$;
                if (node($rule$,3) instanceof OsfV1UntaggedPsiTerm)
                   $node3$ = (OsfV1UntaggedPsiTerm)node($rule$,3);
                 else
                 {
                     $node3$ = new OsfV1UntaggedPsiTerm(node($rule$,3));
                     replaceStackNode($rule$,3,$node3$);
                   }

        $node0$.tag = node($rule$,1).svalue();
        $node0$.sort = $node3$.sort;
        $node0$.keys = $node3$.keys;
        $node0$.subterms = $node3$.subterms;
            break;
            }
          case 25:
            {
            OsfV1UntaggedPsiTerm $node0$ = new OsfV1UntaggedPsiTerm($head$);
                 $head$ = (OsfV1UntaggedPsiTerm)$node0$;
    OsfV1SortExpression $node1$;
                if (node($rule$,1) instanceof OsfV1SortExpression)
                   $node1$ = (OsfV1SortExpression)node($rule$,1);
                 else
                 {
                     $node1$ = new OsfV1SortExpression(node($rule$,1));
                     replaceStackNode($rule$,1,$node1$);
                   }
    OsfV1Body_opt $node2$;
                if (node($rule$,2) instanceof OsfV1Body_opt)
                   $node2$ = (OsfV1Body_opt)node($rule$,2);
                 else
                 {
                     $node2$ = new OsfV1Body_opt(node($rule$,2));
                     replaceStackNode($rule$,2,$node2$);
                   }

        $node0$.sort = $node1$.expression;
        $node0$.keys = $node2$.keys;
        $node0$.subterms = $node2$.subterms;
            break;
            }
          case 27:
            {
            OsfV1Body_opt $node0$ = new OsfV1Body_opt($head$);
                 $head$ = (OsfV1Body_opt)$node0$;
    OsfV1SubTerms $node2$;
                if (node($rule$,2) instanceof OsfV1SubTerms)
                   $node2$ = (OsfV1SubTerms)node($rule$,2);
                 else
                 {
                     $node2$ = new OsfV1SubTerms(node($rule$,2));
                     replaceStackNode($rule$,2,$node2$);
                   }

        $node0$.keys = $node2$.keys;
        $node0$.subterms = $node2$.subterms;
            break;
            }
          case 28:
            {
            OsfV1SubTerms $node0$ = new OsfV1SubTerms($head$);
                 $head$ = (OsfV1SubTerms)$node0$;
    OsfV1SubTerm $node1$;
                if (node($rule$,1) instanceof OsfV1SubTerm)
                   $node1$ = (OsfV1SubTerm)node($rule$,1);
                 else
                 {
                     $node1$ = new OsfV1SubTerm(node($rule$,1));
                     replaceStackNode($rule$,1,$node1$);
                   }

        $node0$.keys = new Stack();
        $node0$.keys.push($node1$.key);
        $node0$.subterms = new Stack();
        $node0$.subterms.push($node1$.psiterm);
            break;
            }
          case 29:
            {
            OsfV1SubTerms $node0$ = new OsfV1SubTerms($head$);
                 $head$ = (OsfV1SubTerms)$node0$;
    OsfV1SubTerms $node3$;
                if (node($rule$,3) instanceof OsfV1SubTerms)
                   $node3$ = (OsfV1SubTerms)node($rule$,3);
                 else
                 {
                     $node3$ = new OsfV1SubTerms(node($rule$,3));
                     replaceStackNode($rule$,3,$node3$);
                   }
    OsfV1SubTerm $node1$;
                if (node($rule$,1) instanceof OsfV1SubTerm)
                   $node1$ = (OsfV1SubTerm)node($rule$,1);
                 else
                 {
                     $node1$ = new OsfV1SubTerm(node($rule$,1));
                     replaceStackNode($rule$,1,$node1$);
                   }

        ($node0$.keys = $node3$.keys).push($node1$.key);
        ($node0$.subterms = $node3$.subterms).push($node1$.psiterm);
            break;
            }
          case 30:
            {
            OsfV1SubTerm $node0$ = new OsfV1SubTerm($head$);
                 $head$ = (OsfV1SubTerm)$node0$;
    OsfV1PsiTerm $node1$;
                if (node($rule$,1) instanceof OsfV1PsiTerm)
                   $node1$ = (OsfV1PsiTerm)node($rule$,1);
                 else
                 {
                     $node1$ = new OsfV1PsiTerm(node($rule$,1));
                     replaceStackNode($rule$,1,$node1$);
                   }

        $node0$.key = null;
        $node0$.psiterm = new RawPsiTerm($node1$.tag,$node1$.sort,$node1$.keys,$node1$.subterms);
            break;
            }
          case 31:
            {
            OsfV1SubTerm $node0$ = new OsfV1SubTerm($head$);
                 $head$ = (OsfV1SubTerm)$node0$;
    OsfV1Feature $node1$;
                if (node($rule$,1) instanceof OsfV1Feature)
                   $node1$ = (OsfV1Feature)node($rule$,1);
                 else
                 {
                     $node1$ = new OsfV1Feature(node($rule$,1));
                     replaceStackNode($rule$,1,$node1$);
                   }
    OsfV1PsiTerm $node3$;
                if (node($rule$,3) instanceof OsfV1PsiTerm)
                   $node3$ = (OsfV1PsiTerm)node($rule$,3);
                 else
                 {
                     $node3$ = new OsfV1PsiTerm(node($rule$,3));
                     replaceStackNode($rule$,3,$node3$);
                   }

        $node0$.key = $node1$.feature;
        $node0$.psiterm = new RawPsiTerm($node3$.tag,$node3$.sort,$node3$.keys,$node3$.subterms);
            break;
            }
          case 32:
            {
            OsfV1Feature $node0$ = new OsfV1Feature($head$);
                 $head$ = (OsfV1Feature)$node0$;

        $node0$.feature = new Integer((int)node($rule$,1).nvalue());
            break;
            }
          case 33:
            {
            OsfV1Feature $node0$ = new OsfV1Feature($head$);
                 $head$ = (OsfV1Feature)$node0$;

        $node0$.feature = node($rule$,1).svalue();
            break;
            }
          case 34:
            {
            OsfV1SortExpression $node0$ = new OsfV1SortExpression($head$);
                 $head$ = (OsfV1SortExpression)$node0$;

        $node0$.expression = new SymbolSortExpression(node($rule$,1).svalue(),context);
            break;
            }
          case 35:
            {
            OsfV1SortExpression $node0$ = new OsfV1SortExpression($head$);
                 $head$ = (OsfV1SortExpression)$node0$;
    OsfV1SortList $node2$;
                if (node($rule$,2) instanceof OsfV1SortList)
                   $node2$ = (OsfV1SortList)node($rule$,2);
                 else
                 {
                     $node2$ = new OsfV1SortList(node($rule$,2));
                     replaceStackNode($rule$,2,$node2$);
                   }

        $node0$.expression = new DisjunctiveSortExpression($node2$.sortList,context);
            break;
            }
          case 36:
            {
            OsfV1SortExpression $node0$ = new OsfV1SortExpression($head$);
                 $head$ = (OsfV1SortExpression)$node0$;
    OsfV1SortExpression $node2$;
                if (node($rule$,2) instanceof OsfV1SortExpression)
                   $node2$ = (OsfV1SortExpression)node($rule$,2);
                 else
                 {
                     $node2$ = new OsfV1SortExpression(node($rule$,2));
                     replaceStackNode($rule$,2,$node2$);
                   }

        $node0$.expression = new NotSortExpression($node2$.expression);
            break;
            }
          case 37:
            {
            OsfV1SortExpression $node0$ = new OsfV1SortExpression($head$);
                 $head$ = (OsfV1SortExpression)$node0$;
    OsfV1SortExpression $node1$;
                if (node($rule$,1) instanceof OsfV1SortExpression)
                   $node1$ = (OsfV1SortExpression)node($rule$,1);
                 else
                 {
                     $node1$ = new OsfV1SortExpression(node($rule$,1));
                     replaceStackNode($rule$,1,$node1$);
                   }
    OsfV1SortExpression $node3$;
                if (node($rule$,3) instanceof OsfV1SortExpression)
                   $node3$ = (OsfV1SortExpression)node($rule$,3);
                 else
                 {
                     $node3$ = new OsfV1SortExpression(node($rule$,3));
                     replaceStackNode($rule$,3,$node3$);
                   }

        $node0$.expression = new AndSortExpression($node1$.expression,$node3$.expression);
            break;
            }
          case 38:
            {
            OsfV1SortExpression $node0$ = new OsfV1SortExpression($head$);
                 $head$ = (OsfV1SortExpression)$node0$;
    OsfV1SortExpression $node1$;
                if (node($rule$,1) instanceof OsfV1SortExpression)
                   $node1$ = (OsfV1SortExpression)node($rule$,1);
                 else
                 {
                     $node1$ = new OsfV1SortExpression(node($rule$,1));
                     replaceStackNode($rule$,1,$node1$);
                   }
    OsfV1SortExpression $node3$;
                if (node($rule$,3) instanceof OsfV1SortExpression)
                   $node3$ = (OsfV1SortExpression)node($rule$,3);
                 else
                 {
                     $node3$ = new OsfV1SortExpression(node($rule$,3));
                     replaceStackNode($rule$,3,$node3$);
                   }

        $node0$.expression = new OrSortExpression($node1$.expression,$node3$.expression);
            break;
            }
          case 39:
            {
            OsfV1SortExpression $node0$ = new OsfV1SortExpression($head$);
                 $head$ = (OsfV1SortExpression)$node0$;
    OsfV1SortExpression $node1$;
                if (node($rule$,1) instanceof OsfV1SortExpression)
                   $node1$ = (OsfV1SortExpression)node($rule$,1);
                 else
                 {
                     $node1$ = new OsfV1SortExpression(node($rule$,1));
                     replaceStackNode($rule$,1,$node1$);
                   }
    OsfV1SortExpression $node3$;
                if (node($rule$,3) instanceof OsfV1SortExpression)
                   $node3$ = (OsfV1SortExpression)node($rule$,3);
                 else
                 {
                     $node3$ = new OsfV1SortExpression(node($rule$,3));
                     replaceStackNode($rule$,3,$node3$);
                   }

        $node0$.expression = new ButnotSortExpression($node1$.expression,$node3$.expression);
            break;
            }
          case 40:
            {
            OsfV1SortExpression $node0$ = new OsfV1SortExpression($head$);
                 $head$ = (OsfV1SortExpression)$node0$;
    OsfV1SortExpression $node2$;
                if (node($rule$,2) instanceof OsfV1SortExpression)
                   $node2$ = (OsfV1SortExpression)node($rule$,2);
                 else
                 {
                     $node2$ = new OsfV1SortExpression(node($rule$,2));
                     replaceStackNode($rule$,2,$node2$);
                   }

        $node0$.expression = $node2$.expression.setParenthesized(true);
            break;
            }
          case 44:
            {
            OsfV1SortList $node0$ = new OsfV1SortList($head$);
                 $head$ = (OsfV1SortList)$node0$;

        $node0$.sortList = new Stack();
        $node0$.sortList.push(node($rule$,1).svalue());
            break;
            }
          case 45:
            {
            OsfV1SortList $node0$ = new OsfV1SortList($head$);
                 $head$ = (OsfV1SortList)$node0$;
    OsfV1SortList $node3$;
                if (node($rule$,3) instanceof OsfV1SortList)
                   $node3$ = (OsfV1SortList)node($rule$,3);
                 else
                 {
                     $node3$ = new OsfV1SortList(node($rule$,3));
                     replaceStackNode($rule$,3,$node3$);
                   }

        ($node0$.sortList = $node3$.sortList).push(node($rule$,1).svalue());
            break;
            }
          case 48:
            {
            Decoded.setEnumSize((int)node($rule$,1).nvalue());
            break;
            }
          case 49:
            {
            OsfV1PragmaArguments_opt $node0$ = new OsfV1PragmaArguments_opt($head$);
                 $head$ = (OsfV1PragmaArguments_opt)$node0$;
    OsfV1FileList $node1$;
                if (node($rule$,1) instanceof OsfV1FileList)
                   $node1$ = (OsfV1FileList)node($rule$,1);
                 else
                 {
                     $node1$ = new OsfV1FileList(node($rule$,1));
                     replaceStackNode($rule$,1,$node1$);
                   }

        $node0$.args = $node1$.files;
            break;
            }
          case 50:
            {
            OsfV1PragmaArguments_opt $node0$ = new OsfV1PragmaArguments_opt($head$);
                 $head$ = (OsfV1PragmaArguments_opt)$node0$;
    OsfV1SortExpression $node1$;
                if (node($rule$,1) instanceof OsfV1SortExpression)
                   $node1$ = (OsfV1SortExpression)node($rule$,1);
                 else
                 {
                     $node1$ = new OsfV1SortExpression(node($rule$,1));
                     replaceStackNode($rule$,1,$node1$);
                   }

        $node0$.args = new ArrayList(1);
        $node0$.args.add($node1$.expression);
            break;
            }
          case 51:
            {
            OsfV1PragmaArguments_opt $node0$ = new OsfV1PragmaArguments_opt($head$);
                 $head$ = (OsfV1PragmaArguments_opt)$node0$;
    OsfV1SortExpression $node1$;
                if (node($rule$,1) instanceof OsfV1SortExpression)
                   $node1$ = (OsfV1SortExpression)node($rule$,1);
                 else
                 {
                     $node1$ = new OsfV1SortExpression(node($rule$,1));
                     replaceStackNode($rule$,1,$node1$);
                   }
    OsfV1SortExpression $node2$;
                if (node($rule$,2) instanceof OsfV1SortExpression)
                   $node2$ = (OsfV1SortExpression)node($rule$,2);
                 else
                 {
                     $node2$ = new OsfV1SortExpression(node($rule$,2));
                     replaceStackNode($rule$,2,$node2$);
                   }

        $node0$.args = new ArrayList(2);
        $node0$.args.add($node1$.expression);
        $node0$.args.add($node2$.expression);
            break;
            }
          case 52:
            {
            OsfV1FileList $node0$ = new OsfV1FileList($head$);
                 $head$ = (OsfV1FileList)$node0$;

        $node0$.files = new Stack();
        $node0$.files.push(node($rule$,1).svalue());
            break;
            }
          case 53:
            {
            OsfV1FileList $node0$ = new OsfV1FileList($head$);
                 $head$ = (OsfV1FileList)$node0$;
    OsfV1FileList $node2$;
                if (node($rule$,2) instanceof OsfV1FileList)
                   $node2$ = (OsfV1FileList)node($rule$,2);
                 else
                 {
                     $node2$ = new OsfV1FileList(node($rule$,2));
                     replaceStackNode($rule$,2,$node2$);
                   }

        ($node0$.files = $node2$.files).push(node($rule$,1).svalue());
            break;
            }
          case 0: case 1: case 5: case 10: case 26: case 47: 
            break;
          default:
            $head$ = $head$.copy(node($rule$,1));
            break;
        }
      return $head$;
    }

  /* **************** */
  /* TERMINAL SYMBOLS */
  /* **************** */

  static void initializeTerminals ()
    {
      terminals = new ParserTerminal[26];

      newTerminal(0,"$EMPTY$",1,2);
      newTerminal(1,"$E_O_I$",1,2);
      newTerminal(2,"error",1,2);
      newTerminal(3,"$OsfV1Program_switch$",1,2);
      newTerminal(4,"$SortExpression_switch$",1,2);
      newTerminal(5,"EOS",1,2);
      newTerminal(6,"IDENTIFIER",11,2);
      newTerminal(7,"PRAGMA",11,2);
      newTerminal(8,"STRING",11,2);
      newTerminal(9,"TOP",11,2);
      newTerminal(10,"BOTTOM",11,2);
      newTerminal(11,"INTEGER",11,2);
      newTerminal(12,"TAG",11,2);
      newTerminal(13,"ARROW",21,2);
      newTerminal(14,"ISA",31,2);
      newTerminal(15,"BUTNOT",41,1);
      newTerminal(16,"OR",51,0);
      newTerminal(17,"AND",61,0);
      newTerminal(18,"NOT",71,1);
      newTerminal(19,",",1,2);
      newTerminal(20,":",1,2);
      newTerminal(21,"(",1,2);
      newTerminal(22,")",1,2);
      newTerminal(23,"{",1,2);
      newTerminal(24,"}",1,2);
      newTerminal(25,";",1,2);
    }

  /* ******************** */
  /* NON-TERMINAL SYMBOLS */
  /* ******************** */

  static void initializeNonTerminals ()
    {
      nonterminals = new ParserNonTerminal[25];

      newNonTerminal(0,"$START$");
      newNonTerminal(1,"$ROOTS$");
      newNonTerminal(2,"OsfV1Program");
      newNonTerminal(3,"SortExpression");
      newNonTerminal(4,"IsaDeclarationStatement");
      newNonTerminal(5,"SortSymbols");
      newNonTerminal(6,"SortList");
      newNonTerminal(7,"UntaggedPsiTerm");
      newNonTerminal(8,"Body_opt");
      newNonTerminal(9,"PsiTerm");
      newNonTerminal(10,"SubTerms");
      newNonTerminal(11,"SubTerm");
      newNonTerminal(12,"Feature");
      newNonTerminal(13,"PragmaArguments_opt");
      newNonTerminal(14,"FileList");
      newNonTerminal(15,"Statements_opt");
      newNonTerminal(16,"Statement");
      newNonTerminal(17,"StatementType");
      newNonTerminal(18,"EndOfStatement");
      newNonTerminal(19,"$ACTION0$");
      newNonTerminal(20,"Pragma");
      newNonTerminal(21,"SortDeclarationStatement");
      newNonTerminal(22,"OsfExpression");
      newNonTerminal(23,"SortSymbol");
      newNonTerminal(24,"Sort");
    }

  /* **************** */
  /* PRODUCTION RULES */
  /* **************** */

  static void initializeRules ()
    {
      rules = new ParserRule[54];

      rules[0] = new ParserRule(0,1,0,1,2);
      rules[1] = new ParserRule(1,1,1,1,2);
      rules[2] = new ParserRule(1,2,2,1,2);
      rules[3] = new ParserRule(1,2,3,1,2);
      rules[4] = new ParserRule(2,1,4,1,2);
      rules[5] = new ParserRule(15,0,5,1,2);
      rules[6] = new ParserRule(15,2,6,1,2);
      rules[7] = new ParserRule(16,2,7,1,2);
      rules[8] = new ParserRule(19,0,8,1,2);
      rules[9] = new ParserRule(18,2,9,1,2);
      rules[10] = new ParserRule(17,0,10,1,2);
      rules[11] = new ParserRule(17,2,11,1,2);
      rules[12] = new ParserRule(17,1,12,1,2);
      rules[13] = new ParserRule(17,1,13,1,2);
      rules[14] = new ParserRule(17,1,14,1,2);
      rules[15] = new ParserRule(21,1,15,1,2);
      rules[16] = new ParserRule(4,3,16,31,2);
      rules[17] = new ParserRule(23,1,17,11,2);
      rules[18] = new ParserRule(5,1,18,1,2);
      rules[19] = new ParserRule(5,3,19,1,2);
      rules[20] = new ParserRule(22,1,20,1,2);
      rules[21] = new ParserRule(22,1,21,1,2);
      rules[22] = new ParserRule(9,1,22,11,2);
      rules[23] = new ParserRule(9,1,23,1,2);
      rules[24] = new ParserRule(9,3,24,1,2);
      rules[25] = new ParserRule(7,2,25,1,2);
      rules[26] = new ParserRule(8,0,26,1,2);
      rules[27] = new ParserRule(8,3,27,1,2);
      rules[28] = new ParserRule(10,1,28,1,2);
      rules[29] = new ParserRule(10,3,29,1,2);
      rules[30] = new ParserRule(11,1,30,1,2);
      rules[31] = new ParserRule(11,3,31,21,2);
      rules[32] = new ParserRule(12,1,32,11,2);
      rules[33] = new ParserRule(12,1,33,11,2);
      rules[34] = new ParserRule(3,1,34,1,2);
      rules[35] = new ParserRule(3,3,35,1,2);
      rules[36] = new ParserRule(3,2,36,71,1);
      rules[37] = new ParserRule(3,3,37,61,0);
      rules[38] = new ParserRule(3,3,38,51,0);
      rules[39] = new ParserRule(3,3,39,41,1);
      rules[40] = new ParserRule(3,3,40,1,2);
      rules[41] = new ParserRule(24,1,41,11,2);
      rules[42] = new ParserRule(24,1,42,11,2);
      rules[43] = new ParserRule(24,1,43,11,2);
      rules[44] = new ParserRule(6,1,44,1,2);
      rules[45] = new ParserRule(6,3,45,1,2);
      rules[46] = new ParserRule(20,1,46,11,2);
      rules[47] = new ParserRule(13,0,47,1,2);
      rules[48] = new ParserRule(13,1,48,11,2);
      rules[49] = new ParserRule(13,1,49,1,2);
      rules[50] = new ParserRule(13,1,50,1,2);
      rules[51] = new ParserRule(13,2,51,1,2);
      rules[52] = new ParserRule(14,1,52,11,2);
      rules[53] = new ParserRule(14,2,53,11,2);
    }

  /* ************** */
  /* PARSER ACTIONS */
  /* ************** */

  static void initializeParserActions ()
    {
      actions = new ParserAction[402];

      newAction(0,5,0);
      newAction(1,2,0);
      newAction(2,0,3);
      newAction(3,0,4);
      newAction(4,1,5);
      newAction(5,1,5);
      newAction(6,1,5);
      newAction(7,1,5);
      newAction(8,1,5);
      newAction(9,1,5);
      newAction(10,1,5);
      newAction(11,1,5);
      newAction(12,1,5);
      newAction(13,1,5);
      newAction(14,1,5);
      newAction(15,1,1);
      newAction(16,1,5);
      newAction(17,1,5);
      newAction(18,1,5);
      newAction(19,1,5);
      newAction(20,1,5);
      newAction(21,1,5);
      newAction(22,1,5);
      newAction(23,1,5);
      newAction(24,1,5);
      newAction(25,1,5);
      newAction(26,1,5);
      newAction(27,0,8);
      newAction(28,0,9);
      newAction(29,0,11);
      newAction(30,0,25);
      newAction(31,0,26);
      newAction(32,0,32);
      newAction(33,1,4);
      newAction(34,1,10);
      newAction(35,0,8);
      newAction(36,0,9);
      newAction(37,0,11);
      newAction(38,0,14);
      newAction(39,0,20);
      newAction(40,0,21);
      newAction(41,0,24);
      newAction(42,0,25);
      newAction(43,0,26);
      newAction(44,1,6);
      newAction(45,1,6);
      newAction(46,1,6);
      newAction(47,1,6);
      newAction(48,1,6);
      newAction(49,1,6);
      newAction(50,1,6);
      newAction(51,1,6);
      newAction(52,1,6);
      newAction(53,1,6);
      newAction(54,1,6);
      newAction(55,1,34);
      newAction(56,1,34);
      newAction(57,1,34);
      newAction(58,1,34);
      newAction(59,1,34);
      newAction(60,1,34);
      newAction(61,1,34);
      newAction(62,1,34);
      newAction(63,1,34);
      newAction(64,1,34);
      newAction(65,1,34);
      newAction(66,1,34);
      newAction(67,1,34);
      newAction(68,0,25);
      newAction(69,0,26);
      newAction(70,0,32);
      newAction(71,0,8);
      newAction(72,0,9);
      newAction(73,0,11);
      newAction(74,0,25);
      newAction(75,0,26);
      newAction(76,0,32);
      newAction(77,1,20);
      newAction(78,0,34);
      newAction(79,0,35);
      newAction(80,0,36);
      newAction(81,0,48);
      newAction(82,0,8);
      newAction(83,0,9);
      newAction(84,0,11);
      newAction(85,0,25);
      newAction(86,0,26);
      newAction(87,0,32);
      newAction(88,0,63);
      newAction(89,1,18);
      newAction(90,1,18);
      newAction(91,0,60);
      newAction(92,1,22);
      newAction(93,1,22);
      newAction(94,1,22);
      newAction(95,0,44);
      newAction(96,1,23);
      newAction(97,1,23);
      newAction(98,1,23);
      newAction(99,1,8);
      newAction(100,0,8);
      newAction(101,0,9);
      newAction(102,0,11);
      newAction(103,1,47);
      newAction(104,0,29);
      newAction(105,0,31);
      newAction(106,0,25);
      newAction(107,0,26);
      newAction(108,0,32);
      newAction(109,1,12);
      newAction(110,1,13);
      newAction(111,1,14);
      newAction(112,1,46);
      newAction(113,1,46);
      newAction(114,1,46);
      newAction(115,1,46);
      newAction(116,1,46);
      newAction(117,1,46);
      newAction(118,1,46);
      newAction(119,1,46);
      newAction(120,1,46);
      newAction(121,1,15);
      newAction(122,1,21);
      newAction(123,1,17);
      newAction(124,1,17);
      newAction(125,1,43);
      newAction(126,1,43);
      newAction(127,1,43);
      newAction(128,1,43);
      newAction(129,1,43);
      newAction(130,1,41);
      newAction(131,1,41);
      newAction(132,1,41);
      newAction(133,1,41);
      newAction(134,1,41);
      newAction(135,1,41);
      newAction(136,1,41);
      newAction(137,1,41);
      newAction(138,1,41);
      newAction(139,1,41);
      newAction(140,1,41);
      newAction(141,1,41);
      newAction(142,1,41);
      newAction(143,1,41);
      newAction(144,1,41);
      newAction(145,1,42);
      newAction(146,1,42);
      newAction(147,1,42);
      newAction(148,1,42);
      newAction(149,1,42);
      newAction(150,1,42);
      newAction(151,1,42);
      newAction(152,1,42);
      newAction(153,1,42);
      newAction(154,1,42);
      newAction(155,1,42);
      newAction(156,1,42);
      newAction(157,1,42);
      newAction(158,1,42);
      newAction(159,1,42);
      newAction(160,1,11);
      newAction(161,0,34);
      newAction(162,0,35);
      newAction(163,0,36);
      newAction(164,1,50);
      newAction(165,0,8);
      newAction(166,0,9);
      newAction(167,0,11);
      newAction(168,0,25);
      newAction(169,0,26);
      newAction(170,0,32);
      newAction(171,1,48);
      newAction(172,1,49);
      newAction(173,1,52);
      newAction(174,0,31);
      newAction(175,1,43);
      newAction(176,1,43);
      newAction(177,1,43);
      newAction(178,1,43);
      newAction(179,1,43);
      newAction(180,1,43);
      newAction(181,1,43);
      newAction(182,1,43);
      newAction(183,1,43);
      newAction(184,1,43);
      newAction(185,1,43);
      newAction(186,1,43);
      newAction(187,1,43);
      newAction(188,1,43);
      newAction(189,1,43);
      newAction(190,1,53);
      newAction(191,0,8);
      newAction(192,0,9);
      newAction(193,0,11);
      newAction(194,0,25);
      newAction(195,0,26);
      newAction(196,0,32);
      newAction(197,0,8);
      newAction(198,0,9);
      newAction(199,0,11);
      newAction(200,0,25);
      newAction(201,0,26);
      newAction(202,0,32);
      newAction(203,0,8);
      newAction(204,0,9);
      newAction(205,0,11);
      newAction(206,0,25);
      newAction(207,0,26);
      newAction(208,0,32);
      newAction(209,0,34);
      newAction(210,0,35);
      newAction(211,0,36);
      newAction(212,1,51);
      newAction(213,0,34);
      newAction(214,0,35);
      newAction(215,0,36);
      newAction(216,1,39);
      newAction(217,1,39);
      newAction(218,1,39);
      newAction(219,1,39);
      newAction(220,1,39);
      newAction(221,1,39);
      newAction(222,1,39);
      newAction(223,1,39);
      newAction(224,1,39);
      newAction(225,1,39);
      newAction(226,0,34);
      newAction(227,0,35);
      newAction(228,1,38);
      newAction(229,1,38);
      newAction(230,1,38);
      newAction(231,1,38);
      newAction(232,1,38);
      newAction(233,1,38);
      newAction(234,1,38);
      newAction(235,1,38);
      newAction(236,1,38);
      newAction(237,1,38);
      newAction(238,1,38);
      newAction(239,1,38);
      newAction(240,0,34);
      newAction(241,1,37);
      newAction(242,1,37);
      newAction(243,1,37);
      newAction(244,1,37);
      newAction(245,1,37);
      newAction(246,1,37);
      newAction(247,1,37);
      newAction(248,1,37);
      newAction(249,1,37);
      newAction(250,1,37);
      newAction(251,1,37);
      newAction(252,1,37);
      newAction(253,1,37);
      newAction(254,1,7);
      newAction(255,1,7);
      newAction(256,1,7);
      newAction(257,1,7);
      newAction(258,1,7);
      newAction(259,1,7);
      newAction(260,1,7);
      newAction(261,1,7);
      newAction(262,1,7);
      newAction(263,1,7);
      newAction(264,1,7);
      newAction(265,0,43);
      newAction(266,1,9);
      newAction(267,1,9);
      newAction(268,1,9);
      newAction(269,1,9);
      newAction(270,1,9);
      newAction(271,1,9);
      newAction(272,1,9);
      newAction(273,1,9);
      newAction(274,1,9);
      newAction(275,1,9);
      newAction(276,1,9);
      newAction(277,0,8);
      newAction(278,0,9);
      newAction(279,0,11);
      newAction(280,0,25);
      newAction(281,0,26);
      newAction(282,0,32);
      newAction(283,1,24);
      newAction(284,1,24);
      newAction(285,1,24);
      newAction(286,0,34);
      newAction(287,0,35);
      newAction(288,0,36);
      newAction(289,1,26);
      newAction(290,1,26);
      newAction(291,1,26);
      newAction(292,0,48);
      newAction(293,1,25);
      newAction(294,1,25);
      newAction(295,1,25);
      newAction(296,0,8);
      newAction(297,0,9);
      newAction(298,0,11);
      newAction(299,0,14);
      newAction(300,0,53);
      newAction(301,0,54);
      newAction(302,0,25);
      newAction(303,0,26);
      newAction(304,0,59);
      newAction(305,1,28);
      newAction(306,0,57);
      newAction(307,1,30);
      newAction(308,1,30);
      newAction(309,0,55);
      newAction(310,1,32);
      newAction(311,1,33);
      newAction(312,1,43);
      newAction(313,1,43);
      newAction(314,1,43);
      newAction(315,1,43);
      newAction(316,1,43);
      newAction(317,1,43);
      newAction(318,0,8);
      newAction(319,0,9);
      newAction(320,0,11);
      newAction(321,0,14);
      newAction(322,0,25);
      newAction(323,0,26);
      newAction(324,0,32);
      newAction(325,1,31);
      newAction(326,1,31);
      newAction(327,0,8);
      newAction(328,0,9);
      newAction(329,0,11);
      newAction(330,0,14);
      newAction(331,0,53);
      newAction(332,0,54);
      newAction(333,0,25);
      newAction(334,0,26);
      newAction(335,1,29);
      newAction(336,1,27);
      newAction(337,1,27);
      newAction(338,1,27);
      newAction(339,0,62);
      newAction(340,1,19);
      newAction(341,1,19);
      newAction(342,1,17);
      newAction(343,1,17);
      newAction(344,1,17);
      newAction(345,0,62);
      newAction(346,1,16);
      newAction(347,0,34);
      newAction(348,0,35);
      newAction(349,0,36);
      newAction(350,0,66);
      newAction(351,1,40);
      newAction(352,1,40);
      newAction(353,1,40);
      newAction(354,1,40);
      newAction(355,1,40);
      newAction(356,1,40);
      newAction(357,1,40);
      newAction(358,1,40);
      newAction(359,1,40);
      newAction(360,1,40);
      newAction(361,1,40);
      newAction(362,1,40);
      newAction(363,1,40);
      newAction(364,1,36);
      newAction(365,1,36);
      newAction(366,1,36);
      newAction(367,1,36);
      newAction(368,1,36);
      newAction(369,1,36);
      newAction(370,1,36);
      newAction(371,1,36);
      newAction(372,1,36);
      newAction(373,1,36);
      newAction(374,1,36);
      newAction(375,1,36);
      newAction(376,1,36);
      newAction(377,0,72);
      newAction(378,1,44);
      newAction(379,0,70);
      newAction(380,0,25);
      newAction(381,0,26);
      newAction(382,0,32);
      newAction(383,1,45);
      newAction(384,1,35);
      newAction(385,1,35);
      newAction(386,1,35);
      newAction(387,1,35);
      newAction(388,1,35);
      newAction(389,1,35);
      newAction(390,1,35);
      newAction(391,1,35);
      newAction(392,1,35);
      newAction(393,1,35);
      newAction(394,1,35);
      newAction(395,1,35);
      newAction(396,1,35);
      newAction(397,1,3);
      newAction(398,0,34);
      newAction(399,0,35);
      newAction(400,0,36);
      newAction(401,1,2);
    }

  /* ************* */
  /* PARSER STATES */
  /* ************* */

  static void initializeParserStates ()
    {
      states = new ParserState[75];

      for (int i=0; i<75; i++) newState(i);
    }

  /* ************* */
  /* ACTION TABLES */
  /* ************* */

  static void initializeActionTables ()
    {
      newActionTables(66);

      newActionTable(0,13);
	setAction(0,1,4);
	setAction(0,2,5);
	setAction(0,3,2);
	setAction(0,4,3);
	setAction(0,5,6);
	setAction(0,6,7);
	setAction(0,7,8);
	setAction(0,9,9);
	setAction(0,10,10);
	setAction(0,12,11);
	setAction(0,18,12);
	setAction(0,21,13);
	setAction(0,23,14);

      newActionTable(1,1);
	setAction(1,1,1);

      newActionTable(2,1);
	setAction(2,1,15);

      newActionTable(3,11);
	setAction(3,1,16);
	setAction(3,2,17);
	setAction(3,18,24);
	setAction(3,21,25);
	setAction(3,5,18);
	setAction(3,23,26);
	setAction(3,6,19);
	setAction(3,7,20);
	setAction(3,9,21);
	setAction(3,10,22);
	setAction(3,12,23);

      newActionTable(4,6);
	setAction(4,18,28);
	setAction(4,21,29);
	setAction(4,6,32);
	setAction(4,23,27);
	setAction(4,9,30);
	setAction(4,10,31);

      newActionTable(5,11);
	setAction(5,1,33);
	setAction(5,2,39);
	setAction(5,18,36);
	setAction(5,21,37);
	setAction(5,5,34);
	setAction(5,6,41);
	setAction(5,23,35);
	setAction(5,7,40);
	setAction(5,9,42);
	setAction(5,10,43);
	setAction(5,12,38);

      newActionTable(6,11);
	setAction(6,1,44);
	setAction(6,2,45);
	setAction(6,18,52);
	setAction(6,21,53);
	setAction(6,5,46);
	setAction(6,23,54);
	setAction(6,6,47);
	setAction(6,7,48);
	setAction(6,9,49);
	setAction(6,10,50);
	setAction(6,12,51);

      newActionTable(7,13);
	setAction(7,1,55);
	setAction(7,5,56);
	setAction(7,6,57);
	setAction(7,9,58);
	setAction(7,10,59);
	setAction(7,15,60);
	setAction(7,17,62);
	setAction(7,16,61);
	setAction(7,19,64);
	setAction(7,18,63);
	setAction(7,21,65);
	setAction(7,23,67);
	setAction(7,22,66);

      newActionTable(8,3);
	setAction(8,6,70);
	setAction(8,9,68);
	setAction(8,10,69);

      newActionTable(9,5);
	setAction(9,17,78);
	setAction(9,16,79);
	setAction(9,21,81);
	setAction(9,5,77);
	setAction(9,15,80);

      newActionTable(10,1);
	setAction(10,14,88);

      newActionTable(11,3);
	setAction(11,19,91);
	setAction(11,5,89);
	setAction(11,14,90);

      newActionTable(12,4);
	setAction(12,19,93);
	setAction(12,20,95);
	setAction(12,5,92);
	setAction(12,22,94);

      newActionTable(13,3);
	setAction(13,19,97);
	setAction(13,5,96);
	setAction(13,22,98);

      newActionTable(14,1);
	setAction(14,5,99);

      newActionTable(15,9);
	setAction(15,18,101);
	setAction(15,21,102);
	setAction(15,5,103);
	setAction(15,6,108);
	setAction(15,23,100);
	setAction(15,8,105);
	setAction(15,9,106);
	setAction(15,10,107);
	setAction(15,11,104);

      newActionTable(16,1);
	setAction(16,5,109);

      newActionTable(17,1);
	setAction(17,5,110);

      newActionTable(18,1);
	setAction(18,5,111);

      newActionTable(19,9);
	setAction(19,18,118);
	setAction(19,21,119);
	setAction(19,5,112);
	setAction(19,23,120);
	setAction(19,6,113);
	setAction(19,8,114);
	setAction(19,9,115);
	setAction(19,10,116);
	setAction(19,11,117);

      newActionTable(20,1);
	setAction(20,5,121);

      newActionTable(21,1);
	setAction(21,5,122);

      newActionTable(22,7);
	setAction(22,17,128);
	setAction(22,16,127);
	setAction(22,19,124);
	setAction(22,21,129);
	setAction(22,5,125);
	setAction(22,14,123);
	setAction(22,15,126);

      newActionTable(23,15);
	setAction(23,1,130);
	setAction(23,5,131);
	setAction(23,6,132);
	setAction(23,9,133);
	setAction(23,10,134);
	setAction(23,15,135);
	setAction(23,17,137);
	setAction(23,16,136);
	setAction(23,19,139);
	setAction(23,18,138);
	setAction(23,21,140);
	setAction(23,23,142);
	setAction(23,22,141);
	setAction(23,25,144);
	setAction(23,24,143);

      newActionTable(24,15);
	setAction(24,1,145);
	setAction(24,5,146);
	setAction(24,6,147);
	setAction(24,9,148);
	setAction(24,10,149);
	setAction(24,15,150);
	setAction(24,17,152);
	setAction(24,16,151);
	setAction(24,19,154);
	setAction(24,18,153);
	setAction(24,21,155);
	setAction(24,23,157);
	setAction(24,22,156);
	setAction(24,25,159);
	setAction(24,24,158);

      newActionTable(25,1);
	setAction(25,5,160);

      newActionTable(26,10);
	setAction(26,17,161);
	setAction(26,16,162);
	setAction(26,18,166);
	setAction(26,21,167);
	setAction(26,5,164);
	setAction(26,6,170);
	setAction(26,23,165);
	setAction(26,9,168);
	setAction(26,10,169);
	setAction(26,15,163);

      newActionTable(27,1);
	setAction(27,5,171);

      newActionTable(28,1);
	setAction(28,5,172);

      newActionTable(29,2);
	setAction(29,5,173);
	setAction(29,8,174);

      newActionTable(30,15);
	setAction(30,1,175);
	setAction(30,5,176);
	setAction(30,6,177);
	setAction(30,9,178);
	setAction(30,10,179);
	setAction(30,15,180);
	setAction(30,17,182);
	setAction(30,16,181);
	setAction(30,19,184);
	setAction(30,18,183);
	setAction(30,21,185);
	setAction(30,23,187);
	setAction(30,22,186);
	setAction(30,25,189);
	setAction(30,24,188);

      newActionTable(31,1);
	setAction(31,5,190);

      newActionTable(32,4);
	setAction(32,17,209);
	setAction(32,16,210);
	setAction(32,5,212);
	setAction(32,15,211);

      newActionTable(33,13);
	setAction(33,1,216);
	setAction(33,5,217);
	setAction(33,6,218);
	setAction(33,9,219);
	setAction(33,10,220);
	setAction(33,15,215);
	setAction(33,17,213);
	setAction(33,16,214);
	setAction(33,19,222);
	setAction(33,18,221);
	setAction(33,21,223);
	setAction(33,23,225);
	setAction(33,22,224);

      newActionTable(34,13);
	setAction(34,1,228);
	setAction(34,5,229);
	setAction(34,6,230);
	setAction(34,9,231);
	setAction(34,10,232);
	setAction(34,15,233);
	setAction(34,17,226);
	setAction(34,16,234);
	setAction(34,19,236);
	setAction(34,18,235);
	setAction(34,21,237);
	setAction(34,23,239);
	setAction(34,22,238);

      newActionTable(35,13);
	setAction(35,1,241);
	setAction(35,5,242);
	setAction(35,6,243);
	setAction(35,9,244);
	setAction(35,10,245);
	setAction(35,15,246);
	setAction(35,17,248);
	setAction(35,16,247);
	setAction(35,19,250);
	setAction(35,18,249);
	setAction(35,21,251);
	setAction(35,23,253);
	setAction(35,22,252);

      newActionTable(36,11);
	setAction(36,1,254);
	setAction(36,2,255);
	setAction(36,18,262);
	setAction(36,21,263);
	setAction(36,5,256);
	setAction(36,23,264);
	setAction(36,6,257);
	setAction(36,7,258);
	setAction(36,9,259);
	setAction(36,10,260);
	setAction(36,12,261);

      newActionTable(37,1);
	setAction(37,5,265);

      newActionTable(38,11);
	setAction(38,1,266);
	setAction(38,2,267);
	setAction(38,18,274);
	setAction(38,21,275);
	setAction(38,5,268);
	setAction(38,23,276);
	setAction(38,6,269);
	setAction(38,7,270);
	setAction(38,9,271);
	setAction(38,10,272);
	setAction(38,12,273);

      newActionTable(39,3);
	setAction(39,19,284);
	setAction(39,5,283);
	setAction(39,22,285);

      newActionTable(40,7);
	setAction(40,17,286);
	setAction(40,16,287);
	setAction(40,19,290);
	setAction(40,21,292);
	setAction(40,5,289);
	setAction(40,22,291);
	setAction(40,15,288);

      newActionTable(41,3);
	setAction(41,19,294);
	setAction(41,5,293);
	setAction(41,22,295);

      newActionTable(42,8);
	setAction(42,18,297);
	setAction(42,21,298);
	setAction(42,6,301);
	setAction(42,23,296);
	setAction(42,9,302);
	setAction(42,10,303);
	setAction(42,11,300);
	setAction(42,12,299);

      newActionTable(43,1);
	setAction(43,22,304);

      newActionTable(44,2);
	setAction(44,19,306);
	setAction(44,22,305);

      newActionTable(45,2);
	setAction(45,19,307);
	setAction(45,22,308);

      newActionTable(46,1);
	setAction(46,13,309);

      newActionTable(47,1);
	setAction(47,13,310);

      newActionTable(48,7);
	setAction(48,17,314);
	setAction(48,16,313);
	setAction(48,19,315);
	setAction(48,21,316);
	setAction(48,22,317);
	setAction(48,13,311);
	setAction(48,15,312);

      newActionTable(49,7);
	setAction(49,18,319);
	setAction(49,21,320);
	setAction(49,6,324);
	setAction(49,23,318);
	setAction(49,9,322);
	setAction(49,10,323);
	setAction(49,12,321);

      newActionTable(50,2);
	setAction(50,19,325);
	setAction(50,22,326);

      newActionTable(51,1);
	setAction(51,22,335);

      newActionTable(52,3);
	setAction(52,19,337);
	setAction(52,5,336);
	setAction(52,22,338);

      newActionTable(53,1);
	setAction(53,6,339);

      newActionTable(54,2);
	setAction(54,5,340);
	setAction(54,14,341);

      newActionTable(55,3);
	setAction(55,19,344);
	setAction(55,5,342);
	setAction(55,14,343);

      newActionTable(56,1);
	setAction(56,5,346);

      newActionTable(57,4);
	setAction(57,17,347);
	setAction(57,16,348);
	setAction(57,22,350);
	setAction(57,15,349);

      newActionTable(58,13);
	setAction(58,1,351);
	setAction(58,5,352);
	setAction(58,6,353);
	setAction(58,9,354);
	setAction(58,10,355);
	setAction(58,15,356);
	setAction(58,17,358);
	setAction(58,16,357);
	setAction(58,19,360);
	setAction(58,18,359);
	setAction(58,21,361);
	setAction(58,23,363);
	setAction(58,22,362);

      newActionTable(59,13);
	setAction(59,1,364);
	setAction(59,5,365);
	setAction(59,6,366);
	setAction(59,9,367);
	setAction(59,10,368);
	setAction(59,15,369);
	setAction(59,17,371);
	setAction(59,16,370);
	setAction(59,19,373);
	setAction(59,18,372);
	setAction(59,21,374);
	setAction(59,23,376);
	setAction(59,22,375);

      newActionTable(60,1);
	setAction(60,24,377);

      newActionTable(61,2);
	setAction(61,25,379);
	setAction(61,24,378);

      newActionTable(62,1);
	setAction(62,24,383);

      newActionTable(63,13);
	setAction(63,1,384);
	setAction(63,5,385);
	setAction(63,6,386);
	setAction(63,9,387);
	setAction(63,10,388);
	setAction(63,15,389);
	setAction(63,17,391);
	setAction(63,16,390);
	setAction(63,19,393);
	setAction(63,18,392);
	setAction(63,21,394);
	setAction(63,23,396);
	setAction(63,22,395);

      newActionTable(64,4);
	setAction(64,17,398);
	setAction(64,16,399);
	setAction(64,1,397);
	setAction(64,15,400);

      newActionTable(65,1);
	setAction(65,1,401);

    }

  /* *********** */
  /* GOTO TABLES */
  /* *********** */

  static void initializeGotoTables ()
    {
      newGotoTables(23);

      newGotoTable(0,3);
	setGoto(0,1,1);
	setGoto(0,2,2);
	setGoto(0,15,5);

      newGotoTable(1,0);

      newGotoTable(2,2);
	setGoto(2,2,74);
	setGoto(2,15,5);

      newGotoTable(3,2);
	setGoto(3,3,73);
	setGoto(3,24,7);

      newGotoTable(4,12);
	setGoto(4,17,16);
	setGoto(4,16,6);
	setGoto(4,3,10);
	setGoto(4,4,22);
	setGoto(4,21,18);
	setGoto(4,20,17);
	setGoto(4,5,12);
	setGoto(4,23,13);
	setGoto(4,22,19);
	setGoto(4,7,15);
	setGoto(4,9,23);
	setGoto(4,24,7);

      newGotoTable(5,2);
	setGoto(5,6,68);
	setGoto(5,24,69);

      newGotoTable(6,2);
	setGoto(6,3,67);
	setGoto(6,24,7);

      newGotoTable(7,1);
	setGoto(7,8,47);

      newGotoTable(8,2);
	setGoto(8,3,65);
	setGoto(8,24,7);

      newGotoTable(9,2);
	setGoto(9,19,42);
	setGoto(9,18,41);

      newGotoTable(10,4);
	setGoto(10,3,28);
	setGoto(10,24,7);
	setGoto(10,13,27);
	setGoto(10,14,30);

      newGotoTable(11,2);
	setGoto(11,3,37);
	setGoto(11,24,7);

      newGotoTable(12,1);
	setGoto(12,14,33);

      newGotoTable(13,2);
	setGoto(13,3,40);
	setGoto(13,24,7);

      newGotoTable(14,2);
	setGoto(14,3,39);
	setGoto(14,24,7);

      newGotoTable(15,2);
	setGoto(15,3,38);
	setGoto(15,24,7);

      newGotoTable(16,3);
	setGoto(16,3,46);
	setGoto(16,7,45);
	setGoto(16,24,7);

      newGotoTable(17,7);
	setGoto(17,3,46);
	setGoto(17,7,15);
	setGoto(17,9,51);
	setGoto(17,24,7);
	setGoto(17,10,49);
	setGoto(17,11,50);
	setGoto(17,12,52);

      newGotoTable(18,4);
	setGoto(18,3,46);
	setGoto(18,7,15);
	setGoto(18,24,7);
	setGoto(18,9,56);

      newGotoTable(19,7);
	setGoto(19,3,46);
	setGoto(19,7,15);
	setGoto(19,9,51);
	setGoto(19,24,7);
	setGoto(19,10,58);
	setGoto(19,11,50);
	setGoto(19,12,52);

      newGotoTable(20,2);
	setGoto(20,5,61);
	setGoto(20,23,13);

      newGotoTable(21,2);
	setGoto(21,5,64);
	setGoto(21,23,13);

      newGotoTable(22,2);
	setGoto(22,6,71);
	setGoto(22,24,69);

    }

  /* ************ */
  /* STATE TABLES */
  /* ************ */

  static void initializeStateTables ()
    {
      setTables(0,0,0);
      setTables(1,1,1);
      setTables(2,2,1);
      setTables(3,3,2);
      setTables(4,4,3);
      setTables(5,5,4);
      setTables(6,6,1);
      setTables(7,7,1);
      setTables(8,8,5);
      setTables(9,4,6);
      setTables(10,9,7);
      setTables(11,4,8);
      setTables(12,10,1);
      setTables(13,11,1);
      setTables(14,12,1);
      setTables(15,13,1);
      setTables(16,14,9);
      setTables(17,15,10);
      setTables(18,16,1);
      setTables(19,17,1);
      setTables(20,18,1);
      setTables(21,19,1);
      setTables(22,20,1);
      setTables(23,21,1);
      setTables(24,22,1);
      setTables(25,23,1);
      setTables(26,24,1);
      setTables(27,25,1);
      setTables(28,26,11);
      setTables(29,27,1);
      setTables(30,28,1);
      setTables(31,29,12);
      setTables(32,30,1);
      setTables(33,31,1);
      setTables(34,4,13);
      setTables(35,4,14);
      setTables(36,4,15);
      setTables(37,32,1);
      setTables(38,33,1);
      setTables(39,34,1);
      setTables(40,35,1);
      setTables(41,36,1);
      setTables(42,37,1);
      setTables(43,38,1);
      setTables(44,4,16);
      setTables(45,39,1);
      setTables(46,40,7);
      setTables(47,41,1);
      setTables(48,42,17);
      setTables(49,43,1);
      setTables(50,44,1);
      setTables(51,45,1);
      setTables(52,46,1);
      setTables(53,47,1);
      setTables(54,48,1);
      setTables(55,49,18);
      setTables(56,50,1);
      setTables(57,42,19);
      setTables(58,51,1);
      setTables(59,52,1);
      setTables(60,53,20);
      setTables(61,54,1);
      setTables(62,55,1);
      setTables(63,53,21);
      setTables(64,56,1);
      setTables(65,57,1);
      setTables(66,58,1);
      setTables(67,59,1);
      setTables(68,60,1);
      setTables(69,61,1);
      setTables(70,8,22);
      setTables(71,62,1);
      setTables(72,63,1);
      setTables(73,64,1);
      setTables(74,65,1);
    }
}

/* ***************** */
/* ANCILLARY CLASSES */
/* ***************** */

class OsfV1IsaDeclarationStatement extends ParseNode 
{
  OsfV1IsaDeclarationStatement (ParseNode node)
    {
      super(node);
    }

  Stack lhs;
  Stack rhs;
}

class OsfV1SortSymbols extends ParseNode 
{
  OsfV1SortSymbols (ParseNode node)
    {
      super(node);
    }

  Stack symbols;
}

class OsfV1SortList extends ParseNode 
{
  OsfV1SortList (ParseNode node)
    {
      super(node);
    }

  Stack sortList;
}

class OsfV1UntaggedPsiTerm extends OsfV1Body_opt 
{
  OsfV1UntaggedPsiTerm (ParseNode node)
    {
      super(node);
    }

  SortExpression sort;
}

class OsfV1PsiTerm extends OsfV1UntaggedPsiTerm 
{
  OsfV1PsiTerm (ParseNode node)
    {
      super(node);
    }

  String tag;
}

class OsfV1Body_opt extends ParseNode 
{
  OsfV1Body_opt (ParseNode node)
    {
      super(node);
    }

  Stack keys;
  Stack subterms;
}

class OsfV1SubTerms extends OsfV1Body_opt 
{
  OsfV1SubTerms (ParseNode node)
    {
      super(node);
    }

  
}

class OsfV1SubTerm extends ParseNode 
{
  OsfV1SubTerm (ParseNode node)
    {
      super(node);
    }

  Object key;
  Object psiterm;
}

class OsfV1Feature extends ParseNode 
{
  OsfV1Feature (ParseNode node)
    {
      super(node);
    }

  Object feature;
}

class OsfV1PragmaArguments_opt extends ParseNode 
{
  OsfV1PragmaArguments_opt (ParseNode node)
    {
      super(node);
    }

  ArrayList args;
}

class OsfV1FileList extends ParseNode 
{
  OsfV1FileList (ParseNode node)
    {
      super(node);
    }

  Stack files;
}



/* ************************************************************************ */
/* ************************* END OF GRAMMAR RULES ************************* */
/* ************************************************************************ */

/* ************************************************************************ */
/* ******************************* UTILITIES ****************************** */
/* ************************************************************************ */

class RawPsiTerm
  {
    String tag;
    SortExpression sort;
    Stack keys;
    Stack subterms;

    RawPsiTerm (String tag, SortExpression sort, Stack keys, Stack subterms)
      {
	this.tag = tag;
	this.sort = sort;
	this.keys = keys;
	this.subterms = subterms;
      }
  }

/* ************************************************************************ */
/* ***************************** END  OF  GRAMMAR ************************* */
/* ************************************************************************ */

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

