Language Overview
The Mini-Compilador Educativo uses a simple imperative language with two primary statement types: variable declarations and print statements. Programs are composed of sequences of these statements, each terminated with a semicolon.Basic Syntax
Variable Declarations
Declare variables using thelet keyword:
All variables must be declared before they can be used in expressions.
Print Statements
Output values using theprint keyword:
Expressions and Operators
Arithmetic Operators
The language supports four basic arithmetic operators with standard precedence:Addition (+)
Adds two values
Subtraction (-)
Subtracts the right operand from the left
Multiplication (*)
Multiplies two values
Division (/)
Integer division (result is truncated)
Operator Precedence
Operators follow standard mathematical precedence rules:- Parentheses
()- Highest priority - Multiplication and Division
*,/ - Addition and Subtraction
+,-- Lowest priority
Using Parentheses
Use parentheses to override default precedence:Data Types
Numbers
The language supports integer literals only:Variables
Variable names (identifiers) must:- Start with a letter (a-z, A-Z) or underscore (_)
- Contain only letters, digits, and underscores
- Not be a reserved word
Reserved Words
The following keywords are reserved:let- Variable declarationprint- Output statementleo- Reserved (no operation)diego- Reserved (no operation)
The keywords
leo and diego are recognized by the lexer but have no semantic effect. They’re included as educational examples of reserved words.Comments
Single-line comments start with//:
Complete Program Examples
Example 1: Basic Arithmetic
Example 2: Expression Evaluation
Example 3: Multi-step Calculation
Best Practices
Use descriptive variable names
Use descriptive variable names
Choose names that indicate the variable’s purpose:
Declare variables before use
Declare variables before use
Always declare variables with
let before referencing them:Use parentheses for clarity
Use parentheses for clarity
Even when not required, parentheses improve readability:
Add comments to explain logic
Add comments to explain logic
Document complex calculations:
Avoid division by zero
Avoid division by zero
The compiler detects division by literal zero:
Common Errors
Syntax Errors
Semantic Errors
Next Steps
Using the CLI
Learn how to compile programs from the command line
Using the GUI
Use the graphical interface to write and compile programs
Interpreting Output
Understand the compiler’s output and error messages
Grammar Reference
Complete language specification and grammar