Releases: peshala-prabhapoorna/jlox
Releases · peshala-prabhapoorna/jlox
jLox v0.1.0
Release Notes: Language Features Summary
The following is a summary of the core features currently available in the language as defined by its grammar productions:
Program Structure
- Program Composition: A program consists of multiple declarations, ending with an EOF token.
Declarations
- Variable Declaration (
var
): Allows declaring variables with an optional initializer. Example:var x = 10;
Statements
- Expression Statements: Evaluate an expression followed by a semicolon. Example:
x + 1;
- For Loops (
for
): Supports initialization, condition, and increment expressions. Example:for (var i = 0; i < 10; i = i + 1) { ... }
- If Statements (
if
): Conditional branching with optionalelse
. Example:if (x > 0) { ... } else { ... }
- Print Statements (
print
): Outputs the result of an expression. Example:print x;
- While Loops (
while
): Repeats execution while a condition is true. Example:while (x > 0) { ... }
- Block Statements: Groups multiple declarations or statements enclosed in
{ }
. Example:{ var x = 10; print x; }
Expressions
- Assignment: Assigns values to variables. Example:
x = 5;
- Comma Expressions: Supports chaining of expressions using commas. Example:
a, b, c;
- Conditional (
? :
): Ternary conditional operator for inline decisions. Example:x > 0 ? "positive" : "non-positive";
- Logical Operations:
- Logical OR (
or
). Example:true or false
- Logical AND (
and
). Example:true and false
- Logical OR (
- Equality Comparisons:
==
and!=
. Example:x == y
- Comparison Operations: Greater than, less than, and their inclusive counterparts (
>
,>=
,<
,<=
). Example:x >= y
- Arithmetic Operations: Addition, subtraction, multiplication, and division (
+
,-
,*
,/
). Example:x + y * z
- Unary Operations: Negation (
-
) and logical NOT (!
). Example:-x
or!true
- Grouping: Parentheses for expression grouping. Example:
(x + y) * z
Literals and Identifiers
- Literals: Supports numbers, strings, booleans (
true
,false
), andnil
. Example:42
,"Hello"
,true
,nil
- Identifiers: Variables and names that can be assigned values or used in expressions.
Full Changelog: https://github.com/peshala-prabhapoorna/jlox/commits/v0.1.0