Project notes

Simple syntax proposal

// 1. Variables
// Using 'let' makes it very easy for your Lexer to know a variable is coming.
let max_connections = 100
let active_users = 85

// 2. Functions
// 'fn' is short, and we don't worry about return types for a simple dynamic language.
fn calculate_load(active, max) {
    let load_percentage = (active / max) * 100
    return load_percentage
}

// 3. Conditionals
// Notice there are NO parentheses around the condition. 
// This makes writing the AST (Abstract Syntax Tree) much simpler.
if active_users >= max_connections {
    print("Error: Network capacity reached")
} else {
    let current_load = calculate_load(active_users, max_connections)
    print("Network is stable. Current load:")
    print(current_load)
}

// 4. Simple Loops
// A basic 'while' loop is the easiest looping construct to interpret.
let counter = 0
while counter < 3 {
    print("Pinging server...")
    counter = counter + 1
}

Why this is easy to build an interpreter for:

  1. No Semicolons: Your lexer can just use newlines (\n) to know when a statement ends.
  2. Keyword Heavy: Words like let, fn, if, and while are exact triggers. When your parser sees if, it immediately knows it needs to look for a condition and then a { block.
  3. Mandatory Braces { }: Python relies on invisible whitespace (indentation) to figure out where blocks of code start and end, which is notoriously difficult to write a parser for. By enforcing { } for blocks, your parser’s logic becomes incredibly straightforward: open brace means step into a new scope, close brace means step out.

The Human-Centric Error Experience

Because the syntax is so strict about using { }, it is very easy to generate helpful errors. If a user types:

if active_users > 50
    print("Warning!")

Your parser can instantly catch the missing brace and output:

❌ Syntax Error: Missing opening brace '{' for the if statement.
  --> monitor.nx:1:20
   |
 1 |   if active_users > 50
   |                       ^
   |                       I expected a '{' right here to start the block.
Found something to improve?Edit this page on GitHub ↗
Search guides, language features, and APIs ↵ to open first result