microScheme
Functions
main.cpp File Reference
#include <stdexcept>
#include "parse.hpp"
#include "eval.hpp"
#include <sstream>

Functions

void parse_eval_print (string sexpr)
 Parse and evaluate the s-expression, and print the result. More...
 
void readsinglesymbol (ifstream &fin, string &str)
 Read single single symbol into the end of a string buffer. More...
 
void readfile (ifstream &fin)
 Read, parse, evaluate, and print the expression one by one from the input stream. More...
 
void readfile (char *fn)
 Read the expressions from the file. More...
 
void readconsole ()
 Read, parse, evaluate, and print the expression one by one from the standard input, interactively. More...
 
int main (int argc, char *argv[])
 Call either the batch or interactive main drivers. More...
 

Detailed Description

Driver code implementing the main read-parse-eval-print loop. Supports both (1) an interactive mode, and (2) a batch mode where input expressions are read from the file specified by the first command-line argument.

Function Documentation

int main ( int  argc,
char *  argv[] 
)

Call either the batch or interactive main drivers.

References readconsole(), and readfile().

void parse_eval_print ( string  sexpr)

Parse and evaluate the s-expression, and print the result.

Parameters
sexprThe string vaule holding the s-expression.

References eval(), and parse().

Referenced by readconsole(), and readfile().

void readconsole ( )

Read, parse, evaluate, and print the expression one by one from the standard input, interactively.

References parse_eval_print().

Referenced by main().

void readfile ( ifstream &  fin)

Read, parse, evaluate, and print the expression one by one from the input stream.

Parameters
finThe input file stream.

References iswhitespace(), parse_eval_print(), and readsinglesymbol().

Referenced by main(), and readfile().

void readfile ( char *  fn)

Read the expressions from the file.

Parameters
fnThe file name.

References readfile().

void readsinglesymbol ( ifstream &  fin,
string &  str 
)

Read single single symbol into the end of a string buffer.

Parameters
finThe input file stream.
strThe string buffer.

References iswhitespace().

Referenced by readfile().