uddin

package module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 17, 2025 License: MIT Imports: 4 Imported by: 0

README ΒΆ

UDDIN-LANG

UDDIN-LANG (Unified Dynamic Decision Interpreter Notation) - A specialized Flexible Rule Logic Platform that resembles a programming language, offering high expressiveness, full flow control, and runtime programmable capabilities for complex business decision support systems.

UDDIN-LANG Logo

Flexible Rule Logic Platform with Programming Language Expressiveness

Go Version License

πŸ“š Read Full Documentation β†’

πŸ“– Table of Contents


🌟 About UDDIN-LANG

UDDIN-LANG is a specialized rule engine platform designed to bridge the gap between simple rule engines and full programming languages. It combines the power of programming language expressiveness with the simplicity needed for business decision systems.

🎯 Perfect For:

  • πŸ›‘οΈ Security & Anti-fraud - Multi-factor authentication rules, transaction monitoring, and behavioral analysis systems
  • πŸ€– Business Automation - Approval workflows, document processing, and intelligent routing systems
  • οΏ½ Decision Support - Recommendation engines, risk assessment tools, and dynamic pricing systems
  • βš–οΈ Compliance Rules - Regulatory compliance engines with audit trails
  • πŸ’° Financial Logic - Complex financial calculations and risk management
  • 🎯 Recommendation Systems - Intelligent content and product recommendations
  • πŸ“‹ Data Validation - Complex validation rules with custom logic
  • πŸ”„ Real-time Data Processing - Change Data Capture (CDC) for live database monitoring and event-driven architectures
πŸš€ Beyond Simple Rules

Unlike traditional rule engines that limit you to simple if-then logic, UDDIN-LANG provides:

  • Full Programming Language Power - Support for loops, functions, and complex logic
  • Runtime Flexibility - Modify rules without system restarts
  • Developer Friendly - Familiar syntax with powerful debugging capabilities
  • Enterprise Ready - Built for scale and performance
πŸ›  Build Rule Platforms

UDDIN-LANG serves as the foundation for building sophisticated rule management platforms:

  • Visual Rule Designers - Drag-and-drop rule creation interfaces
  • Decision Management Systems - Enterprise-grade rule management platforms
  • Workflow Automation - Complex process rules with branching logic
  • React Flow Integration - Perfect backend for visual rule designers
πŸŽ“ Educational Tool

Ideal for learning programming fundamentals with a focus on decision logic:

  • Clean Syntax - Easy to read and understand for beginners
  • Logic First - Focus on decision-making and algorithmic thinking
  • Debugging Friendly - Clear execution flow for learning
πŸ’‘ Language Philosophy

UDDIN-LANG draws inspiration from multiple paradigms while maintaining focus on rule-based logic:

graph TD
    A[Uddin-Lang] --> B[Python - Clean Syntax]
    A --> C[JavaScript - Dynamic Nature]
    A --> D[Go - Simplicity]
    A --> E[Lua - Embedded Scripting]
    A --> F[Ruby - Expressiveness]

    style A fill:#4a90e2,stroke:#333,stroke-width:3px,color:white
    style B fill:#3776ab,stroke:#333,stroke-width:2px,color:white
    style C fill:#f7df1e,stroke:#333,stroke-width:2px,color:black
    style D fill:#00add8,stroke:#333,stroke-width:2px,color:white
    style E fill:#000080,stroke:#333,stroke-width:2px,color:white
    style F fill:#cc342d,stroke:#333,stroke-width:2px,color:white
Core Philosophy
  1. "Code should read like natural language" - Prioritizing readability over brevity
  2. "Functions are first-class citizens" - Everything is a value, including functions
  3. "Fail fast, fail clearly" - Clear error messages and early error detection
  4. "Simple things should be simple" - Common tasks require minimal code

✨ Key Features

πŸ”₯ Core Features
  • βœ… Dynamic Typing with runtime type checking
  • βœ… First-class Functions and closures
  • βœ… Built-in Data Structures (Arrays, Maps/Objects)
  • βœ… Rich Built-in Functions including enhanced range() with Python-like syntax
  • βœ… Exception Handling with try-catch blocks
  • βœ… Advanced Error Reporting with precise error location and clear explanations
  • βœ… Loop Control (break, continue statements)
  • βœ… Module System with import statement for importing .din files
  • βœ… Flexible Comment System with both single-line (//) and multiline (/* */) comments
  • βœ… Functional Programming paradigms
  • βœ… Memory Safe with garbage collection
  • βœ… Rich Operator Set including logical XOR and compound assignment operators
  • βœ… Multiline Strings with backticks for raw text (perfect for JSON, SQL, HTML)
  • βœ… JSON Support with built-in parsing and serialization functions
  • ✨ Extended Standard Library with advanced string manipulation, functional array methods, and new data structures (Set, Stack, Queue) 🌐 Comprehensive Networking with HTTP client, TCP/UDP sockets, and network utilities πŸ—„οΈ Database Integration & CDC with real-time Change Data Capture for PostgreSQL and MySQL binlog streaming
πŸ› οΈ Developer Tools
  • βœ… Syntax Analysis (--analyze) - Fast syntax checking without execution
  • βœ… Performance Profiling (--profile) - Detailed execution metrics and timing
  • βœ… Interactive CLI with comprehensive help and examples
  • βœ… Developer-Friendly Error Messages with source code context
  • βœ… Multiple Execution Modes - Analysis, profiling, and standard execution

πŸ“– For complete language reference, syntax guide, and advanced examples:


πŸš€ Quick Start

Installation
As a Go Library
# Add to your Go project
go get github.com/bonkzero404/uddin-lang
As a CLI Tool
# Install globally
go install github.com/bonkzero404/uddin-lang/cmd/uddin-lang@latest

# Or build from source
git clone https://github.com/bonkzero404/uddin-lang.git
cd uddin-lang
go build -o uddinlang cmd/uddin-lang/main.go
Using as Go Library
package main

import (
    "fmt"
    "github.com/bonkzero404/uddin-lang"
)

func main() {
    // Create a new engine
    engine := uddin.New()

    // Execute code
    result, err := engine.ExecuteString(`
        x = 10
        y = 20
        return x + y
    `)
    if err != nil {
        panic(err)
    }

    fmt.Println("Result:", result) // Output: Result: 30

    // Evaluate expressions
    value, err := engine.EvaluateString("2 + 3 * 4")
    if err != nil {
        panic(err)
    }

    fmt.Println("Expression result:", value) // Output: Expression result: 14
}
Your First Program

Create a file hello.din:

// hello.din - Your first Uddin-Lang program
fun main():
    print("Hello, Uddin-Lang! πŸš€")

    // Variables and expressions
    name = "World"
    message = "Welcome to " + name
    print(message)

    // Simple function
    fun greet(person):
        return "Hello, " + person + "!"
    end

    print(greet("Developer"))
end

Run it:

# If installed globally
uddin-lang hello.din

# If built from source
./uddinlang hello.din

# Or run directly from source
go run cmd/uddin-lang/main.go hello.din
Explore Examples

The language comes with comprehensive examples showcasing all features:

# List all available examples
uddin-lang --examples
# or if built from source: ./uddinlang --examples

# Run specific examples
uddin-lang examples/12_logical_operators.din     # XOR and logical operations
uddin-lang examples/13_assignment_operators.din  # Compound assignments (+=, -=, etc.)
uddin-lang examples/01_hello_world.din          # Basic syntax
uddin-lang examples/03_math_library.din         # Mathematical functions

# ✨ New Standard Library Examples
uddin-lang examples/14_string_manipulation_demo.din  # Advanced string functions
uddin-lang examples/15_array_methods_demo.din        # Functional array methods
uddin-lang examples/16_data_structures_demo.din      # Set, Stack, Queue usage
uddin-lang examples/20_json_handling_demo.din        # JSON parsing and serialization
uddin-lang examples/21_multiline_strings_demo.din    # Multiline string features

# 🌐 Networking Examples
./uddinlang examples/17_http_client_demo.din      # HTTP client operations
./uddinlang examples/18_networking_demo.din       # TCP/UDP networking and utilities
./uddinlang examples/19_persistent_http_server.din # Persistent HTTP server with main function

# πŸ—„οΈ Database & CDC Examples
./uddinlang examples/database/postgres_multi_table_stream_listener.din  # PostgreSQL CDC streaming
./uddinlang examples/database/mysql_multi_table_stream_listener.din     # MySQL binlog CDC streaming
πŸ› οΈ CLI Features & Development Tools

Uddin-Lang provides powerful command-line tools for development workflow:

Syntax Analysis

Check your code syntax without execution - perfect for development and CI/CD:

# Analyze syntax only (fast feedback)
./uddinlang --analyze script.din
./uddinlang -a script.din

# Example output for valid syntax:
# βœ“ Syntax analysis passed - No syntax errors found

# Example output for syntax errors:
# -----------------------------------------------------------
#     if (true):
#              ^
# -----------------------------------------------------------
# Syntax Error: parse error at 6:14: expected then, but got :
Performance Profiling

Monitor execution performance and optimization metrics:

# Run with performance profiling
./uddinlang --profile script.din
./uddinlang -p script.din

# Example profiling output:
# Time Program Execution: 254.166Β΅s
# Elapsed Operation: 53 Ops (208525/s)
# Builtin Calls: 8 (31475/s)
# User Calls: 1 (3934/s)
Memory Optimization

Uddin-Lang provides two levels of memory optimization:

Stable Memory Optimization (Production-Ready)
# Run with stable memory optimizations
./uddinlang --memory-optimize-stable script.din

# Combine with profiling to see optimization effects
./uddinlang --memory-optimize-stable --profile script.din

βœ… Production Features:

  • Tagged value types for reduced memory overhead
  • Compact environment structures
  • Cache-friendly data layouts
  • Thread-safe and concurrent function compatible

When to use:

  • Production environments
  • Applications using concurrent functions
  • Multi-threaded environments
  • Performance-critical applications
Experimental Memory Optimization
# Run with experimental memory optimizations
./uddinlang --memory-optimize-experimental script.din

# Legacy flag (DEPRECATED - maps to experimental)
./uddinlang --memory-optimize script.din
./uddinlang -m script.din

⚠️ Experimental Features (Additional to stable):

  • Variable lookup caching
  • Expression memoization
  • Not compatible with concurrent functions (concurrent_map, concurrent_filter, concurrent_reduce)
  • May have thread safety issues

When to use experimental:

  • Sequential processing workloads only
  • Development and testing environments
  • Performance benchmarking

When to avoid experimental:

  • Programs using concurrent functions
  • Multi-threaded environments
  • Production systems requiring stability
Available CLI Commands
Command Short Description
--help -h Show usage information
--version -v Display version information
--examples -e List all available example files
--analyze -a Syntax analysis without execution
--profile -p Enable performance profiling
--memory-optimize-stable Enable stable memory optimizations (production-ready)
--memory-optimize-experimental Enable experimental memory optimizations
--memory-optimize -m Enable experimental memory optimization (DEPRECATED)
--from_json Execute code from JSON AST format
Usage Examples
# Basic execution
./uddinlang script.din

# Development workflow
./uddinlang --analyze script.din    # Check syntax first
./uddinlang --profile script.din    # Run with performance monitoring

# Memory optimization (experimental)
./uddinlang --memory-optimize script.din  # Enable memory layout optimization
./uddinlang -m script.din                 # Short form

# JSON AST execution
./uddinlang --from_json script.json  # Execute from JSON AST format

# Flexible flag positioning
./uddinlang script.din --analyze    # Flags can be placed after filename
./uddinlang -a -p script.din        # Multiple flags (analyze takes priority)

# Get help and examples
./uddinlang --help                  # Show usage
./uddinlang --examples              # List example files
./uddinlang --version               # Show version info

🎯 Development Workflow Use Cases

Uddin-Lang CLI tools support various development scenarios:

πŸ” Syntax Validation in CI/CD
# Validate all scripts in a project
find . -name "*.din" -exec ./uddinlang --analyze {} \;

# Exit code integration for CI/CD pipelines
./uddinlang --analyze script.din && echo "Syntax OK" || echo "Syntax Error"
πŸ“Š Performance Optimization
# Before optimization
./uddinlang --profile slow_script.din

# After optimization
./uddinlang --profile optimized_script.din

# Compare execution metrics to measure improvements
πŸš€ Rapid Development
# Edit-check-run cycle
vim script.din                      # Edit script
./uddinlang --analyze script.din     # Quick syntax check
./uddinlang script.din               # Run if syntax is valid
πŸ§ͺ IDE/Editor Integration
# Language servers can use syntax analysis
./uddinlang --analyze file.din 2>&1 | parse_errors

# Real-time syntax highlighting based on analysis results

πŸ“ Language Grammar

Formal Grammar (EBNF)
// Program Structure
program        = { statement }

// Statements
statement      = expression_stmt
               | assignment
               | if_stmt
               | while_stmt
               | for_stmt
               | function_def
               | memo_function_def
               | return_stmt
               | break_stmt
               | continue_stmt
               | import_stmt
               | try_catch_stmt

expression_stmt = expression
assignment     = ( IDENTIFIER | subscript ) ( "=" | "+=" | "-=" | "*=" | "/=" | "%=" ) expression

if_stmt        = "if" "(" expression ")" "then" ":" block
                   { ( "else" "if" | "elif" ) "(" expression ")" "then" ":" block }
                   [ "else" ":" block ] "end"

while_stmt     = "while" "(" expression ")" ":" block "end"

for_stmt       = "for" "(" IDENTIFIER "in" expression ")" ":" block "end"

function_def   = "fun" IDENTIFIER "(" [ parameter_list ] ")" ":" block "end"

memo_function_def = "memo" "fun" IDENTIFIER "(" [ parameter_list ] ")" ":" block "end"

return_stmt    = "return" [ expression ]
break_stmt     = "break"
continue_stmt  = "continue"
import_stmt    = "import" STRING

try_catch_stmt = "try" ":" block "catch" "(" IDENTIFIER ")" ":" block "end"

block          = { statement }
parameter_list = IDENTIFIER { "," IDENTIFIER } [ "..." ]

// Expressions (in precedence order, lowest to highest)
expression     = ternary
ternary        = logical_or [ "?" expression ":" expression ]
logical_or     = logical_xor { "or" logical_xor }
logical_xor    = logical_and { "xor" logical_and }
logical_and    = equality { "and" equality }
equality       = comparison { ( "==" | "!=" ) comparison }
comparison     = addition { ( "<" | "<=" | ">" | ">=" ) addition }
addition       = multiplication { ( "+" | "-" ) multiplication }
multiplication = power { ( "*" | "/" | "%" ) power }
power          = unary [ "**" power ]  // Right associative
unary          = ( "not" | "-" ) unary | postfix
postfix        = primary { call_suffix | subscript_suffix | property_suffix }

call_suffix    = "(" [ argument_list ] ")"
subscript_suffix = "[" expression "]"
property_suffix = "." IDENTIFIER

argument_list  = expression { "," expression } [ "..." ]

primary        = IDENTIFIER
               | literal
               | list
               | map
               | function_expression
               | "(" expression ")"

function_expression = "fun" "(" [ parameter_list ] ")" ":" block "end"

list           = "[" [ expression { "," expression } [ "," ] ] "]"
map            = "{" [ map_entry { "," map_entry } [ "," ] ] "}"
map_entry      = ( IDENTIFIER | STRING | "(" expression ")" ) ":" expression

subscript      = postfix "[" expression "]"
               | postfix "." IDENTIFIER

// Literals
literal        = INTEGER
               | FLOAT
               | STRING
               | "true"
               | "false"
               | "null"

// Lexical Elements
IDENTIFIER     = letter { letter | digit | "_" }
INTEGER        = digit { digit }
FLOAT          = digit { digit } "." digit { digit } [ ( "e" | "E" ) [ "+" | "-" ] digit { digit } ]
               | digit { digit } ( "e" | "E" ) [ "+" | "-" ] digit { digit }
STRING         = '"' { string_char } '"'
               | "'" { string_char } "'"
               | '"""' { any_char } '"""'  // Multiline string
string_char    = any_char_except_quote_and_newline | escape_sequence
escape_sequence = "\\" ( "n" | "t" | "r" | "\\" | '"' | "'" )

letter         = "a" ... "z" | "A" ... "Z"
digit          = "0" ... "9"

// Comments
comment        = single_line_comment | multiline_comment
single_line_comment = "//" { any_character_except_newline }
multiline_comment   = "/*" { any_character } "*/"
Operator Precedence (Highest to Lowest)
Precedence Operators Associativity Description
1 () [] . Left Function call, Array access, Property access
2 not - (unary) Right Logical NOT, Unary minus
3 ** Right Exponentiation (power operator)
4 * / % Left Multiplication, Division, Modulo
5 + - Left Addition, Subtraction
6 < <= > >= Left Relational operators
7 == != Left Equality operators
8 and Left Logical AND
9 xor Left Logical XOR (exclusive or)
10 or Left Logical OR
11 ? : Right Ternary conditional operator
12 = += -= *= /= %= Right Assignment and compound assignment
Language Features
Variadic Functions

Functions can accept variable number of arguments using the ellipsis (...) operator:

// Function definition with variadic parameters
parameter_list = IDENTIFIER { "," IDENTIFIER } [ "..." ]

// Function call with argument spreading
argument_list = expression { "," expression } [ "..." ]

Examples:

// Define variadic function
fun sum(numbers...):
    total = 0
    for (num in numbers):
        total += num
    end
    return total
end

// Call with multiple arguments
result = sum(1, 2, 3, 4, 5)

// Call with array spreading
numbers = [1, 2, 3, 4, 5]
result = sum(numbers...)
Memoization

Functions can be memoized for automatic caching using the memo keyword:

memo_function_def = "memo" "fun" IDENTIFIER "(" [ parameter_list ] ")" ( ":" | "{" ) block ( "end" | "}" )

Example:

// Memoized fibonacci function
memo fun fibonacci(n):
    if (n <= 1):
        return n
    end
    return fibonacci(n-1) + fibonacci(n-2)
end
Scientific Notation

Numeric literals support scientific notation:

FLOAT = digit { digit } "." digit { digit } [ ( "e" | "E" ) [ "+" | "-" ] digit { digit } ]
      | digit { digit } ( "e" | "E" ) [ "+" | "-" ] digit { digit }

Examples:

avogadro = 6.022e23
electron_mass = 9.109e-31
speed_of_light = 2.998E+8
Multiline Strings

Strings can span multiple lines using triple quotes:

STRING = '"' { string_char } '"'
       | "'" { string_char } "'"
       | '"""' { any_char } '"""'  // Multiline string

Example:

query = """
    SELECT name, age, email
    FROM users
    WHERE age > 18
    ORDER BY name
"""
Flexible Block Syntax

Blocks use colon-end syntax:

if (condition):
    statements
end

πŸ—„οΈ Database Integration & Change Data Capture (CDC)

UDDIN-LANG provides powerful real-time database integration capabilities with built-in Change Data Capture (CDC) support for monitoring database changes and building event-driven applications.

πŸ”„ Supported CDC Sources
  • PostgreSQL - LISTEN/NOTIFY based real-time streaming
  • MySQL - Binary log (binlog) streaming for high-performance CDC
  • Oracle - Planned support for Oracle CDC
  • MongoDB - Planned support for MongoDB Change Streams
πŸš€ Key CDC Features
  • Real-time Event Streaming - Instant notification of data changes
  • Multi-table Monitoring - Monitor multiple tables simultaneously
  • Event Filtering - Filter events by operation type (INSERT, UPDATE, DELETE)
  • Low Latency - Optimized for high-performance streaming
  • Automatic Reconnection - Built-in resilience and error handling
πŸ“ Quick CDC Example
// PostgreSQL CDC Example
fun main():
    // Configure CDC connection
    config = {
        "host": "localhost",
        "port": 5432,
        "database": "mydb",
        "username": "user",
        "password": "pass"
    }

    // Start streaming changes from multiple tables
    stream_tables(["users", "orders", "products"], config, fun(event):
        print("Database change detected:")
        print("Table: " + event.table)
        print("Operation: " + event.operation)
        print("Data: " + json_stringify(event.data))

        // Process the change event
        if (event.table == "orders" and event.operation == "INSERT") then:
            // Trigger order processing workflow
            process_new_order(event.data)
        end
    end)
end
🎯 CDC Use Cases
  • Real-time Analytics - Stream data changes to analytics dashboards
  • Event-driven Microservices - Trigger business processes from data changes
  • Data Synchronization - Keep multiple systems in sync
  • Audit Logging - Track all data modifications for compliance
  • Cache Invalidation - Update caches when underlying data changes
  • Search Index Updates - Keep search indexes synchronized with database
πŸ“š Learn More

For detailed CDC implementation guides, configuration options, and advanced examples:

πŸ“– Read CDC Documentation β†’


πŸ—οΈ Architecture Overview

Interpreter Architecture
graph TB
    A[Source Code] --> B[Tokenizer/Lexer]
    B --> C[Parser]
    C --> D[Abstract Syntax Tree]
    D --> E[Evaluator]
    E --> F[Interpreter Core]
    F --> G[Runtime Environment]

    %% Core Components
    G --> H[Variable Scopes]
    G --> I[Built-in Dispatcher]
    G --> J[Memory Pools]
    G --> K[Error Handling]

    %% Optimization Layer
    L[Expression Optimizer] --> E
    M[Constant Folder] --> E
    N[Memoization Cache] --> F
    O[String Interning] --> J

    %% Built-in Function Categories
    I --> P[Core Functions]
    I --> Q[Math Functions]
    I --> R[String Functions]
    I --> S[Array Functions]
    I --> T[File System]
    I --> U[Network Functions]
    I --> V[Database Functions]

    %% Memory Management
    J --> W[Array Pools]
    J --> X[Map Pools]
    J --> Y[String Builder Pools]
    J --> Z[Variable Lookup Cache]

    style A fill:#e1f5fe
    style D fill:#f3e5f5
    style E fill:#e8f5e8
    style F fill:#fff3e0
    style G fill:#f0f4c3
    style L fill:#fce4ec
    style I fill:#e0f2f1
Memory Management & Optimization
graph TB
    A[Memory Layout Config] --> B[Tagged Values]
    A --> C[Compact Environment]
    A --> D[Cache-Friendly Structures]

    %% Object Pools
    E[Object Pools] --> F[Array Pool]
    E --> G[Map Pool]
    E --> H[String Builder Pool]
    E --> I[AST Node Pool]

    %% Caching Systems
    J[Caching Layer] --> K[Memoization Cache]
    J --> L[Variable Lookup Cache]
    J --> M[Token Cache]
    J --> N[Parser Cache]

    %% Optimization Engines
    O[Optimization] --> P[Expression Optimizer]
    O --> Q[Constant Folder]
    O --> R[Fast Numeric Evaluator]
    O --> S[String Interning]

    %% Performance Monitoring
    T[Performance Monitor] --> U[Operation Tracking]
    T --> V[Memory Leak Detection]
    T --> W[Call Statistics]

    style A fill:#e3f2fd
    style E fill:#f3e5f5
    style J fill:#e8f5e8
    style O fill:#fff3e0
    style T fill:#fce4ec
Built-in Function System
graph TB
    A[Built-in Dispatcher] --> B[Function Registry]
    B --> C[Argument Validation]
    B --> D[Call Statistics]

    %% Function Categories
    E[Core Functions] --> F[print, len, typeof]
    G[Math Functions] --> H[abs, sqrt, pow, sin, cos]
    I[String Functions] --> J[substr, split, join, contains]
    K[Array Functions] --> L[range, filter, map, reduce]
    M[File System] --> N[read_file, write_file, exists]
    O[Network] --> P[http_get, http_post, tcp_connect]
    Q[Database] --> R[mysql_stream, postgres_stream]
    S[Concurrent] --> T[async, await, parallel]
    U[Data Structure] --> V[stack, queue, heap, graph]

    %% Dispatch Flow
    A --> E
    A --> G
    A --> I
    A --> K
    A --> M
    A --> O
    A --> Q
    A --> S
    A --> U

    %% Optimization
    W[Fast Path] --> X[Type-specific Handlers]
    W --> Y[Specialized Builtins]
    A --> W

    style A fill:#e0f2f1
    style B fill:#f3e5f5
    style W fill:#fff3e0
Execution Flow
sequenceDiagram
    participant U as User
    participant M as Main
    participant T as Tokenizer
    participant P as Parser
    participant I as Interpreter
    participant E as Environment

    U->>M: Run uddinlang script.din
    M->>T: Tokenize source code
    T->>P: Token stream
    P->>I: Abstract Syntax Tree
    I->>E: Execute statements
    E->>I: Return values
    I->>M: Execution result
    M->>U: Output/Error
Component Responsibilities
Component Responsibility
Tokenizer Converts source code into tokens with caching (lexical analysis)
Parser Builds Abstract Syntax Tree from tokens with node pooling
AST Represents program structure in optimized tree form
Evaluator Evaluates expressions with constant folding optimization
Interpreter Core Orchestrates execution flow and manages global state
Runtime Environment Manages variable scopes, I/O streams, and execution context
Built-in Dispatcher Optimized dispatch system for built-in functions
Memory Pools Efficient memory allocation and reuse for arrays, maps, strings
Expression Optimizer Optimizes expressions through constant folding and caching
Memoization Cache Caches function results for pure functions
Variable Lookup Cache Accelerates variable resolution in nested scopes
String Interning Reduces memory usage by reusing identical strings
Performance Monitor Tracks operation counts and detects memory leaks

🀝 Contributing

We welcome contributions! Here's how to get started:

1. Fork & Clone
git clone https://github.com/bonkzero404/uddin-lang.git
cd uddin-lang
2. Create Feature Branch
git checkout -b feature/my-new-feature
3. Make Changes
  • Follow Go coding conventions
  • Add tests for new features
  • Update documentation and examples
  • Ensure all tests pass
4. Submit Pull Request
git commit -m "Add my new feature"
git push origin feature/my-new-feature

Documentation ΒΆ

Overview ΒΆ

Package uddin provides a high-level API for the UDDIN-LANG interpreter. UDDIN-LANG (Unified Dynamic Decision Interpreter Notation) is a specialized rule engine platform that combines programming language expressiveness with business decision system simplicity.

Index ΒΆ

Constants ΒΆ

This section is empty.

Variables ΒΆ

View Source
var (
	// DefaultConfig returns a configuration with sensible defaults
	DefaultConfig = interpreter.DefaultConfig
	// TestConfig returns a configuration suitable for testing
	TestConfig = interpreter.TestConfig
	// PrintStats prints execution statistics
	PrintStats = interpreter.PrintStats
)

Re-export configuration functions

Functions ΒΆ

func ConvertFromJSON ΒΆ

func ConvertFromJSON(jsonData []byte) (string, error)

ConvertFromJSON is a convenience function that converts JSON AST back to source code.

func ConvertJSONToString ΒΆ

func ConvertJSONToString(jsonData []byte) (string, error)

ConvertJSONToString is a convenience function that converts JSON AST back to source code string.

func ConvertStringToJSON ΒΆ

func ConvertStringToJSON(source string) ([]byte, error)

ConvertStringToJSON is a convenience function that converts source code string to JSON AST.

func ConvertToJSON ΒΆ

func ConvertToJSON(source []byte) ([]byte, error)

ConvertToJSON is a convenience function that converts source code to JSON AST.

func EvaluateString ΒΆ

func EvaluateString(source string) (interpreter.Value, *interpreter.Stats, error)

EvaluateString is a convenience function to evaluate an expression with default settings.

func ExecuteFile ΒΆ

func ExecuteFile(filename string) (*interpreter.Stats, error)

ExecuteFile is a convenience function to execute a file with default settings.

func ExecuteString ΒΆ

func ExecuteString(source string) (*interpreter.Stats, error)

ExecuteString is a convenience function to execute source code with default settings.

func ParseExpression ΒΆ

func ParseExpression(source []byte) (interpreter.Expression, error)

ParseExpression is a convenience function to parse an expression with default settings.

func ParseProgram ΒΆ

func ParseProgram(source []byte) (*interpreter.Program, error)

ParseProgram is a convenience function to parse a program with default settings.

Types ΒΆ

type Config ΒΆ

type Config = interpreter.Config

Config represents interpreter configuration

type Engine ΒΆ

type Engine struct {
	// contains filtered or unexported fields
}

Engine represents a UDDIN-LANG interpreter engine instance. It provides a high-level interface for parsing and executing UDDIN-LANG code.

func New ΒΆ

func New() *Engine

New creates a new UDDIN-LANG engine with default configuration.

func NewWithConfig ΒΆ

func NewWithConfig(config *interpreter.Config) *Engine

NewWithConfig creates a new UDDIN-LANG engine with custom configuration.

func (*Engine) ConvertFromJSON ΒΆ

func (e *Engine) ConvertFromJSON(jsonData []byte) (string, error)

ConvertFromJSON converts JSON AST representation back to UDDIN-LANG source code.

func (*Engine) ConvertJSONToString ΒΆ

func (e *Engine) ConvertJSONToString(jsonData []byte) (string, error)

ConvertJSONToString converts JSON AST back to UDDIN-LANG source code string.

func (*Engine) ConvertStringToJSON ΒΆ

func (e *Engine) ConvertStringToJSON(source string) ([]byte, error)

ConvertStringToJSON converts UDDIN-LANG source code string to JSON AST.

func (*Engine) ConvertToJSON ΒΆ

func (e *Engine) ConvertToJSON(source []byte) ([]byte, error)

ConvertToJSON converts UDDIN-LANG source code to JSON AST representation.

func (*Engine) EnableMemoryOptimization ΒΆ

func (e *Engine) EnableMemoryOptimization()

EnableMemoryOptimization enables memory layout optimizations.

func (*Engine) EvaluateExpression ΒΆ

func (e *Engine) EvaluateExpression(expr interpreter.Expression) (interpreter.Value, *interpreter.Stats, error)

EvaluateExpression evaluates a parsed expression and returns the result.

func (*Engine) EvaluateString ΒΆ

func (e *Engine) EvaluateString(source string) (interpreter.Value, *interpreter.Stats, error)

EvaluateString parses and evaluates a UDDIN-LANG expression from a string.

func (*Engine) ExecuteFile ΒΆ

func (e *Engine) ExecuteFile(filename string) (*interpreter.Stats, error)

ExecuteFile parses and executes UDDIN-LANG source code from a file.

func (*Engine) ExecuteProgram ΒΆ

func (e *Engine) ExecuteProgram(prog *interpreter.Program) (*interpreter.Stats, error)

ExecuteProgram executes a parsed program.

func (*Engine) ExecuteString ΒΆ

func (e *Engine) ExecuteString(source string) (*interpreter.Stats, error)

ExecuteString parses and executes UDDIN-LANG source code from a string.

func (*Engine) ParseExpression ΒΆ

func (e *Engine) ParseExpression(source []byte) (interpreter.Expression, error)

ParseExpression parses a UDDIN-LANG expression from source code.

func (*Engine) ParseProgram ΒΆ

func (e *Engine) ParseProgram(source []byte) (*interpreter.Program, error)

ParseProgram parses a UDDIN-LANG program from source code.

func (*Engine) SetArgs ΒΆ

func (e *Engine) SetArgs(args []string)

SetArgs sets command-line arguments for the engine.

func (*Engine) SetStdin ΒΆ

func (e *Engine) SetStdin(r io.Reader)

SetStdin sets the standard input for the engine.

func (*Engine) SetStdout ΒΆ

func (e *Engine) SetStdout(w io.Writer)

SetStdout sets the standard output for the engine.

func (*Engine) SetUnitTestMode ΒΆ

func (e *Engine) SetUnitTestMode(isUnitTest bool)

SetUnitTestMode sets whether the engine is running in unit test mode. In unit test mode, the main() function is not automatically executed.

func (*Engine) SetVariable ΒΆ

func (e *Engine) SetVariable(name string, value any)

SetVariable sets a variable in the engine's global scope.

func (*Engine) SetVariables ΒΆ

func (e *Engine) SetVariables(vars map[string]any)

SetVariables sets multiple variables in the engine's global scope.

type Error ΒΆ

type Error = interpreter.Error

Error represents interpreter errors

type Expression ΒΆ

type Expression = interpreter.Expression

Expression represents a parsed expression

type Program ΒΆ

type Program = interpreter.Program

Program represents a parsed program

type Stats ΒΆ

type Stats = interpreter.Stats

Stats represents execution statistics

type Value ΒΆ

type Value = interpreter.Value

Value represents any runtime value in UDDIN-LANG

Directories ΒΆ

Path Synopsis
cmd
uddin-lang command
internal

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL