Commit 044a5cf8 by alokp@chromium.org

Refactored glslang grammar files to make:

- lexer and parser reentrant - line number handling automatic Caveats: - The preprocessor is still not thread-safe and full of bugs. I have another not-yet-ready patch to replace the preprocessor. - The grammar files use options that are not supported by the old versions of flex and bison checked into compiler/tools. So I need to check-in the generated lexer-parser along with a shell script to generate them. Review URL: http://codereview.appspot.com/2992041 git-svn-id: https://angleproject.googlecode.com/svn/trunk@475 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent 2dfc47e3
......@@ -17,9 +17,9 @@
'../include',
],
'variables': {
'glslang_cpp_file': '<(INTERMEDIATE_DIR)/glslang.cpp',
'glslang_tab_cpp_file': '<(INTERMEDIATE_DIR)/glslang_tab.cpp',
'glslang_tab_h_file': '<(INTERMEDIATE_DIR)/glslang_tab.h',
'glslang_lex_source_file': 'compiler/glslang_lex.cpp',
'glslang_tab_source_file': 'compiler/glslang_tab.cpp',
'glslang_tab_header_file': 'compiler/glslang_tab.h',
},
'sources': [
'compiler/BaseTypes.h',
......@@ -28,6 +28,12 @@
'compiler/ConstantUnion.h',
'compiler/debug.cpp',
'compiler/debug.h',
'compiler/glslang.h',
# BEGIN Generated Files
'<(glslang_lex_source_file)',
'<(glslang_tab_source_file)',
'<(glslang_tab_header_file)',
# END Generated Files
'compiler/InfoSink.cpp',
'compiler/InfoSink.h',
'compiler/Initialize.cpp',
......@@ -58,6 +64,8 @@
'compiler/SymbolTable.h',
'compiler/Types.h',
'compiler/unistd.h',
'compiler/util.cpp',
'compiler/util.h',
'compiler/VariableInfo.cpp',
'compiler/VariableInfo.h',
'compiler/preprocessor/atom.c',
......@@ -77,12 +85,6 @@
'compiler/preprocessor/symbols.h',
'compiler/preprocessor/tokens.c',
'compiler/preprocessor/tokens.h',
'compiler/util.cpp',
'compiler/util.h',
# Generated files
'<(glslang_cpp_file)',
'<(glslang_tab_cpp_file)',
'<(glslang_tab_h_file)',
],
'conditions': [
['OS=="win"', {
......@@ -95,28 +97,15 @@
{
'action_name': 'flex_glslang',
'inputs': ['compiler/glslang.l'],
'outputs': ['<(glslang_cpp_file)'],
'action': [
'flex',
'--noline',
'--nounistd',
'--outfile=<(glslang_cpp_file)',
'<(_inputs)',
],
'outputs': ['<(glslang_lex_source_file)'],
'action': ['compiler/generate_glslang_lexer.sh'],
'message': 'Executing flex on <(_inputs)',
},
{
'action_name': 'bison_glslang',
'inputs': ['compiler/glslang.y'],
'outputs': ['<(glslang_tab_cpp_file)', '<(glslang_tab_h_file)'],
'action': [
'bison',
'--no-lines',
'--defines=<(glslang_tab_h_file)',
'--skeleton=yacc.c',
'--output=<(glslang_tab_cpp_file)',
'<(_inputs)',
],
'outputs': ['<(glslang_tab_source_file)', '<(glslang_tab_header_file)'],
'action': ['compiler/generate_glslang_parser.sh'],
'message': 'Executing bison on <(_inputs)',
},
],
......
......@@ -14,9 +14,24 @@
#include "compiler/PoolAlloc.h"
// We need two pieces of information to report errors/warnings - string and
// line number. We encode these into a single int so that it can be easily
// incremented/decremented by lexer. The right SOURCE_LOC_LINE_SIZE bits store
// line number while the rest store the string number. Since the shaders are
// usually small, we should not run out of memory. SOURCE_LOC_LINE_SIZE
// can be increased to alleviate this issue.
typedef int TSourceLoc;
const unsigned int SourceLocLineMask = 0xffff;
const unsigned int SourceLocStringShift = 16;
const unsigned int SOURCE_LOC_LINE_SIZE = 16; // in bits.
const unsigned int SOURCE_LOC_LINE_MASK = (1 << SOURCE_LOC_LINE_SIZE) - 1;
inline TSourceLoc EncodeSourceLoc(int string, int line) {
return (string << SOURCE_LOC_LINE_SIZE) | (line & SOURCE_LOC_LINE_MASK);
}
inline void DecodeSourceLoc(TSourceLoc loc, int* string, int* line) {
if (string) *string = loc >> SOURCE_LOC_LINE_SIZE;
if (line) *line = loc & SOURCE_LOC_LINE_MASK;
}
//
// Put POOL_ALLOCATOR_NEW_DELETE in base classes to make them use this scheme.
......
......@@ -19,8 +19,6 @@ static bool InitializeSymbolTable(
GlobalParseContext = &parseContext;
setInitialState();
assert(symbolTable.isEmpty());
//
// Parse the built-ins. This should only happen once per
......@@ -31,13 +29,6 @@ static bool InitializeSymbolTable(
// are preserved, and the test for an empty table fails.
//
symbolTable.push();
//Initialize the Preprocessor
if (InitPreprocessor())
{
infoSink.info.message(EPrefixInternalError, "Unable to intialize the Preprocessor");
return false;
}
for (TBuiltInStrings::const_iterator i = builtInStrings.begin(); i != builtInStrings.end(); ++i)
{
......@@ -46,7 +37,7 @@ static bool InitializeSymbolTable(
if (builtInLengths <= 0)
continue;
if (PaParseStrings(&builtInShaders, &builtInLengths, 1, parseContext) != 0)
if (PaParseStrings(1, &builtInShaders, &builtInLengths, &parseContext) != 0)
{
infoSink.info.message(EPrefixInternalError, "Unable to parse built-ins");
return false;
......@@ -55,19 +46,9 @@ static bool InitializeSymbolTable(
IdentifyBuiltIns(type, spec, resources, symbolTable);
FinalizePreprocessor();
return true;
}
static void DefineExtensionMacros(const TExtensionBehavior& extBehavior)
{
for (TExtensionBehavior::const_iterator iter = extBehavior.begin();
iter != extBehavior.end(); ++iter) {
PredefineIntMacro(iter->first.c_str(), 1);
}
}
TCompiler::TCompiler(ShShaderType type, ShShaderSpec spec)
: shaderType(type),
shaderSpec(spec)
......@@ -101,11 +82,6 @@ bool TCompiler::compile(const char* const shaderStrings[],
TParseContext parseContext(symbolTable, extensionBehavior, intermediate,
shaderType, shaderSpec, infoSink);
GlobalParseContext = &parseContext;
setInitialState();
// Initialize preprocessor.
InitPreprocessor();
DefineExtensionMacros(extensionBehavior);
// We preserve symbols at the built-in level from compile-to-compile.
// Start pushing the user-defined symbols at global level.
......@@ -115,7 +91,7 @@ bool TCompiler::compile(const char* const shaderStrings[],
// Parse shader.
bool success =
(PaParseStrings(shaderStrings, 0, numStrings, parseContext) == 0) &&
(PaParseStrings(numStrings, shaderStrings, NULL, &parseContext) == 0) &&
(parseContext.treeRoot != NULL);
if (success) {
success = intermediate.postProcess(parseContext.treeRoot);
......@@ -136,7 +112,6 @@ bool TCompiler::compile(const char* const shaderStrings[],
// throwing away all but the built-ins.
while (!symbolTable.atBuiltInLevel())
symbolTable.pop();
FinalizePreprocessor();
return success;
}
......
......@@ -32,8 +32,8 @@ void TInfoSinkBase::prefix(TPrefixType message) {
}
void TInfoSinkBase::location(TSourceLoc loc) {
int string = loc >> SourceLocStringShift;
int line = loc & SourceLocLineMask;
int string = 0, line = 0;
DecodeSourceLoc(loc, &string, &line);
TPersistStringStream stream;
if (line)
......
......@@ -32,8 +32,4 @@ void IdentifyBuiltIns(ShShaderType type, ShShaderSpec spec,
void InitExtensionBehavior(const ShBuiltInResources& resources,
TExtensionBehavior& extensionBehavior);
extern "C" int InitPreprocessor(void);
extern "C" int FinalizePreprocessor(void);
extern "C" void PredefineIntMacro(const char *name, int value);
#endif // _INITIALIZE_INCLUDED_
......@@ -9,9 +9,35 @@
#include <stdarg.h>
#include <stdio.h>
#include "compiler/glslang.h"
#include "compiler/osinclude.h"
#include "compiler/InitializeParseContext.h"
extern "C" {
extern int InitPreprocessor();
extern int FinalizePreprocessor();
extern void PredefineIntMacro(const char *name, int value);
}
static void ReportInfo(TInfoSinkBase& sink,
TPrefixType type, TSourceLoc loc,
const char* reason, const char* token,
const char* extraInfo)
{
/* VC++ format: file(linenum) : error #: 'token' : extrainfo */
sink.prefix(type);
sink.location(loc);
sink << "'" << token << "' : " << reason << " " << extraInfo << "\n";
}
static void DefineExtensionMacros(const TExtensionBehavior& extBehavior)
{
for (TExtensionBehavior::const_iterator iter = extBehavior.begin();
iter != extBehavior.end(); ++iter) {
PredefineIntMacro(iter->first.c_str(), 1);
}
}
///////////////////////////////////////////////////////////////////////
//
// Sub- vector and matrix fields
......@@ -176,24 +202,32 @@ void TParseContext::recover()
//
// Used by flex/bison to output all syntax and parsing errors.
//
void TParseContext::error(TSourceLoc nLine, const char *szReason, const char *szToken,
const char *szExtraInfoFormat, ...)
void TParseContext::error(TSourceLoc loc,
const char* reason, const char* token,
const char* extraInfoFormat, ...)
{
char szExtraInfo[400];
char extraInfo[512];
va_list marker;
va_start(marker, extraInfoFormat);
vsnprintf(extraInfo, sizeof(extraInfo), extraInfoFormat, marker);
va_start(marker, szExtraInfoFormat);
ReportInfo(infoSink.info, EPrefixError, loc, reason, token, extraInfo);
vsnprintf(szExtraInfo, sizeof(szExtraInfo), szExtraInfoFormat, marker);
va_end(marker);
++numErrors;
}
/* VC++ format: file(linenum) : error #: 'token' : extrainfo */
infoSink.info.prefix(EPrefixError);
infoSink.info.location(nLine);
infoSink.info << "'" << szToken << "' : " << szReason << " " << szExtraInfo << "\n";
void TParseContext::warning(TSourceLoc loc,
const char* reason, const char* token,
const char* extraInfoFormat, ...) {
char extraInfo[512];
va_list marker;
va_start(marker, extraInfoFormat);
vsnprintf(extraInfo, sizeof(extraInfo), extraInfoFormat, marker);
va_end(marker);
ReportInfo(infoSink.info, EPrefixWarning, loc, reason, token, extraInfo);
++numErrors;
va_end(marker);
}
//
......@@ -1380,6 +1414,32 @@ TIntermTyped* TParseContext::addConstStruct(TString& identifier, TIntermTyped* n
return typedNode;
}
//
// Parse an array of strings using yyparse.
//
// Returns 0 for success.
//
int PaParseStrings(int count, const char* const string[], const int length[],
TParseContext* context) {
if ((count == 0) || (string == NULL))
return 1;
// setup preprocessor.
if (InitPreprocessor())
return 1;
DefineExtensionMacros(context->extensionBehavior);
if (glslang_initialize(context))
return 1;
glslang_scan(count, string, length, context);
int error = glslang_parse(context);
glslang_finalize(context);
FinalizePreprocessor();
return (error == 0) && (context->numErrors == 0) ? 0 : 1;
}
OS_TLSIndex GlobalParseContextIndex = OS_INVALID_TLS_INDEX;
bool InitializeParseContextIndex()
......
......@@ -33,7 +33,7 @@ struct TParseContext {
TParseContext(TSymbolTable& symt, const TExtensionBehavior& ext, TIntermediate& interm, ShShaderType type, ShShaderSpec spec, TInfoSink& is) :
intermediate(interm), symbolTable(symt), extensionBehavior(ext), infoSink(is), shaderType(type), shaderSpec(spec), treeRoot(0),
recoveredFromError(false), numErrors(0), lexAfterType(false), loopNestingLevel(0),
inTypeParen(false), contextPragma(true, false) { }
inTypeParen(false), scanner(NULL), contextPragma(true, false) { }
TIntermediate& intermediate; // to hold and build a parse tree
TSymbolTable& symbolTable; // symbol table that goes with the language currently being parsed
TExtensionBehavior extensionBehavior; // mapping between supported extensions and current behavior.
......@@ -49,8 +49,10 @@ struct TParseContext {
const TType* currentFunctionType; // the return type of the function that's currently being parsed
bool functionReturnsValue; // true if a non-void function has a return
void error(TSourceLoc, const char *szReason, const char *szToken,
const char *szExtraInfoFormat, ...);
void error(TSourceLoc loc, const char *reason, const char* token,
const char* extraInfoFormat, ...);
void warning(TSourceLoc loc, const char* reason, const char* token,
const char* extraInfoFormat, ...);
bool reservedErrorCheck(int line, const TString& identifier);
void recover();
......@@ -93,16 +95,14 @@ struct TParseContext {
TIntermTyped* addConstArrayNode(int index, TIntermTyped* node, TSourceLoc line);
TIntermTyped* addConstStruct(TString& , TIntermTyped*, TSourceLoc);
bool arraySetMaxSize(TIntermSymbol*, TType*, int, bool, TSourceLoc);
void* scanner;
struct TPragma contextPragma;
TString HashErrMsg;
bool AfterEOF;
};
int PaParseStrings(const char* const argv[], const int strLen[], int argc, TParseContext&);
void PaReservedWord();
int PaIdentOrType(TString& id, TParseContext&, TSymbol*&);
int PaParseComment(int &lineno, TParseContext&);
void setInitialState();
int PaParseStrings(int count, const char* const string[], const int length[],
TParseContext* context);
typedef TParseContext* TParseContextPointer;
extern TParseContextPointer& GetGlobalParseContext();
......
#!/bin/bash
# Copyright (c) 2010 The ANGLE Project Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# Generates GLSL ES lexer - glslang_lex.cpp
script_dir=$(dirname $0)
input_file=$script_dir/glslang.l
output_file=$script_dir/glslang_lex.cpp
flex --noline --nounistd --outfile=$output_file $input_file
#!/bin/bash
# Copyright (c) 2010 The ANGLE Project Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# Generates GLSL ES parser - glslang_tab.h and glslang_tab.cpp
script_dir=$(dirname $0)
input_file=$script_dir/glslang.y
output_header=$script_dir/glslang_tab.h
output_source=$script_dir/glslang_tab.cpp
bison --no-lines --skeleton=yacc.c --defines=$output_header --output=$output_source $input_file
//
// Copyright (c) 2010 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
struct TParseContext;
extern int glslang_initialize(TParseContext* context);
extern int glslang_finalize(TParseContext* context);
extern void glslang_scan(int count,
const char* const string[],
const int length[],
TParseContext* context);
extern int glslang_parse(TParseContext* context);
This source diff could not be displayed because it is too large. You can view the blob instead.
/* A Bison parser, made by GNU Bison 2.3. */
/* Skeleton interface for Bison's Yacc-like parsers in C
Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA. */
/* As a special exception, you may create a larger work that contains
part or all of the Bison parser skeleton and distribute that work
under terms of your choice, so long as that work isn't itself a
parser generator using the skeleton or a modified version thereof
as a parser skeleton. Alternatively, if you modify or redistribute
the parser skeleton itself, you may (at your option) remove this
special exception, which will cause the skeleton and the resulting
Bison output files to be licensed under the GNU General Public
License without this special exception.
This special exception was added by the Free Software Foundation in
version 2.2 of Bison. */
/* Tokens. */
#ifndef YYTOKENTYPE
# define YYTOKENTYPE
/* Put the tokens into the symbol table, so that GDB and other debuggers
know about them. */
enum yytokentype {
INVARIANT = 258,
HIGH_PRECISION = 259,
MEDIUM_PRECISION = 260,
LOW_PRECISION = 261,
PRECISION = 262,
ATTRIBUTE = 263,
CONST_QUAL = 264,
BOOL_TYPE = 265,
FLOAT_TYPE = 266,
INT_TYPE = 267,
BREAK = 268,
CONTINUE = 269,
DO = 270,
ELSE = 271,
FOR = 272,
IF = 273,
DISCARD = 274,
RETURN = 275,
BVEC2 = 276,
BVEC3 = 277,
BVEC4 = 278,
IVEC2 = 279,
IVEC3 = 280,
IVEC4 = 281,
VEC2 = 282,
VEC3 = 283,
VEC4 = 284,
MATRIX2 = 285,
MATRIX3 = 286,
MATRIX4 = 287,
IN_QUAL = 288,
OUT_QUAL = 289,
INOUT_QUAL = 290,
UNIFORM = 291,
VARYING = 292,
STRUCT = 293,
VOID_TYPE = 294,
WHILE = 295,
SAMPLER2D = 296,
SAMPLERCUBE = 297,
IDENTIFIER = 298,
TYPE_NAME = 299,
FLOATCONSTANT = 300,
INTCONSTANT = 301,
BOOLCONSTANT = 302,
FIELD_SELECTION = 303,
LEFT_OP = 304,
RIGHT_OP = 305,
INC_OP = 306,
DEC_OP = 307,
LE_OP = 308,
GE_OP = 309,
EQ_OP = 310,
NE_OP = 311,
AND_OP = 312,
OR_OP = 313,
XOR_OP = 314,
MUL_ASSIGN = 315,
DIV_ASSIGN = 316,
ADD_ASSIGN = 317,
MOD_ASSIGN = 318,
LEFT_ASSIGN = 319,
RIGHT_ASSIGN = 320,
AND_ASSIGN = 321,
XOR_ASSIGN = 322,
OR_ASSIGN = 323,
SUB_ASSIGN = 324,
LEFT_PAREN = 325,
RIGHT_PAREN = 326,
LEFT_BRACKET = 327,
RIGHT_BRACKET = 328,
LEFT_BRACE = 329,
RIGHT_BRACE = 330,
DOT = 331,
COMMA = 332,
COLON = 333,
EQUAL = 334,
SEMICOLON = 335,
BANG = 336,
DASH = 337,
TILDE = 338,
PLUS = 339,
STAR = 340,
SLASH = 341,
PERCENT = 342,
LEFT_ANGLE = 343,
RIGHT_ANGLE = 344,
VERTICAL_BAR = 345,
CARET = 346,
AMPERSAND = 347,
QUESTION = 348
};
#endif
/* Tokens. */
#define INVARIANT 258
#define HIGH_PRECISION 259
#define MEDIUM_PRECISION 260
#define LOW_PRECISION 261
#define PRECISION 262
#define ATTRIBUTE 263
#define CONST_QUAL 264
#define BOOL_TYPE 265
#define FLOAT_TYPE 266
#define INT_TYPE 267
#define BREAK 268
#define CONTINUE 269
#define DO 270
#define ELSE 271
#define FOR 272
#define IF 273
#define DISCARD 274
#define RETURN 275
#define BVEC2 276
#define BVEC3 277
#define BVEC4 278
#define IVEC2 279
#define IVEC3 280
#define IVEC4 281
#define VEC2 282
#define VEC3 283
#define VEC4 284
#define MATRIX2 285
#define MATRIX3 286
#define MATRIX4 287
#define IN_QUAL 288
#define OUT_QUAL 289
#define INOUT_QUAL 290
#define UNIFORM 291
#define VARYING 292
#define STRUCT 293
#define VOID_TYPE 294
#define WHILE 295
#define SAMPLER2D 296
#define SAMPLERCUBE 297
#define IDENTIFIER 298
#define TYPE_NAME 299
#define FLOATCONSTANT 300
#define INTCONSTANT 301
#define BOOLCONSTANT 302
#define FIELD_SELECTION 303
#define LEFT_OP 304
#define RIGHT_OP 305
#define INC_OP 306
#define DEC_OP 307
#define LE_OP 308
#define GE_OP 309
#define EQ_OP 310
#define NE_OP 311
#define AND_OP 312
#define OR_OP 313
#define XOR_OP 314
#define MUL_ASSIGN 315
#define DIV_ASSIGN 316
#define ADD_ASSIGN 317
#define MOD_ASSIGN 318
#define LEFT_ASSIGN 319
#define RIGHT_ASSIGN 320
#define AND_ASSIGN 321
#define XOR_ASSIGN 322
#define OR_ASSIGN 323
#define SUB_ASSIGN 324
#define LEFT_PAREN 325
#define RIGHT_PAREN 326
#define LEFT_BRACKET 327
#define RIGHT_BRACKET 328
#define LEFT_BRACE 329
#define RIGHT_BRACE 330
#define DOT 331
#define COMMA 332
#define COLON 333
#define EQUAL 334
#define SEMICOLON 335
#define BANG 336
#define DASH 337
#define TILDE 338
#define PLUS 339
#define STAR 340
#define SLASH 341
#define PERCENT 342
#define LEFT_ANGLE 343
#define RIGHT_ANGLE 344
#define VERTICAL_BAR 345
#define CARET 346
#define AMPERSAND 347
#define QUESTION 348
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
typedef union YYSTYPE
{
struct {
TSourceLoc line;
union {
TString *string;
float f;
int i;
bool b;
};
TSymbol* symbol;
} lex;
struct {
TSourceLoc line;
TOperator op;
union {
TIntermNode* intermNode;
TIntermNodePair nodePair;
TIntermTyped* intermTypedNode;
TIntermAggregate* intermAggregate;
};
union {
TPublicType type;
TPrecision precision;
TQualifier qualifier;
TFunction* function;
TParameter param;
TTypeLine typeLine;
TTypeList* typeList;
};
} interm;
}
/* Line 1489 of yacc.c. */
YYSTYPE;
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
# define YYSTYPE_IS_DECLARED 1
# define YYSTYPE_IS_TRIVIAL 1
#endif
......@@ -42,7 +42,7 @@ TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
\****************************************************************************/
# include "compiler/preprocessor/slglobals.h"
#include "compiler/preprocessor/slglobals.h"
extern CPPStruct *cpp;
int InitCPPStruct(void);
int InitScanner(CPPStruct *cpp);
......
......@@ -60,8 +60,6 @@ typedef struct SourceLoc_Rec {
unsigned short file, line;
} SourceLoc;
int yyparse (void);
int yylex_CPP(char* buf, int maxSize);
typedef struct InputSrc {
......
Flex carries the copyright used for BSD software, slightly modified
because it originated at the Lawrence Berkeley (not Livermore!) Laboratory,
which operates under a contract with the Department of Energy:
Copyright (c) 1990 The Regents of the University of California.
All rights reserved.
This code is derived from software contributed to Berkeley by
Vern Paxson.
The United States Government has rights in this work pursuant
to contract no. DE-AC03-76SF00098 between the United States
Department of Energy and the University of California.
Redistribution and use in source and binary forms are permitted
provided that: (1) source distributions retain this entire
copyright notice and comment, and (2) distributions including
binaries display the following acknowledgement: ``This product
includes software developed by the University of California,
Berkeley and its contributors'' in the documentation or other
materials provided with the distribution and in all advertising
materials mentioning features or use of this software. Neither the
name of the University nor the names of its contributors may be
used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE.
This basically says "do whatever you please with this software except
remove this notice or take advantage of the University's (or the flex
authors') name".
Note that the "flex.skl" scanner skeleton carries no copyright notice.
You are free to do whatever you please with scanners generated using flex;
for them, you are not even bound by the above copyright.
The standalone Bison and Flex win32 executables
were created by Wilbur Streett and can be obtained from:
http://userpages.monmouth.com/~wstreett/lex-yacc/lex-yacc.html
Bison version 1.24:
See COPYING.bison for license information.
The original source distribution for bison can be obtained from the following location:
http://angleproject.googlecode.com/files/bison.zip
Flex version 2.5.2
See COPYING.flex for license information.
The original source distribution for flex can be obtained from the following location:
http://angleproject.googlecode.com/files/flex.zip
extern int timeclock;
int yyerror; /* Yyerror and yycost are set by guards. */
int yycost; /* If yyerror is set to a nonzero value by a */
/* guard, the reduction with which the guard */
/* is associated is not performed, and the */
/* error recovery mechanism is invoked. */
/* Yycost indicates the cost of performing */
/* the reduction given the attributes of the */
/* symbols. */
/* YYMAXDEPTH indicates the size of the parser's state and value */
/* stacks. */
#ifndef YYMAXDEPTH
#define YYMAXDEPTH 500
#endif
/* YYMAXRULES must be at least as large as the number of rules that */
/* could be placed in the rule queue. That number could be determined */
/* from the grammar and the size of the stack, but, as yet, it is not. */
#ifndef YYMAXRULES
#define YYMAXRULES 100
#endif
#ifndef YYMAXBACKUP
#define YYMAXBACKUP 100
#endif
short yyss[YYMAXDEPTH]; /* the state stack */
YYSTYPE yyvs[YYMAXDEPTH]; /* the semantic value stack */
YYLTYPE yyls[YYMAXDEPTH]; /* the location stack */
short yyrq[YYMAXRULES]; /* the rule queue */
int yychar; /* the lookahead symbol */
YYSTYPE yylval; /* the semantic value of the */
/* lookahead symbol */
YYSTYPE yytval; /* the semantic value for the state */
/* at the top of the state stack. */
YYSTYPE yyval; /* the variable used to return */
/* semantic values from the action */
/* routines */
YYLTYPE yylloc; /* location data for the lookahead */
/* symbol */
YYLTYPE yytloc; /* location data for the state at the */
/* top of the state stack */
int yynunlexed;
short yyunchar[YYMAXBACKUP];
YYSTYPE yyunval[YYMAXBACKUP];
YYLTYPE yyunloc[YYMAXBACKUP];
short *yygssp; /* a pointer to the top of the state */
/* stack; only set during error */
/* recovery. */
YYSTYPE *yygvsp; /* a pointer to the top of the value */
/* stack; only set during error */
/* recovery. */
YYLTYPE *yyglsp; /* a pointer to the top of the */
/* location stack; only set during */
/* error recovery. */
/* Yyget is an interface between the parser and the lexical analyzer. */
/* It is costly to provide such an interface, but it avoids requiring */
/* the lexical analyzer to be able to back up the scan. */
yyget()
{
if (yynunlexed > 0)
{
yynunlexed--;
yychar = yyunchar[yynunlexed];
yylval = yyunval[yynunlexed];
yylloc = yyunloc[yynunlexed];
}
else if (yychar <= 0)
yychar = 0;
else
{
yychar = yylex();
if (yychar < 0)
yychar = 0;
else yychar = YYTRANSLATE(yychar);
}
}
yyunlex(chr, val, loc)
int chr;
YYSTYPE val;
YYLTYPE loc;
{
yyunchar[yynunlexed] = chr;
yyunval[yynunlexed] = val;
yyunloc[yynunlexed] = loc;
yynunlexed++;
}
yyrestore(first, last)
register short *first;
register short *last;
{
register short *ssp;
register short *rp;
register int symbol;
register int state;
register int tvalsaved;
ssp = yygssp;
yyunlex(yychar, yylval, yylloc);
tvalsaved = 0;
while (first != last)
{
symbol = yystos[*ssp];
if (symbol < YYNTBASE)
{
yyunlex(symbol, yytval, yytloc);
tvalsaved = 1;
ssp--;
}
ssp--;
if (first == yyrq)
first = yyrq + YYMAXRULES;
first--;
for (rp = yyrhs + yyprhs[*first]; symbol = *rp; rp++)
{
if (symbol < YYNTBASE)
state = yytable[yypact[*ssp] + symbol];
else
{
state = yypgoto[symbol - YYNTBASE] + *ssp;
if (state >= 0 && state <= YYLAST && yycheck[state] == *ssp)
state = yytable[state];
else
state = yydefgoto[symbol - YYNTBASE];
}
*++ssp = state;
}
}
if ( ! tvalsaved && ssp > yyss)
{
yyunlex(yystos[*ssp], yytval, yytloc);
ssp--;
}
yygssp = ssp;
}
int
yyparse()
{
register int yystate;
register int yyn;
register short *yyssp;
register short *yyrq0;
register short *yyptr;
register YYSTYPE *yyvsp;
int yylen;
YYLTYPE *yylsp;
short *yyrq1;
short *yyrq2;
yystate = 0;
yyssp = yyss - 1;
yyvsp = yyvs - 1;
yylsp = yyls - 1;
yyrq0 = yyrq;
yyrq1 = yyrq0;
yyrq2 = yyrq0;
yychar = yylex();
if (yychar < 0)
yychar = 0;
else yychar = YYTRANSLATE(yychar);
yynewstate:
if (yyssp >= yyss + YYMAXDEPTH - 1)
{
yyabort("Parser Stack Overflow");
YYABORT;
}
*++yyssp = yystate;
yyresume:
yyn = yypact[yystate];
if (yyn == YYFLAG)
goto yydefault;
yyn += yychar;
if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar)
goto yydefault;
yyn = yytable[yyn];
if (yyn < 0)
{
yyn = -yyn;
goto yyreduce;
}
else if (yyn == 0)
goto yyerrlab;
yystate = yyn;
yyptr = yyrq2;
while (yyptr != yyrq1)
{
yyn = *yyptr++;
yylen = yyr2[yyn];
yyvsp -= yylen;
yylsp -= yylen;
yyguard(yyn, yyvsp, yylsp);
if (yyerror)
goto yysemerr;
yyaction(yyn, yyvsp, yylsp);
*++yyvsp = yyval;
yylsp++;
if (yylen == 0)
{
yylsp->timestamp = timeclock;
yylsp->first_line = yytloc.first_line;
yylsp->first_column = yytloc.first_column;
yylsp->last_line = (yylsp-1)->last_line;
yylsp->last_column = (yylsp-1)->last_column;
yylsp->text = 0;
}
else
{
yylsp->last_line = (yylsp+yylen-1)->last_line;
yylsp->last_column = (yylsp+yylen-1)->last_column;
}
if (yyptr == yyrq + YYMAXRULES)
yyptr = yyrq;
}
if (yystate == YYFINAL)
YYACCEPT;
yyrq2 = yyptr;
yyrq1 = yyrq0;
*++yyvsp = yytval;
*++yylsp = yytloc;
yytval = yylval;
yytloc = yylloc;
yyget();
goto yynewstate;
yydefault:
yyn = yydefact[yystate];
if (yyn == 0)
goto yyerrlab;
yyreduce:
*yyrq0++ = yyn;
if (yyrq0 == yyrq + YYMAXRULES)
yyrq0 = yyrq;
if (yyrq0 == yyrq2)
{
yyabort("Parser Rule Queue Overflow");
YYABORT;
}
yyssp -= yyr2[yyn];
yyn = yyr1[yyn];
yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
yystate = yytable[yystate];
else
yystate = yydefgoto[yyn - YYNTBASE];
goto yynewstate;
yysemerr:
*--yyptr = yyn;
yyrq2 = yyptr;
yyvsp += yyr2[yyn];
yyerrlab:
yygssp = yyssp;
yygvsp = yyvsp;
yyglsp = yylsp;
yyrestore(yyrq0, yyrq2);
yyrecover();
yystate = *yygssp;
yyssp = yygssp;
yyvsp = yygvsp;
yyrq0 = yyrq;
yyrq1 = yyrq0;
yyrq2 = yyrq0;
goto yyresume;
}
$
......@@ -167,10 +167,10 @@
>
<Tool
Name="VCCustomBuildTool"
Description="Executing flex on $(InputPath)"
CommandLine="@echo on&#x0D;&#x0A;if EXIST &quot;$(InputDir)Gen_glslang.cpp&quot; del &quot;$(InputDir)Gen_glslang.cpp&quot;&#x0D;&#x0A;&quot;$(InputDir)tools\flex.exe&quot; &quot;$(InputPath)&quot;&#x0D;&#x0A;rename &quot;$(InputDir)lex.yy.c&quot; Gen_$(InputName).cpp&#x0D;&#x0A;@echo off&#x0D;&#x0A;"
AdditionalDependencies="glslang_tab.h"
Outputs="$(InputDir)Gen_glslang.cpp"
Description=""
CommandLine=""
AdditionalDependencies=""
Outputs=""
/>
</FileConfiguration>
<FileConfiguration
......@@ -178,10 +178,10 @@
>
<Tool
Name="VCCustomBuildTool"
Description="Executing flex on $(InputPath)"
CommandLine="@echo on&#x0D;&#x0A;if EXIST &quot;$(InputDir)Gen_glslang.cpp&quot; del &quot;$(InputDir)Gen_glslang.cpp&quot;&#x0D;&#x0A;&quot;$(InputDir)tools\flex.exe&quot; &quot;$(InputPath)&quot;&#x0D;&#x0A;rename &quot;$(InputDir)lex.yy.c&quot; Gen_$(InputName).cpp&#x0D;&#x0A;@echo off&#x0D;&#x0A;"
AdditionalDependencies="glslang_tab.h"
Outputs="$(InputDir)Gen_glslang.cpp"
Description=""
CommandLine=""
AdditionalDependencies=""
Outputs=""
/>
</FileConfiguration>
</File>
......@@ -193,9 +193,9 @@
>
<Tool
Name="VCCustomBuildTool"
Description="Executing Bison on $(InputPath)"
CommandLine="@echo on&#x0D;&#x0A;SET BISON_SIMPLE=tools\bison.simple&#x0D;&#x0A;SET BISON_HAIRY=tools\bison.simple&#x0D;&#x0A;if EXIST &quot;$(InputDir)Gen_$(InputName)_tab.cpp&quot; del &quot;$(InputDir)Gen_$(InputName)_tab.cpp&quot;&#x0D;&#x0A;tools\bison.exe -d -t -v $(InputName).y&#x0D;&#x0A;rename &quot;$(InputDir)$(InputName)_tab.c&quot; Gen_$(InputName)_tab.cpp&#x0D;&#x0A;@echo off&#x0D;&#x0A;"
Outputs="$(InputDir)Gen_$(InputName)_tab.cpp"
Description=""
CommandLine=""
Outputs=""
/>
</FileConfiguration>
<FileConfiguration
......@@ -203,9 +203,9 @@
>
<Tool
Name="VCCustomBuildTool"
Description="Executing Bison on $(InputPath)"
CommandLine="@echo on&#x0D;&#x0A;SET BISON_SIMPLE=tools\bison.simple&#x0D;&#x0A;SET BISON_HAIRY=tools\bison.simple&#x0D;&#x0A;if EXIST &quot;$(InputDir)Gen_$(InputName)_tab.cpp&quot; del &quot;$(InputDir)Gen_$(InputName)_tab.cpp&quot;&#x0D;&#x0A;tools\bison.exe -d -t -v $(InputName).y&#x0D;&#x0A;rename &quot;$(InputDir)$(InputName)_tab.c&quot; Gen_$(InputName)_tab.cpp&#x0D;&#x0A;@echo off&#x0D;&#x0A;"
Outputs="$(InputDir)Gen_$(InputName)_tab.cpp"
Description=""
CommandLine=""
Outputs=""
/>
</FileConfiguration>
</File>
......@@ -309,11 +309,11 @@
Name="generated"
>
<File
RelativePath=".\Gen_glslang.cpp"
RelativePath=".\glslang_lex.cpp"
>
</File>
<File
RelativePath=".\Gen_glslang_tab.cpp"
RelativePath=".\glslang_tab.cpp"
>
</File>
</Filter>
......@@ -412,10 +412,6 @@
>
</File>
<File
RelativePath=".\unistd.h"
>
</File>
<File
RelativePath=".\util.h"
>
</File>
......
// This is a NULL file and is meant to be empty
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment