Spectra programming language
Programming language made for my tutorial videos (my youtube channel):
Syntax
Declaring a variable:
var a = 3;
Function expression:
var even = fun (n) {
n % 2 == 0
};
If expression:
print("number a is " + if a % 2 == 0 {
"even"
} else {
"odd"
});
While expression:
while true {
println("HELLO!");
}
Classes:
class Point {
x,
y,
constructor (x, y) {
this.x = x;
this.y = y;
}
distance_from (other_point) { todo() }
}
Progress
- Lexer
- Tokenize identifiers
- Tokenize string literals (without escape sequences)
- Tokenize char literals (without escape sequences)
- Process escape sequences
- Tokenize integers
- Tokenize floats
- Process comments
- Parser
- Parse expressions
- Parse binary expression
- Parse postfix expression
- Parse prefix expression
- Parse if expression
- Parse while expression
- Parse statement
- Parse
break
statement - Parse
continue
statement - Parse expression statement
- Parse class statement
- Parse
- Parse expressions
- Tree-walk interpreter
- Implement scopes
- Evaluate expressions
- Evaluate binary expression
- Evaluate postfix expression
- Evaluate prefix expression
- Evaluate if expression
- Evaluate while expression
- Evaluate statements
- Evaluate
break
statement - Evaluate
continue
statement - Evaluate expression statement
- Evaluate class statement
- Evaluate
- VM
- VM Bytecode Compiler