2
// Copyright � 1997 - 2001, Paul C. Gregory
4
// Contact: pgregory@aqsis.com
6
// This library is free software; you can redistribute it and/or
7
// modify it under the terms of the GNU General Public
8
// License as published by the Free Software Foundation; either
9
// version 2 of the License, or (at your option) any later version.
11
// This library is distributed in the hope that it will be useful,
12
// but WITHOUT ANY WARRANTY; without even the implied warranty of
13
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
// General Public License for more details.
16
// You should have received a copy of the GNU General Public
17
// License along with this library; if not, write to the Free Software
18
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22
\brief Implements the entrypoint for the shader compiler.
23
\author Paul C. Gregory (pgregory@aqsis.com)
26
#include "libslparse.h"
27
#include "parsenode.h"
31
START_NAMESPACE( Aqsis )
35
extern CqParseNode* ParseTreePointer;
36
extern void TypeCheck();
37
extern void Optimise();
38
extern void InitStandardNamespace();
41
std::istream* ParseInputStream = &std::cin;
42
CqString ParseStreamName = "stdin";
43
std::ostream* ParseErrorStream = &std::cerr;
44
TqInt ParseLineNumber;
45
TqBool ParseSucceeded = true;
47
TqBool Parse( std::istream& InputStream, const CqString StreamName, std::ostream& ErrorStream )
49
ParseInputStream = &InputStream;
50
ParseStreamName = StreamName;
51
ParseErrorStream = &ErrorStream;
53
ParseSucceeded = true;
55
InitStandardNamespace();
64
( *ParseErrorStream ) << error.c_str() << std::endl;
65
( *ParseErrorStream ) << "ERROR: Shader not compiled" << std::endl;
66
ParseSucceeded = false;
71
std::vector<CqVarDef>::iterator iv;
72
for ( iv = gLocalVars.begin(); iv != gLocalVars.end(); iv++ )
73
if ( iv->pDefValue() ) iv->pDefValue() ->Optimise();
75
return ParseSucceeded;
80
ParseInputStream = &std::cin;
81
ParseStreamName = "stdin";
82
ParseErrorStream = &std::cerr;
84
ParseSucceeded = true;
88
IqParseNode* GetParseTree()
90
return ( ParseTreePointer );
93
END_NAMESPACE( Aqsis )
95
//-------------------------------------------------------------