Welcome to Expresiones
Expresiones is a complete compiler and interpreter implementation built with ANTLR4, designed to demonstrate fundamental compiler construction principles including lexical analysis, syntax parsing, semantic analysis, and expression evaluation. The language supports variable declarations with type checking, arithmetic expressions with proper operator precedence, conditional control flow, and comprehensive logical operations.Key Features
ANTLR4 Grammar
Complete grammar definition with lexical and syntactic rules for robust language parsing
Type System
Support for int, float, and bool types with compile-time type checking
Expression Evaluation
Arithmetic expressions with correct operator precedence and parentheses support
Control Flow
Conditional statements (if-else) with relational and logical operators
Symbol Table
Complete symbol table management for tracking variable declarations and values
Visitor Pattern
Clean implementation of the visitor pattern for AST traversal and semantic analysis
Quick Example
Here’s a simple program written in the Expresiones language:example.txt
How It Works
The compiler processes source code through several stages:Lexical Analysis
The ExpresionesLexer tokenizes the input source code into a stream of tokens based on the grammar rules.
Syntax Parsing
The ExpresionesParser analyzes the token stream and builds an Abstract Syntax Tree (AST) according to the grammar’s syntactic rules.
Semantic Analysis
The Visitor traverses the AST, performing type checking, variable scope validation, and building the symbol table.
Next Steps
Installation
Set up ANTLR4 and Python dependencies to run the compiler
Quick Start
Write and execute your first Expresiones program
Language Reference
Learn the complete syntax and semantics of the language
Architecture
Understand the compiler’s internal architecture and design