sauravcode

A programming language that reads like thought. No parentheses, no commas, no semicolons โ€” just logic.

License Language Last Commit

Other languages

def add(x, y):
    return x + y

result = add(3, 5)
print(result)

sauravcode

function add x y
    return x + y

print add 3 5

Features

Everything you need, nothing you don't.

โšก

Two Execution Modes

Interpret with saurav.py for quick runs, or compile to native C with sauravcc.py for maximum performance.

๐Ÿงน

Clean Syntax

No parens for calls, no commas between args, no semicolons. Indentation defines blocks. Code reads like pseudocode.

๐Ÿ”„

Recursion

Full recursion support. Parentheses disambiguate nested calls: factorial (n - 1).

๐Ÿ“ฆ

Lists

Dynamic arrays with append, len, indexing, and assignment. Compiles to bounds-checked C arrays.

๐Ÿ—๏ธ

Classes

Object-oriented with class, self, and new. Methods and field access via dot notation.

๐Ÿ›ก๏ธ

Error Handling

try/catch blocks. The compiler maps these to setjmp/longjmp in generated C.

๐Ÿš€ Quick Start

Requirements: Python 3, gcc (MinGW on Windows) for compiling.

$ git clone https://github.com/sauravbhattacharya001/sauravcode.git
$ cd sauravcode

Run with the interpreter:

$ python saurav.py hello.srv

Or compile to native executable:

$ python sauravcc.py hello.srv

Examples

See sauravcode in action.

Fibonacci
function fib n
    if n <= 1
        return n
    return fib (n - 1) + fib (n - 2)

print fib 10    # 55
Factorial
function factorial n
    if n <= 1
        return 1
    return n * factorial (n - 1)

print factorial 10  # 3628800
Lists & Control Flow
# Dynamic lists with bounds checking
nums = [10, 20, 30]
append nums 40

for i 0 (len nums)
    if nums[i] > 25
        print nums[i]   # prints 30, 40
Classes
class Point
    function init x y
        self.x = x
        self.y = y

    function display
        print self.x
        print self.y

p = new Point
p.init 10 20
p.display

How the Compiler Works

From .srv to native executable in four stages.

StageInputOutputTool
1. TokenizeSource codeTokensRegex scanner
2. ParseTokensASTRecursive descent
3. GenerateASTC sourceCCodeGenerator
4. CompileC sourceExecutablegcc

Use --emit-c to see the generated C code, or --keep-c to preserve it alongside the binary.

Documentation

Deep-dive into sauravcode.

๐Ÿ“–

Language Reference

Complete specification with EBNF grammar.

๐Ÿ›๏ธ

Architecture

Tokenizer, parser, and compiler internals.

๐Ÿ’ก

Examples

Annotated programs covering all features.

๐Ÿ“‹

Changelog

Version history and notable changes.