Guido Biosca

Mini Scheme Interpreter

Developed using Python and ANTLR as a part of a functional programming project.

Overview

This project implements an interpreter for a simplified version of the Scheme language, derived from Lisp. It supports key features such as basic arithmetic operations, function definitions, list management, and control structures. The interpreter is built using Python and ANTLR, providing a robust foundation for functional programming exploration.

Key Features

Implementation Details

The interpreter leverages Python and ANTLR for parsing and executing Scheme expressions. Key components include:

The system supports nested expressions, recursive calls, and robust error handling, ensuring accurate execution of Scheme programs.

Grammar

grammar scheme;

root : expr* EOF;

expr
    : ( ''(' | '(' ) expr* ')' #expression
    | BOOLEAN #bool
    | NUMBER #num
    | IDENTIFIER #id
    | OPERATOR #op
    | STRING #str
    ;

OPERATOR: '+'|'-'|'*'|'/'|'<'|'>'|'='|'<='|'>='|'and'|'or'|'not'|'mod';
IDENTIFIER: [a-zA-Z][a-zA-Z0-9\-]* '?'?;
NUMBER : '-'? [0-9]+ ;
BOOLEAN : '#t' | '#f';
STRING : '"' .*? '"';
WS  : [ \t\n]+ -> skip;
COMMENT: ';' .*? '\n' -> skip;

      

Explore More