Primary Internal
Parser_rule// Parsed by parse_primary_internal()
Internal parser rule for primary internal.
Examples:
// Implementation specific
Heritage: Internal compiler parsing logic.
// comment text
Comments that extend to the end of the line.
// This is a comment
let x = 5; // inline comment
Heritage: C++ style single-line comments.
/* comment text */
Comments that can span multiple lines.
/* This is a
multi-line comment */
Heritage: C-style block comments for longer documentation.
/// documentation text
Special comments for generating documentation.
/// Calculates the sum of two numbers
/// Returns: The sum as an integer
Heritage: Documentation comments from Rust and modern documentation tools.
if condition {
// if block
} else {
// else block
}
Conditional execution based on boolean expressions. In Cyl, if is an expression that returns a value.
if x > 0 {
print("positive");
}
let result = if condition { value1 } else { value2 };
Heritage: If expressions from functional languages combined with C-style syntax.
while condition {
// statements
}
Repeatedly executes the loop body while the condition remains true. Supports variable assignment and complex conditions.
while i < 10 {
print_int(i);
i = i + 1;
}
while continue_loop {
process_data();
continue_loop = check_condition();
}
Heritage: Standard while loop construct from imperative programming languages with C-style syntax.
for item in iterable {
// loop body
}
Iterates over collections or ranges with automatic iteration variable binding.
for i in 0..10 {
print(i);
}
for item in array {
process(item);
}
Heritage: For-in loops from Python and modern languages with range syntax from Rust.
match value {
pattern => result,
_ => default
}
Pattern matching with exhaustive case analysis, similar to switch statements but more powerful.
match status {
"ok" => process(),
"error" => handle_error(),
_ => unknown()
}
Heritage: Pattern matching from functional languages like ML and Rust.
let variable_name: type = value;
Declares a new variable with an explicit type and initial value. Variables in Cyl are immutable by default.
let count: i32 = 42;
let name: string = "Hello";
let is_active: bool = true;
Heritage: Inspired by Rust's let bindings with mandatory type annotations for clarity.
let mut variable_name: type = value;
Declares a mutable variable that can be reassigned after initialization.
let mut counter: i32 = 0;
let mut buffer: string = "";
Heritage: Follows Rust's explicit mutability model for memory safety.
fn function_name(param: type) -> return_type {
// function body
}
Defines a function with parameters and return type. Functions are first-class values in Cyl.
fn add(a: i32, b: i32) -> i32 {
return a + b;
}
fn greet(name: string) -> string {
return "Hello, " + name;
}
Heritage: Function syntax borrowed from Rust with influences from modern functional languages.
const CONSTANT_NAME: type = value;
Declares a compile-time constant that cannot be changed.
const PI: f64 = 3.14159;
const MAX_SIZE: i32 = 1000;
Heritage: Constant declaration pattern from Rust and C++ traditions.
operand operator operand
Mathematical operations with standard operator precedence.
5 + 3
x * y - z
(a + b) / 2
Heritage: Standard arithmetic operators with C-style precedence rules.
function_name(arg1, arg2, ...)
Calls a function with the provided arguments and evaluates to the return value.
add(5, 3)
print("Hello")
max(a, b, c)
Heritage: Function call syntax from C-family languages.
literal_value
Direct representation of values like numbers, strings, and booleans.
42
"Hello, World!"
true
3.14
Heritage: Standard literal syntax across programming languages.
variable_name
References the value stored in a variable.
counter
user_name
is_ready
Heritage: Simple variable reference from all major programming languages.
+, -, *, /, %
Basic arithmetic operations: addition, subtraction, multiplication, division, and modulo.
5 + 3
10 - 4
6 * 7
15 / 3
17 % 5
Heritage: Standard arithmetic operators from mathematical notation and C.
==, !=, <, >, <=, >=
Operators for comparing values and producing boolean results.
x == y
a != b
count < 10
score >= 90
Heritage: Comparison operators from C with logical mathematical symbols.
&&, ||, !
Boolean logic operators for combining and negating boolean expressions.
x && y
a || b
!condition
Heritage: Logical operators from C-family languages.
// Parsed by parse_statement()
Internal parser rule for statement.
// Implementation specific
Heritage: Internal compiler parsing logic.
// Parsed by parse_declare()
Internal parser rule for declare.
// Implementation specific
Heritage: Internal compiler parsing logic.
// Parsed by parse_return()
Internal parser rule for return.
// Implementation specific
Heritage: Internal compiler parsing logic.
// Parsed by parse_if()
Internal parser rule for if.
// Implementation specific
Heritage: Internal compiler parsing logic.
// Parsed by parse_while()
Internal parser rule for while.
// Implementation specific
Heritage: Internal compiler parsing logic.
// Parsed by parse_for()
Internal parser rule for for.
// Implementation specific
Heritage: Internal compiler parsing logic.
// Parsed by parse_match()
Internal parser rule for match.
// Implementation specific
Heritage: Internal compiler parsing logic.
// Parsed by parse_pattern()
Internal parser rule for pattern.
// Implementation specific
Heritage: Internal compiler parsing logic.
// Parsed by parse_try()
Internal parser rule for try.
// Implementation specific
Heritage: Internal compiler parsing logic.
// Parsed by parse_import()
Internal parser rule for import.
// Implementation specific
Heritage: Internal compiler parsing logic.
// Parsed by parse_expression()
Internal parser rule for expression.
// Implementation specific
Heritage: Internal compiler parsing logic.
// Parsed by parse_expression_stop_at_left_brace()
Internal parser rule for expression stop at left brace.
// Implementation specific
Heritage: Internal compiler parsing logic.
// Parsed by parse_expression_internal()
Internal parser rule for expression internal.
// Implementation specific
Heritage: Internal compiler parsing logic.
// Parsed by parse_assignment_internal()
Internal parser rule for assignment internal.
// Implementation specific
Heritage: Internal compiler parsing logic.
// Parsed by parse_logical_or_internal()
Internal parser rule for logical or internal.
// Implementation specific
Heritage: Internal compiler parsing logic.
// Parsed by parse_logical_and_internal()
Internal parser rule for logical and internal.
// Implementation specific
Heritage: Internal compiler parsing logic.
// Parsed by parse_equality_internal()
Internal parser rule for equality internal.
// Implementation specific
Heritage: Internal compiler parsing logic.
// Parsed by parse_comparison_internal()
Internal parser rule for comparison internal.
// Implementation specific
Heritage: Internal compiler parsing logic.
// Parsed by parse_term_internal()
Internal parser rule for term internal.
// Implementation specific
Heritage: Internal compiler parsing logic.
// Parsed by parse_factor_internal()
Internal parser rule for factor internal.
// Implementation specific
Heritage: Internal compiler parsing logic.
// Parsed by parse_unary_internal()
Internal parser rule for unary internal.
// Implementation specific
Heritage: Internal compiler parsing logic.
// Parsed by parse_postfix_internal()
Internal parser rule for postfix internal.
// Implementation specific
Heritage: Internal compiler parsing logic.
// Parsed by parse_primary_internal()
Internal parser rule for primary internal.
// Implementation specific
Heritage: Internal compiler parsing logic.
expression;
Any expression followed by a semicolon becomes a statement that discards its value.
print("Hello");
calculate_result();
5 + 3;
Heritage: Statement-expression distinction from C-family languages.
variable = expression;
Assigns a new value to a mutable variable.
counter = counter + 1;
name = "New Name";
Heritage: Traditional assignment semantics with mutation restrictions.
return expression;
Returns a value from a function and exits the function immediately.
return 42;
return calculate_sum(a, b);
Heritage: Standard return statement from imperative programming languages.
{
// statements
}
Groups multiple statements together and creates a new scope.
{
let x = 5;
print(x);
}
Heritage: Block scoping from C-family languages with Rust-like scope rules.
i8, i16, i32, i64, u8, u16, u32, u64
Signed (i) and unsigned (u) integer types with explicit bit sizes.
let small: i8 = 127;
let big: u64 = 18446744073709551615;
Heritage: Explicit integer sizing from Rust for predictable memory usage.
f32, f64
IEEE 754 floating point numbers with 32-bit and 64-bit precision.
let pi: f64 = 3.14159;
let ratio: f32 = 0.5;
Heritage: Standard floating point types from systems programming languages.
bool
Boolean type with true and false values.
let is_ready: bool = true;
let finished: bool = false;
Heritage: Standard boolean type from most modern programming languages.
string
UTF-8 encoded string type for text data.
let message: string = "Hello, World!";
Heritage: String handling influenced by modern languages with UTF-8 by default.
plugins/
directory and the compiler will auto-load it at runtime.
class LanguagePlugin:
# ... implement plugin methods ...