--- /dev/null
+xopackage com.ReasoningTechnology.Ariadne;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.List;
+import java.util.ArrayList;
+
+public class Ariadne_GraphDirectedAcyclic extends Ariadne_Graph {
+
+ /*--------------------------------------------------------------------------------
+ Constructors
+ */
+
+ public Ariadne_GraphDirectedAcyclic(Map<Ariadne_Label, Ariadne_Node> node_map, Ariadne_ProductionList recognizer_f_list, Ariadne_LabelList root_node_list, int max_depth, boolean verbose) {
+ super(node_map, recognizer_f_list);
+ Ariadne_TokenSet cycle_detection_result = graph_mark_cycles(root_node_list, max_depth, verbose);
+ }
+
+ public Ariadne_GraphDirectedAcyclic(Map<Ariadne_Label, Ariadne_Node> node_map, Ariadne_ProductionList recognizer_f_list, Ariadne_LabelList root_node_list) {
+ super(node_map, recognizer_f_list);
+ Ariadne_TokenSet cycle_detection_result = graph_mark_cycles(root_node_list);
+ }
+
+ /*--------------------------------------------------------------------------------
+ Instance Data Extension
+ */
+
+ private static boolean debug = true;
+
+ /*--------------------------------------------------------------------------------
+ Interface
+ */
+
+ private List<Integer> path_find_cycle(Ariadne_LabelList path) {
+ if (path.size() <= 1) return null;
+
+ int rightmost_index = path.size() - 1;
+ Ariadne_Label rightmost_node_label = path.get(rightmost_index);
+
+ int cycle_leftmost_index = path.indexOf(rightmost_node_label);
+ Boolean has_cycle = cycle_leftmost_index < rightmost_index;
+ if (!has_cycle) return null;
+
+ List<Integer> result = new ArrayList<>();
+ result.add(cycle_leftmost_index);
+ result.add(rightmost_index);
+ return result;
+ }
+
+ private boolean graph_descend_cycle_case(Ariadne_LabelList left_path, List<Ariadne_LabelList> path_stack, boolean verbose) {
+
+ List<Integer> cycle_index_interval = path_find_cycle(left_path);
+ if (cycle_index_interval == null) {
+ return false;
+ }
+
+ int cycle_i0 = cycle_index_interval.get(0);
+ int cycle_n = cycle_index_interval.get(1);
+
+ if (verbose) Ariadne_Util.print_list(
+ "Found cycle:",
+ left_path.subList(cycle_i0, cycle_n + 1)
+ );
+
+ Ariadne_LabelList undefined_node_list = new Ariadne_LabelList();
+ for (int i = cycle_i0; i <= cycle_n; i++) {
+ Ariadne_Label node_label = left_path.get(i);
+ Ariadne_Node node = super.lookup(node_label);
+ if (node != null) {
+ node.mark(new Ariadne_Token("cycle_member"));
+ } else {
+ undefined_node_list.add(node_label);
+ }
+ }
+
+ if (verbose) Ariadne_Util.print_list(
+ "Each undefined node could not be marked as a cycle member:",
+ undefined_node_list
+ );
+
+ path_stack.subList(cycle_i0 + 1, cycle_n + 1).clear();
+
+ return true;
+ }
+
+ private static Ariadne_TokenSet graph_descend_set = new Ariadne_TokenSet() {{
+ add(new Ariadne_Token("empty_path_stack"));
+ add(new Ariadne_Token("cycle_found"));
+ add(new Ariadne_Token("undefined_node"));
+ add(new Ariadne_Token("leaf"));
+ add(new Ariadne_Token("max_depth_reached"));
+ }};
+
+ private Ariadne_TokenSet graph_descend(List<Ariadne_LabelList> path_stack, int max_depth, boolean verbose) {
+ Ariadne_TokenSet ret_value = new Ariadne_TokenSet();
+
+ if (path_stack.isEmpty()) {
+ ret_value.add(new Ariadne_Token("empty_path_stack"));
+ return ret_value;
+ }
+
+ Ariadne_LabelList left_path = new Ariadne_LabelList();
+ for (Ariadne_LabelList neighbor_list : path_stack) {
+ left_path.add(neighbor_list.get(0));
+ }
+
+ do {
+
+ if (graph_descend_cycle_case(left_path, path_stack, verbose)) {
+ ret_value.add(new Ariadne_Token("cycle_found"));
+ return ret_value;
+ }
+
+ Ariadne_Label it_node_label = path_stack.get(path_stack.size() - 1).get(0);
+ Ariadne_Node it_node = super.lookup(it_node_label);
+ if (it_node == null) {
+ ret_value.add(new Ariadne_Token("undefined_node"));
+ return ret_value;
+ }
+
+ Ariadne_LabelList neighbor_list = it_node.neighbor_LabelList();
+ if (neighbor_list.isEmpty()) {
+ ret_value.add(new Ariadne_Token("leaf"));
+ return ret_value;
+ }
+
+ path_stack.add(new Ariadne_LabelList(neighbor_list));
+ Ariadne_Label it_next_label = neighbor_list.get(0);
+ left_path.add(it_next_label);
+
+ if (max_depth > 0) {
+ max_depth--;
+ if (max_depth == 0) {
+ if (verbose) {
+ Ariadne_Util.print_list("GraphDirectedAcyclic.GraphDescend:: max_depth reached, ending descent:", path_stack);
+ }
+ ret_value.add(new Ariadne_Token("max_depth_reached"));
+ return ret_value;
+ }
+ }
+
+ } while (true);
+ }
+
+ public static Ariadne_TokenSet graph_mark_cycles_set = new Ariadne_TokenSet() {{
+ add(new Ariadne_Token("empty_root_label_list"));
+ add(new Ariadne_Token("cycle_exists"));
+ add(new Ariadne_Token("undefined_node_exists"));
+ add(new Ariadne_Token("bad_descent_termination"));
+ add(new Ariadne_Token("max_depth_reached"));
+ }};
+
+ public Ariadne_TokenSet graph_mark_cycles(Ariadne_LabelList root_node_LabelList, int max_depth, boolean verbose) {
+ Ariadne_TokenSet ret_value = new Ariadne_TokenSet();
+ boolean exists_malformed = false;
+ Ariadne_TokenSet result;
+
+ if (root_node_LabelList.isEmpty()) {
+ ret_value.add(new Ariadne_Token("empty_root_label_list"));
+ return ret_value;
+ }
+
+ List<Ariadne_LabelList> path_stack = new ArrayList<>();
+ path_stack.add(new Ariadne_LabelList(root_node_LabelList));
+
+ do {
+ result = graph_descend(path_stack, max_depth, verbose);
+ if (result.contains(new Ariadne_Token("cycle_found"))) ret_value.add(new Ariadne_Token("cycle_exists"));
+ if (result.contains(new Ariadne_Token("undefined_node"))) ret_value.add(new Ariadne_Token("undefined_node_exists"));
+ if (result.contains(new Ariadne_Token("max_depth_reached"))) ret_value.add(new Ariadne_Token("max_depth_reached"));
+ if (!result.contains(new Ariadne_Token("leaf")) && !result.contains(new Ariadne_Token("cycle_found"))) ret_value.add(new Ariadne_Token("bad_descent_termination"));
+
+ Ariadne_LabelList top_list = path_stack.get(path_stack.size() - 1);
+ top_list.remove(0);
+ if (top_list.isEmpty()) path_stack.remove(path_stack.size() - 1);
+
+ } while (!path_stack.isEmpty());
+
+ if (verbose) {
+ if (ret_value.contains("bad_descent_termination")) {
+ System.out.println("GraphDirectedAcyclic.graph_mark_cycles:: terminated with unexpected condition.");
+ }
+ if (ret_value.contains("cycle_exists")) {
+ System.out.println("GraphDirectedAcyclic.graph_mark_cycles:: One or more cycles detected.");
+ }
+ if (ret_value.contains("undefined_node_exists")) {
+ System.out.println("GraphDirectedAcyclic.graph_mark_cycles:: Undefined nodes exist.");
+ }
+ }
+
+ return ret_value;
+ }
+
+ public Ariadne_TokenSet graph_mark_cycles(Ariadne_LabelList root_node_LabelList) {
+ return graph_mark_cycles(root_node_LabelList, this.debug ? 40 : -1, this.debug);
+ }
+
+ @Override
+ public Ariadne_Node lookup(Ariadne_Label node_label, boolean verbose) {
+ Ariadne_Node node = super.lookup(node_label, verbose);
+ if (node != null && node.has_mark(new Ariadne_Token("cycle_member"))) {
+ if (verbose) {
+ System.out.println("GraphDirectedAcyclic.lookup:: Node is part of a cycle, not returned: " + node_label);
+ }
+ return null;
+ }
+ return node;
+ }
+
+ public Ariadne_Node lookup(Ariadne_Label node_label) {
+ return lookup(node_label, this.debug);
+ }
+
+}
--- /dev/null
+*
+!/.gitignore
+++ /dev/null
-package com.ReasoningTechnology.Ariadne;
-
-import java.io.IOException;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-public class Ariadne_File {
- static boolean debug = false;
-
- public static Map<String, String> unpack_file_path(String file_fp) {
- if (debug) System.out.println("unpack_file_path::file_fp: " + file_fp);
-
- // Use java.io.File explicitly to avoid conflict with the custom Ariadne_File class
- java.io.File file = new java.io.File(file_fp);
- String parent_dp = (file.getParent() != null) ? file.getParent() : "";
-
- if (!parent_dp.isEmpty() && !parent_dp.endsWith(java.io.File.separator)) {
- parent_dp += java.io.File.separator;
- }
-
- String file_fn = file.getName();
- String file_fn_base = file_fn;
- String file_fn_ext = "";
-
- int last_index = file_fn.lastIndexOf('.');
- if (last_index > 0) {
- file_fn_base = file_fn.substring(0, last_index);
- if (last_index + 1 < file_fn.length()) {
- file_fn_ext = file_fn.substring(last_index + 1);
- }
- }
-
- Map<String, String> ret_val = new HashMap<>();
- ret_val.put("dp", parent_dp);
- ret_val.put("fn", file_fn);
- ret_val.put("fn_base", file_fn_base);
- ret_val.put("fn_ext", file_fn_ext);
-
- if (debug) System.out.println("unpack_file_path::ret_val: " + ret_val);
-
- return ret_val;
- }
-
- public static boolean file_exists_q(String fp_string) {
- Path fp_object = Paths.get(fp_string);
- return Files.exists(fp_object);
- }
-
- /*
- Given a target_fp and a list of dependency_fp.
-
- Returns false if the target is newer than all dependencies or if a file is missing;
- otherwise, returns true.
- */
- public static boolean newer_than_all(String target_fp_string, List<String> dependency_fp_list) throws IOException {
- Path target_fp_object = Paths.get(target_fp_string);
- if (!Files.exists(target_fp_object)) return false;
-
- long target_last_modified_time = Files.getLastModifiedTime(target_fp_object).toMillis();
-
- return dependency_fp_list.stream().allMatch(dependency_fp -> {
- try {
- Path dependency_fp_object = Paths.get(dependency_fp);
- if (!Files.exists(dependency_fp_object)) return false;
- long dependency_last_modified_time = Files.getLastModifiedTime(dependency_fp_object).toMillis();
- return target_last_modified_time > dependency_last_modified_time;
- } catch (IOException e) {
- return false;
- }
- });
- }
-}
+++ /dev/null
-package com.ReasoningTechnology.Ariadne;
-
-import java.util.HashMap;
-import java.util.Map;
-
-public class Graph{
-
- /*--------------------------------------------------------------------------------
- constructors
- */
-
- public Graph(Map<Label ,Node> node_map ,ProductionList recognizer_f_list){
- if(node_map == null && recognizer_f_list == null){
- System.err.println("AriadneGraph: At least one of 'node_map' (Map) or 'recognizer_f_list' (List) must be provided.");
- System.exit(1);
- }
-
- // Initialize each of node_map and recognizer_f_list to empty collections if null
- this.node_map = (node_map != null) ? node_map : new HashMap<Label ,Node>();
- this.recognizer_f_list = (recognizer_f_list != null) ? recognizer_f_list : new ProductionList();
- }
-
- /*--------------------------------------------------------------------------------
- instance data
- */
-
- private static boolean debug = true;
- private Map<Label ,Node> node_map;
- private ProductionList recognizer_f_list;
-
- /*--------------------------------------------------------------------------------
- interface
- */
-
- // Lookup method to find a node by its label
- public Node lookup(Label node_label ,boolean verbose){
- if( node_label == null || node_label.isEmpty() ){
- if(verbose){
- System.out.println("lookup:: given node_label is null or empty.");
- }
- return null;
- }
-
- // Try to retrieve the node from the map
- Node node = this.node_map.get(node_label);
-
- if(verbose){
- if(node != null){
- System.out.println("lookup:: found node: " + node);
- } else {
- System.out.println("lookup:: node not found for label: " + node_label);
- }
- }
-
- return node;
- }
-
- // Overloaded lookup method with default verbosity (true)
- public Node lookup(Label node_label){
- return lookup(node_label ,true);
- }
-
-}
+++ /dev/null
-package com.ReasoningTechnology.Ariadne;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.List;
-import java.util.ArrayList;
-
-public class GraphDirectedAcyclic extends Graph{
-
- /*--------------------------------------------------------------------------------
- constructors
- */
-
- public GraphDirectedAcyclic(Map<Label ,Node> node_map ,ProductionList recognizer_f_list ,LabelList root_node_list ,int max_depth ,boolean verbose){
- super( node_map ,recognizer_f_list );
- TokenSet cycle_detection_result = graph_mark_cycles(root_node_list ,max_depth ,verbose);
- }
-
- public GraphDirectedAcyclic(Map<Label ,Node> node_map ,ProductionList recognizer_f_list ,LabelList root_node_list){
- super( node_map ,recognizer_f_list );
- TokenSet cycle_detection_result = graph_mark_cycles(root_node_list);
- }
-
-
- /*--------------------------------------------------------------------------------
- instance data extension
- */
-
- private static boolean debug = true;
-
-
- /*--------------------------------------------------------------------------------
- Interface
- */
-
- /*
- Given a path to a node in the graph, `left_path`.
-
- Checks if the rightmost node (referenced by label) recurs earlier in the path.
- Presumably the rightmost node has been recently appended to the path.
-
- If there is no cycle, returns null, otherwise returns the interval [i ,n],
- of indexes into the path where the cycle is found. `n` will always be
- the index of the rightmost node in the path list.
- */
- private List<Integer> path_find_cycle(LabelList path ){
- if( path.size() <= 1 ) return null;
-
- int rightmost_index = path.size() - 1;
- Label rightmost_node_label = path.get( rightmost_index );
-
- // if there is no cycle, searching for rightmost_node_label will find itself:
- int cycle_leftmost_index = path.indexOf(rightmost_node_label);
- Boolean has_cycle = cycle_leftmost_index < rightmost_index;
- if( ! has_cycle ) return null;
-
- List<Integer> result = new ArrayList<>();
- result.add(cycle_leftmost_index);
- result.add(rightmost_index);
- return result;
- }
-
- /*
- Given a path_stack, which is our graph iterator. Also given `left_path`
- which is derived from path_stack, and represents the left most neighbor
- of each of the neighbor lists in the path_stack.
-
- Calls `path_find_cycle` to see if the most recently added to the path node,
- i.e. the rightmost node, forms a cycle with other node(s) in the path. Upon
- finding a cycle, unwinds the path_stack (decrements the iterator), to the top
- of the cycle.
-
- If a cycle is found, returns false, otherwise returns true.
- */
- private boolean graph_descend_cycle_case( LabelList left_path ,List<LabelList> path_stack ,boolean verbose ){
-
- List<Integer> cycle_index_interval = path_find_cycle(left_path);
- if( cycle_index_interval == null ){
- return false; // No cycle found
- }
-
- int cycle_i0 = cycle_index_interval.get(0); // Cycle leftmost, inclusive
- int cycle_n = cycle_index_interval.get(1); // Cycle rightmost, inclusive
-
- if(verbose) Util.print_list(
- "Found cycle:"
- ,left_path.subList( cycle_i0 ,cycle_n + 1)
- );
-
- // Mark cycle members
- LabelList undefined_node_list = new LabelList();
- for( int i = cycle_i0; i <= cycle_n; i++ ){
- Label node_label = left_path.get(i);
- Node node = super.lookup( node_label );
- if (node != null){
- node.mark(new Token("cycle_member"));
- }else{
- undefined_node_list.add( node_label );
- }
- }
-
- if(verbose) Util.print_list(
- "Each undefined node could not be marked as a cycle member:"
- ,undefined_node_list
- );
-
- // Reset the graph iterator to the top of the cycle
- path_stack.subList( cycle_i0 + 1 ,cycle_n + 1 ).clear();
-
- return true; // cycle found
- }
-
- /*
- Given a path_stack initialized to the root nodes for the graph traversal.
-
- Perform depth first descent from each node in succession while searching for
- cycles by calling graph_descent_cycle_case. Algorithm follows the leftmost
- nodes in the path_stack list of child lists.
-
- Returns the descent termination condition.
- */
- private static TokenSet graph_descend_set = new TokenSet() {{
- add(new Token("empty_path_stack"));
- add(new Token("cycle_found"));
- add(new Token("undefined_node"));
- add(new Token("leaf"));
- add(new Token("max_depth_reached"));
- }};
- private TokenSet graph_descend( List<LabelList> path_stack ,int max_depth ,boolean verbose ){
- TokenSet ret_value = new TokenSet();
-
- if( path_stack.isEmpty() ){
- ret_value.add( new Token("empty_path_stack") );
- return ret_value;
- }
-
- // a leftmost path through the neighbor lists of the leftmost nodes
- LabelList left_path = new LabelList();
- for( LabelList neighbor_list : path_stack ){
- left_path.add( neighbor_list.get(0) );
- }
-
- // do descend
- do{
-
- // cycle case
- if( graph_descend_cycle_case( left_path ,path_stack ,verbose ) ){
- ret_value.add( new Token("cycle_found") );
- return ret_value;
- }
-
- // Non-cycle case, descend further into the tree.
- // Increment the graph iterator (path_stack) to go down a level.
- Label it_node_label = path_stack.get( path_stack.size() - 1 ).get(0);
- Node it_node = super.lookup( it_node_label );
- if( it_node == null ){
- ret_value.add( new Token("undefined_node") );
- return ret_value;
- }
-
- LabelList neighbor_list = it_node.neighbor_LabelList();
- if( neighbor_list.isEmpty() ){
- ret_value.add( new Token("leaf") );
- return ret_value;
- }
-
- // The iterator will destroy the neighbor_list as we traverse the graph,
- // so we give it a copy.
- path_stack.add( new LabelList(neighbor_list) );
- Label it_next_label = neighbor_list.get(0);
- left_path.add( it_next_label ); // also extend the left_path
-
- // bound the size of problem we are willing to work on
- // set max_depth <= 0 to have this test ignored
- if( max_depth > 0 ){
- max_depth--; // Typo fixed
- if( max_depth == 0 ){
- if(verbose){
- Util.print_list("GraphDirectedAcyclic.GraphDescend:: max_depth reached, preternaturally ending the descent:" ,path_stack);
- }
- ret_value.add( new Token("max_depth_reached") );
- return ret_value;
- }
- }
-
- }while(true); // while descend
- }
-
-
- /*
- Given root_node_label_list and a maximum depth for traversal.
-
- Cycles are handled gracefully, rather the constraint `max_depth` is present
- because the user is allowed to provide production *functions* for generating
- nodes. Who knows what crazy graphs a user could come up with, see the
- document on the algorithm for more info.
-
- Does a left first depth first traversal of the graph while marking
- cycles. This routine pushes the graph traversal iterator to the right one
- node after a left descent traversal, then it calls `graph_descend` descend
- from said node.
-
- Returns one or more symbols that characterize the termination condition.
- */
-
- public static TokenSet graph_mark_cycles_set = new TokenSet() {{
- add(new Token("empty_root_label_list"));
- add(new Token("cycle_exists"));
- add(new Token("undefined_node_exists"));
- add(new Token("bad_descent_termination"));
- add(new Token("max_depth_reached"));
- }};
- public TokenSet graph_mark_cycles( LabelList root_node_LabelList ,int max_depth ,boolean verbose ){
- TokenSet ret_value = new TokenSet();
- boolean exists_malformed = false;
- TokenSet result; // used variously
-
- if( root_node_LabelList.isEmpty() ){
- ret_value.add(new Token("empty_root_label_list"));
- return ret_value;
- }
-
- // `path_stack` is our graph iterator. It is initialized with the
- // `root_node_LabelList`.
- List<LabelList> path_stack = new ArrayList<>();
- path_stack.add( new LabelList(root_node_LabelList) );
-
- // each call to graph_descend does a leftmost descent to a leaf
- do{
- result = graph_descend( path_stack ,max_depth ,verbose );
- if( result.contains(new Token("cycle_found")) ) ret_value.add(new Token("cycle_exists"));
- if( result.contains(new Token("undefined_node")) ) ret_value.add(new Token("undefined_node_exists"));
- if( result.contains(new Token("max_depth_reached")) ) ret_value.add(new Token("max_depth_reached"));
- if( !result.contains(new Token("leaf")) && !result.contains(new Token("cycle_found")) ) ret_value.add(new Token("bad_descent_termination"));
-
- // Push the iterator to the right by one node
- LabelList top_list = path_stack.get( path_stack.size() - 1 );
- top_list.remove(0);
- if( top_list.isEmpty() ) path_stack.remove( path_stack.size() - 1 );
-
- }while( !path_stack.isEmpty() );
-
- if(verbose){
- if( ret_value.contains("bad_descent_termination") ){
- System.out.println("GraphDirectedAcyclic.graph_mark_cycles:: graph_descend terminated with other than leaf or cycle found condition.");
- }
- if( ret_value.contains("cycle_exists") ){
- System.out.println("GraphDirectedAcyclic.graph_mark_cycles:: There are one or more cycles in the graph.");
- }
- if( ret_value.contains("undefined_node_exists") ){
- System.out.println("GraphDirectedAcyclic.graph_mark_cycles:: There are one or more node label references that do not correspond to a defined node in this graph.");
- }
- }
-
- return ret_value;
- }
- public TokenSet graph_mark_cycles(LabelList root_node_LabelList){
- return graph_mark_cycles(root_node_LabelList ,this.debug?40:-1 ,this.debug);
- }
-
-
- /*--------------------------------------------------------------------------------
- Graph traversal
- */
-
- @Override
- public Node lookup(Label node_label, boolean verbose){
- Node node = super.lookup(node_label, verbose);
- if(node != null && node.has_mark(new Token("cycle_member"))){
- if(verbose){
- System.out.println("GraphDirectedAcyclic.lookup:: Node is part of a cycle so it will not be returned: " + node_label);
- }
- return null; // Exclude nodes in cycles
- }
- return node;
- }
-
- public Node lookup(Label node_label){
- return lookup(node_label ,this.debug);
- }
-
-}
+++ /dev/null
-package com.ReasoningTechnology.Ariadne;
-
-/*
- A value for the node.label property.
-
- This is a wrapper for a String. We can't instead use an alias by extending
- String, because String is a JavaScript 'final' type.
-
-*/
-public class Label {
- private final String value;
-
- public Label(String value){
- this.value = value;
- }
-
- public boolean isEmpty() {
- return value.isEmpty();
- }
-
- public String get(){
- return value;
- }
-
- @Override
- public String toString(){
- return value;
- }
-
- @Override
- public boolean equals(Object o){
- if(this == o) return true;
- if( o == null || getClass() != o.getClass() ) return false;
- Label label = (Label)o;
- return value.equals( label.value );
- }
-
- @Override
- public int hashCode(){
- return value.hashCode();
- }
-}
+++ /dev/null
-// LabelList.java
-package com.ReasoningTechnology.Ariadne;
-import java.util.List;
-import java.util.ArrayList;
-
-public class LabelList extends ArrayList<Label> {
- // Constructor
- public LabelList(){
- super();
- }
- public LabelList(List<Label> labels){
- super(); // Initialize the parent class
- if (labels != null) {
- this.addAll(labels); // Copy all elements from the provided list
- }
- }
-
-}
+++ /dev/null
-package com.ReasoningTechnology.Ariadne;
-import java.util.HashMap;
-import java.util.ArrayList;
-import java.util.List;
-
-public class Node extends HashMap<String, Object>{
-
- private static String mark_property_name = "mark";
- private static String neighbor_property_name = "neighbor";
-
- public Node(){
- super();
- // Initialize the neighbor list in the constructor
- this.put(neighbor_property_name, new LabelList());
- }
-
- public void mark(Token token){
- if( this.get(mark_property_name) == null ){
- this.put(mark_property_name, new TokenSet());
- }
- ((TokenSet)this.get(mark_property_name)).add(token);
- }
-
- public boolean has_mark(Token token){
- TokenSet mark = (TokenSet)this.get(mark_property_name);
- return mark != null && mark.contains(token);
- }
-
- // Return the neighbor list (always exists after initialization)
- public LabelList neighbor_LabelList(){
- return (LabelList)this.get(neighbor_property_name);
- }
-
-}
+++ /dev/null
-// NodeList.java
-package com.ReasoningTechnology.Ariadne;
-import java.util.ArrayList;
-
-public class NodeList extends ArrayList<Node> {
- // Constructor
- public NodeList(){
- super();
- }
-}
+++ /dev/null
-// Production.java
-package com.ReasoningTechnology.Ariadne;
-import java.util.function.Function;
-
-public interface Production extends Function<Label, Node> {}
+++ /dev/null
-// ProductionList.java
-package com.ReasoningTechnology.Ariadne;
-import java.util.ArrayList;
-
-public class ProductionList extends ArrayList<Production> {
- // Constructor
- public ProductionList(){
- super();
- }
-}
+++ /dev/null
-package com.ReasoningTechnology.Ariadne;
-
-/*
-An error token.
-
-*/
-public class Token {
- private final String value;
-
- public Token(String value){
- this.value = value;
- }
-
- public String get(){
- return value;
- }
-
- @Override
- public String toString(){
- return value;
- }
-
- @Override
- public boolean equals(Object o){
- if(this == o) return true; // No padding, not nested
- if( o == null || getClass() != o.getClass() ) return false; // Padded, because it's nested
- Token token = (Token)o;
- return value.equals( token.value );
- }
-
- @Override
- public int hashCode(){
- return value.hashCode();
- }
-}
+++ /dev/null
-// TokenSet.java
-package com.ReasoningTechnology.Ariadne;
-import java.util.HashSet;
-
-public class TokenSet extends HashSet<Token> {
- // Constructor
- public TokenSet(){
- super();
- }
-}
+++ /dev/null
-package com.ReasoningTechnology.Ariadne;
-import java.util.List;
-
-public class Util{
- static boolean debug = false;
-
- public static void print_list(String prefix ,List<?> item_list){
- if( item_list == null || item_list.isEmpty() ){
- return;
- }
- if( prefix != null && !prefix.isEmpty() ){
- System.out.print(prefix);
- }
- int i = 0;
- int n = item_list.size() - 1;
- System.out.print( " '" + item_list.get(i) + "'" );
- do{
- i++;
- if( i > n ) break;
- System.out.print(", " + "'" + item_list.get(i) + "'");
- }while( true );
- System.out.println(".");
- }
-
-}
--- /dev/null
+*
+!/.gitignore