Interpreter¶
Language: Español | English
The Crespi interpreter (crespi) runs your code directly without compilation. It's ideal for development, learning, and scripting.
Quick Start¶
# Run a file
crespi program.crespi
# Run code directly
crespi -c 'print("Hello, World!")'
# Start interactive REPL
crespi
Execution Modes¶
Run File¶
crespi my_program.crespi
Executes the file and displays output in the terminal.
Type Check (Optional)¶
crespi --check my_program.crespi
Runs the static type checker before execution and exits on errors.
Inline Code¶
crespi -c 'var x = 5; print(x * 2)'
Useful for quick tests without creating files.
Interactive REPL¶
crespi
# or explicitly:
crespi repl
The REPL (Read-Eval-Print Loop) lets you write and execute code line by line:
Crespi REPL v0.0.1
Type 'exit' to exit
>>> var name = "Ana"
>>> print("Hello, " + name)
Hello, Ana
>>> exit
Debugging Commands¶
View Tokens¶
crespi tokens program.crespi
Shows tokens generated by the lexer:
Token { kind: Var, lexeme: "var", ... }
Token { kind: Identifier, lexeme: "x", ... }
Token { kind: Equal, lexeme: "=", ... }
...
View AST¶
crespi ast program.crespi
Shows the abstract syntax tree generated by the parser.
CLI Reference¶
| Command | Description |
|---|---|
crespi <file> |
Run a file |
crespi -c <code> |
Run inline code |
crespi repl |
Start interactive REPL |
crespi tokens <file> |
Show lexer tokens |
crespi ast <file> |
Show syntax tree |
crespi --check <file> |
Run type checker before execution |
crespi --help |
Show help |
crespi --version |
Show version |
Supported Features¶
The interpreter supports all language features:
- Variables and constants
- All data types (including dictionaries)
- Control flow:
if,while,for - Functions and closures
- Classes with inheritance
- Decorators (
@memoize) - Tail-call optimization (TCO)
When to Use the Interpreter¶
| Use Case | Recommendation |
|---|---|
| Development and testing | ✅ Interpreter |
| Learning the language | ✅ Interpreter |
| Quick scripts | ✅ Interpreter |
| Using dictionaries | ✅ Interpreter (only option) |
| Distributing executables | ❌ Use compiler |
| Maximum performance | ❌ Use compiler |
See Also¶
- Native Compiler - Compile to executables
- Variables - Data types and variables
- Functions - Defining and using functions