simple_eiffel_parser

Lightweight Eiffel Source Code Parser

v0.1.0 MIT Complete

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_file (a_path: STRING): EIFFEL_AST

Parse an Eiffel source file and return the abstract syntax tree.

Contracts

require: a_path /= Void and then not a_path.is_empty
ensure: Result /= Void

parse_string

parse_string (a_source: STRING): EIFFEL_AST

Parse Eiffel source code from a string.

Contracts

require: a_source /= Void
ensure: Result /= Void

Architecture

The parser consists of 11 classes totaling 2,327 lines of Eiffel code:

ClassLinesPurpose
SIMPLE_EIFFEL_PARSER107Facade class
EIFFEL_PARSER871Recursive descent parser
EIFFEL_LEXER436Tokenizer
EIFFEL_TOKEN160Token definitions
EIFFEL_CLASS_NODE155Class representation
EIFFEL_FEATURE_NODE265Feature representation
EIFFEL_PARENT_NODE88Inheritance representation
EIFFEL_AST64AST container
EIFFEL_ARGUMENT_NODE47Argument representation
EIFFEL_LOCAL_NODE47Local variable representation
EIFFEL_PARSE_ERROR87Error representation

Building from Source

Prerequisites

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