Changeset 21992

Show
Ignore:
Timestamp:
10/23/08 22:12:01 (5 years ago)
Author:
mokehehe
Message:

ソース分類

Location:
lang/c/misc/mlisp
Files:
3 added
12 modified

Legend:

Unmodified
Added
Removed
  • lang/c/misc/mlisp/SExp.vcproj

    r21991 r21992  
    157157                        </File> 
    158158                        <File 
     159                                RelativePath=".\src\core\sstrm.h"> 
     160                        </File> 
     161                        <File 
    159162                                RelativePath=".\src\core\ssym.c"> 
    160163                        </File> 
    161164                        <File 
     165                                RelativePath=".\src\core\ssym.h"> 
     166                        </File> 
     167                        <File 
    162168                                RelativePath=".\src\core\stype.h"> 
     169                        </File> 
     170                        <File 
     171                                RelativePath=".\src\core\sutil.c"> 
     172                        </File> 
     173                        <File 
     174                                RelativePath=".\src\core\sutil.h"> 
    163175                        </File> 
    164176                </Filter> 
  • lang/c/misc/mlisp/src/core/inner.h

    r21991 r21992  
    1616#define NIL             MAKE_SPECIAL(0) 
    1717#define T               MAKE_SPECIAL(1) 
    18  
    19  
    20 // �V���{���e�[�u�� 
    21 void init_symbol_table(); 
    22 void term_symbol_table(); 
    2318 
    2419 
  • lang/c/misc/mlisp/src/core/s_eval.c

    r21991 r21992  
    44 
    55#include "sexp.h" 
     6#include "ssym.h" 
    67#include "inner.h" 
    78 
     
    1011#define TRUE    (1) 
    1112#endif 
    12  
    13  
    14 int evlis(SExp* buf, SExp ls, int b_eval) { 
    15         SExp p; 
    16         int n = 0; 
    17         // �����ׂĕ]�� 
    18         for (p = ls; !nilp(p); p = cdr(p)) { 
    19                 SExp v = car(p); 
    20                 if (b_eval) { 
    21                         buf[n] = eval(v); 
    22                 } else { 
    23                         buf[n] = v; 
    24                 } 
    25                 ++n; 
    26         } 
    27         return n; 
    28 } 
    29  
    30 SExp bind_arglist(SExp arglist, SExp values[], int n) { 
    31         SExp alist = nil; 
    32         SExp p; 
    33         int i; 
    34         for (p = arglist, i=0; !nilp(p) && i<n; p = cdr(p), ++i) { 
    35                 SExp sym = car(p); 
    36                 assert(type_of(sym) == tSym); 
    37                 alist = cons(cons(sym, values[i]), alist); 
    38         } 
    39         return alist; 
    40 } 
    4113 
    4214 
  • lang/c/misc/mlisp/src/core/s_print.c

    r21991 r21992  
    44 
    55#include "sexp.h" 
     6#include "sstrm.h" 
    67#include "inner.h" 
    78#include <stdio.h> 
  • lang/c/misc/mlisp/src/core/s_read.c

    r21991 r21992  
    44 
    55#include "sexp.h" 
     6#include "ssym.h" 
    67#include "inner.h" 
    78#include <stdio.h> 
  • lang/c/misc/mlisp/src/core/sexp.c

    r21991 r21992  
    1010//============================================================================= 
    1111 
     12#define __SEXP_C__ 
     13 
    1214#include "sexp.h" 
    13 #include "inner.h" 
    1415#include "smem.h" 
    1516#include "sutil.h" 
     17#include "sstrm.h" 
     18#include "ssym.h" 
     19#include "inner.h" 
    1620#include <string.h> 
    1721#include <assert.h> 
     
    2529SExp t = { T }; 
    2630 
     31void error(const char* msg, SExp a, SExp b, SExp c) { 
     32        fprintf(stderr, "%s\n", msg); 
     33        assert(!"error"); 
     34} 
     35 
    2736static void type_error() { 
    28         assert(FALSE); 
     37        error("type error", nil, nil, nil); 
    2938} 
    3039 
     
    5564} 
    5665 
    57 void error(const char* msg, SExp a, SExp b, SExp c) { 
    58         fprintf(stderr, "%s\n", msg); 
    59         assert(!"error"); 
    60 } 
    61  
    6266//============================================================================= 
    6367// �Z�� 
  • lang/c/misc/mlisp/src/core/sexp.h

    r21991 r21992  
    3535 
    3636 
    37 SExp intern(const char* str); 
    3837SExp gen_str(const char* str); 
    3938void rplaca(SExp s, SExp a); 
     
    4342extern SExp t; 
    4443 
    45 SExp make_file_stream(FILE* fp, const char* fn); 
    46  
    47 void write(SExp strm, const char* str); 
    48 void prin1(SExp s, SExp strm); 
    4944SExp read(SExp s); 
    5045SExp eval(SExp s); 
    5146 
     47#ifndef __SEXP_C__ 
    5248void error(const char* msg, ...); 
    53  
    54  
    55 void setq(SExp sym, SExp val); 
    56 SExp getvar(SExp sym); 
     49#endif 
    5750 
    5851SExp gen_specialform(SpecialFormType cfunc, const char* name); 
     
    6053SExp gen_lambda(SExp arglist, SExp body); 
    6154SExp gen_macro(SExp arglist, SExp body); 
    62  
    63 void push_env(SExp newenv); 
    64 void pop_env(void); 
    6555 
    6656//============================================================================= 
  • lang/c/misc/mlisp/src/core/smem.c

    r21991 r21992  
    4040#include <stdio.h> 
    4141#include "sexp.h" 
     42#include "sstrm.h" 
    4243#include "inner.h" 
    4344void smem_dump(void) { 
  • lang/c/misc/mlisp/src/core/sstream.c

    r21991 r21992  
    33//============================================================================= 
    44 
    5 #include "sexp.h" 
     5#include "sstrm.h" 
    66#include "smem.h" 
    77#include "inner.h" 
  • lang/c/misc/mlisp/src/core/ssym.c

    r21991 r21992  
    33//============================================================================= 
    44 
    5 #include "sexp.h" 
     5#include "ssym.h" 
    66#include "shash.h" 
    77#include "smem.h" 
     8#include "sstrm.h" 
     9#include "sutil.h" 
    810#include "inner.h" 
    911#include <string.h> 
     
    3840static SExp g_env; 
    3941 
    40 void init_symbol_table() { 
     42void init_symbol_table(void) { 
    4143        init_hash_table(&s_symbol_table, &s_symbol_vtbl); 
    4244        ht_resize(&s_symbol_table, SymbolHashBufSize); 
     
    4547} 
    4648 
    47 void term_symbol_table() { 
     49void term_symbol_table(void) { 
    4850        ht_free(&s_symbol_table); 
    4951} 
     
    7678} 
    7779 
    78  
    79 SExp assoc(SExp key, SExp ls) { 
    80         for (; !nilp(ls); ls = cdr(ls)) { 
    81                 SExp a = car(ls); 
    82                 if (eq(car(a), key)) { 
    83                         return a; 
    84                 } 
    85         } 
    86         return nil; 
    87 } 
    88  
    8980void push_env(SExp newenv) { 
    9081        g_env = cons(newenv, g_env); 
     
    10697        } 
    10798        return nil; 
    108 } 
    109  
    110 SExp last(SExp s) { 
    111         if (consp(s)) { 
    112                 for (;;) { 
    113                         SExp d = cdr(s); 
    114                         if (nilp(d))    return s; 
    115                         s = d; 
    116                 } 
    117         } else { 
    118                 return s; 
    119         } 
    12099} 
    121100 
  • lang/c/misc/mlisp/src/core/sutil.h

    r21991 r21992  
    11//============================================================================= 
    2 ///     �������֘A 
     2///     ���[�e�B���e�B 
    33//============================================================================= 
    44 
     
    1212#endif 
    1313 
     14SExp last(SExp s); 
     15 
     16SExp assoc(SExp key, SExp ls); 
     17 
    1418int evlis(SExp* buf, SExp ls, int b_eval); 
    1519 
  • lang/c/misc/mlisp/src/test/main.cpp

    r21991 r21992  
    11#include "sexp.h" 
     2#include "ssym.h" 
     3#include "sstrm.h" 
    24#include "smem.h" 
    35#include <stdio.h>