From d0716a1f0b1247ec9717a5b74adbf27dbd9cf2ac Mon Sep 17 00:00:00 2001 From: Funky Waddle Date: Mon, 24 Nov 2025 17:17:20 -0600 Subject: [PATCH] Redo the directory structure. Add a couple not-finished core modules. Add .gitignore --- .gitignore | 2 + {core/bnf => compiler}/.gitkeep | 0 core/bnf/expressions.bnf | 46 ----- core/bnf/functions.bnf | 23 --- core/bnf/main.bnf | 11 -- core/bnf/types.bnf | 29 --- grammar/core/base_types.bnf | 11 ++ {core/bnf => grammar/core}/identifiers.bnf | 2 + grammar/core/literals.bnf | 24 +++ grammar/core/modules.bnf | 16 ++ grammar/core/visibility.bnf | 5 + .../declarations/function_declarations.bnf | 19 ++ grammar/declarations/type_declarations.bnf | 21 +++ grammar/interfaces/interface_definitions.bnf | 21 +++ grammar/main.bnf | 23 +++ {core/compiler => grammar/modules}/.gitkeep | 0 grammar/modules/core/directory.wdl | 176 ++++++++++++++++++ grammar/modules/core/file.wdl | 48 +++++ grammar/modules/core/proc.wdl | 94 ++++++++++ .../operations/control_flow.bnf | 20 +- grammar/operations/expressions.bnf | 20 ++ grammar/operations/method_calls.bnf | 17 ++ {core/lexicon => lexicon}/.gitkeep | 0 {core/runtime => runtime}/.gitkeep | 0 24 files changed, 512 insertions(+), 116 deletions(-) create mode 100644 .gitignore rename {core/bnf => compiler}/.gitkeep (100%) delete mode 100644 core/bnf/expressions.bnf delete mode 100644 core/bnf/functions.bnf delete mode 100644 core/bnf/main.bnf delete mode 100644 core/bnf/types.bnf create mode 100644 grammar/core/base_types.bnf rename {core/bnf => grammar/core}/identifiers.bnf (94%) create mode 100644 grammar/core/literals.bnf create mode 100644 grammar/core/modules.bnf create mode 100644 grammar/core/visibility.bnf create mode 100644 grammar/declarations/function_declarations.bnf create mode 100644 grammar/declarations/type_declarations.bnf create mode 100644 grammar/interfaces/interface_definitions.bnf create mode 100644 grammar/main.bnf rename {core/compiler => grammar/modules}/.gitkeep (100%) create mode 100644 grammar/modules/core/directory.wdl create mode 100644 grammar/modules/core/file.wdl create mode 100644 grammar/modules/core/proc.wdl rename core/bnf/statements.bnf => grammar/operations/control_flow.bnf (68%) create mode 100644 grammar/operations/expressions.bnf create mode 100644 grammar/operations/method_calls.bnf rename {core/lexicon => lexicon}/.gitkeep (100%) rename {core/runtime => runtime}/.gitkeep (100%) diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..56bcbd6 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +prompt.sh +prompt.txt \ No newline at end of file diff --git a/core/bnf/.gitkeep b/compiler/.gitkeep similarity index 100% rename from core/bnf/.gitkeep rename to compiler/.gitkeep diff --git a/core/bnf/expressions.bnf b/core/bnf/expressions.bnf deleted file mode 100644 index a59ce74..0000000 --- a/core/bnf/expressions.bnf +++ /dev/null @@ -1,46 +0,0 @@ - ::= - | - | - | "(" ")" - | - - ::= - | "(" ")" - | .eq() - | .is() - | .not() - | .gt() - | .lt() - | .gte() - | .lte() - | Boolean.or(, ) - | Boolean.and(, ) - - - ::= "." "(" ? ")" - | ".sum()" - -Note: "set" is available on all base objects. -Methods listed after it are grouped by type: -group 1 are String methods, -group 2 are Integer/Decimal methods, -group 3 are Array methods, -group 4 are Integer Array methods - ::= "set" - | "length" | "reverse" | "split" | "format" | "search" | "concat" | "replace" - | "add" | "subtract" | "multiply" | "divide" | "mod" | "round" - | "remove" | "first" | "last" | "find" | "glue" | "contains" | "add" | "each" - | "sum" - | - - ::= "fn" "(" ? ")" "->" "[" "]" "{" * "}" - - ::= | | - - ::= + - - ::= '"' [^"]* '"' - - ::= "True" | "False" - - ::= "my." diff --git a/core/bnf/functions.bnf b/core/bnf/functions.bnf deleted file mode 100644 index 5a2d910..0000000 --- a/core/bnf/functions.bnf +++ /dev/null @@ -1,23 +0,0 @@ - ::= "fn" "on_create" "(" ? ")" "->" "[Null]" "{" * "}" - - ::= "fn" "on_destroy" "(" ? ")" "->" "[Null]" "{" * "}" - - ::= "@" "{" "}" - - ::= * - - ::= "fn" ";" - - ::= "fn" "{" * "}" - - ::= "(" ? ")" "->" - - ::= "-" | "" | "+" - - ::= "[" ("," )* "]" | "Runnable" - - ::= ("," )* [("," )*] - - ::= ":" - - ::= ":" "=" diff --git a/core/bnf/main.bnf b/core/bnf/main.bnf deleted file mode 100644 index 9831201..0000000 --- a/core/bnf/main.bnf +++ /dev/null @@ -1,11 +0,0 @@ - ::= * * - - ::= "use" ("." )* ";" - - ::= | - -import "types.bnf" -import "statements.bnf" -import "functions.bnf" -import "expressions.bnf" -import "identifiers.bnf" diff --git a/core/bnf/types.bnf b/core/bnf/types.bnf deleted file mode 100644 index 272dedd..0000000 --- a/core/bnf/types.bnf +++ /dev/null @@ -1,29 +0,0 @@ - ::= ["/" ] ["->" ] "{" "}" - - ::= ( | | | )* - - ::= "String" | "Integer" | "Decimal" | "Boolean" | | - - ::= | "Runnable" - - ::= [".set(" ")"] ";" - - ::= "fn" "{" * "}" - - ::= "(" ? ")" "->" - - ::= "-" | "" | "+" - - ::= "[" ("," )*] | "Runnable" - - ::= ("," )* [("," )*] - - ::= ":" - - ::= ":" "=" - - ::= "<>" - - ::= "fn" "on_create" "(" ? ")" "->" "[Null]" "{" * "}" - - ::= "fn" "on_destroy" "(" ? ")" "->" "[Null]" "{" * "}" diff --git a/grammar/core/base_types.bnf b/grammar/core/base_types.bnf new file mode 100644 index 0000000..382008a --- /dev/null +++ b/grammar/core/base_types.bnf @@ -0,0 +1,11 @@ + ::= | | + + ::= "String" | "Integer" | "Decimal" | "Boolean" + + ::= ["/" ] + + ::= "<>" + + ::= | "Runnable" + + ::= "[" ("," )* "]" | "Runnable" diff --git a/core/bnf/identifiers.bnf b/grammar/core/identifiers.bnf similarity index 94% rename from core/bnf/identifiers.bnf rename to grammar/core/identifiers.bnf index 11c8ccf..d7b0ca8 100644 --- a/core/bnf/identifiers.bnf +++ b/grammar/core/identifiers.bnf @@ -4,6 +4,8 @@ ::= + ::= "my." + ::= | ::= "A" | "B" | "C" | "D" | "E" | "F" | "G" | "H" | "I" | "J" | "K" | "L" | "M" | "N" | "O" | "P" | "Q" | "R" | "S" | "T" | "U" | "V" | "W" | "X" | "Y" | "Z" diff --git a/grammar/core/literals.bnf b/grammar/core/literals.bnf new file mode 100644 index 0000000..2e4bec1 --- /dev/null +++ b/grammar/core/literals.bnf @@ -0,0 +1,24 @@ + ::= + | + | + | + | + + ::= | + + ::= + + | "-" + + + ::= + "." + + | "-" + "." + + + ::= '"' [^"]* '"' + | "'" [^']* "'" + + ::= "True" | "False" + + ::= "Null" + + ::= "<" ? ">" + + ::= ("," )* diff --git a/grammar/core/modules.bnf b/grammar/core/modules.bnf new file mode 100644 index 0000000..3bf83cf --- /dev/null +++ b/grammar/core/modules.bnf @@ -0,0 +1,16 @@ + ::= "module" "{" + ( + | + | )* +"}" + + ::= + "export" + ( + | + | ) + + ::= + + ( + | ) \ No newline at end of file diff --git a/grammar/core/visibility.bnf b/grammar/core/visibility.bnf new file mode 100644 index 0000000..a089d7d --- /dev/null +++ b/grammar/core/visibility.bnf @@ -0,0 +1,5 @@ + ::= + "-" + | "" + | "+" + | "export" diff --git a/grammar/declarations/function_declarations.bnf b/grammar/declarations/function_declarations.bnf new file mode 100644 index 0000000..a6ac2a7 --- /dev/null +++ b/grammar/declarations/function_declarations.bnf @@ -0,0 +1,19 @@ + ::= "fn" + + "{" * "}" + + ::= "(" ? ")" + "->" + + ::= + ("," )* + [("," )*] + + ::= ":" + + ::= ":" + "=" + + ::= "fn" "(" ? ")" + "->" "[" "]" + "{" * "}" diff --git a/grammar/declarations/type_declarations.bnf b/grammar/declarations/type_declarations.bnf new file mode 100644 index 0000000..8b8a855 --- /dev/null +++ b/grammar/declarations/type_declarations.bnf @@ -0,0 +1,21 @@ + ::= + ["/" ]? + ["->" ]? + "{" "}" + + ::= ( + | + | + | + | )* + + ::= "extends" + + ::= "<" ">" + + ::= ("," )* + + ::= + [".set(" ")"]? ";" + + ::= ".define(" ");" diff --git a/grammar/interfaces/interface_definitions.bnf b/grammar/interfaces/interface_definitions.bnf new file mode 100644 index 0000000..6e42c06 --- /dev/null +++ b/grammar/interfaces/interface_definitions.bnf @@ -0,0 +1,21 @@ + ::= "@" "{" "}" + + ::= + + ::= * + + ::= + "fn" ";" + + ::= "->" + + ::= + "fn" + + ::= + "@" "<" ">" + "{" "}" + + ::= + "@" "extends" + "{" "}" diff --git a/grammar/main.bnf b/grammar/main.bnf new file mode 100644 index 0000000..3f792f9 --- /dev/null +++ b/grammar/main.bnf @@ -0,0 +1,23 @@ + ::= * * * + + ::= "module" "{" + ( | )* +"}" + + ::= "export" + ( | ) + + ::= "use" ("." )* ";" + +import "core/base_types.bnf" +import "core/identifiers.bnf" +import "core/literals.bnf" +import "core/visibility.bnf" +import "core/modules.bnf" +import "declarations/type_declarations.bnf" +import "declarations/function_declarations.bnf" +import "operations/expressions.bnf" +import "operations/method_calls.bnf" +import "operations/control_flow.bnf" +import "interfaces/interface_definitions.bnf" +import "modules/**/*.bnf" diff --git a/core/compiler/.gitkeep b/grammar/modules/.gitkeep similarity index 100% rename from core/compiler/.gitkeep rename to grammar/modules/.gitkeep diff --git a/grammar/modules/core/directory.wdl b/grammar/modules/core/directory.wdl new file mode 100644 index 0000000..6f1a38f --- /dev/null +++ b/grammar/modules/core/directory.wdl @@ -0,0 +1,176 @@ +use core.accessibility_modifier; +use core.identifier; +use core.type_system; + +module Directory { + syntax { + type_system.extend({ + name: "Directory", + category: "system_resource", + immutable_operations: true + }); + } + + // Directory permissions enum + type DirectoryPermission { + String read = "r"; + String write = "w"; + String execute = "x"; + } + + // Core Directory type + type Directory { + String path; + Integer item_count; + + +fn on_create(String dirpath) -> [Directory]; + + +fn list_contents() -> [String<>]; + +fn create() -> [Boolean]; + + +fn exists() -> [Boolean]; + +fn delete() -> [Boolean]; + +fn move(String destination) -> [Boolean]; + +fn copy(String destination) -> [Boolean]; + + +fn get_permissions() -> [DirectoryPermission<>]; + +fn set_permissions(DirectoryPermission<> permissions) -> [Boolean]; + } + + // Directory operations + +fn create(String path) -> [Directory]; + +fn exists(String path) -> [Boolean]; + +fn delete(String path) -> [Boolean]; + +fn move(String source, String destination) -> [Boolean]; + +fn copy(String source, String destination) -> [Boolean]; + +fn list_contents(String path) -> [String<>]; +} + + + + + + +module Directory { + // Language extension configuration + syntax { + type_system.extend({ + name: "Directory", + category: "system_resource", + runtime_layer: "low_level", + platform_dependent: true, + safety_features: { + access_control: true, + error_handling: true, + async_support: true + } + }); + } + + // Error types specific to directory operations + type DirectoryError { + String code; + String message; + Any context; + } + + // Permissions model + type DirectoryPermission { + Boolean read = False; + Boolean write = False; + Boolean execute = False; + String owner; + String group; + } + + // Core Directory type with comprehensive system interaction + type Directory { + String absolute_path; + String name; + Integer item_count; + DirectoryPermission permissions; + + // Core operations with error handling + +proc create() -> [Boolean, DirectoryError]; + +proc exists() -> [Boolean, DirectoryError]; + +proc delete() -> [Boolean, DirectoryError]; + +proc move(String destination) -> [Boolean, DirectoryError]; + +proc copy(String destination) -> [Boolean, DirectoryError]; + + // Advanced file system interactions + +proc list_contents() -> [String<>, DirectoryError]; + +proc find(String pattern) -> [String<>, DirectoryError]; + +proc watch() -> [Runnable, DirectoryError]; // File system watcher + } + + // Platform-specific implementation configuration + implementation { + // Base implementation with platform abstraction + +proc create(String path) -> [Directory, DirectoryError] { + proc native_create() -> [Directory, DirectoryError] { + // Platform-specific directory creation + match (SystemPlatform.current()) { + Windows { rtn WindowsFS.create_directory(path); } + Posix { rtn PosixFS.create_directory(path); } + MacOS { rtn MacFS.create_directory(path); } + error { + rtn DirectoryError( + code: "PLATFORM_UNSUPPORTED", + message: "Cannot create directory on this platform" + ); + } + } + } + + rtn native_create(); + } + + // Sophisticated error handling and async support + +proc exists(String path) -> [Boolean, DirectoryError] { + proc check_directory() -> [Boolean, DirectoryError] { + try { + + } attempt { + ok { + my.result.set(SystemFS.path_exists(path)); + my.result.and(SystemFS.is_directory(path)); + rtn my.result; + } + error { + rtn DirectoryError( + code: "ACCESS_DENIED", + message: "Cannot access directory", + context: path + ); + } + } + } + + rtn check_directory(); + } + } + + // Cross-platform utility functions + +fn normalize_path(String path) -> [String]; + +fn get_current_directory() -> [Directory]; + +fn get_temp_directory() -> [Directory]; + + // Advanced system integration + platform { + windows { + // Windows-specific optimizations + +fn get_special_folder(String folder_type) -> [Directory]; + } + + posix { + // Unix/Linux specific methods + +fn get_home_directory() -> [Directory]; + } + } + + // Security and access control + security { + +fn validate_access(Directory dir, DirectoryPermission required) -> [Boolean]; + +fn set_permissions(Directory dir, DirectoryPermission new_permissions) -> [Boolean]; + } +} diff --git a/grammar/modules/core/file.wdl b/grammar/modules/core/file.wdl new file mode 100644 index 0000000..26cb774 --- /dev/null +++ b/grammar/modules/core/file.wdl @@ -0,0 +1,48 @@ +// File.wdl +use core.accessibility_modifier; +use core.identifier; +use core.type_system; + +module File { + syntax { + type_system.extend({ + name: "File", + category: "system_resource", + immutable_operations: true + }); + } + + // File permissions enum + type FilePermission { + String read = "r"; + String write = "w"; + String execute = "x"; + } + + // Core File type + type File { + String path; + Integer size; + + +fn on_create(String filepath) -> [File]; + + +fn read() -> [String]; + +fn write(String content) -> [Boolean]; + +fn append(String content) -> [Boolean]; + + +fn exists() -> [Boolean]; + +fn delete() -> [Boolean]; + +fn move(String destination) -> [Boolean]; + +fn copy(String destination) -> [Boolean]; + + +fn get_permissions() -> [FilePermission<>]; + +fn set_permissions(FilePermission<> permissions) -> [Boolean]; + } + + // File system operations + +fn create(String path) -> [File]; + +fn exists(String path) -> [Boolean]; + +fn delete(String path) -> [Boolean]; + +fn move(String source, String destination) -> [Boolean]; + +fn copy(String source, String destination) -> [Boolean]; +} diff --git a/grammar/modules/core/proc.wdl b/grammar/modules/core/proc.wdl new file mode 100644 index 0000000..b4e0387 --- /dev/null +++ b/grammar/modules/core/proc.wdl @@ -0,0 +1,94 @@ +use core.accessibility_modifier; +use core.identifier; +use core.statement; +use core.parameter_list; +use core.return_type_list; +use core.type_system; + +module Proc { + syntax { + type_system.extend({ + name: "proc", + category: "concurrency", + primary_async_type: true, + replaces: ["async", "await"] + }); + + declaration.configure({ + // Proc is the primary async function type + primary_async_keyword: "proc", + structure: { + prefix: ["accessibility_modifier"], + keyword: "proc", + name: "identifier", + signature: "required", + body: "block_required" + } + }); + + signature.configure({ + // Async-specific signature constraints + concurrency_model: "cooperative", + return_types: { + // Can return Runnable or specific async result + allowed: ["Runnable", "Any"], + default: "Runnable" + }, + features: { + cancellation: true, + timeout: true, + error_propagation: true + } + }); + + run_block.configure({ + sections: [ + { + name: "ok", + description: "Successful execution path", + required: true + }, + { + name: "error", + description: "Error handling path", + required: false + }, + { + name: "cancel", + description: "Cancellation handling", + required: false + } + ] + }); + } + + type ProcError { + String message; + Integer error_code; + Any context; + } + + type Proc { + +proc run() -> [Runnable]; + +proc cancel() -> [Boolean]; + +proc is_running() -> [Boolean]; + +proc is_completed() -> [Boolean]; + + +proc get_result() -> [Any]; + +proc get_status() -> [String]; + + +proc set_timeout(Integer milliseconds) -> [Boolean]; + +proc set_priority(Integer priority) -> [Boolean]; + + +proc on_error() -> [ProcError]; + +proc recover(fn error_handler) -> [Boolean]; + } + + +fn create() -> [Proc]; + +fn wait_all(Proc<> tasks) -> [Boolean]; + +fn wait_any(Proc<> tasks) -> [Proc]; + + +fn parallel_map(fn mapper, Any<> input) -> [Any<>]; + +fn parallel_filter(fn predicate, Any<> input) -> [Any<>]; + +fn race(Proc<> tasks) -> [Proc]; +} diff --git a/core/bnf/statements.bnf b/grammar/operations/control_flow.bnf similarity index 68% rename from core/bnf/statements.bnf rename to grammar/operations/control_flow.bnf index 8949ff7..9f77e0a 100644 --- a/core/bnf/statements.bnf +++ b/grammar/operations/control_flow.bnf @@ -10,21 +10,27 @@ ::= ".set(" ")" ";" - ::= "if" "(" ")" "{" * "}" ["else" "{" * "}"]? + ::= "if" "(" ")" + "{" * "}" + ["else" "{" * "}"]? - ::= "while" "(" ")" "{" * "}" + ::= "while" "(" ")" + "{" * "}" - ::= "loop" "(" "," "->" ["," ]? ")" "{" * "}" + ::= "loop" "(" "," "->" + ["," ]? ")" + "{" * "}" - ::= "rloop" "(" "," "->" ["," ]? ")" "{" * "}" + ::= "rloop" "(" "," "->" + ["," ]? ")" + "{" * "}" ::= "(" ? ")" ";" - ::= ("," )* - ::= "rtn" ";" - ::= "using" ".set(" ")" "{" * "}" + ::= "using" ".set(" ")" + "{" * "}" ::= ".attempt" "{" * "}" diff --git a/grammar/operations/expressions.bnf b/grammar/operations/expressions.bnf new file mode 100644 index 0000000..fc8122d --- /dev/null +++ b/grammar/operations/expressions.bnf @@ -0,0 +1,20 @@ + ::= + | + | + | + | "(" ")" + | + + ::= + | "(" ")" + | .eq() + | .is() + | .not() + | .gt() + | .lt() + | .gte() + | .lte() + | Boolean.or(, ) + | Boolean.and(, ) + + ::= ".define(" ")" diff --git a/grammar/operations/method_calls.bnf b/grammar/operations/method_calls.bnf new file mode 100644 index 0000000..ae13492 --- /dev/null +++ b/grammar/operations/method_calls.bnf @@ -0,0 +1,17 @@ + ::= "." "(" ? ")" + | ".sum()" + + ::= "set" + | "define" + | "length" | "reverse" | "split" | "format" + | "search" | "concat" | "replace" + | "add" | "subtract" | "multiply" | "divide" | "idivide" + | "mod" | "round" | "floor" | "ceiling" + | "power" | "abs" | "sqrt" + | "remove" | "first" | "last" + | "find" | "glue" | "contains" + | "each" + | "sum" + | + + ::= ("," )* diff --git a/core/lexicon/.gitkeep b/lexicon/.gitkeep similarity index 100% rename from core/lexicon/.gitkeep rename to lexicon/.gitkeep diff --git a/core/runtime/.gitkeep b/runtime/.gitkeep similarity index 100% rename from core/runtime/.gitkeep rename to runtime/.gitkeep