muse_port.c File Reference

#include "muse_port.h"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

Include dependency graph for muse_port.c:


Data Structures

struct  ez_result_t
struct  white_space_t

Pretty print support.

enum  { MAX_INDENT_COLS = 128 }
static void pretty_printer_reset (muse_port_t p)
static void pretty_printer_indent ()
static void pretty_printer_unindent ()
static void pretty_printer_line_break (muse_port_t f)
static void pretty_printer_move (int numc)
static int g_align_cols [MAX_INDENT_COLS]
static int g_align_level = 0
static muse_boolean g_pretty_printer_enabled = MUSE_TRUE
static int g_tab_size = 4

Ports implementation API

void port_init (muse_port_base_t *p)
 Intended to be called inside a particular port's init function at port creation time.
void port_destroy (muse_port_base_t *p)
 Intended to be called inside a particular ports destroy function at port destruction time.
int port_getc (muse_port_base_t *p)
 Same protocol as the system getc function, but works with the given port.
int port_ungetc (int c, muse_port_base_t *p)
 Same protocol as the system ungetc function.
int port_putc (int c, muse_port_base_t *p)
 Same protocol as the system putc function.
int port_eof (muse_port_base_t *port)
 Returns EOF if the port has reached end of stream.
void port_close (muse_port_base_t *p)
 Flushes the port and call's the port's close function to release system resources.
size_t port_read (void *buffer, size_t nbytes, muse_port_base_t *port)
 Wraps the port specific read function.
size_t port_write (void *buffer, size_t nbytes, muse_port_base_t *port)
 Wraps the port specific write function.
int port_flush (muse_port_base_t *port)
 Writes any data pending in the port's output buffer and then calls the port-specific flush function.

ezscheme structures

int ez_update_col (int ch, int col)
static ez_result_t ez_result (muse_cell expr, int col_start, int col_end)
ez_result_t ez_parse (muse_port_t p, int col, muse_boolean is_head)
 Indentation dependent parsing of expressions - ezscheme.
muse_cell ez_parse_expr (muse_port_t p)

Defines

#define portfn(p, fn)   ((muse_port_type_t*)((muse_functional_object_t*)p)->type_info)->fn

Enumerations

enum  {
  PORT_BUFFER_SIZE = 4096,
  PORT_BUFFER_MASK = PORT_BUFFER_SIZE - 1,
  PORT_BUFFER_UNGET_SIZE = 16
}
enum  {
  PARSE_EOF = -1000,
  PARSE_ERROR = -1001,
  PARSE_ERROR_BUFFER_OVERFLOW = -1002,
  PARSE_ERROR_EXPECTED_STRING = -1003,
  PARSE_ERROR_EXPECTED_LIST = -1004,
  PARSE_ERROR_BAD_CONS_SYNTAX = -1005,
  PARSE_ERROR_EXPECTED_SYMBOL = -1006,
  PARSE_EMPTY_GROUP = -10000,
  PARSE_END_OF_GROUP = -10001,
  PARSE_END_OF_LIST = -10002,
  PARSE_LIST_ITEM_SEPARATOR = -10003
}

Functions

static void port_init_buffer (muse_port_buffer_t *buffer)
static void port_destroy_buffer (muse_port_buffer_t *buffer)
static int peekc (muse_port_t f)
white_space_t ez_skip_whitespace (muse_port_t f, int line, int col)
 Skips all white space and comments following the current stream position in the given stream Returns the column position at which the next non-white space character starts.
static int _token_begin_list (int c)
static int _token_end_list (int c)
static ez_result_t _read_number (muse_port_t f, int col)
 Reads a decimal number starting from the current stream position.
static int hex (int c)
static ez_result_t _read_hex (muse_port_t f, int col)
 Reads a hexadecimal number starting from the current stream position.
static ez_result_t _read_string (muse_port_t f, int col)
 Reads and returns the next string delimited by double quote characters.
static muse_boolean is_symbol_char (int c)
static ez_result_t _read_symbol (muse_port_t f, int col)
 Reads a symbol from the current stream position.
static ez_result_t _read_atom (muse_port_t f, int col)
 An atom is a number, symbol or a string.
static muse_cell _read_list (muse_port_t f)
 Reads a list delimited by parentheses.
static muse_boolean is_macro_sexpr (muse_cell sexpr)
 Returns MUSE_TRUE if the given sexpr is a macro expression.
muse_cell muse_pread (muse_port_t f)
 Reads the next symbolic expression at the current stream position, ignoring white space and comment lines.
static void muse_print_q (muse_port_t f, muse_cell sexpr, muse_boolean quote)
 Prints the given s-expr to the given stream.
static void muse_print_int (muse_port_t f, muse_cell i)
static void muse_print_float (muse_port_t s, muse_cell f)
static size_t muse_print_text (muse_port_t f, muse_cell t, muse_boolean quote)
static void muse_print_list (muse_port_t f, muse_cell l, muse_boolean quote)
static void muse_print_sym (muse_port_t f, muse_cell s)
static void muse_print_lambda (muse_port_t f, muse_cell l, muse_boolean quote)
static void muse_print_nativefn (muse_port_t f, muse_cell l)
void muse_pprint (muse_port_t port, muse_cell sexpr)
void muse_pwrite (muse_port_t f, muse_cell sexpr)
 Writes the given s-expression to the given stream.
muse_port_t muse_port (muse_cell p)
 Takes a muSE port represented as a cell and returns the internal port object that it uses.
static ez_result_t ez_expr (muse_cell expr, int col_start, int col_end)
ez_result_t ez_parse_atom (muse_port_t p, int col)
 A ezscheme atom is a normal scheme atom - symbol, number, string.
ez_result_t ez_parse_group (muse_port_t p, int col)
 An ezscheme group is an expression enclosed in parentheses.
ez_result_t ez_parse_list (muse_port_t p, int col)
 An ezscheme list is a bunch of stuff enclosed in square brackets - [].
static muse_boolean is_operator (const muse_char *name)
 An ezscheme operator is any symbol that does not have alphanumeric characters or underscores.
static muse_boolean is_data_cell (muse_cell c)

Detailed Description

Author:
Srikumar K. S. (mailto:kumar@muvee.com)
Copyright (c) 2006 Jointly owned by Srikumar K. S. and muvee Technologies Pte. Ltd.

All rights reserved. See LICENSE.txt distributed with this source code or http://muvee-symbolic-expressions.googlecode.com/svn/trunk/LICENSE.txt for terms and conditions under which this software is provided to you.


Function Documentation

static ez_result_t ez_expr ( muse_cell  expr,
int  col_start,
int  col_end 
) [static]

ez_result_t ez_parse_atom ( muse_port_t  p,
int  col 
)

A ezscheme atom is a normal scheme atom - symbol, number, string.

ez_result_t ez_parse_group ( muse_port_t  p,
int  col 
)

An ezscheme group is an expression enclosed in parentheses.

ezscheme uses parentheses to "group" as opposed to defining function heads. This means that enclosing an expression in multiple set of parentheses has no effect compared to just usig a single set - i.e. (hello) is exactly the same as (((hello))).

ez_result_t ez_parse_list ( muse_port_t  p,
int  col 
)

An ezscheme list is a bunch of stuff enclosed in square brackets - [].

For example, [a,b,c,d]

static muse_boolean is_operator ( const muse_char name  )  [static]

An ezscheme operator is any symbol that does not have alphanumeric characters or underscores.

static muse_boolean is_data_cell ( muse_cell  c  )  [static]


Generated on Mon Sep 25 23:12:47 2006 for muSE by  doxygen 1.4.7