Compare commits
2 commits
f9eaf1a657
...
760ae5ffc1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
760ae5ffc1 | ||
|
|
d0716a1f0b |
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
prompt.sh
|
||||||
|
prompt.txt
|
||||||
|
|
@ -1,46 +0,0 @@
|
||||||
<expression> ::= <my_identifier>
|
|
||||||
| <literal>
|
|
||||||
| <object_method_call>
|
|
||||||
| "(" <expression> ")"
|
|
||||||
| <lambda_expression>
|
|
||||||
|
|
||||||
<boolean_expression> ::= <boolean_literal>
|
|
||||||
| "(" <boolean_expression> ")"
|
|
||||||
| <my_identifier>.eq(<expression>)
|
|
||||||
| <my_identifier>.is(<expression>)
|
|
||||||
| <my_identifier>.not(<expression>)
|
|
||||||
| <my_identifier>.gt(<expression>)
|
|
||||||
| <my_identifier>.lt(<expression>)
|
|
||||||
| <my_identifier>.gte(<expression>)
|
|
||||||
| <my_identifier>.lte(<expression>)
|
|
||||||
| Boolean.or(<boolean_expression>, <boolean_expression>)
|
|
||||||
| Boolean.and(<boolean_expression>, <boolean_expression>)
|
|
||||||
|
|
||||||
|
|
||||||
<object_method_call> ::= <my_identifier> "." <method_name> "(" <argument_list>? ")"
|
|
||||||
| <my_identifier> ".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
|
|
||||||
<method_name> ::= "set"
|
|
||||||
| "length" | "reverse" | "split" | "format" | "search" | "concat" | "replace"
|
|
||||||
| "add" | "subtract" | "multiply" | "divide" | "mod" | "round"
|
|
||||||
| "remove" | "first" | "last" | "find" | "glue" | "contains" | "add" | "each"
|
|
||||||
| "sum"
|
|
||||||
| <identifier>
|
|
||||||
|
|
||||||
<lambda_expression> ::= "fn" "(" <parameter_list>? ")" "->" "[" <type> "]" "{" <statement>* "}"
|
|
||||||
|
|
||||||
<literal> ::= <number_literal> | <string_literal> | <boolean_literal>
|
|
||||||
|
|
||||||
<number_literal> ::= <digit>+
|
|
||||||
|
|
||||||
<string_literal> ::= '"' [^"]* '"'
|
|
||||||
|
|
||||||
<boolean_literal> ::= "True" | "False"
|
|
||||||
|
|
||||||
<my_identifier> ::= "my." <identifier>
|
|
||||||
|
|
@ -1,23 +0,0 @@
|
||||||
<constructor_declaration> ::= <accessibility_modifier>"fn" "on_create" "(" <parameter_list>? ")" "->" "[Null]" "{" <statement>* "}"
|
|
||||||
|
|
||||||
<destructor_declaration> ::= <accessibility_modifier>"fn" "on_destroy" "(" <parameter_list>? ")" "->" "[Null]" "{" <statement>* "}"
|
|
||||||
|
|
||||||
<interface_declaration> ::= "@"<interface_identifier> "{" <interface_body> "}"
|
|
||||||
|
|
||||||
<interface_body> ::= <interface_method_declaration>*
|
|
||||||
|
|
||||||
<interface_method_declaration> ::= <accessibility_modifier>"fn" <identifier> <function_signature> ";"
|
|
||||||
|
|
||||||
<function_declaration> ::= <accessibility_modifier>"fn" <identifier> <function_signature> "{" <statement>* "}"
|
|
||||||
|
|
||||||
<function_signature> ::= "(" <parameter_list>? ")" "->" <return_type_list>
|
|
||||||
|
|
||||||
<accessibility_modifier> ::= "-" | "" | "+"
|
|
||||||
|
|
||||||
<return_type_list> ::= "[" <type> ("," <type>)* "]" | "Runnable"
|
|
||||||
|
|
||||||
<parameter_list> ::= <required_parameter> ("," <required_parameter>)* [("," <default_parameter>)*]
|
|
||||||
|
|
||||||
<required_parameter> ::= <identifier> ":" <parameter_type>
|
|
||||||
|
|
||||||
<default_parameter> ::= <identifier> ":" <parameter_type> "=" <expression>
|
|
||||||
|
|
@ -1,11 +0,0 @@
|
||||||
<program> ::= <use_statement>* <declaration>*
|
|
||||||
|
|
||||||
<use_statement> ::= "use" <identifier> ("." <identifier>)* ";"
|
|
||||||
|
|
||||||
<declaration> ::= <type_declaration> | <interface_declaration>
|
|
||||||
|
|
||||||
import "types.bnf"
|
|
||||||
import "statements.bnf"
|
|
||||||
import "functions.bnf"
|
|
||||||
import "expressions.bnf"
|
|
||||||
import "identifiers.bnf"
|
|
||||||
|
|
@ -1,29 +0,0 @@
|
||||||
<type_declaration> ::= <identifier> ["/" <identifier>] ["->" <interface_identifier_list>] "{" <class_body> "}"
|
|
||||||
|
|
||||||
<class_body> ::= (<variable_declaration> | <function_declaration> | <constructor_declaration> | <destructor_declaration>)*
|
|
||||||
|
|
||||||
<type> ::= "String" | "Integer" | "Decimal" | "Boolean" | <identifier> | <array_type>
|
|
||||||
|
|
||||||
<parameter_type> ::= <type> | "Runnable"
|
|
||||||
|
|
||||||
<variable_declaration> ::= <type> <identifier> [".set(" <expression> ")"] ";"
|
|
||||||
|
|
||||||
<function_declaration> ::= <accessibility_modifier> "fn" <identifier> <function_signature> "{" <statement>* "}"
|
|
||||||
|
|
||||||
<function_signature> ::= "(" <parameter_list>? ")" "->" <return_type_list>
|
|
||||||
|
|
||||||
<accessibility_modifier> ::= "-" | "" | "+"
|
|
||||||
|
|
||||||
<return_type_list> ::= "[" <type> ("," <type>)*] | "Runnable"
|
|
||||||
|
|
||||||
<parameter_list> ::= <required_parameter> ("," <required_parameter>)* [("," <default_parameter>)*]
|
|
||||||
|
|
||||||
<required_parameter> ::= <identifier> ":" <parameter_type>
|
|
||||||
|
|
||||||
<default_parameter> ::= <identifier> ":" <parameter_type> "=" <expression>
|
|
||||||
|
|
||||||
<array_type> ::= <type> "<>"
|
|
||||||
|
|
||||||
<constructor_declaration> ::= "fn" "on_create" "(" <parameter_list>? ")" "->" "[Null]" "{" <statement>* "}"
|
|
||||||
|
|
||||||
<destructor_declaration> ::= "fn" "on_destroy" "(" <parameter_list>? ")" "->" "[Null]" "{" <statement>* "}"
|
|
||||||
11
grammar/core/base_types.bnf
Normal file
11
grammar/core/base_types.bnf
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
<type> ::= <primitive_type> | <complex_type> | <array_type>
|
||||||
|
|
||||||
|
<primitive_type> ::= "String" | "Integer" | "Decimal" | "Boolean"
|
||||||
|
|
||||||
|
<complex_type> ::= <identifier> ["/" <identifier>]
|
||||||
|
|
||||||
|
<array_type> ::= <type> "<>"
|
||||||
|
|
||||||
|
<parameter_type> ::= <type> | "Runnable"
|
||||||
|
|
||||||
|
<return_type_list> ::= "[" <type> ("," <type>)* "]" | "Runnable"
|
||||||
|
|
@ -4,6 +4,8 @@
|
||||||
|
|
||||||
<interface_identifier> ::= <identifier>
|
<interface_identifier> ::= <identifier>
|
||||||
|
|
||||||
|
<my_identifier> ::= "my." <identifier>
|
||||||
|
|
||||||
<letter> ::= <upper_letter> | <lower_letter>
|
<letter> ::= <upper_letter> | <lower_letter>
|
||||||
|
|
||||||
<upper_letter> ::= "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"
|
<upper_letter> ::= "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"
|
||||||
24
grammar/core/literals.bnf
Normal file
24
grammar/core/literals.bnf
Normal file
|
|
@ -0,0 +1,24 @@
|
||||||
|
<literal> ::= <number_literal>
|
||||||
|
| <string_literal>
|
||||||
|
| <boolean_literal>
|
||||||
|
| <null_literal>
|
||||||
|
| <array_literal>
|
||||||
|
|
||||||
|
<number_literal> ::= <integer_literal> | <decimal_literal>
|
||||||
|
|
||||||
|
<integer_literal> ::= <digit>+
|
||||||
|
| "-" <digit>+
|
||||||
|
|
||||||
|
<decimal_literal> ::= <digit>+ "." <digit>+
|
||||||
|
| "-" <digit>+ "." <digit>+
|
||||||
|
|
||||||
|
<string_literal> ::= '"' [^"]* '"'
|
||||||
|
| "'" [^']* "'"
|
||||||
|
|
||||||
|
<boolean_literal> ::= "True" | "False"
|
||||||
|
|
||||||
|
<null_literal> ::= "Null"
|
||||||
|
|
||||||
|
<array_literal> ::= "<" <literal_list>? ">"
|
||||||
|
|
||||||
|
<literal_list> ::= <literal> ("," <literal>)*
|
||||||
16
grammar/core/modules.bnf
Normal file
16
grammar/core/modules.bnf
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
<module_declaration> ::= "module" <identifier> "{"
|
||||||
|
(<export_declaration>
|
||||||
|
| <constant_declaration>
|
||||||
|
| <declaration>)*
|
||||||
|
"}"
|
||||||
|
|
||||||
|
<export_declaration> ::=
|
||||||
|
<accessibility_modifier>"export"
|
||||||
|
(<constant_declaration>
|
||||||
|
| <type_declaration>
|
||||||
|
| <function_declaration>)
|
||||||
|
|
||||||
|
<visibility_rule> ::=
|
||||||
|
<accessibility_modifier>
|
||||||
|
(<type_declaration>
|
||||||
|
| <function_declaration>)
|
||||||
5
grammar/core/visibility.bnf
Normal file
5
grammar/core/visibility.bnf
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
<accessibility_modifier> ::=
|
||||||
|
"-"
|
||||||
|
| ""
|
||||||
|
| "+"
|
||||||
|
| "export"
|
||||||
19
grammar/declarations/function_declarations.bnf
Normal file
19
grammar/declarations/function_declarations.bnf
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
<function_declaration> ::= <accessibility_modifier>"fn" <identifier>
|
||||||
|
<function_signature>
|
||||||
|
"{" <statement>* "}"
|
||||||
|
|
||||||
|
<function_signature> ::= "(" <parameter_list>? ")"
|
||||||
|
"->" <return_type_list>
|
||||||
|
|
||||||
|
<parameter_list> ::= <required_parameter>
|
||||||
|
("," <required_parameter>)*
|
||||||
|
[("," <default_parameter>)*]
|
||||||
|
|
||||||
|
<required_parameter> ::= <identifier> ":" <parameter_type>
|
||||||
|
|
||||||
|
<default_parameter> ::= <identifier> ":" <parameter_type>
|
||||||
|
"=" <expression>
|
||||||
|
|
||||||
|
<lambda_declaration> ::= "fn" "(" <parameter_list>? ")"
|
||||||
|
"->" "[" <type> "]"
|
||||||
|
"{" <statement>* "}"
|
||||||
21
grammar/declarations/type_declarations.bnf
Normal file
21
grammar/declarations/type_declarations.bnf
Normal file
|
|
@ -0,0 +1,21 @@
|
||||||
|
<type_declaration> ::= <identifier>
|
||||||
|
["/" <identifier>]?
|
||||||
|
["->" <interface_identifier_list>]?
|
||||||
|
"{" <class_body> "}"
|
||||||
|
|
||||||
|
<class_body> ::= (<variable_declaration>
|
||||||
|
| <constant_declaration>
|
||||||
|
| <function_declaration>
|
||||||
|
| <constructor_declaration>
|
||||||
|
| <destructor_declaration>)*
|
||||||
|
|
||||||
|
<type_inheritance> ::= "extends" <identifier>
|
||||||
|
|
||||||
|
<generic_type_declaration> ::= <identifier> "<" <type_parameter_list> ">"
|
||||||
|
|
||||||
|
<type_parameter_list> ::= <identifier> ("," <identifier>)*
|
||||||
|
|
||||||
|
<variable_declaration> ::= <type> <identifier>
|
||||||
|
[".set(" <expression> ")"]? ";"
|
||||||
|
|
||||||
|
<constant_declaration> ::= <type> <identifier> ".define(" <literal> ");"
|
||||||
21
grammar/interfaces/interface_definitions.bnf
Normal file
21
grammar/interfaces/interface_definitions.bnf
Normal file
|
|
@ -0,0 +1,21 @@
|
||||||
|
<interface_declaration> ::= "@" <interface_identifier> "{" <interface_body> "}"
|
||||||
|
|
||||||
|
<interface_identifier> ::= <identifier>
|
||||||
|
|
||||||
|
<interface_body> ::= <interface_method_declaration>*
|
||||||
|
|
||||||
|
<interface_method_declaration> ::=
|
||||||
|
<accessibility_modifier> "fn" <identifier> <function_signature> ";"
|
||||||
|
|
||||||
|
<interface_implementation> ::= <type_declaration> "->" <interface_identifier_list>
|
||||||
|
|
||||||
|
<interface_method_signature> ::=
|
||||||
|
<accessibility_modifier>"fn" <identifier> <function_signature>
|
||||||
|
|
||||||
|
<generic_interface_declaration> ::=
|
||||||
|
"@" <interface_identifier> "<" <type_parameter_list> ">"
|
||||||
|
"{" <interface_body> "}"
|
||||||
|
|
||||||
|
<interface_inheritance> ::=
|
||||||
|
"@" <interface_identifier> "extends" <interface_identifier_list>
|
||||||
|
"{" <interface_body> "}"
|
||||||
23
grammar/main.bnf
Normal file
23
grammar/main.bnf
Normal file
|
|
@ -0,0 +1,23 @@
|
||||||
|
<program> ::= <module_declaration>* <use_statement>* <declaration>*
|
||||||
|
|
||||||
|
<module_declaration> ::= "module" <identifier> "{"
|
||||||
|
(<export_declaration> | <declaration>)*
|
||||||
|
"}"
|
||||||
|
|
||||||
|
<export_declaration> ::= <accessibility_modifier>"export"
|
||||||
|
(<type_declaration> | <function_declaration>)
|
||||||
|
|
||||||
|
<use_statement> ::= "use" <identifier> ("." <identifier>)* ";"
|
||||||
|
|
||||||
|
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"
|
||||||
176
grammar/modules/core/directory.wdl
Normal file
176
grammar/modules/core/directory.wdl
Normal file
|
|
@ -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];
|
||||||
|
}
|
||||||
|
}
|
||||||
48
grammar/modules/core/file.wdl
Normal file
48
grammar/modules/core/file.wdl
Normal file
|
|
@ -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];
|
||||||
|
}
|
||||||
94
grammar/modules/core/proc.wdl
Normal file
94
grammar/modules/core/proc.wdl
Normal file
|
|
@ -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];
|
||||||
|
}
|
||||||
|
|
@ -10,21 +10,27 @@
|
||||||
|
|
||||||
<assignment_statement> ::= <my_identifier> ".set(" <expression> ")" ";"
|
<assignment_statement> ::= <my_identifier> ".set(" <expression> ")" ";"
|
||||||
|
|
||||||
<if_statement> ::= "if" "(" <boolean_expression> ")" "{" <statement>* "}" ["else" "{" <statement>* "}"]?
|
<if_statement> ::= "if" "(" <boolean_expression> ")"
|
||||||
|
"{" <statement>* "}"
|
||||||
|
["else" "{" <statement>* "}"]?
|
||||||
|
|
||||||
<while_statement> ::= "while" "(" <expression> ")" "{" <statement>* "}"
|
<while_statement> ::= "while" "(" <expression> ")"
|
||||||
|
"{" <statement>* "}"
|
||||||
|
|
||||||
<loop_statement> ::= "loop" "(" <identifier> "," <expression> "->" <expression> ["," <expression>]? ")" "{" <statement>* "}"
|
<loop_statement> ::= "loop" "(" <identifier> "," <expression> "->" <expression>
|
||||||
|
["," <expression>]? ")"
|
||||||
|
"{" <statement>* "}"
|
||||||
|
|
||||||
<reverse_loop_statement> ::= "rloop" "(" <identifier> "," <expression> "->" <expression> ["," <expression>]? ")" "{" <statement>* "}"
|
<reverse_loop_statement> ::= "rloop" "(" <identifier> "," <expression> "->" <expression>
|
||||||
|
["," <expression>]? ")"
|
||||||
|
"{" <statement>* "}"
|
||||||
|
|
||||||
<function_call_statement> ::= <my_identifier> "(" <argument_list>? ")" ";"
|
<function_call_statement> ::= <my_identifier> "(" <argument_list>? ")" ";"
|
||||||
|
|
||||||
<argument_list> ::= <expression> ("," <expression>)*
|
|
||||||
|
|
||||||
<return_statement> ::= "rtn" <expression> ";"
|
<return_statement> ::= "rtn" <expression> ";"
|
||||||
|
|
||||||
<using_statement> ::= "using" <type> <identifier> ".set(" <expression> ")" "{" <statement>* "}"
|
<using_statement> ::= "using" <type> <identifier> ".set(" <expression> ")"
|
||||||
|
"{" <statement>* "}"
|
||||||
|
|
||||||
<attempt_statement> ::= <expression> ".attempt" "{" <attempt_handler>* "}"
|
<attempt_statement> ::= <expression> ".attempt" "{" <attempt_handler>* "}"
|
||||||
|
|
||||||
20
grammar/operations/expressions.bnf
Normal file
20
grammar/operations/expressions.bnf
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
<expression> ::= <my_identifier>
|
||||||
|
| <literal>
|
||||||
|
| <object_method_call>
|
||||||
|
| <constant_expression>
|
||||||
|
| "(" <expression> ")"
|
||||||
|
| <lambda_expression>
|
||||||
|
|
||||||
|
<boolean_expression> ::= <boolean_literal>
|
||||||
|
| "(" <boolean_expression> ")"
|
||||||
|
| <my_identifier>.eq(<expression>)
|
||||||
|
| <my_identifier>.is(<expression>)
|
||||||
|
| <my_identifier>.not(<expression>)
|
||||||
|
| <my_identifier>.gt(<expression>)
|
||||||
|
| <my_identifier>.lt(<expression>)
|
||||||
|
| <my_identifier>.gte(<expression>)
|
||||||
|
| <my_identifier>.lte(<expression>)
|
||||||
|
| Boolean.or(<boolean_expression>, <boolean_expression>)
|
||||||
|
| Boolean.and(<boolean_expression>, <boolean_expression>)
|
||||||
|
|
||||||
|
<constant_expression> ::= <my_identifier> ".define(" <literal> ")"
|
||||||
17
grammar/operations/method_calls.bnf
Normal file
17
grammar/operations/method_calls.bnf
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
<object_method_call> ::= <my_identifier> "." <method_name> "(" <argument_list>? ")"
|
||||||
|
| <my_identifier> ".sum()"
|
||||||
|
|
||||||
|
<method_name> ::= "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"
|
||||||
|
| <identifier>
|
||||||
|
|
||||||
|
<argument_list> ::= <expression> ("," <expression>)*
|
||||||
Loading…
Reference in a new issue