+++ /dev/null
-
-wellformed is a single word. Its antonym is 'malformed'. Wellformed syntax
-parses without errors.
+++ /dev/null
-
-predicate == is_well_formed_q
-
-We can not check that the node labels are unique because the given value
-is a single node, and the code is stateless. Besides there is no contract with
-the programmer on how to use the predicated, so the programmer could call the
-predicate multiple times on the same node. Now can we test this condition in
-our do_markup_graph routine because of the way lookup works, it will always
-return the same node for the same label. This would be a truly difficult check
-to perform because the map does not given an error but just takes the second of
-the duplicate key definitions (is this really true?) besides, it would require
-a formal proof of the recognizer functions that they do not return different
-definitions for different keys to match regexprs against. I've been mulling
-this over. As we currently the programmer provides the map and function
-definitions, we don't even know which nodes will be in the graph...
## 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.
+
+- `_afp`: Refers to an absolute file path.
- `_dp`: Refers to a directory path. By convention, the value ends in a slash.
+- `_adp`: Refers to an absolute directory path.
+
- `_fn`: Refers to a file name. Value has no slashes.
- `_dn`: Refers to a directory name. Value has no slashes.
}
public static int run(){
- System.out.println("Mosic currently does not have a shell user interface.");
+ System.out.println("Main function placeholder. Currently Mosaic is used by extending the TestBench class.");
return 0;
}
- // Main function to provide a shell interface for running tests
- public static int main(String[] args){
- // currently accepts no arguments or options
- return run();
+ public static void main(String[] args){
+ int return_code = run();
+ System.exit(return_code);
+ return;
}
+
}
import java.time.Instant;
import java.time.ZoneOffset;
import java.time.format.DateTimeFormatter;
+import java.util.function.Predicate;
public class Util{
- // Typically used to gather conditions before returning a test result.
- // As this is used for testing, and an empty conditions list is unusual,
- // returns false for an empty conditions list.
- public static boolean all(boolean[] conditions){
- if( conditions.length == 0 ) return false;
- for(boolean condition : conditions) if(!condition) return false;
- return true;
+ // Linear search with a predicate
+ public static <T> T find( T[] elements ,Predicate<T> predicate ){
+ for( T element : elements ){
+ if( predicate.test( element )) return element; // Return the first match
+ }
+ return null; // Return null if no element satisfies the predicate
+ }
+
+ // True when it does a search and finds a true value; otherwise false.
+ public static boolean exists( Object[] elements ){
+ return elements.length > 0 && find( elements ,element -> (element instanceof Boolean) && (Boolean) element ) != null;
}
+
+ // True when it does a search and does not find a false value; otherwise false.
+ public static boolean all( Object[] elements ){
+ return elements.length > 0 && find( elements ,element -> !(element instanceof Boolean) || !(Boolean) element ) == null;
+ }
+
public static void all_set_false(boolean[] conditions){
for(boolean condition : conditions) condition = false;
}
#!/usr/bin/env bash
+script_afp=$(realpath "${BASH_SOURCE[0]}")
# Removes all files found in the build directories. It asks no questions as to
# how or why the files got there. Be especially careful with the 'shell' directory
#!/usr/bin/env bash
+script_afp=$(realpath "${BASH_SOURCE[0]}")
# remove all files created by make's call to `javac`
# input guards
#!/usr/bin/env bash
+script_afp=$(realpath "${BASH_SOURCE[0]}")
# remove all files made by `make`
# input guards
#!/usr/bin/env bash
+script_afp=$(realpath "${BASH_SOURCE[0]}")
# remove files made by `make` and by `release`
# input guards
#!/bin/env bash
+script_afp=$(realpath "${BASH_SOURCE[0]}")
# This script links the sources into the directory tree in parallel to the package.
#!/bin/env bash
+script_afp=$(realpath "${BASH_SOURCE[0]}")
# input guards
#!/usr/bin/env bash
+script_afp=$(realpath "${BASH_SOURCE[0]}")
# input guards
#!/bin/env bash
+script_afp=$(realpath "${BASH_SOURCE[0]}")
# input guards
--- /dev/null
+
+I had a lot of problems in bash scripting language, while trying to export a
+function that could report the name of the script it was called in.
+
+1.
+
+BASH_SOURCE[0] was used because $0 did not work with sourced scripts (a
+fact that is leveraged for detecting when in a sourced script).
+
+2.
+
+Hence, this did not work in general:
+
+ read -r -d '' script_afp_string <<'EOF'
+ realpath "${BASH_SOURCE[0]}" 2>/dev/null
+ EOF
+
+ script_afp(){
+ eval "$script_afp_string"
+ }
+
+ export script_afp_string
+ export -f script_afp
+
+When `script_afp` was exported, used in another file, and used within a function
+in that other file, it reported `environment` for the script name at
+BASH_SOURCE[0]. In various call scenarios the actual script name appears at
+BASH_SOURCE[1] or even at BASH_SOURCE[2].
+
+3.
+
+As a stable alternative to having a script_afp function, place this line
+at the top of scripts that use the `script_XX` functions, or at the top
+of all scripts:
+
+ script_afp=realpath "${BASH_SOURCE[0]}"
+
+Then use $script_afp as a string within other functions. It will have stable
+value no matter the call structure.
5. make_source_tree also integrated into make
-6. replacement for bespoke/env and all other env files
+6. replacement for bespoke/env and all other env files, related document.
+
+
+++ /dev/null
-/var/user_data/Thomas-developer/Mosaic//tester/javac
\ No newline at end of file
+++ /dev/null
-
-jdb will be in the third_party tools directory:
-
- 2024-10-27T09:34:37Z[Mosaic_tester]
- Thomas-developer@Blossac§/var/user_data/Thomas-developer/Mosaic/tester§
- > which jdb
- /var/user_data/Thomas-developer/Mosaic/tool_shared/third_party/jdk-11/bin/jdb
-
-If Emacs has been run from outside of `env_developer` or `env_tester` then
-emacs will not see the path to tool_shared/third_party. Emacs can be told
-explicitly:
-
- (setenv "PATH" (concat (getenv "PATH") ":/var/user_data/Thomas-developer/Mosaic/tool_shared/third_party/jdk-11/bin"))
- (setq exec-path (append exec-path '("/var/user_data/Thomas-developer/Mosaic/tool_shared/third_party/jdk-11/bin")))
-
-but this probably won't work as other things will also be missing from the
-environment.So either run emacs in the correct environment, or run jdb from a
-shell after sourcing the environment.
--- /dev/null
+
+1. location
+
+ jdb will be in the third_party tools directory:
+
+ 2024-10-27T09:34:37Z[Mosaic_tester]
+ Thomas-developer@Blossac§/var/user_data/Thomas-developer/Mosaic/tester§
+ > which jdb
+ /var/user_data/Thomas-developer/Mosaic/tool_shared/third_party/jdk-11/bin/jdb
+
+2. IDE and the environment
+
+ The environment must be set before running the IDE or the IDE will not
+ have access to it.
+
+ For example Emacs will be following the PATH as it was when Emacs
+ was invoked, for file completion in the Emacs shell, etc. Even when
+ the environment is set in a shell running inside of emacs.
+
+ FYI, the path can be fixed but other environment settings will still be missing.
+ (setenv "PATH" (concat (getenv "PATH") ":<directory>"))
+ (setq exec-path (append exec-path '("<directory")))
+
+3. command line:
+
+ SOURCEPATH must be defined in advance. There is no space between -source and the
+ source path. Typically SOURCEPATH will be `javac`.
+
+ jdb -sourcepath $SOURCEPATH <class_name>
+
+ currently, in emacs, e.g.:
+ jdb -sourcepathjavac Test_Util
+
+ When invoked from Emacs M-x jdb, there is no space between the -sourcepath and
+ the $SOURCEPATH.
+
+ In jdb run from gud-gdb, when packages are used, the SOURCEPATH is the path
+ to the directory that holds a directory tree, where said directory tree
+ parallels the package name. Otherwise it is the directory path to the source
+ directory. Note the `distribute_sources` script.
+
+ When using packages, the <class_name> is fully qualified.
+
+
+
--- /dev/null
+#!/bin/env bash
+java Test0
--- /dev/null
+#!/bin/env bash
+java Test_IO
--- /dev/null
+#!/bin/env bash
+java Test_Util
--- /dev/null
+#!/bin/env bash
+script_afp=$(realpath "${BASH_SOURCE[0]}")
+
+# input guards
+env_must_be="tester/tool/env"
+if [ "$ENV" != "$env_must_be" ]; then
+ echo "$(script_fp):: error: must be run in the $env_must_be environment"
+ exit 1
+fi
+
+jdb -sourcepath "$SOURCEPATH" "$@"
+
:"$REPO_HOME"/tester/jvm/Test_"$PROJECT".jar\
:"$CLASSPATH"
+export SOURCEPATH=\
+"$REPO_HOME"/tester/javac/\
+:"$REPO_HOME"/developer/scratchpad/\
+
+
# misc
# make .githolder and .gitignore visible
for file in $wrapper;do
cat > shell/$file << EOL
#!/bin/env bash
-java com.ReasoningTechnology.$PROJECT.Test.$file
+java $file
EOL
chmod +x shell/$file
done
--- /dev/null
+#!/bin/env bash
+script_afp=$(realpath "${BASH_SOURCE[0]}")
+
+# input guards
+env_must_be="tester/tool/env"
+if [ "$ENV" != "$env_must_be" ]; then
+ echo "$(script_fp):: error: must be run in the $env_must_be environment"
+ exit 1
+fi
+
+jdb -sourcepath "$SOURCEPATH" "$@"
-#!/bin/bash
+#!/bin/env bash
script_afp=$(realpath "${BASH_SOURCE[0]}")
# input guards
#!/usr/bin/env bash
+script_afp=$(realpath "${BASH_SOURCE[0]}")
# Check if at least one file is provided
if [ $# -eq 0 ]; then
#!/usr/bin/env bash
+script_afp=$(realpath "${BASH_SOURCE[0]}")
# cp subtree at <source> under file path <destination>, and make all the copied
# files read-only. The intended use case is for moving files to a `deprecated`
# directory. This helps prevent subsequent accidental editing.
-SCRIPT_NAME=$(basename "$0")
if [ "$#" -lt 2 ]; then
- echo "Usage: $SCRIPT_NAME <source> <destination>"
+ echo "Usage: $script_afp <source> <destination>"
exit 1
fi
SRC="$1"
exit 1
fi
-# This is the base environment shared by all roles in the project.
+# --------------------------------------------------------------------------------
+# project definition
-# The project administrator sets up the following tools for all roles to use:
-#
- export JAVA_HOME="$REPO_HOME/tool_shared/third_party/jdk-11"
-
-# Absolute path to script file. The use of eval makes it suitable for exporting
-# and use with other scripts
-#
-# IMHO it is not possible write a function in bash that reliably returns the
-# script's path in all execution scenarios of direct execute, sourcing, and
-# usage in other functions. So instead, define a variable script_afp at the top
-# of each script:
-#
-# script_afp=realpath "${BASH_SOURCE[0]}"
-#
-# read -r -d '' script_afp_string <<'EOF'
-# realpath "${BASH_SOURCE[0]}" 2>/dev/null
-# EOF
-# script_afp(){
-# eval "$script_afp_string"
-# }
+# actual absolute director path for this script file
script_adp(){
dirname "$script_afp"
}
-
-# This script assumes it is located at $REPO_HOME/tools_shared/bespoke and works
-# backwards to recover $REPO_HOME, etc.
+# assume this script is located $REPO_HOME/tools_shared/bespoke and work backwards
+# to get $REPO_HOME, etc.
REPO_HOME=$(dirname "$(dirname "$(script_adp)")")
echo REPO_HOME "$REPO_HOME"
PROJECT=$(basename "$REPO_HOME")
echo PROJECT "$PROJECT"
+
+ # set the prompt decoration to the name of the project
PROMPT_DECOR=$PROJECT
+# --------------------------------------------------------------------------------
+# The project administrator sets up the following tools for all roles to use:
+#
+ export JAVA_HOME="$REPO_HOME/tool_shared/third_party/jdk-11"
-# These functions are offered as a convenience to be run inside other scripts.
-# These produce $REPO_HOME relative results, and thus preferred over script_adp.
+# --------------------------------------------------------------------------------
+# the following functions are provided for other scripts to use.
+# at the top of files that make use of these functions put the following line:
+# script_afp=$(realpath "${BASH_SOURCE[0]}")
+#
## script's filename
script_fn(){
dirname "$(script_fp)"
}
-# Exports, and give the exported environment a name
+# --------------------------------------------------------------------------------
+# Exports
# Bash has no 'closure' hence when exporting a function, one must also export all the pieces.
+# do not export script_afp
export REPO_HOME PROJECT PROMPT_DECOR
-# export script_afp_string
-# export -f script_afp script_adp script_fn script_dp script_fp
export -f script_adp script_fn script_dp script_fp
export ENV=$(script_fp)
+++ /dev/null
-#!/usr/bin/env bash
-script_afp=$(realpath "${BASH_SOURCE[0]}")
-
-# This is the base environment shared by all roles in the project.
-
-# The project administrator sets up the following tools for all roles to use:
-#
- export JAVA_HOME="$REPO_HOME/tool_shared/third_party/jdk-11"
-
-# Absolute path to script file. The use of eval makes it suitable for exporting
-# and use with other scripts
-#
-# IMHO it is not possible write a function in bash that reliably returns the
-# script's path in all execution scenarios of direct execute, sourcing, and
-# usage in other functions. So instead, define a variable script_afp at the top
-# of each script:
-#
-# script_afp=realpath "${BASH_SOURCE[0]}"
-#
-# read -r -d '' script_afp_string <<'EOF'
-# realpath "${BASH_SOURCE[0]}" 2>/dev/null
-# EOF
-# script_afp(){
-# eval "$script_afp_string"
-# }
-
- script_adp(){
- dirname "$script_afp"
- }
-
-
-# This script assumes it is located at $REPO_HOME/tools_shared/bespoke and works
-# backwards to recover $REPO_HOME, etc.
-
- REPO_HOME=$(dirname "$(dirname "$(script_adp)")")
- echo REPO_HOME "$REPO_HOME"
-
- PROJECT=$(basename "$REPO_HOME")
- echo PROJECT "$PROJECT"
- PROMPT_DECOR=$PROJECT
-
-
-# These functions are offered as a convenience to be run inside other scripts.
-# These produce $REPO_HOME relative results, and thus preferred over script_adp.
-
- ## script's filename
- script_fn(){
- basename "$script_afp"
- }
-
- ## script's dirpath relative to $REPO_HOME
- script_fp(){
- realpath --relative-to="${REPO_HOME}" "$script_afp"
- }
-
- ## script's dirpath relative to $REPO_HOME
- script_dp(){
- dirname "$(script_fp)"
- }
-
-# Exports, and give the exported environment a name
-# Bash has no 'closure' hence when exporting a function, one must also export all the pieces.
-
- export REPO_HOME PROJECT PROMPT_DECOR
-# export script_afp_string
-# export -f script_afp script_adp script_fn script_dp script_fp
- export -f script_adp script_fn script_dp script_fp
-
- export ENV=$(script_fp)
- echo ENV "$ENV"
-
-echo
-echo "--------------------------------------------------------------------------------"
-echo "from within, at the end, of test_shared/bespoke/env the script functions return the following."
-echo
-echo "REPO_HOME:" "$REPO_HOME"
-echo "PROJECT:" "$PROJECT"
-echo "script_afp:" "$script_afp"
-echo "script_adp:" "$(script_adp)"
-echo "script_fn:" "$(script_fn)"
-echo "script_fp:" "$(script_fp)"
-echo "script_dp:" "$(script_dp)"
-echo "ENV:" "$ENV"
-echo "---------"
-echo "the stack"
- top_index=$(( ${#BASH_SOURCE[@]} - 1 ))
- for (( i=0; i<=top_index; i++ )); do
- echo "$i: ${BASH_SOURCE[$i]}"
- done
-
#!/bin/env bash
+script_afp=$(realpath "${BASH_SOURCE[0]}")
# 2024-10-24T14:56:09Z project skeleton and test bench files extracted from Ariadne
echo v0.1
#!/usr/bin/env bash
+script_afp=$(realpath "${BASH_SOURCE[0]}")
# vl 'vertical list'
# Check if the command is provided
#!/usr/bin/env bash
+script_afp=$(realpath "${BASH_SOURCE[0]}")
# remove all files in the release directory
set -e