cons.hpp File Reference

#include "Cell.hpp"
#include <string>
#include <iostream>

Go to the source code of this file.

Functions

Cellmake_int (int i)
 Make an int cell.
Cellmake_double (double d)
 Make a double cell.
Cellmake_symbol (const char *s)
 Make a symbol cell.
Cellcons (const Cell *my_car, const Cell *my_cdr)
 Make a conspair cell.
bool nullp (const Cell *c)
 Check if c points to an empty list, i.e., is a null pointer.
bool listp (const Cell *c)
 Check if c points to a list (i.e., nil or a cons cell).
bool intp (const Cell *c)
 Check if c points to an int cell.
bool doublep (const Cell *c)
 Check if c points to a double cell.
bool symbolp (const Cell *c)
 Check if c points to a symbol cell.
int get_int (const Cell *c)
 Accessor (error if c is not an int cell).
double get_double (const Cell *c)
 Accessor (error if c is not a double cell).
std::string get_symbol (const Cell *c)
 Retrieve the symbol name as a string (error if c is not a symbol cell).
Cellcar (const Cell *c)
 Accessor (error if c is not a cons cell).
Cellcdr (const Cell *c)
 Accessor (error if c is not a string cell).
std::ostream & operator<< (std::ostream &os, const Cell &c)
 Print the subtree rooted at c, in s-expression notation.

Variables

const Cellnil
 The null pointer value.


Detailed Description

Encapsulates an abstract interface layer for a cons list ADT, without using member functions. Makes no assumptions about what kind of concrete type Cell will be defined to be.

Function Documentation

Cell* car ( const Cell c  )  [inline]

Accessor (error if c is not a cons cell).

Returns:
The car pointer in the cons cell pointed to by c.

References Cell::get_car().

Referenced by separate_parse().

Cell* cdr ( const Cell c  )  [inline]

Accessor (error if c is not a string cell).

Returns:
The cdr pointer in the cons cell pointed to by c.

References Cell::get_cdr().

Referenced by separate_parse().

Cell* cons ( const Cell my_car,
const Cell my_cdr 
) [inline]

Make a conspair cell.

Parameters:
my_car The initial car pointer to be stored in the new cell.
my_cdr The initial cdr pointer to be stored in the new cell.

Referenced by separate_parse().

bool doublep ( const Cell c  )  [inline]

Check if c points to a double cell.

Returns:
True iff c points to a double cell.

References Cell::is_double(), and nullp().

double get_double ( const Cell c  )  [inline]

Accessor (error if c is not a double cell).

Returns:
The value in the double cell pointed to by c.

References Cell::get_double().

int get_int ( const Cell c  )  [inline]

Accessor (error if c is not an int cell).

Returns:
The value in the int cell pointed to by c.

References Cell::get_int().

std::string get_symbol ( const Cell c  )  [inline]

Retrieve the symbol name as a string (error if c is not a symbol cell).

Returns:
The symbol name in the symbol cell pointed to by c.

References Cell::get_symbol().

bool intp ( const Cell c  )  [inline]

Check if c points to an int cell.

Returns:
True iff c points to an int cell.

References Cell::is_int(), and nullp().

bool listp ( const Cell c  )  [inline]

Check if c points to a list (i.e., nil or a cons cell).

Returns:
True iff c points to a list (i.e., nil or a cons cell).

References Cell::is_cons(), and nullp().

Cell* make_double ( double  d  )  [inline]

Make a double cell.

Parameters:
d The initial double value to be stored in the new cell.

Referenced by makecell().

Cell* make_int ( int  i  )  [inline]

Make an int cell.

Parameters:
i The initial int value to be stored in the new cell.

Referenced by makecell().

Cell* make_symbol ( const char *  s  )  [inline]

Make a symbol cell.

Parameters:
s The initial symbol name to be stored in the new cell.

Referenced by makecell().

bool nullp ( const Cell c  )  [inline]

Check if c points to an empty list, i.e., is a null pointer.

Returns:
True iff c points to an empty list, i.e., is a null pointer.

Referenced by doublep(), intp(), listp(), and symbolp().

std::ostream& operator<< ( std::ostream &  os,
const Cell c 
) [inline]

Print the subtree rooted at c, in s-expression notation.

Parameters:
os The output stream to print to.
c The root cell of the subtree to be printed.

References Cell::print().

bool symbolp ( const Cell c  )  [inline]

Check if c points to a symbol cell.

Returns:
True iff c points to a symbol cell.

References Cell::is_symbol(), and nullp().


Variable Documentation

const Cell* nil

The null pointer value.

Referenced by parse_eval_print().


Generated on Tue Feb 25 15:59:39 2014 for a1 by  doxygen 1.5.8