|
HootMain.java
|
// FILE. . . . . d:/hak/hlt/src/hlt/osf/hoot/sources/HootMain.java // EDIT BY . . . Hassan Ait-Kaci // ON MACHINE. . Hak-Laptop // STARTED ON. . Sat May 4 04:49:34 2019
|
package hlt.osf.hoot; import java.io.File; import java.io.IOException; import java.time.LocalDate; import java.time.LocalTime; import hlt.osf.util.BitCode; import hlt.language.util.Error;
| This is the main entry file for running any version of the OSF constraint language HOOT (Hierarchical Ontologies of Objects and Types). It is based on the internal representation of the OSF data structure described in the HOOT specification. It also relies on operations to build and manipulate such internal structures, all of which are defined in the other Jacc grammar files. It also provides the basic lattice operations for unification and generalization, together with the machinary for inference remembering tag bindings for undoing purposes such as bactracking. This class creates a tokenizer and a parser for HOOT and starts an interactive session with HOOT. |
public class HootMain { final static String version = "0.00"; final static String now () { return LocalDate.now()+" - "+LocalTime.now().toString().substring(0,8); } final static void p () { System.out.println(); } final static void p (String line) { System.out.println(line); } final static void welcome () { p(); p("****************************************************"); p("*** ***"); p("*** This is HOOT - a language to build and query ***"); p("*** ***"); p("*** Hierarchical Ontologies of Objects and Types ***"); p("*** ***"); p("****************************************************"); p(); p("*** HOOT Version "+version+" - run of "+now()); p("*** Interactive mode: type '%help.' for where to go."); p(); } final static void exit () { p(); p(); p("******************************************************"); p("*** Exiting HOOT Version "+version+" on "+now()); p("******************************************************"); p(); System.exit(0); } final static void report (HootParser parser, Throwable issue, String reason) { parser .errorManager() .reportError(new Error() .setLabel(reason+": ") .setMsg(issue.getMessage()+" reporting") .setSee("...")); } final public static void main (String args[]) { // create a HOOT tokenizer: HootTokenizer tokenizer = new HootTokenizer(); // use it to create a HOOT parser: HootParser parser = new HootParser(tokenizer); // say hello: welcome(); // set the bit-vector notation using +/1 (instead of default 1/0) BitCode.setOnChar('+'); BitCode.setOffChar('-'); try { // load all the files in the command line: for (int i=0; i<args.length; i++) { parser.displayLine("*** Loading file: "+args[i]); parser.parse(args[i]); } // enter an interactive session: tokenizer.setInteractive(); // XML representation of the parse tree: parser.setTreeType("XML"); // initiate parsing the interactive input: parser.parse(); } catch (IOException issue) { report(parser,issue,"IO Error"); } catch (Throwable issue) { report(parser,issue,"Fatal Error"); issue.printStackTrace(); } finally { exit(); } } }
This file was generated on Wed Oct 09 17:17:20 PDT 2019 from file HootMain.java
by the hlt.language.tools.Hilite Java tool written by Hassan Aït-Kaci