Developed using Python and ANTLR as a part of a functional programming project.
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.
car
, cdr
, cons
, and null?
.if
and cond
.read
, display
, and newline
.let
.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 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;