From: Thomas Walker Lynch Date: Mon, 21 Oct 2024 17:46:28 +0000 (+0000) Subject: breaking Graph into component layers X-Git-Url: https://git.reasoningtechnology.com/fossil/raw/src/makeheaders.c?a=commitdiff_plain;h=caa5e743508b4be690c54c2b62076a7073d28b38;p=Ariadne breaking Graph into component layers --- diff --git a/developer/deprecated/Label.java b/developer/deprecated/Label.java deleted file mode 100644 index 7802cf8..0000000 --- a/developer/deprecated/Label.java +++ /dev/null @@ -1,35 +0,0 @@ -package Ariadne; - -/* -A node label. - -*/ -public class Label { - private final String value; - - public Label(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; - if (o == null || getClass() != o.getClass()) return false; - Label label = (Label) o; - return value.equals(label.value); - } - - @Override - public int hashCode() { - return value.hashCode(); - } -} diff --git a/developer/deprecated/Token.java b/developer/deprecated/Token.java deleted file mode 100644 index 1d1c36f..0000000 --- a/developer/deprecated/Token.java +++ /dev/null @@ -1,35 +0,0 @@ -package 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; - if (o == null || getClass() != o.getClass()) return false; - Token token = (Token) o; - return value.equals(token.value); - } - - @Override - public int hashCode() { - return value.hashCode(); - } -} diff --git a/developer/deprecated/cycle_case.java b/developer/deprecated/cycle_case.java new file mode 100644 index 0000000..040654b --- /dev/null +++ b/developer/deprecated/cycle_case.java @@ -0,0 +1,48 @@ + //---------------------------------------- + // cycle case + // + + List cycle_index_interval; + if( cycle_index_interval=path_find_cycle(left_path ,verbose) ){ + ret_value.add( "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 ,n +1) + ); + + // mark cycle + LabelList undefined_node_list; + int i = cycle_i0; + do{ + node_label = left_path.get(i); + node = super.lookup(node_label); + if(node){ + if( node.get("mark") == null ){ + node.put( "mark" ,new HashTokenSet() ); + } + ( (TokenSet)node.get("mark") ).add("cycle_member"); + }else{ + undefined_node_list.add(node_label); + ret_value.add( "undefined_node" ); + } + i++; + if( i > cycle_n ) break; + }while(true); + + if(verbose) Util.print_list( + "Each undefined node could not be marked as a cycle member:" + ,undefined_node_list + ); + + // Reset the graph iterator to immediately top of the cycle, then return + // as though we had hit a leaf node. (Upon return the the i0 node will + // be dropped as part of incrementing the iterator.) + path_stack.subList(cycle_i0 + 1 ,cycle_n + 1).clear(); + + return ret_value; + } + diff --git a/developer/document/#question_jan.txt# b/developer/document/#question_jan.txt# new file mode 100644 index 0000000..9b0715c --- /dev/null +++ b/developer/document/#question_jan.txt# @@ -0,0 +1,2 @@ + +On a directed acyclic graph, is it \ No newline at end of file diff --git a/developer/document/#variable_suffix_conventions.txt# b/developer/document/#variable_suffix_conventions.txt# new file mode 100644 index 0000000..8aca090 --- /dev/null +++ b/developer/document/#variable_suffix_conventions.txt# @@ -0,0 +1,27 @@ +# Suffix Conventions + +## Specify interface used with variable when clarification is useful: + +- `_set`: Indicates that the variable holds a set of items. + +- `_list`: Used for variables that represent a list of items. + +- `_f`: Refers to a function. + +Instead of making a variable name plural, add the interface qualifier: + + e.g. names -> name_set or name_list + +## Always a good idea to use these when working with files: + +- `_fp`: Refers to a file path. The part after the last slash is a file name. + +- `_dp`: Refers to a directory path. By convention, the value ends in a slash. + +- `_fn`: Refers to a file name. Value has no slashes. + +- `_dn`: Refers to a directory name. Value has no slashes. + +- `_fn_base`: The file name without the last dot and subsequent characters. + +- `_fn_ext`: The subsequent characters after the last dot in a file name. diff --git a/developer/document/RT_code_format.txt b/developer/document/RT_code_format.txt new file mode 100644 index 0000000..7f85e16 --- /dev/null +++ b/developer/document/RT_code_format.txt @@ -0,0 +1,127 @@ +RT code formatting: + +This has evolved into place after decades of programming in Unix culture projects +in multiple languages. + +AI tools we have used are OK with the commas, but have had difficulties +with the padding rules for enclosures. + +1. Two space indentation. + +2. Variable Naming: + + - Use **PascalCase** for namespaces and types. + + - Use **snake_case** for function and variable names. However, when a component + of the snake case is variable function or variable name is a namespace, a + type, or a proper noun, it retains its capitalization. e.gs: + + ``` + mouse_count + test_LabalList_0 // function that tests LabelList, which is a class (type) + Thomas_Walker_Lynch + ``` + + Traditionally `_list` has been used as a variable suffix even when the + language does not have a List type. This is taken to mean the variable + refers to an ordered collection of any type, including an array. It is + abstraction of type, analogous to the `mouse_count` example above. + + +3. Binary Operators: + + - One space around **binary operators** (e.g., `a + b`). + + - One space around **assignment** `=` (e.g., `a = b`). + + - **No space** around **sampling** assignment `=` (typically seen in `if`, `while`, etc.): + + **Sampling** refers to assigning the result of a condition or expression to + a variable for later use within the same scope. + + Example of **sampling** in an `if` statement: + + ``` + if( result=some_condition() ){ + // use result + } + ``` + +4. Enclosures `(...)`, `{...}`, `[...]`, '<...>': + + - No space between the enclosure and the preceding identifier (e.g., `function(arg)`). + + - No space after the enclosure when followed by another enclosure (e.g., `map[key]()`). + + Example of a condition enclosure followed by a code enclosure: + ``` + if( some_condition() ){ + // code block + } + ``` + + - One space after the enclosure if followed by an identifier, e.g., + `function() somethingElse`. + + - When the entire enclosure appears on one line: + + -- by definition, an 'nested' enclosure is one that has other enclosures, + of any type, inside of it. This is true independent of whatever else + is inside the enclosure. These are examples of nested enclosures: + + ``` + ( o == null || getClass() != o.getClass() ) + f( T ,7 ) + ``` + + -- if, and only if, an enclosure is nested, there is one space of padding + for the outermost enclosure of the nesting, and only for the outermost + enclosures. e.g.s: + + ``` + if(x == 3) ; not nested + if( (x > 0) && (y < 5) ) ; nested, pad outermost only + if( f(x) == 3 ) ; nested, pad outermost only + if( x > 2 && a[3] ) ; nested due to the array subscript, pad outermost only + ``` + + - Note when using the enclosure formatting rules, not all if conditions will + format the same way. Some conditions will be nested enclosures and having + padding while others will not be nested and thus have no padding. The must + be formatted individually. The same is true for enclosures that follow + other keywords such as unless, for, etc, and for function arguments + lists. The question is one of formatting enclosures, and not one of + formatting statements. + + ``` + f(x) + f( x[0] ) + ``` + + +5. Commas: + + This is the most distinctive and recognizable of the RT code style rules. + + - One space **before** the comma (e.g., `a ,b`). + + - No space **after** the comma (e.g., `a ,b`). + + - **Line break before** the comma when breaking lines, but no line break after, as examples: + + ``` + a + ,b + ``` + + and, when a function call gets too long, perhaps due to long argument + names it will look like this: + + ``` + result = some_function( + arg1 + ,arg2_has_a_very_long_name_causing_the_call_to_not_fit_on_a_single_line + ,arg3_has_a_long_name_also_but_not_as_long_as_for_arg2 + ); + ``` + diff --git a/developer/document/variable_suffix_conventions.txt b/developer/document/variable_suffix_conventions.txt new file mode 100644 index 0000000..e5ef76e --- /dev/null +++ b/developer/document/variable_suffix_conventions.txt @@ -0,0 +1,27 @@ +# Suffix Conventions + +## Specify interface used with variable when clarification is useful + +- `_set`: Indicates that the variable holds a set of items. + +- `_list`: Used for variables that represent a list of items. + +- `_f`: Refers to a function. + +Instead of making a variable name plural, add the interface qualifier. + + e.g. names -> name_set or name_lisst + +## Always a good idea to use these when working with files + +- `_fp`: Refers to a file path. The part after the last slash is a file name. + +- `_dp`: Refers to a directory path. By convention, the value ends in a slash. + +- `_fn`: Refers to a file name. Value has no slashes. + +- `_dn`: Refers to a directory name. Value has no slashes. + +- `_fn_base`: The file name without the last dot and subsequent characters. + +- `_fn_ext`: The subsequent characters after the last dot in a file name. diff --git a/developer/javac/Graph.java b/developer/javac/Graph.java new file mode 100644 index 0000000..3b7f970 --- /dev/null +++ b/developer/javac/Graph.java @@ -0,0 +1,66 @@ +package com.ReasoningTechnology.Ariadne; + +import java.util.HashMap; +import java.util.Map; + +public class Graph{ + + /*-------------------------------------------------------------------------------- + constructors + */ + + public Graph(Map