Overview
simple_eiffel_parser is a recursive descent parser that extracts structural information from Eiffel source code. It's designed for IDE tooling, code analysis, and documentation generation - not compilation.
Built as a dependency for simple_lsp, this parser provides the symbol extraction needed for hover documentation, go-to-definition, code completion, and document outline features.
What It Extracts
Class Declarations
Deferred, expanded, frozen classes with header comments.
Feature Signatures
Arguments, return types, and export status for all features.
Contracts
Preconditions (require) and postconditions (ensure) as text.
Inheritance
Parent classes with rename, redefine, undefine, and select clauses.
Local Variables
Local variable declarations with types and line numbers.
Error Recovery
Continues parsing after errors, returns partial results.
API Design
simple_eiffel_parser follows Design by Contract principles:
parse_file
Parse an Eiffel source file and return the abstract syntax tree.
Contracts
parse_string
Parse Eiffel source code from a string.
Contracts
Architecture
The parser consists of 11 classes totaling 2,327 lines of Eiffel code:
| Class | Lines | Purpose |
|---|---|---|
| SIMPLE_EIFFEL_PARSER | 107 | Facade class |
| EIFFEL_PARSER | 871 | Recursive descent parser |
| EIFFEL_LEXER | 436 | Tokenizer |
| EIFFEL_TOKEN | 160 | Token definitions |
| EIFFEL_CLASS_NODE | 155 | Class representation |
| EIFFEL_FEATURE_NODE | 265 | Feature representation |
| EIFFEL_PARENT_NODE | 88 | Inheritance representation |
| EIFFEL_AST | 64 | AST container |
| EIFFEL_ARGUMENT_NODE | 47 | Argument representation |
| EIFFEL_LOCAL_NODE | 47 | Local variable representation |
| EIFFEL_PARSE_ERROR | 87 | Error representation |
Building from Source
Prerequisites
- EiffelStudio 25.02+
- simple_file library
- simple_regex library
Build Commands
# Set environment variables
export SIMPLE_EIFFEL_PARSER=/path/to/simple_eiffel_parser
export SIMPLE_FILE=/path/to/simple_file
export SIMPLE_REGEX=/path/to/simple_regex
# Compile and run tests
ec.exe -batch -config simple_eiffel_parser.ecf -target simple_eiffel_parser_tests -c_compile
./EIFGENs/simple_eiffel_parser_tests/W_code/simple_eiffel_parser.exe