Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ashton314/mini_scheme
A tiny implementation of the Scheme programming language: the core written in Perl, and the auxiliary functions written in Scheme itself. The interpreter uses the syntactic analysis method of evaluation outlined in "Structure and Interpretation of Computer Programs" (Sussman et al)
https://github.com/ashton314/mini_scheme
metacircular-interpreter perl scheme scheme-interpreter syntactic-analysis
Last synced: 4 days ago
JSON representation
A tiny implementation of the Scheme programming language: the core written in Perl, and the auxiliary functions written in Scheme itself. The interpreter uses the syntactic analysis method of evaluation outlined in "Structure and Interpretation of Computer Programs" (Sussman et al)
- Host: GitHub
- URL: https://github.com/ashton314/mini_scheme
- Owner: ashton314
- Created: 2012-11-23T22:41:18.000Z (about 12 years ago)
- Default Branch: master
- Last Pushed: 2017-02-28T06:14:57.000Z (almost 8 years ago)
- Last Synced: 2025-01-29T02:57:18.734Z (4 days ago)
- Topics: metacircular-interpreter, perl, scheme, scheme-interpreter, syntactic-analysis
- Language: Perl
- Homepage:
- Size: 147 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.pod
Awesome Lists containing this project
README
=head1 NAME
Mini Scheme -- A science project
=head1 DESCRIPTION
Load syntactic analyzer implementation:
perl scheme.pl [-quiet] [-no-init] [-no-stats] [-echo-file ] [-load ] [-init-file ]
Load metacircular evaluator implementation:
perl metacircular.pl [-quiet] [-no-init] [-no-stats] [-echo-file ] [-load ] [-init-file ]
=head1 BACKGROUND
This is for a science project that I am doing. The abstract of my project:
=over 2
B
Studying the Effects of a Syntactic Analyzer on Scheme Program Execution Time
B
In the MIT introductory book to computer programming, Structure and
Interpretation of Computer Programs, the outline for a simple Scheme
interpreter is given. In following sections, enhancements are made to
this interpreter. One of the most radical changes to the interpreter
is done by separating syntactic analysis of a Scheme expression from
the execution of the same. According to the authors, this greatly
improves execution times.The purpose of this experiment is to study the effects of a syntactic
analyzer on run time. We believe that if a syntactic analyzer is used
before evaluation of Scheme code, a great increase in speed will be
observed.=back
For the full, up-to-date lab report, see the doc/ directory in this
project.=head1 METACIRCULAR VS. SYNTACTIC ANALYZER
In chapter 4 of I,
the authors describe a simple scheme interpreter. In subsequent
sections, enhancements are made to this interpreter. The two main
versions of interpreters are "metacircular" interpreters and "syntactic
analyzers".=head2 METACIRCULAR
TODO: Write how a metacircular evaluator works.
=head2 SYNTACTIC ANALYZER
TODO: Write how a syntactic analyzer works.
=head1 CONTROL FLAGS
=over 4
=item quiet
When this flag is present, load messages are silenced.
=item no-init
When this flag is present, the init file in F is not loaded.
=item no-stats
When this flag present, memory statistics are suppressed.
=item load
Takes a filename and loads it immediately after loading the L and printing the memory statistics.
=item echo-file
This takes a file name to output memory statistics.
=item init-file
Takes a alternate L to load. Default is F in the working directory.
=back
=head1 KNOWN ISSUES
=over 4
=item *
No hygienic macro system.
=item *
The numeric tower is not implemented. All number types are snarfed directly from Perl.
=item *
STRING is a special form. This is purely for ease of implementation.
=item *
The following features are adapted from CMU Common Lisp:
=over 4
=item *
NIL is a symbol.
=back
=item *
No tail-call optimizations.
=item *
Next to no type checking.
=item *
Next to no error checking.
=back
=head1 FEATURES
=over 4
=item Init file
The default init file is init.scm in the working directory. An alternate file may be specified with the L-init-file> option.
=item Lexical Addressing
This cut down my execution times by about 50%. Big win.
=back
=head1 FEATURES TO ADD
When I get around to it, I'll try to add these things in:
=over 4
=item Debugger
B maybe.
=back
=head1 TODO
=over 4
=item *
I think I could optimize memory in the following manner: because of
syntactic analysis, we can know what variables are going to be needed
in a given expression. We can use this to do two things: warn the user
when there is a variable that is not used, and optimize which
variables get saved in a closure environment.=item *
I I be able to replace the Cons class with some more low-level
managing of hashes. This might make it a bit more difficult to
distinguish between different data types, but it might make my data
structures operate a bit faster. I think I might be able to get a big
speed gain out of this.=back
=head1 BUGS
=over 4
=item *
DOTimes is not working in the metacircular interpreter. Big problem.
=item *
Macros are not inserted into the global enviroment. This allows for
namespace collision. If a symbol, defined as a macro, is defined as a
function, the macro will be expanded, to the confusion of the
programmer. Also, a symbol may be a variable without
conflict.I could add checking for this in variable/function lookups,
definitions, and assignments.=item *
The Cons package may have self-referential data structures, not
allowing the garbage collector to reallocate memory so consumed.=item *
Too slow. I'm looking for optimizations.
=item *
NIL really needs some clean-up.
=item *
Backquote does not handle dotted tail notation properly.
=back
=head1 AUTHOR
Ashton Wiersdorf