| 1 | /*---------------------------------------------------------------------------- |
| 2 | ChucK Strongly-timed Audio Programming Language |
| 3 | Compiler, Virtual Machine, and Synthesis Engine |
| 4 | |
| 5 | Copyright (c) 2003 Ge Wang and Perry R. Cook. All rights reserved. |
| 6 | http://chuck.stanford.edu/ |
| 7 | http://chuck.cs.princeton.edu/ |
| 8 | |
| 9 | This program is free software; you can redistribute it and/or modify |
| 10 | it under the dual-license terms of EITHER the MIT License OR the GNU |
| 11 | General Public License (the latter as published by the Free Software |
| 12 | Foundation; either version 2 of the License or, at your option, any |
| 13 | later version). |
| 14 | |
| 15 | This program is distributed in the hope that it will be useful and/or |
| 16 | interesting, but WITHOUT ANY WARRANTY; without even the implied warranty |
| 17 | of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 18 | MIT Licence and/or the GNU General Public License for details. |
| 19 | |
| 20 | You should have received a copy of the MIT License and the GNU General |
| 21 | Public License (GPL) along with this program; a copy of the GPL can also |
| 22 | be obtained by writing to the Free Software Foundation, Inc., 59 Temple |
| 23 | Place, Suite 330, Boston, MA 02111-1307 U.S.A. |
| 24 | -----------------------------------------------------------------------------*/ |
| 25 | |
| 26 | //----------------------------------------------------------------------------- |
| 27 | // file: chuck_symbol.h |
| 28 | // desc: symbols in the syntax, adapted from Tiger compiler by Appel Appel |
| 29 | // |
| 30 | // author: Ge Wang ([email protected] | [email protected]) |
| 31 | // adapted from: Andrew Appel ([email protected]) |
| 32 | // date: Autumn 2002 |
| 33 | //----------------------------------------------------------------------------- |
| 34 | #ifndef __CHUCK_SYMBOL_H__ |
| 35 | #define __CHUCK_SYMBOL_H__ |
| 36 | |
| 37 | #include "chuck_def.h" |
| 38 | |
| 39 | |
| 40 | #if defined(_cplusplus) || defined(__cplusplus) |
| 41 | extern "C" { |
| 42 | #endif |
| 43 | |
| 44 | |
| 45 | typedef struct S_Symbol_ * S_Symbol; |
| 46 | |
| 47 | /* Make a unique symbol from a given c_str. |
| 48 | * Different calls to make_symbol("foo") will yield the same S_Symbol |
| 49 | * value, even if the "foo" c_str are at different locations. */ |
| 50 | S_Symbol insert_symbol( c_constr ); |
| 51 | |
| 52 | /* Extract the underlying c_str from a symbol */ |
| 53 | c_str S_name(S_Symbol); |
| 54 | |
| 55 | /* S_table is a mapping from S_Symbol->any, where "any" is represented |
| 56 | * here by void* */ |
| 57 | typedef struct TAB_table_ *S_table; |
| 58 | |
| 59 | /* Make a new table */ |
| 60 | S_table S_empty(void); |
| 61 | S_table S_empty2(unsigned int size); |
| 62 | |
| 63 | /* Enter a binding "sym->value" into "t", shadowing but not deleting |
| 64 | * any previous binding of "sym". */ |
| 65 | void S_enter(S_table t, S_Symbol sym, void * value); |
| 66 | void S_enter2(S_table t, c_constr str, void * value); |
| 67 | |
| 68 | /* Look up the most recent binding of "sym" in "t", or return NULL |
| 69 | * if sym is unbound. */ |
| 70 | void * S_look(S_table t, S_Symbol sym); |
| 71 | void * S_look2(S_table t, c_constr str); |
| 72 | |
| 73 | /* Start a new "scope" in "t". Scopes are nested. */ |
| 74 | void S_beginScope(S_table t); |
| 75 | |
| 76 | /* Remove any bindings entered since the current scope began, |
| 77 | and end the current scope. */ |
| 78 | void S_endScope(S_table t); |
| 79 | void S_pop(S_table t); |
| 80 | |
| 81 | |
| 82 | #if defined(_cplusplus) || defined(__cplusplus) |
| 83 | } |
| 84 | #endif |
| 85 | |
| 86 | |
| 87 | |
| 88 | |
| 89 | // moved here from archaic chuck_utils.h | 1.5.2.0 (ge) |
| 90 | #if defined(_cplusplus) || defined(__cplusplus) |
| 91 | extern "C" { |
| 92 | #endif |
| 93 | |
| 94 | |
| 95 | typedef struct U_boolList_ * U_boolList; |
| 96 | struct U_boolList_ |
| 97 | { |
| 98 | t_CKBOOL head; |
| 99 | U_boolList tail; |
| 100 | }; |
| 101 | |
| 102 | |
| 103 | void * checked_malloc( t_CKINT size ); |
| 104 | c_str cc_str( char * ); |
| 105 | U_boolList U_BoolList( t_CKBOOL head, U_boolList tail ); |
| 106 | |
| 107 | |
| 108 | #if defined(_cplusplus) || defined(__cplusplus) |
| 109 | } |
| 110 | #endif |
| 111 | |
| 112 | |
| 113 | |
| 114 | #endif |