|
FuzzyFOTLatticeParser.java
|
// ******************************************************************* // This file has been automatically generated from the grammar in file // FuzzyFOTLattice.grm by hlt.language.syntax.ParserGenerator on // Wed Dec 18 03:39:35 PST 2019 --- !!! PLEASE DO NO EDIT !!! // ******************************************************************* import java.io.Reader; import java.io.StringReader; import java.io.IOException; import hlt.language.syntax.*; import java.util.Date; import java.util.Stack; import java.util.Vector; import java.util.HashMap; import java.util.ArrayList; import java.io.FileNotFoundException; import hlt.fot.*; import hlt.fot.fuz.*; import hlt.math.fuzzy.FuzzyMatrix; import hlt.language.util.SetOf; import hlt.language.util.IntArrayList; import hlt.language.util.DoubleArrayList; import hlt.language.tools.Misc; import hlt.language.io.CircularInclusionException; /* ************ */ /* PARSER CLASS */ /* ************ */ class FuzzyFOTLatticeParser extends StaticParser { /* ************************ */ /* PARSER CLASS CONSTRUCTOR */ /* ************************ */ public FuzzyFOTLatticeParser (Tokenizer t) { input = t; xmlroot = "Session"; } /* ************************* */ /* PARSER CLASS DECLARATIONS */ /* ************************* */ /* ******************************************************************** */
| Declare and initialize some global names and structures (accessible by all methods in the parser). More are declared and initialized below just before or after the first method that uses them. |
// temp structure used to process subterms Stack termStack = new Stack(); // "raw" term structure - a tree of strings SyntacticTerm temp; // temps for holding the actual term read off the raw term and fot operations' operands FirstOrderTerm term, lhs, rhs; // the signature of functors some of which are similar SimilarFunctorSignature signature = new SimilarFunctorSignature(); // a name -> functor table to retrieve functors by name: HashMap functorTable = new HashMap(); // the similarity (when computed - null otherwise) SignatureSimilarity similarity; // the list of similarity degrees in the similarity (if not null) - sorted in ascending order DoubleArrayList degrees; // the current similarity degree - initialized to 1.0 (crisp true) double degree = 1.0; // the current tracing detail level - initialized to 0 (shut-up level) int tracingVerbosity = 0; /* ************************************************************************ */
| Shorthands for tools to ease tagged interaction messaging. |
// output a new line void line () { out.println(); } // output a new line containing msg void line (String msg) { out.println(msg); } // outputs a sequence of new lines containing an element of array msgs void lines (String[] msgs) { for (int i=0; i<msgs.length; i++) line(msgs[i]); } // output a new line starting with "*** " containing msg void say (String msg) { line("*** "+msg); } // outputs a sequence of new lines each starting with "*** " and // containing an element of array msgs void sayLines (String[] msgs) { for (int i=0; i<msgs.length; i++) say(msgs[i]); } // output a new line starting with ">>> " containing msg void note (String msg) { err.println(">>> "+msg); } // output a new line starting with "!!! " containing msg void warn (String msg) { err.println("!!! "+msg); } /* ************************************************************************ */
| Pragma bookkeeping. |
// current pragma being executed if one is; null otherwise private String pragma = null; String pragma () { return pragma; } void setPragma (String pragma) { this.pragma = pragma; } // table of strings containing the formats of the defined pragmas ArrayList pragmaTable = initializePragmaTable(); // method to initialize the pragma table ArrayList initializePragmaTable () { pragmaTable = new ArrayList(); pragmaTable.add("#info pragma;"); pragmaTable.add("#fun f1/n1 ... fk/nk;"); pragmaTable.add("#sig;"); pragmaTable.add("#sim f1 g1 α1 ... fk gk αk;"); pragmaTable.add("#close;"); pragmaTable.add("#funclass f α;"); pragmaTable.add("#termclass term α;"); pragmaTable.add("#funrep f α;"); pragmaTable.add("#termrep term α;"); pragmaTable.add("#show;"); pragmaTable.add("#map f g α i1:j1 ... ik:jk;"); pragmaTable.add("#comp;"); pragmaTable.add("#load \"file\";"); pragmaTable.add("#trace n;"); pragmaTable.add("#reset;"); return pragmaTable; } /* ******************************************************************** */
| Static global arrays of text strings containing detailed info per pragma. Each element is a line that will be printed with 'say' in the order of indices. |
private static String[] infoPragmaInfoLines = new String[] { "'#info;' will list all currently known info topics;", "'#info #foo;' will print info specific to known pragma '#foo'." }; private static String[] funPragmaInfoLines = new String[] { "'#fun f1/n1 ... fk/nk;' will declare signature functor symbols,", "where fi is an identifier denoting a functor's name being declared,", "and ni is a natural number specifying its arity, for each i = 1,...,k,", "then print the current signature; the slashes '/' are optional and can", "be blank space; e.g., '#fun f1 n1 ... fk nk;'." }; private static String[] sigPragmaInfoLines = new String[] { "'#sig;' will print the current signature (same as '#fun;')." }; private static String[] simPragmaInfoLines = new String[] { "'#sim f1 g1 α1 ... fk gk αk;' will declare similar pairs of functors,", "where fi and gi denote (necessarily distinct and similar) functors' names", "and each αi is a value in the interval (0.0,1.0] defining their similariy", "degree, for each i = 1,...,k." }; private static String[] closePragmaInfoLines = new String[] { "'#close;' will compute the similarity closure of the set of fuzzy pairs", "that have been declared for the current signature." }; private static String[] showPragmaInfoLines = new String[] { "'#show;' will display the currently declared similar pairs on the current", "signature as a square matrix on the signature, of values in [0.0,1.0], its", "corresponding set of similarity degrees, and lists the partitions per", "similarity degrees." }; private static String[] funclassPragmaInfoLines = new String[] { "'#funclass f α;' will, if the similarity has been closed, display the", "similarity class of functor f at similarity degree α." }; private static String[] termclassPragmaInfoLines = new String[] { "'#termclass t α;' will, if the similarity has been closed, display the", "similarity class of FOT t at similarity degree α." }; private static String[] funrepPragmaInfoLines = new String[] { "'#funrep f α;', will, if the similarity has been closed, show the", "similarity class representative of functor f at similarity degree α." }; private static String[] termrepPragmaInfoLines = new String[] { "'#termrep t α;' will, if the similarity has been closed, show the", "similarity class representative of FOT t at similarity degree α." }; private static String[] mapPragmaInfoLines = new String[] { "'#map f g α i1:j1 ... ik:jk;' will specify an argument-position map where:\n", "\t- f and g are (necessarily distinct and similar) functors;\n", "\t- α is a value in the interval (0.0,1.0] that belongs to the (finite)", "set of known approximation degrees in the current similarity on the current", "functor signature (if it is not, it will be set de facto to the greatest", "known positive degree in the similary that has a lesser value if one exists,", "otherwise this will generate an error);\n", "\t- k is a natural number such that 0 <= k <= Math.min(f.arity(),g.arity());\n", "\t- each i:j is a pair of non-zero natural numbers such that 1 <= i <= f.arity()", "and 1 <= j <= g.arity() indicating which argument positions of f and g are in", "(necessarily injective) mutual correspondence at approximation level α.\n\n", "This is therefore equivalent to '#map g f α j1:i1 ... jk:ik'.\n\n", "Note that when k=0 (i.e., just entering '#map f g α;'), the similarity between", "any two term structures whose root symbols are these respective functors will", "involve none of their subterms at approximation degree α or less, regardless of", "whether either of their respective arities is non-zero.\n\n", "N.B.: a #map pragma may be executed several times on the same two functors f and", "g for a same or different α. Upon invoking the pragma #comp, the compound effects", "on the same pair will result, in the order specified if these position maps are", "verified to be consistent, later ones overriding the effects of any earlier ones", "executed. Also, for any pair of functors (f,g) for which no #map is specified,", "the default is the identity on {1, ..., Math.min(f.arity(),g.arity())}." }; private static String[] compPragmaInfoLines = new String[] { "'#comp;' will verify all the necessary consistency conditions for partial", "non-aligned similar functor arguments: namely, that all the declared", "argument-position maps between any similar pair of functors for the current", "signature's similarity have, for all the similarity's approximation degrees,", "monotonically decreasing domains, ranges, and similarity classes as the fuzzy", "approximation degree decreases and are consistent under composition (completing", "the signature and its similarity if necessary and if a consistent completion is", "possible), or indicates an existing map inconsistency." }; private static String[] loadPragmaInfoLines = new String[] { "'#load \"file\";' will load and execute the clauses contained in the file." }; private static String[] tracePragmaInfoLines = new String[] { "'#trace n;' where n is a natural number will turn on tracing mode at a verbosity", "detail level of n (the greater, the more verbose). To turn off tracing mode, one", "uses '#trace 0;' (or simply '#trace;'). When in tracing mode, FFF gives details of", "what it does (useful for debugging or if one wishes to see this sort of information)." }; private static String[] resetPragmaInfoLines = new String[] { "'#reset;' will erase all declared functors and reset the signature and similarity." }; /* ************************************************************************ */
| Register the name of a functor, ensuring only one arity per functor name. |
void registerFunctor (String name, Functor functor) { // if one is already registered under this name but not with this // arity the following test will raise a BadFunctorArityException: if (functorTable.put(name,signature.functor(name,functor.arity())) != null) // registered with same arity: no need to worry return; // // new functor; inform about this // warn("New functor added to signature: "+functor); // if similarity not yet defined, a new functor causes no harm: we're done! if (similarity == null) return; // similarity was defined; must update it on the fly on the augmented // signature as this may happen while evaluating a lattice operation // containing the new functor similarity = new SignatureSimilarity(signature,triplesToArray(declaredPairs)); // inform of the deed warn("New functor: "+functor+ " ('#show;<CR>' to see new least similarity on "+signature+")"); } /* ************************************************************************ */ ArrayList declaredPairs = new ArrayList(); void declareSimilarPair (String left, String right, double degree) { if (left == right) { warn("Bad similarity declaration: can only declare distinct similar pairs"); warn("Similarity declaration ignored"); return; } Functor L = (Functor)functorTable.get(left); boolean leftUnknown = (L == null); if (leftUnknown) warn("Unknown functor "+left); Functor R = (Functor)functorTable.get(right); boolean rightUnknown = (R == null); if (rightUnknown) warn("Unknown functor "+right); if (leftUnknown || rightUnknown) { warn("Similarity declaration ignored"); return; } // record the declared pair and degree declaredPairs.add(new SignatureSimilarityTriple(L,R,degree)); if (similarity != null) { // reset and warn of need to re-compute similarity = null; warn("New similarity declaration: re-compute closure with '#close;<CR>'"); } } /* ************************************************************************ */ ArrayList declaredMaps = new ArrayList(); IntArrayList declaredPairMapList = new IntArrayList(); void declareArgumentMapping (String left, String right, double degree) { // the following is commented out since already done when the FuzzyPair was read // declareSimilarPair(left,right,degree); if (declaredMaps.size() == 0) say("There are no declared argument mappings"); else say("Declared argument mappings: "); for (int i = 0; i < declaredMaps.size(); i++) line("\t"+declaredMaps.get(i)); } /* ************************************************************************ */
| Transforms the set of declared fuzzy pairs, an ArrayList of SignatureSimilarityTriple objects, into the same information encoded as a functor-indexed 2D matrix of fuzzy weights. This may be then closed to the least similarity containing the declared fuzzy pairs. |
double[][] triplesToArray (ArrayList declaredPairs) { double[][] data = new double[signature.size()][signature.size()]; for (int i = 0; i < declaredPairs.size(); i++) { SignatureSimilarityTriple t = (SignatureSimilarityTriple)declaredPairs.get(i); data[t.left().index()][t.right().index()] = t.degree(); } return data; } /* ************************************************************************ */ Stack fileStack = new Stack(); boolean readingFromFile () { return fileStack.size() > 0; } String currentFile () { if (fileStack == null || fileStack.isEmpty()) return ""; return (String)fileStack.peek(); } /* ************************************************************************ */ String inputClause; private void echoFileReadClause (String clause) { if (readingFromFile()) line(inputClause); }
| Execute the current pragma. |
void executePragma () { note("Executing pragma: #"+pragma); switch (pragma) { case "info": inputClause = "#info"+inputClause+";"; echoFileReadClause(inputClause); System.err.println("%%% READ inputClause = "+inputClause); executeInfoPragma(); break; case "fun": inputClause = "#fun"+inputClause+";"; echoFileReadClause(inputClause); executeFunPragma(); break; case "sig": inputClause = "#sig;"; echoFileReadClause(inputClause); executeSigPragma(); break; case "sim": inputClause = "#sim"+inputClause+";"; echoFileReadClause(inputClause); executeSimPragma(); break; case "close": inputClause = "#close;"; echoFileReadClause(inputClause); executeClosePragma(); break; case "show": inputClause = "#show;"; echoFileReadClause(inputClause); executeShowPragma(); break; case "funclass": inputClause = "#funclass "+functorName+" "+classDegree+";"; echoFileReadClause(inputClause); executeFunclassPragma(); break; case "termclass": inputClause = "#termclass "+term+" "+classDegree+";"; echoFileReadClause(inputClause); executeTermclassPragma(); break; case "funrep": inputClause = "#funrep "+functorName+" "+classDegree+";"; echoFileReadClause(inputClause); executeFunrepPragma(); break; case "termrep": inputClause = "#termrep "+term+" "+classDegree+";"; echoFileReadClause(inputClause); executeTermrepPragma(); break; case "map": inputClause = "#map"+inputClause+";"; echoFileReadClause(inputClause); executeMapPragma(); break; case "comp": inputClause = "#comp;"; echoFileReadClause(inputClause); executeCompPragma(); break; case "load": inputClause = "#load "+(currentFile())+"\";"; echoFileReadClause(inputClause); executeLoadPragma(); break; case "trace": inputClause = "#trace "+tracingVerbosity+";"; echoFileReadClause(inputClause); executeTracePragma(); break; case "reset": inputClause = "#reset;"; echoFileReadClause(inputClause); executeResetPragma(); break; default: // actually never done: an undefined pragma causes a parsing exception in the tokenizer warn("Unknown pragma: '#"+pragma+"' (ignored)"); } inputClause = ""; } /* ******************************************************************** */ String infoPragmaName; void executeInfoPragma () { // System.err.println("$$$ executing pragma name = "+infoPragmaName); switch (infoPragmaName) { case "info": sayLines(infoPragmaInfoLines); break; case "fun": lines(funPragmaInfoLines); break; case "sig": lines(sigPragmaInfoLines); break; case "sim": lines(simPragmaInfoLines); break; case "close": lines(closePragmaInfoLines); break; case "show": lines(showPragmaInfoLines); break; case "funclass": lines(funclassPragmaInfoLines); break; case "termclass": lines(termclassPragmaInfoLines); break; case "funrep": lines(funrepPragmaInfoLines); break; case "termrep": lines(termrepPragmaInfoLines); break; case "map": lines(mapPragmaInfoLines); break; case "comp": lines(compPragmaInfoLines); break; case "load": lines(loadPragmaInfoLines); break; case "trace": lines(tracePragmaInfoLines); break; case "reset": lines(resetPragmaInfoLines); break; default: executeEmptyInfoPragma(); } } /* ******************************************************************** */ void executeEmptyInfoPragma () { say("Currently supported FFF pragmas:\n"); for (int i=0; i<pragmaTable.size(); i++) line("\t"+pragmaTable.get(i)); line(); say("Currently supported FFF operations:\n"); line("\tt1 /\\ t2; computes the infimum of terms t1 and t2 (unification);"); line("\tt1 \\/ t2; computes the supremum of terms t1 and t2 (generalization);"); line("\tt1 ~ t2; computes the similarity degree of terms t1 and t2 (value in [0.0,1.0])."); line(); say("If a similarity is defined on the signature, these operations are fuzzy; otherwise, they are crisp."); } /* ******************************************************************** */ void executeFunPragma () { showSignature(); } /* ******************************************************************** */ void executeSigPragma () { showSignature(); } /* ******************************************************************** */ void showSignature () { say("The current signature has "+signature.size()+" functors: "+signature); } /* ******************************************************************** */ void executeSimPragma () { showDeclaredPairs(); } /* ******************************************************************** */ void showDeclaredPairs () { if (declaredPairs.size() == 0) say("There are no declared similarities "); else say("Declared similarities: "); for (int i = 0; i < declaredPairs.size(); i++) line("\t"+declaredPairs.get(i)); } void executeClosePragma () { if (declaredPairs.isEmpty()) warn("Cannot compute a similarity closure when no similar pairs have been declared"); else { similarity = new SignatureSimilarity(signature,triplesToArray(declaredPairs)); say("Computed similarity closure (enter '#show;<CR>' to see it)"); } } /* ******************************************************************** */ void executeShowPragma () { showSignature(); line(); if (declaredPairs.isEmpty()) { say("No functors have been declared similar"); return; } // BUG!!! // In the following code beware that the size of declaredPairs is // reset to the size of the last list of position pairs that was // declared! say("The declared similar functor pairs are: "); for (int i=0; i<declaredPairs.size(); i++) line("\t"+declaredPairs.get(i)); line(); // FIX: there should be as many declaredPairs arrays as there are values in degree()! if (similarity == null) { say("No similarity closure has been computed yet "); line("(use pragma '#close;' to compute it)"); return; } say("The similarity closure of the declared similar functor pairs is:\n"); // FuzzyMatrix.precision = "%4.1f "; similarity.show(); //("%4.1f "); degrees = similarity.degrees(); say("It has "+degrees.size()+" similarity degrees: "+degrees); line(); say("The "+degrees.size()+" corresponding fuzzy partitions are:"); for (int index = 0; index < degrees.size(); index++) { double cut = degrees.get(index); line(); // warn similarity.sayIfTracing ("computing partition["+index+"] corresponding to degree "+cut); say(">= "+cut+": "+similarity.partitionToString(similarity.getPartition(index))); } } /* ******************************************************************** */ private String functorName; private double classDegree; void executeFunrepPragma () { Functor functor = (Functor)functorTable.get(functorName); if (functor == null) { warn("Unknown functor "+functorName+" (#funrep query ignored)"); return; } say("The "+classDegree+"-similar functor representative of "+functorName+" is "+ similarity.functorRep(functor,classDegree)); } void executeTermrepPragma () { FirstOrderTerm termrep = similarity.termRep(term,classDegree); say("The "+classDegree+"-similar term representative of "+term+" is "+termrep); } void executeFunclassPragma () { if (similarity == null) { warn("No similarity has been defined yet; so functors are only similar to themselves:"); say(classDegree+"-similarity class of functor "+functorName+": ["+functorName+"]"); return; } Functor functor = (Functor)functorTable.get(functorName); if (functor == null) { warn("Unknown functor "+functorName+" (#funclass query ignored)"); return; } say(classDegree+"-similarity class of functor "+functorName+": "+ similarity.functorClass(functor,classDegree)); } void executeTermclassPragma () { if (similarity == null) { warn("No similarity has been defined yet; so terms are only similar to themselves:"); say(classDegree+"-similarity class of term "+term+": ["+term+"]"); return; } ArrayList termClass = similarity.termClass(term,classDegree); say(classDegree+"-similarity class of term "+term+" ("+termClass.size()+ " term"+(termClass.size()>1?"s":"")+"): "+ // termClass+"\n"); // write only the first 120 characters (because this can be and explosive number!) Misc.etc(120,termClass.toString())+"\n"); } /* ******************************************************************** */ // void executeMapPragma () // { // notyet("map"); // } void executeMapPragma () { // showDeclaredPairs(); showDeclaredMaps(); } void showDeclaredMaps () { if (declaredMaps.size() == 0) say("There are no declared argument maps "); else say("Declared argument maps: "); for (int i = 0; i < declaredMaps.size(); i++) line("\t"+declaredMaps.get(i)); } /* ******************************************************************** */ void executeCompPragma () { notyet("comp"); } /* ******************************************************************** */ void executeLoadPragma () { try { ((FuzzyFOTLatticeTokenizer)input).include(currentFile()); } catch (FileNotFoundException e) { warn(syntaxError("file not found: "+currentFile(),currentNode()).toString()); } catch (CircularInclusionException e) { warn(syntaxError("circular file inclusion of file: "+currentFile(),currentNode()).toString()); } } // void doneLoading () // { // say("Done reading from file: "+currentFile()); // fileStack.pop(); // note("fileStack = "+fileStack); // if (fileStack.isEmpty()) // FuzzyFOTLatticeTokenizer.interactive = true; // note("#load pragma done"); // } /* ******************************************************************** */ void executeTracePragma () { SignatureSimilarity.toggleTracing(tracingVerbosity); } /* ******************************************************************** */ void executeResetPragma () { functorTable.clear(); // = new HashMap(); signature = new SimilarFunctorSignature(); declaredPairs.clear(); // = new ArrayList(); declaredMaps.clear(); // = new ArrayList(); declaredPairMapList = new IntArrayList(); similarity = null; degrees = null; say("All structures have been reset"); } /* ******************************************************************** */ private void notyet (String clause) { warn("Sorry: '"+clause+"' clause is not yet implemented"); } /* ******************************************************************** */ void processSimilarityDegree () { try { inputClause = lhs+" ~ "+rhs+";"; echoFileReadClause(inputClause); if (similarity == null) { warn ("No similarity defined: similarity degree can only be 1.0 (equal) or 0.0 (unequal)"); if (lhs.equal(rhs)) say("These terms are equal (similarity degree = 1.0)"); else say("These terms are not equal (similarity degree = 0.0)"); } else // check term similarity: say("These terms' similarity degree is "+similarity.similarityDegree(lhs,rhs)); } catch (Exception e) { warn("Term similarity query aborted"); } } /* ******************************************************************** */ void processUnification () { if (similarity == null) processCrispUnification(); else processFuzzyUnification(); } void processCrispUnification () { // note("Processing crisp unification"); try { inputClause = lhs+" /\\ "+rhs+";"; echoFileReadClause(inputClause); if (FirstOrderTerm.unify(lhs,rhs)) { say("Glb = "+lhs.derefToString()); showUnifier(); } else say("These terms are not unifiable"); } catch (Exception e) { note(e.getMessage()); warn("Term unification aborted"); } } void processFuzzyUnification () { // note("Processing fuzzy unification"); try { inputClause = lhs+" /\\ "+rhs+";"; echoFileReadClause(inputClause); degree = similarity.unify(lhs,rhs); if (degree > 0.0) { say("The fuzzy glb is "+lhs.derefToString()); say("Its approximation degree is "+degree); say("Its "+degree+"-similar term representative is "+ similarity.termRep(lhs,degree).deref()); showUnifier(); } else say("These terms are not fuzzy unifiable"); } catch (Exception e) { note(e.getMessage()); warn("Term fuzzy unification aborted"); } } void showUnifier () { int count = 0; boolean isEmpty = true; SignatureSimilarity.sayIfTracing("registered variables: "+Variable.registeredVariableNames); for (int i = 0; i < Variable.registeredVariableNames.size(); i++) { String varName = (String)Variable.registeredVariableNames.get(i); Variable var = (Variable)Variable.registeredVariableTable.get(varName); if (var.isBound()) { isEmpty = false; if (count == 0) say("Unifying substitution:"); count++; if (similarity == null) say("\t"+varName+" = "+var.deref().deref()); else say("\t"+varName+" = "+similarity.termRep(var.deref().deref(),degree)); } } if (isEmpty) say("Empty unifying substitution"); } /* ******************************************************************** */ void processGeneralization () { if (similarity == null) processCrispGeneralization(); else processFuzzyGeneralization(); } void processCrispGeneralization () { // note("Processing crisp generalization"); try { inputClause = lhs+" \\/ "+rhs+";"; echoFileReadClause(inputClause); FirstOrderTerm.resetGeneralizer(); say("Lub = "+FirstOrderTerm.generalize(lhs,rhs)); showGeneralizers(); } catch (Exception e) { warn("Term generalization aborted"); } } void processFuzzyGeneralization () { // note("Processing fuzzy generalization"); try { inputClause = lhs+" \\/ "+rhs+";"; echoFileReadClause(inputClause); similarity.resetGeneralizer(); FuzzyFirstOrderTerm result = similarity.generalize(lhs,rhs,1.0); say("The fuzzy lub is "+result.term()); say("Its approximation degree is "+result.degree()); say("Its "+result.degree()+"-similar term representative is "+ similarity.termRep(result.term().deref(),result.degree())); showGeneralizers(); } catch (Exception e) { e.printStackTrace(); warn("Term fuzzy generalization aborted"); } } void showGeneralizers () { SignatureSimilarity.sayIfTracing("registered variables: "+Variable.registeredVariableNames); if (similarity == null) showCrispGeneralizers(); else showFuzzyGeneralizers(); } void showCrispGeneralizers () { Variable var; FirstOrderTerm term; if (!FirstOrderTerm.generatedVariables.isEmpty()) { say("Left generalizing substitution:"); for (int i = 0; i < FirstOrderTerm.generatedVariables.size(); i++) { var = (Variable)FirstOrderTerm.generatedVariables.get(i); term = (FirstOrderTerm)FirstOrderTerm.lSubstitution.get(var); say("\t"+var+" = "+term); } say("Right generalizing substitution:"); for (int i = 0; i < FirstOrderTerm.generatedVariables.size(); i++) { var = (Variable)FirstOrderTerm.generatedVariables.get(i); term = (FirstOrderTerm)FirstOrderTerm.rSubstitution.get(var); say("\t"+var+" = "+term); } } // Map.Entry keyval; // say("Left substitution:"); // for (Iterator i = FirstOrderTerm.lSubstitution.entrySet().iterator(); i.hasNext();) // { // keyval = (Map.Entry)i.next(); // var = (Variable)keyval.getKey(); // term = (FirstOrderTerm)keyval.getValue(); // say(var+" = "+term); // } // say("Right substitution:"); // for (Iterator i = FirstOrderTerm.rSubstitution.entrySet().iterator(); i.hasNext();) // { // keyval = (Map.Entry)i.next(); // var = (Variable)keyval.getKey(); // term = (FirstOrderTerm)keyval.getValue(); // say(var+" = "+term); // } } void showFuzzyGeneralizers () { Variable var; FirstOrderTerm term; if (!similarity.generatedVariables.isEmpty()) { say("Left substitution:"); for (int i = 0; i < similarity.generatedVariables.size(); i++) { var = (Variable)similarity.generatedVariables.get(i); term = (FirstOrderTerm)similarity.lSubstitution.get(var); say("\t"+var+" = "+similarity.termRep(term,degree)); } say("Right substitution:"); for (int i = 0; i < similarity.generatedVariables.size(); i++) { var = (Variable)similarity.generatedVariables.get(i); term = (FirstOrderTerm)similarity.rSubstitution.get(var); say("\t"+var+" = "+similarity.termRep(term,degree)); } } } /* ********************** */ /* STATIC INITIALIZATIONS */ /* ********************** */ static { initializeTerminals(); initializeNonTerminals(); initializeRules(); initializeParserActions(); initializeParserStates(); initializeActionTables(); initializeGotoTables(); initializeStateTables(); } /* ********************* */ /* PARTIAL PARSE METHODS */ /* ********************* */ final static ParseNode $SESSION_SWITCH$ = new ParseNode(terminals[3]); public final void parseSession (String s) throws IOException { parseSession(new StringReader(s)); } public final void parseSession (Reader r) throws IOException { input.setReader(r); errorManager().recoverFromErrors(false); setSwitchToken($SESSION_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 7: { executePragma(); FuzzyFOTLatticeTokenizer.prompt(); break; } case 9: { processSimilarityDegree(); FuzzyFOTLatticeTokenizer.prompt(); break; } case 11: { processUnification(); FuzzyFOTLatticeTokenizer.prompt(); break; } case 13: { processGeneralization(); FuzzyFOTLatticeTokenizer.prompt(); break; } case 15: { // errorManager().reportErrors(true); FuzzyFOTLatticeTokenizer.prompt(); break; } case 17: { out.println(); out.println("------------------------------------------------------------------------"); out.println("*** Ending FFF session on "+ (new Date())); out.println("------------------------------------------------------------------------"); // out.println("*** "); // out.println("*** So long - and thanks for using FFF..."); // out.println("*** Come back soon for some more Fun Fuzzy Fiddling! 8^D"); out.println(); System.exit(0); break; } case 35: { infoPragmaName = ""; inputClause = ""; break; } case 36: { infoPragmaName = node($rule$,1).svalue(); // System.err.println("&&& reading infoPragmaName = "+infoPragmaName); inputClause += " "+infoPragmaName; // System.err.println("&&& READ "+infoPragmaName+" setting inputClause = "+inputClause); break; } case 52: { inputClause = ""; break; } case 58: { inputClause += " "+node($rule$,1).svalue()+"/"+(int)node($rule$,3).nvalue(); try { // if one is already registered under this name but not with this // arity the following will raise a BadFunctorArityException; // otherwise, it will register it and check need to recompute similarity: registerFunctor(node($rule$,1).svalue(),signature.functor(node($rule$,1).svalue(),(int)node($rule$,3).nvalue())); } catch (Exception e) { // we need to report whether this functor was already // declared with a different arity err.println("!!! "+e.getMessage()+ " (declaration "+node($rule$,1).svalue()+"/"+(int)node($rule$,3).nvalue()+" ignored)"); } break; } case 62: { inputClause = ""; break; } case 68: { $FuzzyPair$ $node0$ = new $FuzzyPair$($head$); $head$ = ($FuzzyPair$)$node0$; inputClause += " "+node($rule$,1).svalue()+" "+node($rule$,2).svalue()+" "+node($rule$,3).nvalue(); declareSimilarPair(node($rule$,1).svalue(),node($rule$,2).svalue(),node($rule$,3).nvalue()); $node0$.left = node($rule$,1).svalue(); $node0$.right = node($rule$,2).svalue(); $node0$.degree = node($rule$,3).nvalue(); break; } case 71: { $head$.setSvalue(node($rule$,1).svalue()); functorName = node($rule$,2).svalue(); classDegree = node($rule$,3).nvalue(); break; } case 72: { $head$.setSvalue(node($rule$,1).svalue()); functorName = node($rule$,2).svalue(); classDegree = node($rule$,3).nvalue(); temp = (SyntacticTerm)termStack.pop(); try { // we need to report if a functor is used with // inconsistent arities converting the parsed // SyntacticTerm temp into its FirstOrderTerm object's // canonical form term = temp.canonical(signature,functorTable); } catch (Exception e) { err.println("!!! "+e.getMessage()); // recoverFromError(); // FuzzyFOTLatticeTokenizer.prompt(); } break; } case 75: { $head$.setSvalue(node($rule$,1).svalue()); functorName = node($rule$,2).svalue(); classDegree = node($rule$,3).nvalue(); break; } case 76: { $head$.setSvalue(node($rule$,1).svalue()); functorName = node($rule$,2).svalue(); classDegree = node($rule$,3).nvalue(); try { // we need to report if a functor is used with // inconsistent arities converting the parsed // SyntacticTerm into its FirstOrderTerm object's // canonical form term = ((SyntacticTerm)termStack.pop()).canonical(signature,functorTable); } catch (Exception e) { err.println("!!! "+e.getMessage()); recoverFromError(); FuzzyFOTLatticeTokenizer.prompt(); } break; } case 77: { inputClause = ""; break; } case 81: { $FuzzyPair$ $node1$; if (node($rule$,1) instanceof $FuzzyPair$) $node1$ = ($FuzzyPair$)node($rule$,1); else { $node1$ = new $FuzzyPair$(node($rule$,1)); replaceStackNode($rule$,1,$node1$); } inputClause += " "+ArgumentMappingData.pairsToString(declaredPairMapList); // record the argument-position map for the fuzzy pair: declaredMaps.add(new ArgumentMappingData(signature.functor($node1$.left), signature.functor($node1$.right), $node1$.degree, declaredPairMapList)); // reset declared pairs to a new empty list to record the next set of pairs: declaredPairMapList = new IntArrayList(); break; } case 85: { declaredPairMapList.add((int)node($rule$,1).nvalue()); declaredPairMapList.add((int)node($rule$,3).nvalue()); break; } case 87: { fileStack.push(node($rule$,2).svalue()); // out.println(">>> fileStack = "+fileStack); $head$.setSvalue(node($rule$,1).svalue()); break; } case 90: { SignatureSimilarity.setTracingVerbosity(tracingVerbosity = (int)node($rule$,1).nvalue()); break; } case 95: { termStack.clear(); Variable.resetRegisteredVariables(); break; } case 96: { try { // we need to report if a functor is used with // inconsistent arities converting the parsed // SyntacticTerm object into its FirstOrderTerm object's // canonical form lhs = ((SyntacticTerm)termStack.pop()).canonical(signature,functorTable); } catch (Exception e) { err.println("!!! "+e.getMessage()); recoverFromError(); FuzzyFOTLatticeTokenizer.prompt(); } break; } case 97: { termStack.clear(); break; } case 98: { try { // we need to report if a functor is used with // inconsistent arities converting the parsed // SyntacticTerm object into its FirstOrderTerm object's // canonical form rhs = ((SyntacticTerm)termStack.pop()).canonical(signature,functorTable); } catch (Exception e) { err.println("!!! "+e.getMessage()); // recoverFromError(); // FuzzyFOTLatticeTokenizer.prompt(); } break; } case 99: { termStack.push(new SyntacticTerm(node($rule$,1).svalue()).markAsVariable()); break; } case 102: { termStack.push(new SyntacticTerm(node($rule$,1).svalue())); break; } case 103: { termStack.push(new SyntacticTerm(node($rule$,-1).svalue(),new Vector())); break; } case 105: { temp = (SyntacticTerm)termStack.pop(); ((SyntacticTerm)termStack.peek()).body.add(temp); break; } case 106: { temp = (SyntacticTerm)termStack.pop(); ((SyntacticTerm)termStack.peek()).body.add(temp); break; } case 0: case 1: case 54: case 59: case 64: case 79: case 82: case 89: break; default: $head$ = $head$.copy(node($rule$,1)); break; } return $head$; } /* **************** */ /* TERMINAL SYMBOLS */ /* **************** */ static void initializeTerminals () { terminals = new ParserTerminal[34]; newTerminal(0,"$EMPTY$",1,2); newTerminal(1,"$E_O_I$",1,2); newTerminal(2,"error",1,2); newTerminal(3,"$Session_switch$",1,2); newTerminal(4,"FUNCTOR",1,2); newTerminal(5,"VARIABLE",1,2); newTerminal(6,"STRING",1,2); newTerminal(7,"NATURAL",1,2); newTerminal(8,"INF",1,2); newTerminal(9,"SUP",1,2); newTerminal(10,"FUZZYVAL",1,2); newTerminal(11,"INFO",1,2); newTerminal(12,"FUN",1,2); newTerminal(13,"SIG",1,2); newTerminal(14,"SIM",1,2); newTerminal(15,"CLOSE",1,2); newTerminal(16,"SHOW",1,2); newTerminal(17,"EQS",1,2); newTerminal(18,"FUNCLASS",1,2); newTerminal(19,"TERMCLASS",1,2); newTerminal(20,"FUNREP",1,2); newTerminal(21,"TERMREP",1,2); newTerminal(22,"MAP",1,2); newTerminal(23,"COMP",1,2); newTerminal(24,"LOAD",1,2); newTerminal(25,"TRACE",1,2); newTerminal(26,"RESET",1,2); newTerminal(27,";",1,2); newTerminal(28,"exit",1,2); newTerminal(29,"/",1,2); newTerminal(30,":",1,2); newTerminal(31,"(",1,2); newTerminal(32,")",1,2); newTerminal(33,",",1,2); } /* ******************** */ /* NON-TERMINAL SYMBOLS */ /* ******************** */ static void initializeNonTerminals () { nonterminals = new ParserNonTerminal[58]; newNonTerminal(0,"$START$"); newNonTerminal(1,"$ROOTS$"); newNonTerminal(2,"Session"); newNonTerminal(3,"FuzzyPair"); newNonTerminal(4,"Clauses"); newNonTerminal(5,"Exit"); newNonTerminal(6,"Clause"); newNonTerminal(7,"Pragma"); newNonTerminal(8,"$ACTION0$"); newNonTerminal(9,"SimilarityDegree"); newNonTerminal(10,"$ACTION1$"); newNonTerminal(11,"Unification"); newNonTerminal(12,"$ACTION2$"); newNonTerminal(13,"Generalization"); newNonTerminal(14,"$ACTION3$"); newNonTerminal(15,"$ACTION4$"); newNonTerminal(16,"$ACTION5$"); newNonTerminal(17,"InfoPragma"); newNonTerminal(18,"FunPragma"); newNonTerminal(19,"SigPragma"); newNonTerminal(20,"SimPragma"); newNonTerminal(21,"ClosePragma"); newNonTerminal(22,"ShowPragma"); newNonTerminal(23,"FunclassPragma"); newNonTerminal(24,"TermclassPragma"); newNonTerminal(25,"FunrepPragma"); newNonTerminal(26,"TermrepPragma"); newNonTerminal(27,"MapPragma"); newNonTerminal(28,"CompPragma"); newNonTerminal(29,"LoadPragma"); newNonTerminal(30,"TracePragma"); newNonTerminal(31,"ResetPragma"); newNonTerminal(32,"PragmaName_opt"); newNonTerminal(33,"PragmaName"); newNonTerminal(34,"FunctorsArities_opt"); newNonTerminal(35,"$ACTION6$"); newNonTerminal(36,"FunctorsArities"); newNonTerminal(37,"FunctorArity"); newNonTerminal(38,"SlashOpt"); newNonTerminal(39,"FuzzyPairs_Opt"); newNonTerminal(40,"$ACTION7$"); newNonTerminal(41,"FuzzyPairs"); newNonTerminal(42,"Term"); newNonTerminal(43,"NaturalOrFuzzyval"); newNonTerminal(44,"MapPragmaData_opt"); newNonTerminal(45,"$ACTION8$"); newNonTerminal(46,"MapPragmaData"); newNonTerminal(47,"MapPairs_opt"); newNonTerminal(48,"MapPairs"); newNonTerminal(49,"MapPair"); newNonTerminal(50,"LevelOpt"); newNonTerminal(51,"LhsTerm"); newNonTerminal(52,"RhsTerm"); newNonTerminal(53,"$ACTION9$"); newNonTerminal(54,"$ACTION10$"); newNonTerminal(55,"Structure"); newNonTerminal(56,"Body"); newNonTerminal(57,"$ACTION11$"); } /* **************** */ /* PRODUCTION RULES */ /* **************** */ static void initializeRules () { rules = new ParserRule[107]; 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(2,2,3,1,2); rules[4] = new ParserRule(2,1,4,1,2); rules[5] = new ParserRule(4,1,5,1,2); rules[6] = new ParserRule(4,2,6,1,2); rules[7] = new ParserRule(8,0,7,1,2); rules[8] = new ParserRule(6,3,8,1,2); rules[9] = new ParserRule(10,0,9,1,2); rules[10] = new ParserRule(6,3,10,1,2); rules[11] = new ParserRule(12,0,11,1,2); rules[12] = new ParserRule(6,3,12,1,2); rules[13] = new ParserRule(14,0,13,1,2); rules[14] = new ParserRule(6,3,14,1,2); rules[15] = new ParserRule(15,0,15,1,2); rules[16] = new ParserRule(6,3,16,1,2); rules[17] = new ParserRule(16,0,17,1,2); rules[18] = new ParserRule(5,3,18,1,2); rules[19] = new ParserRule(7,1,19,1,2); rules[20] = new ParserRule(7,1,20,1,2); rules[21] = new ParserRule(7,1,21,1,2); rules[22] = new ParserRule(7,1,22,1,2); rules[23] = new ParserRule(7,1,23,1,2); rules[24] = new ParserRule(7,1,24,1,2); rules[25] = new ParserRule(7,1,25,1,2); rules[26] = new ParserRule(7,1,26,1,2); rules[27] = new ParserRule(7,1,27,1,2); rules[28] = new ParserRule(7,1,28,1,2); rules[29] = new ParserRule(7,1,29,1,2); rules[30] = new ParserRule(7,1,30,1,2); rules[31] = new ParserRule(7,1,31,1,2); rules[32] = new ParserRule(7,1,32,1,2); rules[33] = new ParserRule(7,1,33,1,2); rules[34] = new ParserRule(17,2,34,1,2); rules[35] = new ParserRule(32,0,35,1,2); rules[36] = new ParserRule(32,1,36,1,2); rules[37] = new ParserRule(33,1,37,1,2); rules[38] = new ParserRule(33,1,38,1,2); rules[39] = new ParserRule(33,1,39,1,2); rules[40] = new ParserRule(33,1,40,1,2); rules[41] = new ParserRule(33,1,41,1,2); rules[42] = new ParserRule(33,1,42,1,2); rules[43] = new ParserRule(33,1,43,1,2); rules[44] = new ParserRule(33,1,44,1,2); rules[45] = new ParserRule(33,1,45,1,2); rules[46] = new ParserRule(33,1,46,1,2); rules[47] = new ParserRule(33,1,47,1,2); rules[48] = new ParserRule(33,1,48,1,2); rules[49] = new ParserRule(33,1,49,1,2); rules[50] = new ParserRule(33,1,50,1,2); rules[51] = new ParserRule(33,1,51,1,2); rules[52] = new ParserRule(35,0,52,1,2); rules[53] = new ParserRule(18,3,53,1,2); rules[54] = new ParserRule(34,0,54,1,2); rules[55] = new ParserRule(34,1,55,1,2); rules[56] = new ParserRule(36,1,56,1,2); rules[57] = new ParserRule(36,2,57,1,2); rules[58] = new ParserRule(37,3,58,1,2); rules[59] = new ParserRule(38,0,59,1,2); rules[60] = new ParserRule(38,1,60,1,2); rules[61] = new ParserRule(19,1,61,1,2); rules[62] = new ParserRule(40,0,62,1,2); rules[63] = new ParserRule(20,3,63,1,2); rules[64] = new ParserRule(39,0,64,1,2); rules[65] = new ParserRule(39,1,65,1,2); rules[66] = new ParserRule(41,1,66,1,2); rules[67] = new ParserRule(41,2,67,1,2); rules[68] = new ParserRule(3,3,68,1,2); rules[69] = new ParserRule(21,1,69,1,2); rules[70] = new ParserRule(22,1,70,1,2); rules[71] = new ParserRule(23,3,71,1,2); rules[72] = new ParserRule(24,3,72,1,2); rules[73] = new ParserRule(43,1,73,1,2); rules[74] = new ParserRule(43,1,74,1,2); rules[75] = new ParserRule(25,3,75,1,2); rules[76] = new ParserRule(26,3,76,1,2); rules[77] = new ParserRule(45,0,77,1,2); rules[78] = new ParserRule(27,3,78,1,2); rules[79] = new ParserRule(44,0,79,1,2); rules[80] = new ParserRule(44,1,80,1,2); rules[81] = new ParserRule(46,2,81,1,2); rules[82] = new ParserRule(47,0,82,1,2); rules[83] = new ParserRule(47,1,83,1,2); rules[84] = new ParserRule(48,2,84,1,2); rules[85] = new ParserRule(49,3,85,1,2); rules[86] = new ParserRule(28,1,86,1,2); rules[87] = new ParserRule(29,2,87,1,2); rules[88] = new ParserRule(30,2,88,1,2); rules[89] = new ParserRule(50,0,89,1,2); rules[90] = new ParserRule(50,1,90,1,2); rules[91] = new ParserRule(31,1,91,1,2); rules[92] = new ParserRule(9,3,92,1,2); rules[93] = new ParserRule(11,3,93,1,2); rules[94] = new ParserRule(13,3,94,1,2); rules[95] = new ParserRule(53,0,95,1,2); rules[96] = new ParserRule(51,2,96,1,2); rules[97] = new ParserRule(54,0,97,1,2); rules[98] = new ParserRule(52,2,98,1,2); rules[99] = new ParserRule(42,1,99,1,2); rules[100] = new ParserRule(42,1,100,1,2); rules[101] = new ParserRule(42,3,101,1,2); rules[102] = new ParserRule(55,1,102,1,2); rules[103] = new ParserRule(57,0,103,1,2); rules[104] = new ParserRule(55,5,104,1,2); rules[105] = new ParserRule(56,1,105,1,2); rules[106] = new ParserRule(56,3,106,1,2); } /* ************** */ /* PARSER ACTIONS */ /* ************** */ static void initializeParserActions () { actions = new ParserAction[433]; newAction(0,5,0); newAction(1,2,0); newAction(2,0,3); newAction(3,0,7); newAction(4,0,12); newAction(5,0,29); newAction(6,0,30); newAction(7,0,31); newAction(8,0,32); newAction(9,0,33); newAction(10,0,34); newAction(11,0,35); newAction(12,0,36); newAction(13,0,37); newAction(14,0,38); newAction(15,0,39); newAction(16,0,40); newAction(17,0,41); newAction(18,0,42); newAction(19,0,43); newAction(20,1,95); newAction(21,1,95); newAction(22,1,95); newAction(23,1,1); newAction(24,0,7); newAction(25,0,12); newAction(26,0,29); newAction(27,0,30); newAction(28,0,31); newAction(29,0,32); newAction(30,0,33); newAction(31,0,34); newAction(32,0,35); newAction(33,0,36); newAction(34,0,37); newAction(35,0,38); newAction(36,0,39); newAction(37,0,40); newAction(38,0,41); newAction(39,0,42); newAction(40,0,43); newAction(41,1,95); newAction(42,1,95); newAction(43,1,95); newAction(44,0,7); newAction(45,0,12); newAction(46,0,29); newAction(47,0,30); newAction(48,0,31); newAction(49,0,32); newAction(50,0,33); newAction(51,0,34); newAction(52,0,35); newAction(53,0,36); newAction(54,0,37); newAction(55,0,38); newAction(56,0,39); newAction(57,0,40); newAction(58,0,41); newAction(59,0,42); newAction(60,0,43); newAction(61,1,95); newAction(62,1,95); newAction(63,1,95); newAction(64,1,4); newAction(65,1,5); newAction(66,1,5); newAction(67,1,5); newAction(68,1,5); newAction(69,1,5); newAction(70,1,5); newAction(71,1,5); newAction(72,1,5); newAction(73,1,5); newAction(74,1,5); newAction(75,1,5); newAction(76,1,5); newAction(77,1,5); newAction(78,1,5); newAction(79,1,5); newAction(80,1,5); newAction(81,1,5); newAction(82,1,5); newAction(83,1,5); newAction(84,1,5); newAction(85,1,17); newAction(86,1,7); newAction(87,1,9); newAction(88,1,11); newAction(89,1,13); newAction(90,1,15); newAction(91,1,19); newAction(92,1,20); newAction(93,1,21); newAction(94,1,22); newAction(95,1,23); newAction(96,1,24); newAction(97,1,25); newAction(98,1,26); newAction(99,1,27); newAction(100,1,28); newAction(101,1,29); newAction(102,1,30); newAction(103,1,31); newAction(104,1,32); newAction(105,1,33); newAction(106,0,117); newAction(107,0,118); newAction(108,0,119); newAction(109,1,35); newAction(110,0,102); newAction(111,0,103); newAction(112,0,104); newAction(113,0,105); newAction(114,0,106); newAction(115,0,107); newAction(116,0,108); newAction(117,0,109); newAction(118,0,110); newAction(119,0,111); newAction(120,0,112); newAction(121,0,113); newAction(122,0,114); newAction(123,0,115); newAction(124,0,116); newAction(125,1,52); newAction(126,1,52); newAction(127,1,61); newAction(128,1,62); newAction(129,1,62); newAction(130,1,69); newAction(131,1,70); newAction(132,0,84); newAction(133,0,46); newAction(134,0,48); newAction(135,0,49); newAction(136,0,78); newAction(137,0,46); newAction(138,0,48); newAction(139,0,49); newAction(140,1,77); newAction(141,1,77); newAction(142,1,86); newAction(143,0,61); newAction(144,1,89); newAction(145,0,60); newAction(146,1,91); newAction(147,0,46); newAction(148,0,48); newAction(149,0,49); newAction(150,1,96); newAction(151,1,96); newAction(152,1,96); newAction(153,1,99); newAction(154,1,99); newAction(155,1,99); newAction(156,1,99); newAction(157,1,99); newAction(158,1,99); newAction(159,1,99); newAction(160,1,99); newAction(161,1,100); newAction(162,1,100); newAction(163,1,100); newAction(164,1,100); newAction(165,1,100); newAction(166,1,100); newAction(167,1,100); newAction(168,1,100); newAction(169,0,46); newAction(170,0,48); newAction(171,0,49); newAction(172,1,102); newAction(173,1,102); newAction(174,1,102); newAction(175,1,102); newAction(176,1,102); newAction(177,1,102); newAction(178,1,102); newAction(179,1,102); newAction(180,0,50); newAction(181,1,103); newAction(182,1,103); newAction(183,1,103); newAction(184,0,46); newAction(185,0,48); newAction(186,0,49); newAction(187,0,54); newAction(188,0,55); newAction(189,1,105); newAction(190,1,105); newAction(191,1,104); newAction(192,1,104); newAction(193,1,104); newAction(194,1,104); newAction(195,1,104); newAction(196,1,104); newAction(197,1,104); newAction(198,1,104); newAction(199,0,46); newAction(200,0,48); newAction(201,0,49); newAction(202,1,106); newAction(203,1,106); newAction(204,0,58); newAction(205,1,101); newAction(206,1,101); newAction(207,1,101); newAction(208,1,101); newAction(209,1,101); newAction(210,1,101); newAction(211,1,101); newAction(212,1,101); newAction(213,1,88); newAction(214,1,90); newAction(215,1,87); newAction(216,0,64); newAction(217,1,79); newAction(218,1,78); newAction(219,0,74); newAction(220,1,80); newAction(221,1,82); newAction(222,0,70); newAction(223,1,81); newAction(224,1,83); newAction(225,1,82); newAction(226,0,70); newAction(227,0,71); newAction(228,0,72); newAction(229,1,85); newAction(230,1,85); newAction(231,1,84); newAction(232,0,75); newAction(233,1,68); newAction(234,1,68); newAction(235,1,68); newAction(236,0,77); newAction(237,1,76); newAction(238,0,79); newAction(239,1,75); newAction(240,0,82); newAction(241,0,83); newAction(242,1,72); newAction(243,1,73); newAction(244,1,74); newAction(245,0,85); newAction(246,1,71); newAction(247,0,64); newAction(248,1,64); newAction(249,1,63); newAction(250,1,65); newAction(251,0,64); newAction(252,1,66); newAction(253,1,66); newAction(254,1,67); newAction(255,1,67); newAction(256,1,54); newAction(257,0,95); newAction(258,1,53); newAction(259,1,55); newAction(260,0,95); newAction(261,1,56); newAction(262,1,56); newAction(263,1,59); newAction(264,0,97); newAction(265,0,98); newAction(266,1,60); newAction(267,1,58); newAction(268,1,58); newAction(269,1,57); newAction(270,1,57); newAction(271,1,34); newAction(272,1,36); newAction(273,1,37); newAction(274,1,38); newAction(275,1,39); newAction(276,1,40); newAction(277,1,41); newAction(278,1,42); newAction(279,1,43); newAction(280,1,44); newAction(281,1,45); newAction(282,1,46); newAction(283,1,47); newAction(284,1,48); newAction(285,1,49); newAction(286,1,50); newAction(287,1,51); newAction(288,1,97); newAction(289,1,97); newAction(290,1,97); newAction(291,1,97); newAction(292,1,97); newAction(293,1,97); newAction(294,1,97); newAction(295,1,97); newAction(296,1,97); newAction(297,1,94); newAction(298,0,46); newAction(299,0,48); newAction(300,0,49); newAction(301,1,98); newAction(302,1,93); newAction(303,1,92); newAction(304,0,126); newAction(305,1,16); newAction(306,1,16); newAction(307,1,16); newAction(308,1,16); newAction(309,1,16); newAction(310,1,16); newAction(311,1,16); newAction(312,1,16); newAction(313,1,16); newAction(314,1,16); newAction(315,1,16); newAction(316,1,16); newAction(317,1,16); newAction(318,1,16); newAction(319,1,16); newAction(320,1,16); newAction(321,1,16); newAction(322,1,16); newAction(323,1,16); newAction(324,1,16); newAction(325,0,128); newAction(326,1,14); newAction(327,1,14); newAction(328,1,14); newAction(329,1,14); newAction(330,1,14); newAction(331,1,14); newAction(332,1,14); newAction(333,1,14); newAction(334,1,14); newAction(335,1,14); newAction(336,1,14); newAction(337,1,14); newAction(338,1,14); newAction(339,1,14); newAction(340,1,14); newAction(341,1,14); newAction(342,1,14); newAction(343,1,14); newAction(344,1,14); newAction(345,1,14); newAction(346,0,130); newAction(347,1,12); newAction(348,1,12); newAction(349,1,12); newAction(350,1,12); newAction(351,1,12); newAction(352,1,12); newAction(353,1,12); newAction(354,1,12); newAction(355,1,12); newAction(356,1,12); newAction(357,1,12); newAction(358,1,12); newAction(359,1,12); newAction(360,1,12); newAction(361,1,12); newAction(362,1,12); newAction(363,1,12); newAction(364,1,12); newAction(365,1,12); newAction(366,1,12); newAction(367,0,132); newAction(368,1,10); newAction(369,1,10); newAction(370,1,10); newAction(371,1,10); newAction(372,1,10); newAction(373,1,10); newAction(374,1,10); newAction(375,1,10); newAction(376,1,10); newAction(377,1,10); newAction(378,1,10); newAction(379,1,10); newAction(380,1,10); newAction(381,1,10); newAction(382,1,10); newAction(383,1,10); newAction(384,1,10); newAction(385,1,10); newAction(386,1,10); newAction(387,1,10); newAction(388,0,134); newAction(389,1,8); newAction(390,1,8); newAction(391,1,8); newAction(392,1,8); newAction(393,1,8); newAction(394,1,8); newAction(395,1,8); newAction(396,1,8); newAction(397,1,8); newAction(398,1,8); newAction(399,1,8); newAction(400,1,8); newAction(401,1,8); newAction(402,1,8); newAction(403,1,8); newAction(404,1,8); newAction(405,1,8); newAction(406,1,8); newAction(407,1,8); newAction(408,1,8); newAction(409,0,136); newAction(410,1,18); newAction(411,1,3); newAction(412,1,6); newAction(413,1,6); newAction(414,1,6); newAction(415,1,6); newAction(416,1,6); newAction(417,1,6); newAction(418,1,6); newAction(419,1,6); newAction(420,1,6); newAction(421,1,6); newAction(422,1,6); newAction(423,1,6); newAction(424,1,6); newAction(425,1,6); newAction(426,1,6); newAction(427,1,6); newAction(428,1,6); newAction(429,1,6); newAction(430,1,6); newAction(431,1,6); newAction(432,1,2); } /* ************* */ /* PARSER STATES */ /* ************* */ static void initializeParserStates () { states = new ParserState[140]; for (int i=0; i<140; i++) newState(i); } /* ************* */ /* ACTION TABLES */ /* ************* */ static void initializeActionTables () { newActionTables(130); newActionTable(0,21); setAction(0,2,4); setAction(0,3,2); setAction(0,4,20); setAction(0,5,21); setAction(0,11,5); setAction(0,12,6); setAction(0,13,7); setAction(0,14,8); setAction(0,15,9); setAction(0,16,10); setAction(0,18,11); setAction(0,19,12); setAction(0,20,13); setAction(0,21,14); setAction(0,22,15); setAction(0,23,16); setAction(0,24,17); setAction(0,25,18); setAction(0,26,19); setAction(0,28,3); setAction(0,31,22); newActionTable(1,1); setAction(1,1,1); newActionTable(2,1); setAction(2,1,23); newActionTable(3,20); setAction(3,2,25); setAction(3,4,41); setAction(3,5,42); setAction(3,11,26); setAction(3,12,27); setAction(3,13,28); setAction(3,14,29); setAction(3,15,30); setAction(3,16,31); setAction(3,18,32); setAction(3,19,33); setAction(3,20,34); setAction(3,21,35); setAction(3,22,36); setAction(3,23,37); setAction(3,24,38); setAction(3,25,39); setAction(3,26,40); setAction(3,28,24); setAction(3,31,43); newActionTable(4,1); setAction(4,1,64); newActionTable(5,20); setAction(5,2,65); setAction(5,4,66); setAction(5,5,67); setAction(5,11,68); setAction(5,12,69); setAction(5,13,70); setAction(5,14,71); setAction(5,15,72); setAction(5,16,73); setAction(5,18,74); setAction(5,19,75); setAction(5,20,76); setAction(5,21,77); setAction(5,22,78); setAction(5,23,79); setAction(5,24,80); setAction(5,25,81); setAction(5,26,82); setAction(5,28,83); setAction(5,31,84); newActionTable(6,1); setAction(6,27,85); newActionTable(7,1); setAction(7,27,86); newActionTable(8,1); setAction(8,27,87); newActionTable(9,1); setAction(9,27,88); newActionTable(10,1); setAction(10,27,89); newActionTable(11,1); setAction(11,27,90); newActionTable(12,1); setAction(12,27,91); newActionTable(13,1); setAction(13,27,92); newActionTable(14,1); setAction(14,27,93); newActionTable(15,1); setAction(15,27,94); newActionTable(16,1); setAction(16,27,95); newActionTable(17,1); setAction(17,27,96); newActionTable(18,1); setAction(18,27,97); newActionTable(19,1); setAction(19,27,98); newActionTable(20,1); setAction(20,27,99); newActionTable(21,1); setAction(21,27,100); newActionTable(22,1); setAction(22,27,101); newActionTable(23,1); setAction(23,27,102); newActionTable(24,1); setAction(24,27,103); newActionTable(25,1); setAction(25,27,104); newActionTable(26,1); setAction(26,27,105); newActionTable(27,3); setAction(27,17,106); setAction(27,8,107); setAction(27,9,108); newActionTable(28,16); setAction(28,11,110); setAction(28,12,111); setAction(28,13,112); setAction(28,14,113); setAction(28,15,114); setAction(28,16,115); setAction(28,18,116); setAction(28,19,117); setAction(28,20,118); setAction(28,21,119); setAction(28,22,120); setAction(28,23,121); setAction(28,24,122); setAction(28,25,123); setAction(28,26,124); setAction(28,27,109); newActionTable(29,2); setAction(29,4,125); setAction(29,27,126); newActionTable(30,1); setAction(30,27,127); newActionTable(31,2); setAction(31,4,128); setAction(31,27,129); newActionTable(32,1); setAction(32,27,130); newActionTable(33,1); setAction(33,27,131); newActionTable(34,1); setAction(34,4,132); newActionTable(35,3); setAction(35,4,135); setAction(35,5,133); setAction(35,31,134); newActionTable(36,1); setAction(36,4,136); newActionTable(37,2); setAction(37,4,140); setAction(37,27,141); newActionTable(38,1); setAction(38,27,142); newActionTable(39,1); setAction(39,6,143); newActionTable(40,2); setAction(40,7,145); setAction(40,27,144); newActionTable(41,1); setAction(41,27,146); newActionTable(42,3); setAction(42,17,152); setAction(42,8,150); setAction(42,9,151); newActionTable(43,8); setAction(43,32,159); setAction(43,17,157); setAction(43,33,160); setAction(43,7,153); setAction(43,8,154); setAction(43,9,155); setAction(43,10,156); setAction(43,27,158); newActionTable(44,8); setAction(44,32,167); setAction(44,17,165); setAction(44,33,168); setAction(44,7,161); setAction(44,8,162); setAction(44,9,163); setAction(44,10,164); setAction(44,27,166); newActionTable(45,9); setAction(45,32,178); setAction(45,17,176); setAction(45,33,179); setAction(45,7,172); setAction(45,8,173); setAction(45,9,174); setAction(45,10,175); setAction(45,27,177); setAction(45,31,180); newActionTable(46,3); setAction(46,4,181); setAction(46,5,182); setAction(46,31,183); newActionTable(47,2); setAction(47,32,187); setAction(47,33,188); newActionTable(48,2); setAction(48,32,189); setAction(48,33,190); newActionTable(49,8); setAction(49,32,197); setAction(49,17,195); setAction(49,33,198); setAction(49,7,191); setAction(49,8,192); setAction(49,9,193); setAction(49,10,194); setAction(49,27,196); newActionTable(50,2); setAction(50,32,202); setAction(50,33,203); newActionTable(51,1); setAction(51,32,204); newActionTable(52,8); setAction(52,32,211); setAction(52,17,209); setAction(52,33,212); setAction(52,7,205); setAction(52,8,206); setAction(52,9,207); setAction(52,10,208); setAction(52,27,210); newActionTable(53,1); setAction(53,27,213); newActionTable(54,1); setAction(54,27,214); newActionTable(55,1); setAction(55,27,215); newActionTable(56,2); setAction(56,4,216); setAction(56,27,217); newActionTable(57,1); setAction(57,27,218); newActionTable(58,1); setAction(58,4,219); newActionTable(59,1); setAction(59,27,220); newActionTable(60,2); setAction(60,7,222); setAction(60,27,221); newActionTable(61,1); setAction(61,27,223); newActionTable(62,1); setAction(62,27,224); newActionTable(63,1); setAction(63,30,227); newActionTable(64,1); setAction(64,7,228); newActionTable(65,2); setAction(65,7,229); setAction(65,27,230); newActionTable(66,1); setAction(66,27,231); newActionTable(67,1); setAction(67,10,232); newActionTable(68,3); setAction(68,4,233); setAction(68,7,234); setAction(68,27,235); newActionTable(69,1); setAction(69,10,236); newActionTable(70,1); setAction(70,27,237); newActionTable(71,1); setAction(71,10,238); newActionTable(72,1); setAction(72,27,239); newActionTable(73,2); setAction(73,7,240); setAction(73,10,241); newActionTable(74,1); setAction(74,27,242); newActionTable(75,1); setAction(75,27,243); newActionTable(76,1); setAction(76,27,244); newActionTable(77,1); setAction(77,10,245); newActionTable(78,1); setAction(78,27,246); newActionTable(79,2); setAction(79,4,247); setAction(79,27,248); newActionTable(80,1); setAction(80,27,249); newActionTable(81,2); setAction(81,4,251); setAction(81,27,250); newActionTable(82,2); setAction(82,4,252); setAction(82,27,253); newActionTable(83,2); setAction(83,4,254); setAction(83,27,255); newActionTable(84,2); setAction(84,4,257); setAction(84,27,256); newActionTable(85,1); setAction(85,27,258); newActionTable(86,2); setAction(86,4,260); setAction(86,27,259); newActionTable(87,2); setAction(87,4,261); setAction(87,27,262); newActionTable(88,2); setAction(88,7,263); setAction(88,29,264); newActionTable(89,1); setAction(89,7,265); newActionTable(90,1); setAction(90,7,266); newActionTable(91,2); setAction(91,4,267); setAction(91,27,268); newActionTable(92,2); setAction(92,4,269); setAction(92,27,270); newActionTable(93,1); setAction(93,27,271); newActionTable(94,1); setAction(94,27,272); newActionTable(95,1); setAction(95,27,273); newActionTable(96,1); setAction(96,27,274); newActionTable(97,1); setAction(97,27,275); newActionTable(98,1); setAction(98,27,276); newActionTable(99,1); setAction(99,27,277); newActionTable(100,1); setAction(100,27,278); newActionTable(101,1); setAction(101,27,279); newActionTable(102,1); setAction(102,27,280); newActionTable(103,1); setAction(103,27,281); newActionTable(104,1); setAction(104,27,282); newActionTable(105,1); setAction(105,27,283); newActionTable(106,1); setAction(106,27,284); newActionTable(107,1); setAction(107,27,285); newActionTable(108,1); setAction(108,27,286); newActionTable(109,1); setAction(109,27,287); newActionTable(110,3); setAction(110,4,288); setAction(110,5,289); setAction(110,31,290); newActionTable(111,1); setAction(111,27,297); newActionTable(112,1); setAction(112,27,301); newActionTable(113,1); setAction(113,27,302); newActionTable(114,1); setAction(114,27,303); newActionTable(115,1); setAction(115,27,304); newActionTable(116,20); setAction(116,2,305); setAction(116,4,306); setAction(116,5,307); setAction(116,11,308); setAction(116,12,309); setAction(116,13,310); setAction(116,14,311); setAction(116,15,312); setAction(116,16,313); setAction(116,18,314); setAction(116,19,315); setAction(116,20,316); setAction(116,21,317); setAction(116,22,318); setAction(116,23,319); setAction(116,24,320); setAction(116,25,321); setAction(116,26,322); setAction(116,28,323); setAction(116,31,324); newActionTable(117,1); setAction(117,27,325); newActionTable(118,20); setAction(118,2,326); setAction(118,4,327); setAction(118,5,328); setAction(118,11,329); setAction(118,12,330); setAction(118,13,331); setAction(118,14,332); setAction(118,15,333); setAction(118,16,334); setAction(118,18,335); setAction(118,19,336); setAction(118,20,337); setAction(118,21,338); setAction(118,22,339); setAction(118,23,340); setAction(118,24,341); setAction(118,25,342); setAction(118,26,343); setAction(118,28,344); setAction(118,31,345); newActionTable(119,1); setAction(119,27,346); newActionTable(120,20); setAction(120,2,347); setAction(120,4,348); setAction(120,5,349); setAction(120,11,350); setAction(120,12,351); setAction(120,13,352); setAction(120,14,353); setAction(120,15,354); setAction(120,16,355); setAction(120,18,356); setAction(120,19,357); setAction(120,20,358); setAction(120,21,359); setAction(120,22,360); setAction(120,23,361); setAction(120,24,362); setAction(120,25,363); setAction(120,26,364); setAction(120,28,365); setAction(120,31,366); newActionTable(121,1); setAction(121,27,367); newActionTable(122,20); setAction(122,2,368); setAction(122,4,369); setAction(122,5,370); setAction(122,11,371); setAction(122,12,372); setAction(122,13,373); setAction(122,14,374); setAction(122,15,375); setAction(122,16,376); setAction(122,18,377); setAction(122,19,378); setAction(122,20,379); setAction(122,21,380); setAction(122,22,381); setAction(122,23,382); setAction(122,24,383); setAction(122,25,384); setAction(122,26,385); setAction(122,28,386); setAction(122,31,387); newActionTable(123,1); setAction(123,27,388); newActionTable(124,20); setAction(124,2,389); setAction(124,4,390); setAction(124,5,391); setAction(124,11,392); setAction(124,12,393); setAction(124,13,394); setAction(124,14,395); setAction(124,15,396); setAction(124,16,397); setAction(124,18,398); setAction(124,19,399); setAction(124,20,400); setAction(124,21,401); setAction(124,22,402); setAction(124,23,403); setAction(124,24,404); setAction(124,25,405); setAction(124,26,406); setAction(124,28,407); setAction(124,31,408); newActionTable(125,1); setAction(125,27,409); newActionTable(126,1); setAction(126,1,410); newActionTable(127,1); setAction(127,1,411); newActionTable(128,20); setAction(128,2,412); setAction(128,4,413); setAction(128,5,414); setAction(128,11,415); setAction(128,12,416); setAction(128,13,417); setAction(128,14,418); setAction(128,15,419); setAction(128,16,420); setAction(128,18,421); setAction(128,19,422); setAction(128,20,423); setAction(128,21,424); setAction(128,22,425); setAction(128,23,426); setAction(128,24,427); setAction(128,25,428); setAction(128,26,429); setAction(128,28,430); setAction(128,31,431); newActionTable(129,1); setAction(129,1,432); } /* *********** */ /* GOTO TABLES */ /* *********** */ static void initializeGotoTables () { newGotoTables(35); newGotoTable(0,26); setGoto(0,1,1); setGoto(0,2,2); setGoto(0,4,4); setGoto(0,5,5); setGoto(0,6,6); setGoto(0,7,8); setGoto(0,9,9); setGoto(0,11,10); setGoto(0,13,11); setGoto(0,17,13); setGoto(0,18,14); setGoto(0,19,15); setGoto(0,20,16); setGoto(0,21,17); setGoto(0,22,18); setGoto(0,23,19); setGoto(0,24,20); setGoto(0,25,21); setGoto(0,26,22); setGoto(0,27,23); setGoto(0,28,24); setGoto(0,29,25); setGoto(0,30,26); setGoto(0,31,27); setGoto(0,51,28); setGoto(0,53,44); newGotoTable(1,0); newGotoTable(2,25); setGoto(2,2,139); setGoto(2,4,4); setGoto(2,5,5); setGoto(2,6,6); setGoto(2,7,8); setGoto(2,9,9); setGoto(2,11,10); setGoto(2,13,11); setGoto(2,17,13); setGoto(2,18,14); setGoto(2,19,15); setGoto(2,20,16); setGoto(2,21,17); setGoto(2,22,18); setGoto(2,23,19); setGoto(2,24,20); setGoto(2,25,21); setGoto(2,26,22); setGoto(2,27,23); setGoto(2,28,24); setGoto(2,29,25); setGoto(2,30,26); setGoto(2,31,27); setGoto(2,51,28); setGoto(2,53,44); newGotoTable(3,23); setGoto(3,5,137); setGoto(3,6,138); setGoto(3,7,8); setGoto(3,9,9); setGoto(3,11,10); setGoto(3,13,11); setGoto(3,17,13); setGoto(3,18,14); setGoto(3,19,15); setGoto(3,51,28); setGoto(3,20,16); setGoto(3,21,17); setGoto(3,53,44); setGoto(3,22,18); setGoto(3,23,19); setGoto(3,24,20); setGoto(3,25,21); setGoto(3,26,22); setGoto(3,27,23); setGoto(3,28,24); setGoto(3,29,25); setGoto(3,30,26); setGoto(3,31,27); newGotoTable(4,1); setGoto(4,16,135); newGotoTable(5,1); setGoto(5,8,133); newGotoTable(6,1); setGoto(6,10,131); newGotoTable(7,1); setGoto(7,12,129); newGotoTable(8,1); setGoto(8,14,127); newGotoTable(9,1); setGoto(9,15,125); newGotoTable(10,2); setGoto(10,32,100); setGoto(10,33,101); newGotoTable(11,1); setGoto(11,35,91); newGotoTable(12,1); setGoto(12,40,86); newGotoTable(13,2); setGoto(13,55,47); setGoto(13,42,80); newGotoTable(14,2); setGoto(14,55,47); setGoto(14,42,76); newGotoTable(15,1); setGoto(15,45,62); newGotoTable(16,1); setGoto(16,50,59); newGotoTable(17,2); setGoto(17,55,47); setGoto(17,42,45); newGotoTable(18,2); setGoto(18,55,47); setGoto(18,42,57); newGotoTable(19,1); setGoto(19,57,51); newGotoTable(20,3); setGoto(20,55,47); setGoto(20,56,52); setGoto(20,42,53); newGotoTable(21,2); setGoto(21,55,47); setGoto(21,42,56); newGotoTable(22,3); setGoto(22,3,66); setGoto(22,44,63); setGoto(22,46,65); newGotoTable(23,3); setGoto(23,48,68); setGoto(23,49,69); setGoto(23,47,67); newGotoTable(24,3); setGoto(24,48,68); setGoto(24,49,69); setGoto(24,47,73); newGotoTable(25,1); setGoto(25,43,81); newGotoTable(26,3); setGoto(26,3,89); setGoto(26,39,87); setGoto(26,41,88); newGotoTable(27,1); setGoto(27,3,90); newGotoTable(28,3); setGoto(28,34,92); setGoto(28,36,93); setGoto(28,37,94); newGotoTable(29,1); setGoto(29,37,99); newGotoTable(30,1); setGoto(30,38,96); newGotoTable(31,2); setGoto(31,52,124); setGoto(31,54,121); newGotoTable(32,2); setGoto(32,52,123); setGoto(32,54,121); newGotoTable(33,2); setGoto(33,52,120); setGoto(33,54,121); newGotoTable(34,2); setGoto(34,55,47); setGoto(34,42,122); } /* ************ */ /* STATE TABLES */ /* ************ */ static void initializeStateTables () { setTables(0,0,0); setTables(1,1,1); setTables(2,2,1); setTables(3,3,2); setTables(4,3,3); setTables(5,4,1); setTables(6,5,1); setTables(7,6,4); setTables(8,7,5); setTables(9,8,6); setTables(10,9,7); setTables(11,10,8); setTables(12,11,9); setTables(13,12,1); setTables(14,13,1); setTables(15,14,1); setTables(16,15,1); setTables(17,16,1); setTables(18,17,1); setTables(19,18,1); setTables(20,19,1); setTables(21,20,1); setTables(22,21,1); setTables(23,22,1); setTables(24,23,1); setTables(25,24,1); setTables(26,25,1); setTables(27,26,1); setTables(28,27,1); setTables(29,28,10); setTables(30,29,11); setTables(31,30,1); setTables(32,31,12); setTables(33,32,1); setTables(34,33,1); setTables(35,34,1); setTables(36,35,13); setTables(37,36,1); setTables(38,35,14); setTables(39,37,15); setTables(40,38,1); setTables(41,39,1); setTables(42,40,16); setTables(43,41,1); setTables(44,35,17); setTables(45,42,1); setTables(46,43,1); setTables(47,44,1); setTables(48,35,18); setTables(49,45,1); setTables(50,46,19); setTables(51,35,20); setTables(52,47,1); setTables(53,48,1); setTables(54,49,1); setTables(55,35,21); setTables(56,50,1); setTables(57,51,1); setTables(58,52,1); setTables(59,53,1); setTables(60,54,1); setTables(61,55,1); setTables(62,56,22); setTables(63,57,1); setTables(64,58,1); setTables(65,59,1); setTables(66,60,23); setTables(67,61,1); setTables(68,62,1); setTables(69,60,24); setTables(70,63,1); setTables(71,64,1); setTables(72,65,1); setTables(73,66,1); setTables(74,67,1); setTables(75,68,1); setTables(76,69,1); setTables(77,70,1); setTables(78,71,1); setTables(79,72,1); setTables(80,73,25); setTables(81,74,1); setTables(82,75,1); setTables(83,76,1); setTables(84,77,1); setTables(85,78,1); setTables(86,79,26); setTables(87,80,1); setTables(88,81,27); setTables(89,82,1); setTables(90,83,1); setTables(91,84,28); setTables(92,85,1); setTables(93,86,29); setTables(94,87,1); setTables(95,88,30); setTables(96,89,1); setTables(97,90,1); setTables(98,91,1); setTables(99,92,1); setTables(100,93,1); setTables(101,94,1); setTables(102,95,1); setTables(103,96,1); setTables(104,97,1); setTables(105,98,1); setTables(106,99,1); setTables(107,100,1); setTables(108,101,1); setTables(109,102,1); setTables(110,103,1); setTables(111,104,1); setTables(112,105,1); setTables(113,106,1); setTables(114,107,1); setTables(115,108,1); setTables(116,109,1); setTables(117,110,31); setTables(118,110,32); setTables(119,110,33); setTables(120,111,1); setTables(121,35,34); setTables(122,112,1); setTables(123,113,1); setTables(124,114,1); setTables(125,115,1); setTables(126,116,1); setTables(127,117,1); setTables(128,118,1); setTables(129,119,1); setTables(130,120,1); setTables(131,121,1); setTables(132,122,1); setTables(133,123,1); setTables(134,124,1); setTables(135,125,1); setTables(136,126,1); setTables(137,127,1); setTables(138,128,1); setTables(139,129,1); } } /* ***************** */ /* ANCILLARY CLASSES */ /* ***************** */ class $FuzzyPair$ extends ParseNode { $FuzzyPair$ (ParseNode node) { super(node); } String left; String right; double degree; }
| This is the class for terms being partially parsed as syntactic objects and eventually translated into a FirstOrderTerm. N.B.: numbers are not parsed as we consider only symbolic functors. |
class SyntacticTerm { String symbol = null; Vector body = null; Functor functor = null; FirstOrderTerm term = null; FirstOrderTerm[] arguments = null; boolean isVariable = false; SyntacticTerm markAsVariable () { isVariable = true; return this; } SyntacticTerm (String symbol) { this.symbol = symbol; } SyntacticTerm (String symbol, Vector body) { this.symbol = symbol; this.body = body; } final boolean hasBody () { return (body != null && !body.isEmpty()); } public String toString () { if (!hasBody()) return symbol; StringBuffer s = new StringBuffer(symbol); s.append("("); for (int i=0; i<body.size(); i++) { s.append(body.get(i)); if (i<body.size()-1) s.append(","); } s.append(")"); return s.toString(); } /* ************************************************************************ */
| Converts this parsed SyntacticTerm into an actual FirstOrderTerm where functors are registered in the provided Signature and in the provided name -> functor table functorTable. |
FirstOrderTerm canonical (Signature signature, HashMap functorTable) { if (isVariable) return Variable.getVariable(symbol); if (!hasBody()) { FuzzyFOTLatticeMain.parser.registerFunctor (symbol,functor = signature.functor(symbol,0)); return new FirstOrderTermStructure(functor); } FuzzyFOTLatticeMain.parser.registerFunctor (symbol,functor = signature.functor(symbol,body.size())); arguments = new FirstOrderTerm[body.size()]; term = new FirstOrderTermStructure(functor,arguments); for (int i = 0; i < arguments.length; i++) arguments[i] = ((SyntacticTerm)body.get(i)).canonical(signature,functorTable); return term; } } /* ************************************************************************ */
| End of FFF grammar |
/* ******************************************************************** */
This file was generated on Wed Dec 18 03:39:39 PST 2019 from file FuzzyFOTLatticeParser.java
by the hlt.language.tools.Hilite Java tool written by Hassan Aït-Kaci