Skip to content

AbdelkaderCE/Oker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
3(1)

Oker Programming Language

Overview

Oker is a custom interpreted programming language designed with human-readable syntax and comprehensive language features.
The project consists of a C++ compiler/interpreter backend with a web-based frontend interface for interactive development and testing.


System Architecture

Backend Architecture

  • Language: C++17
  • Build System: CMake
  • Architecture: Traditional compiler pipeline with interpreter
  • Components:
    Lexer → Parser → Semantic Analyzer → Code Generator → Virtual Machine

Frontend Architecture

  • Technology: Vanilla JavaScript with HTML/CSS
  • Server: Python HTTP server for API endpoints
  • Interface: Single-page application with real-time compilation

Core Language Features

  • Natural language-like syntax (say, let, if, while, repeat)
  • Object-oriented programming with classes
  • Error handling with try/fail blocks
  • File I/O operations
  • Built-in functions and type system

Key Components

Compiler Pipeline (C++)

  • Lexer (src/lexer.cpp/.h): Tokenizes source code into language tokens
  • Parser (src/parser.cpp/.h): Builds Abstract Syntax Tree (AST) from tokens
  • Semantic Analyzer (src/semantic.cpp/.h): Type checking and semantic validation
  • Code Generator (src/codegen.cpp/.h): Generates bytecode from AST
  • Virtual Machine (src/vm.cpp/.h): Executes generated bytecode
  • Built-ins (src/builtins.cpp/.h): Standard library functions

Web Interface (JavaScript/Python)

  • Frontend (web/app.js): Interactive code editor with compilation features
  • HTTP Server (web/server.py): REST API for compilation requests
  • UI (web/index.html, web/style.css): Modern web interface with syntax highlighting

Testing Infrastructure

  • Unit tests for all compiler components
  • Test files for lexer, parser, semantic analysis, and code generation
  • CMake-integrated testing framework

Data Flow

  1. Source Code Input: User writes Oker code in web interface
  2. Tokenization: Lexer breaks code into tokens
  3. Parsing: Parser constructs AST from tokens
  4. Semantic Analysis: Validates types and semantics
  5. Code Generation: Produces bytecode instructions
  6. Execution: Virtual machine interprets bytecode
  7. Output: Results displayed in web interface

Web API Flow

  1. User submits code via web interface
  2. JavaScript sends POST request to Python server
  3. Python server invokes C++ compiler binary
  4. Compilation results returned as JSON
  5. Frontend displays output, tokens, AST, or bytecode

External Dependencies

Build Dependencies

  • CMake (3.16+)
  • C++17 compatible compiler
  • Python 3 (for web server)

Development Tools

  • Address sanitizer for debugging
  • Comprehensive compiler flags for code quality
  • Testing framework integration

Web Dependencies

  • Font Awesome icons
  • Modern web browser with ES6 support
  • No external JavaScript frameworks (vanilla JS approach)

Deployment Strategy

Local Development

  • CMake build system for cross-platform compilation
  • Debug builds with sanitizers for development
  • Release builds with optimization for production

Web Interface

  • Simple Python HTTP server for development
  • Static file serving for HTML/CSS/JS
  • RESTful API for compilation requests

Testing Strategy

  • Unit tests for all compiler components
  • Integration tests through web interface
  • Automated testing via CMake

User Preferences

Preferred communication style: Simple, everyday language.


Recent Changes

  • July 08, 2025: Fixed compilation errors in Symbol and Function structs by adding default constructors
  • July 08, 2025: Fixed missing <cmath> include in VM for modulo operations
  • July 08, 2025: Successfully built Oker compiler binary with full functionality
  • July 08, 2025: Set up web interface with Python HTTP server on port 5000
  • July 08, 2025: Fixed comment parsing issue - tilde comments not properly implemented in lexer
  • July 08, 2025: Verified all core language features working: variables, functions, math operations, string operations
  • July 08, 2025: MAJOR BREAKTHROUGH - Fixed function declarations and jump resolution completely
  • July 08, 2025: Fixed string concatenation type system to allow mixed string/non-string operations
  • July 08, 2025: All critical compiler issues resolved - comments, functions, expressions, blocks, conditionals, loops all working

Current Status

✅ Compiler builds successfully and generates working executable
✅ Web interface operational with code editor and compilation features
✅ Core language features functional: variables, arithmetic, strings, functions
✅ Built-in functions implemented: str(), len(), upper(), lower()
✅ Example programs working correctly
✅ Comments (~) parsing and handling completely functional
✅ Function declarations (makef) with parameters working perfectly
✅ String concatenation with mixed types working
✅ Control structures (if/else, while, repeat) fully operational
✅ All compiler phases working: lexer, parser, semantic analyzer, code generator, VM


Known Issues

  • Test suite has multiple definition errors (tests still functional individually)
  • All core language features are now fully functional

Changelog

July 08, 2025 — Initial setup and complete implementation