1 /*----------------------------------------------------------------------------
2 ChucK Concurrent, On-the-fly Audio Programming Language
3 Compiler and Virtual Machine
5 Copyright (c) 2004 Ge Wang and Perry R. Cook. All rights reserved.
6 http://chuck.cs.princeton.edu/
7 http://soundlab.cs.princeton.edu/
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
23 -----------------------------------------------------------------------------*/
25 //-----------------------------------------------------------------------------
26 // file: chuck_parse.h
27 // desc: chuck parser interface (using flex and bison)
29 // author: Ge Wang (gewang@cs.princeton.edu)
30 // Perry R. Cook (prc@cs.princeton.edu)
31 // date: Autumn 2002 - original in chuck_main.cpp
32 // Autumn 2005 - this file
33 //-----------------------------------------------------------------------------
34 #ifndef __CHUCK_PARSE_H__
35 #define __CHUCK_PARSE_H__
37 #include "chuck_def.h"
38 #include "chuck_absyn.h"
44 // 'C' specification necessary for windows to link properly
45 #ifdef __PLATFORM_WIN32__
46 extern "C" a_Program g_program
;
48 extern a_Program g_program
;
51 // link with the parser
52 extern "C" int yyparse( void );
53 extern "C" void yyrestart( FILE * );
55 struct yy_buffer_state
;
56 typedef yy_buffer_state
* YY_BUFFER_STATE
;
57 extern "C" YY_BUFFER_STATE
yy_scan_string( const char * );
58 extern "C" void yy_delete_buffer( YY_BUFFER_STATE
);
60 // open file with .ck append as appropriate
61 FILE * open_cat_ck( c_str filename
);
63 t_CKBOOL
chuck_parse( c_constr fname
, FILE * fd
= NULL
, c_constr code
= NULL
);
68 // syntax highlighting tools
72 // syntax types (for highlighting)
103 // from the beginning of line
104 std::string::size_type begin
;
105 // from the beginning of line
106 std::string::size_type end
;
109 SyntaxToken() : type(0) { }
111 SyntaxToken( const SyntaxToken
& rhs
)
122 struct SyntaxTokenList
124 std::vector
<SyntaxToken
> list
;
125 std::vector
<SyntaxToken
>::size_type howmany
;
127 SyntaxTokenList( const SyntaxTokenList
& rhs
)
130 howmany
= rhs
.howmany
;
132 list
.resize( howmany
);
134 for( std::vector
<SyntaxToken
>::size_type i
= 0; i
< howmany
; i
++ )
135 list
[i
] = rhs
.list
[i
];
147 t_CKBOOL
parseLine( const std::string
& line
,
148 SyntaxTokenList
& tokens
);