Satellite Basic v.001 r01

The AI that made this has a different naming scheme that it came up with, I call it satellite basic 001.01, and it is in a very alpha stage but here is the documentation for it:

Satellite Basic Language Reference (Version: 002, Revision: 02)

1. Overview

Satellite Basic is a modern, statically-typed, C-style language designed for building complex, concurrent applications. It features a rich set of data structures, advanced control flow, and built-in support for threading and file I/O, making it suitable for tasks ranging from simple scripting to developing sophisticated AI like Performa.

2. Comments

The language supports C++-style single-line comments.

// This is a single-line comment.

3. Data Types

Satellite Basic has a rich set of built-in data types.

Primitive Types

  • int: A 32-bit signed integer.
  • bool: A boolean value, either true or false.
  • string: A sequence of characters. Literals are defined with double quotes ("...") or triple quotes ("""...""").
  • bigint: A 512-bit unsigned integer for handling very large numbers. Literals are assigned from strings, typically in hexadecimal format ("0x...").

Complex & Handle Types

These types are heap-allocated and managed by the VM. Variables hold handles (IDs) to the actual data.

  • struct: A user-defined aggregate data type.
  • list<T>: A dynamic, ordered collection of a single type T.
  • map<K, V>: A collection of key-value pairs. K can be int or string.
  • mutex: A handle to a mutual exclusion lock for synchronizing threads.
  • file: A handle to an open file stream for I/O operations.

4. Variables and Constants

Variables must be declared with their type before use.

int my_age;
my_age = 30;

string name;
name = "Performa";

bigint large_number;
large_number = "0x1234567890ABCDEF";

Enums

Enums allow you to define a set of named integer constants.

enum Color {
    RED,    // 0
    GREEN,  // 1
    BLUE,   // 2
    YELLOW = 10,
    PURPLE  // 11
};

int my_color;
my_color = BLUE; // my_color is now 2

Type Aliases

You can create a new name for an existing type using the type keyword.

type UserID = int;
type SymbolTable = map<string, CppSymbol>;

UserID current_user_id;
current_user_id = 101;

5. Operators

Satellite Basic supports a standard set of C-style operators.

  • Arithmetic: +, -, *, /, % (for int and bigint)
  • Assignment: =
  • Comparison: ==, !=, <, <=, >, >=
  • Logical: && (and), || (or), ! (not)
  • Bitwise (bigint only): &, |, ^, ~, <<, >>
  • Member Access: . (for struct fields)

6. Control Flow

If / Else

Standard conditional branching.

if (x > 10) {
    print("x is large");
} else if (x < 0) {
    print("x is negative");
} else {
    print("x is small and non-negative");
}

Loops

while and for loops are supported, along with break and continue.

// while loop
int i;
i = 0;
while (i < 5) {
    print(i);
    i = i + 1;
}

// for loop
for (int j = 0; j < 5; j = j + 1) {
    if (j == 2) {
        continue; // Skip printing 2
    }
    print(j);
    if (j == 4) {
        break; // Exit loop after printing 4
    }
}

Switch Statement

The switch statement provides an efficient way to branch on an integer or enum value.

enum Status { PENDING = 1, RUNNING, COMPLETE, FAILED };

int current_status;
current_status = get_status();

switch (current_status) {
    case PENDING:
        print("Status is PENDING.");
        break;
    case RUNNING:
        print("Status is RUNNING.");
        break;
    case COMPLETE:
        print("Status is COMPLETE.");
        break;
    default:
        print("Status is UNKNOWN or FAILED.");
        break;
}

7. Functions

Functions are defined with a return type, name, and a list of typed parameters. void is used for functions that do not return a value.

void log_message(string msg, int level) {
    print(int_to_string(level) + ": " + msg);
}

int add(int a, int b) {
    return a + b;
}

void main() {
    log_message("System starting...", 0);
    int result;
    result = add(5, 10); // result is 15
}

8. Data Structures

Structs

Define custom data types to group related data.

struct Point {
    int x;
    int y;
};

Point p1;
p1.x = 10;
p1.y = 20;
print(p1.x);

Lists

Dynamic arrays that can hold elements of a single type.

list<string> names;

add(names, "Alice");
add(names, "Bob");

string first_name;
first_name = get(names, 0); // "Alice"

int count;
count = size(names); // 2

Maps

Key-value stores. Keys can be int or string.

map<string, int> ages;

put(ages, "Alice", 30);
put(ages, "Bob", 45);

if (contains(ages, "Alice")) {
    int alice_age;
    alice_age = get(ages, "Alice");
    print(alice_age); // 30
}

9. Threading

Satellite Basic has built-in support for multi-threading.

  • thread <func_name>(<args...>): Spawns a new thread and returns a bigint handle.
  • join(<handle>): Waits for the specified thread to finish.
  • detach(<handle>): Allows a thread to run independently.
  • mutex, lock(<mutex_handle>), unlock(<mutex_handle>): For synchronizing access to shared data.
mutex my_lock;
int shared_counter;

void worker() {
    lock(my_lock);
    shared_counter = shared_counter + 1;
    unlock(my_lock);
}

void main_thread() {
    shared_counter = 0;
    bigint t1;
    t1 = thread worker();
    bigint t2;
    t2 = thread worker();
    
    join(t1);
    join(t2);
    // shared_counter will be 2
}

10. Native Function Library

A growing library of built-in functions provides core functionality.

String Functions

  • int length(string)
  • string char_at(string, int index)
  • string substring(string, int start, int length)
  • int find(string, string substr)
  • string replace(string, string to_replace, string replacement)
  • string int_to_string(int)
  • string bigint_to_string(bigint)
  • string bool_to_string(bool)

I/O Functions

  • int input_int()
  • string input_string()

List Functions

  • add(list_handle, value)
  • value get(list_handle, int index)
  • set(list_handle, int index, value)
  • int size(list_handle)

Map Functions

  • put(map_handle, key, value)
  • value get(map_handle, key)
  • bool contains(map_handle, key)
  • int map_size(map_handle)
  • list<KeyType> keys(map_handle)

File I/O

  • file open_file(string path, string mode) (mode: “r”, “w”, “a”)
  • void close_file(file handle)
  • `bool write_string_to_file(

Pretty cool huh? The language will follow later when I have it working!

Here is the AI that goes with the satellite basic language, an AI written entirely in s. basic!

Performa AI Language & API Reference (Version: 001, Revision: 09)

1. Overview

Performa is an artificial intelligence written entirely in the Satellite Basic programming language. Its primary purpose is to understand high-level descriptions of programs and generate valid, well-structured C++ source code.

At its core, Performa operates on an internal data model called an Abstract Syntax Tree (AST). The entire process follows a simple but powerful pipeline:

  1. Parse Instructions: Performa reads a high-level command or a simple Domain-Specific Language (DSL) that describes the desired C++ program.
  2. Build AST: Based on the parsed instructions, it programmatically constructs an AST using Satellite Basic’s struct and list data types. This tree is an internal, language-agnostic representation of the code’s logic and structure.
  3. Emit Code: It traverses the completed AST and uses a rule-based engine to translate each node in the tree into its corresponding C++ string representation.
  4. Output: The final generated C++ code string is saved to a file.

2. The Performa AST

The fundamental data structure in Performa is the AstNode struct. Every element of a C++ program is represented by one of these nodes.

2.1. The AstNode Struct

struct AstNode {
    CppNodeType node_type; // The kind of C++ construct this node represents
    string string_value1;  // Primary string value (e.g., name, content)
    string string_value2;  // Secondary string value (e.g., return type)
    int int_value1;        
    bool bool_value1;      // e.g., for includes, true = system header <>
    list<AstNode> children; // For nested structures like function bodies
};

2.2. CppNodeType Enumeration

The node_type field determines the purpose of the AstNode and how its other fields are used.

Enum MemberPurposestring_value1string_value2bool_value1children
NODE_PROGRAMThe root of the entire program.Holds NODE_INCLUDE_DIRECTIVE and NODE_FUNCTION_DEFINITION nodes.
NODE_INCLUDE_DIRECTIVERepresents an #include.The header name (e.g., “iostream”).true for system (<>), false for user ("").
NODE_FUNCTION_DEFINITIONRepresents a C++ function.The function’s name.The function’s return type.Holds a list of statement nodes that form the function body.
NODE_VARIABLE_DECLARATIONRepresents a variable declaration.The variable’s name.The variable’s C++ type.
NODE_STATEMENT_ASSIGNMENTAn assignment statement.Child 0: L-value (e.g., NODE_EXPRESSION_IDENTIFIER). Child 1: R-value (any expression node).
NODE_EXPRESSION_BINARY_OPAn operation with two operands.The operator (e.g., “+”, “*”).Child 0: Left-hand side expression. Child 1: Right-hand side expression.
NODE_EXPRESSION_IDENTIFIERThe use of a variable name.The name of the variable.
NODE_EXPRESSION_LITERAL_INTAn integer literal.The integer value is in int_value1.

3. The Performa API (Functions in Satellite Basic)

Performa exposes a set of helper functions (written in Satellite Basic) for building and manipulating its AST.

3.1. Node Creation Functions

These functions are the primary way to construct the AST.

  • AstNode create_cpp_program_node()
  • AstNode create_cpp_include_node(string header, bool is_system)
  • AstNode create_cpp_function_node(string return_type, string name)
  • AstNode create_cpp_var_decl_node(string var_type, string var_name)
  • AstNode create_cpp_assignment_statement_node(AstNode target_var, AstNode value_expr)
  • AstNode create_cpp_binary_op_node(string operator, AstNode left, AstNode right)
  • AstNode create_cpp_identifier_node(string name)
  • AstNode create_cpp_int_literal_node(int value)

3.2. Code Generation

The generation process is initiated by a single function call.

  • string emit_cpp_ast_node(AstNode node): The main emitter function. It takes the root node of an AST and recursively traverses it, generating the complete C++ source code as a single string. It uses a switch statement internally to dispatch to the correct code generation logic for each node type.

4. Example Workflow: Generating Code from a DSL

This example shows the end-to-end process of using Performa, from providing a high-level instruction to getting a C++ file as output.

void run_performa_task() {
    // 1. Define the input DSL. This is the high-level instruction for Performa.
    string dsl_input;
    dsl_input = """
        program: GREETING; 
        target: 'Satellite Programmer'; 
        output: "greeting.cpp";
    """;
    print("Performa: Processing DSL: " + dsl_input);

    // 2. Performa's internal parser tokenizes and parses the DSL into a map.
    StringList dsl_tokens = dsl_tokenize(dsl_input);
    StringMap dsl_data = dsl_parse(dsl_tokens);

    // 3. Performa's builder uses the parsed data to construct a specific AST.
    AstNode generated_ast = build_ast_from_dsl(dsl_data);
    print("Performa: AST model built successfully from DSL.");

    // 4. Performa's emitter traverses the AST to generate the C++ code string.
    string generated_cpp_code = emit_cpp_ast_node(generated_ast);
    print("Performa: C++ code generated.");

    // 5. Performa uses the file I/O library to save the result.
    string output_filename = get(dsl_data, "output");
    output_filename = replace(output_filename, "\"", ""); // Sanitize filename
    
    bigint file_handle = open_file(output_filename, "w");
    if (file_handle != bigint("-1")) { // Basic error check
        write_string_to_file(file_handle, generated_cpp_code);
        close_file(file_handle);
        print("Performa: Successfully wrote code to " + output_filename);
    } else {
        print("Performa: Error writing to file.");
    }
}

This documentation provides a snapshot of Performa’s capabilities and internal design as of Version: 001, Revision: 09.

tada!

You may also like...

3 Responses

  1. phim xxx says:

    Veery energetic article, I likedd that bit.
    Willl there bbe a part 2?

  2. neueporn.com says:

    Hey I know this is offf topijc bbut I wwas wonderting if yyou
    knew off any widgets I culd addd to my bllg thatt automaqtically tweeet myy nrwest twsitter updates.
    I’ve been looking for a plug-in like thios for quite soje time annd wwas hopibg maybe you would have some experience with somethiing lik
    this. Pleasee lett me knoow iff youu run intoo anything.

    I treuly ennjoy reading your bog and I look firward to ylur new updates.

Leave a Reply

Your email address will not be published. Required fields are marked *