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
......@@ -32,13 +30,6 @@ static bool InitializeSymbolTable(
//
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)
{
const char* builtInShaders = i->c_str();
......@@ -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);
......@@ -4,33 +4,27 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
*/
/* Based on
ANSI C grammar, Lex specification
In 1985, Jeff Lee published this Lex specification together with a Yacc
grammar for the April 30, 1985 ANSI C draft. Tom Stockfisch reposted
both to net.sources in 1987; that original, as mentioned in the answer
to question 17.25 of the comp.lang.c FAQ, can be ftp'ed from ftp.uu.net,
file usenet/net.sources/ansi.c.grammar.Z.
I intend to keep this version as close to the current C Standard grammar
as possible; please let me know if you discover discrepancies.
This file contains the Lex specification for GLSL ES.
Based on ANSI C grammar, Lex specification:
http://www.lysator.liu.se/c/ANSI-C-grammar-l.html
Jutta Degener, 1995
IF YOU MODIFY THIS FILE YOU ALSO NEED TO RUN generate_glslang_lexer.sh,
WHICH GENERATES THE GLSL ES LEXER (glslang_lex.cpp).
*/
D [0-9]
L [a-zA-Z_]
H [a-fA-F0-9]
E [Ee][+-]?{D}+
O [0-7]
%top{
//
// 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.
//
%option nounput
%{
#include <stdio.h>
#include <stdlib.h>
// This file is auto-generated by generate_glslang_lexer.sh. DO NOT EDIT!
}
%{
#include "compiler/glslang.h"
#include "compiler/ParseHelper.h"
#include "compiler/util.h"
#include "glslang_tab.h"
......@@ -40,407 +34,304 @@ O [0-7]
#pragma warning(disable : 4102)
#endif
int yy_input(char* buf, int max_size);
extern int yyparse(void*);
#define YY_DECL int yylex(YYSTYPE* pyylval, void* parseContextLocal)
#define parseContext (*((TParseContext*)(parseContextLocal)))
#define YY_INPUT(buf,result,max_size) (result = yy_input(buf, max_size))
#define YY_USER_ACTION yylval->lex.line = yylineno;
#define YY_INPUT(buf, result, max_size) \
result = string_input(buf, max_size, yyscanner);
static int string_input(char* buf, int max_size, yyscan_t yyscanner);
static int check_type(yyscan_t yyscanner);
static int reserved_word(yyscan_t yyscanner);
%}
/*
TODO(alokp): yylineno is only here to support old flex.exe in compiler/tools.
Remove it when we can exclusively use the newer version.
*/
%option yylineno
%option noyywrap
%option never-interactive
%x FIELDS
%option noyywrap nounput never-interactive
%option yylineno reentrant bison-bridge
%option stack
%option extra-type="TParseContext*"
%x COMMENT FIELDS
D [0-9]
L [a-zA-Z_]
H [a-fA-F0-9]
E [Ee][+-]?{D}+
O [0-7]
%%
<*>"//"[^\n]*"\n" { /* ?? carriage and/or line-feed? */ };
"invariant" { pyylval->lex.line = yylineno; return(INVARIANT); }
"highp" { pyylval->lex.line = yylineno; return(HIGH_PRECISION); }
"mediump" { pyylval->lex.line = yylineno; return(MEDIUM_PRECISION); }
"lowp" { pyylval->lex.line = yylineno; return(LOW_PRECISION); }
"precision" { pyylval->lex.line = yylineno; return(PRECISION); }
"attribute" { pyylval->lex.line = yylineno; return(ATTRIBUTE); }
"const" { pyylval->lex.line = yylineno; return(CONST_QUAL); }
"uniform" { pyylval->lex.line = yylineno; return(UNIFORM); }
"varying" { pyylval->lex.line = yylineno; return(VARYING); }
"break" { pyylval->lex.line = yylineno; return(BREAK); }
"continue" { pyylval->lex.line = yylineno; return(CONTINUE); }
"do" { pyylval->lex.line = yylineno; return(DO); }
"for" { pyylval->lex.line = yylineno; return(FOR); }
"while" { pyylval->lex.line = yylineno; return(WHILE); }
"if" { pyylval->lex.line = yylineno; return(IF); }
"else" { pyylval->lex.line = yylineno; return(ELSE); }
"in" { pyylval->lex.line = yylineno; return(IN_QUAL); }
"out" { pyylval->lex.line = yylineno; return(OUT_QUAL); }
"inout" { pyylval->lex.line = yylineno; return(INOUT_QUAL); }
"float" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return(FLOAT_TYPE); }
"int" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return(INT_TYPE); }
"void" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return(VOID_TYPE); }
"bool" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return(BOOL_TYPE); }
"true" { pyylval->lex.line = yylineno; pyylval->lex.b = true; return(BOOLCONSTANT); }
"false" { pyylval->lex.line = yylineno; pyylval->lex.b = false; return(BOOLCONSTANT); }
"discard" { pyylval->lex.line = yylineno; return(DISCARD); }
"return" { pyylval->lex.line = yylineno; return(RETURN); }
"mat2" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return(MATRIX2); }
"mat3" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return(MATRIX3); }
"mat4" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return(MATRIX4); }
"vec2" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return (VEC2); }
"vec3" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return (VEC3); }
"vec4" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return (VEC4); }
"ivec2" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return (IVEC2); }
"ivec3" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return (IVEC3); }
"ivec4" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return (IVEC4); }
"bvec2" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return (BVEC2); }
"bvec3" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return (BVEC3); }
"bvec4" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return (BVEC4); }
"sampler2D" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return SAMPLER2D; }
"samplerCube" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return SAMPLERCUBE; }
"struct" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return(STRUCT); }
"asm" { PaReservedWord(); return 0; }
"class" { PaReservedWord(); return 0; }
"union" { PaReservedWord(); return 0; }
"enum" { PaReservedWord(); return 0; }
"typedef" { PaReservedWord(); return 0; }
"template" { PaReservedWord(); return 0; }
"this" { PaReservedWord(); return 0; }
"packed" { PaReservedWord(); return 0; }
"goto" { PaReservedWord(); return 0; }
"switch" { PaReservedWord(); return 0; }
"default" { PaReservedWord(); return 0; }
"inline" { PaReservedWord(); return 0; }
"noinline" { PaReservedWord(); return 0; }
"volatile" { PaReservedWord(); return 0; }
"public" { PaReservedWord(); return 0; }
"static" { PaReservedWord(); return 0; }
"extern" { PaReservedWord(); return 0; }
"external" { PaReservedWord(); return 0; }
"interface" { PaReservedWord(); return 0; }
"long" { PaReservedWord(); return 0; }
"short" { PaReservedWord(); return 0; }
"double" { PaReservedWord(); return 0; }
"half" { PaReservedWord(); return 0; }
"fixed" { PaReservedWord(); return 0; }
"unsigned" { PaReservedWord(); return 0; }
"input" { PaReservedWord(); return 0; }
"output" { PaReservedWord(); return 0; }
"hvec2" { PaReservedWord(); return 0; }
"hvec3" { PaReservedWord(); return 0; }
"hvec4" { PaReservedWord(); return 0; }
"fvec2" { PaReservedWord(); return 0; }
"fvec3" { PaReservedWord(); return 0; }
"fvec4" { PaReservedWord(); return 0; }
"dvec2" { PaReservedWord(); return 0; }
"dvec3" { PaReservedWord(); return 0; }
"dvec4" { PaReservedWord(); return 0; }
"sizeof" { PaReservedWord(); return 0; }
"cast" { PaReservedWord(); return 0; }
"namespace" { PaReservedWord(); return 0; }
"using" { PaReservedWord(); return 0; }
%{
TParseContext* context = yyextra;
%}
/* Single-line comments */
"//"[^\n]* ;
/* Multi-line comments */
"/*" { yy_push_state(COMMENT, yyscanner); }
<COMMENT>. |
<COMMENT>\n ;
<COMMENT>"*/" { yy_pop_state(yyscanner); }
"invariant" { return(INVARIANT); }
"highp" { return(HIGH_PRECISION); }
"mediump" { return(MEDIUM_PRECISION); }
"lowp" { return(LOW_PRECISION); }
"precision" { return(PRECISION); }
"attribute" { return(ATTRIBUTE); }
"const" { return(CONST_QUAL); }
"uniform" { return(UNIFORM); }
"varying" { return(VARYING); }
"break" { return(BREAK); }
"continue" { return(CONTINUE); }
"do" { return(DO); }
"for" { return(FOR); }
"while" { return(WHILE); }
"if" { return(IF); }
"else" { return(ELSE); }
"in" { return(IN_QUAL); }
"out" { return(OUT_QUAL); }
"inout" { return(INOUT_QUAL); }
"float" { context->lexAfterType = true; return(FLOAT_TYPE); }
"int" { context->lexAfterType = true; return(INT_TYPE); }
"void" { context->lexAfterType = true; return(VOID_TYPE); }
"bool" { context->lexAfterType = true; return(BOOL_TYPE); }
"true" { yylval->lex.b = true; return(BOOLCONSTANT); }
"false" { yylval->lex.b = false; return(BOOLCONSTANT); }
"discard" { return(DISCARD); }
"return" { return(RETURN); }
"mat2" { context->lexAfterType = true; return(MATRIX2); }
"mat3" { context->lexAfterType = true; return(MATRIX3); }
"mat4" { context->lexAfterType = true; return(MATRIX4); }
"vec2" { context->lexAfterType = true; return (VEC2); }
"vec3" { context->lexAfterType = true; return (VEC3); }
"vec4" { context->lexAfterType = true; return (VEC4); }
"ivec2" { context->lexAfterType = true; return (IVEC2); }
"ivec3" { context->lexAfterType = true; return (IVEC3); }
"ivec4" { context->lexAfterType = true; return (IVEC4); }
"bvec2" { context->lexAfterType = true; return (BVEC2); }
"bvec3" { context->lexAfterType = true; return (BVEC3); }
"bvec4" { context->lexAfterType = true; return (BVEC4); }
"sampler2D" { context->lexAfterType = true; return SAMPLER2D; }
"samplerCube" { context->lexAfterType = true; return SAMPLERCUBE; }
"struct" { context->lexAfterType = true; return(STRUCT); }
"asm" { return reserved_word(yyscanner); }
"class" { return reserved_word(yyscanner); }
"union" { return reserved_word(yyscanner); }
"enum" { return reserved_word(yyscanner); }
"typedef" { return reserved_word(yyscanner); }
"template" { return reserved_word(yyscanner); }
"this" { return reserved_word(yyscanner); }
"packed" { return reserved_word(yyscanner); }
"goto" { return reserved_word(yyscanner); }
"switch" { return reserved_word(yyscanner); }
"default" { return reserved_word(yyscanner); }
"inline" { return reserved_word(yyscanner); }
"noinline" { return reserved_word(yyscanner); }
"volatile" { return reserved_word(yyscanner); }
"public" { return reserved_word(yyscanner); }
"static" { return reserved_word(yyscanner); }
"extern" { return reserved_word(yyscanner); }
"external" { return reserved_word(yyscanner); }
"interface" { return reserved_word(yyscanner); }
"long" { return reserved_word(yyscanner); }
"short" { return reserved_word(yyscanner); }
"double" { return reserved_word(yyscanner); }
"half" { return reserved_word(yyscanner); }
"fixed" { return reserved_word(yyscanner); }
"unsigned" { return reserved_word(yyscanner); }
"input" { return reserved_word(yyscanner); }
"output" { return reserved_word(yyscanner); }
"hvec2" { return reserved_word(yyscanner); }
"hvec3" { return reserved_word(yyscanner); }
"hvec4" { return reserved_word(yyscanner); }
"fvec2" { return reserved_word(yyscanner); }
"fvec3" { return reserved_word(yyscanner); }
"fvec4" { return reserved_word(yyscanner); }
"dvec2" { return reserved_word(yyscanner); }
"dvec3" { return reserved_word(yyscanner); }
"dvec4" { return reserved_word(yyscanner); }
"sizeof" { return reserved_word(yyscanner); }
"cast" { return reserved_word(yyscanner); }
"namespace" { return reserved_word(yyscanner); }
"using" { return reserved_word(yyscanner); }
{L}({L}|{D})* {
pyylval->lex.line = yylineno;
pyylval->lex.string = NewPoolTString(yytext);
return PaIdentOrType(*pyylval->lex.string, parseContext, pyylval->lex.symbol);
yylval->lex.string = NewPoolTString(yytext);
return check_type(yyscanner);
}
0[xX]{H}+ { pyylval->lex.line = yylineno; pyylval->lex.i = strtol(yytext, 0, 0); return(INTCONSTANT); }
0{O}+ { pyylval->lex.line = yylineno; pyylval->lex.i = strtol(yytext, 0, 0); return(INTCONSTANT); }
0{D}+ { pyylval->lex.line = yylineno; parseContext.error(yylineno, "Invalid Octal number.", yytext, "", ""); parseContext.recover(); return 0;}
{D}+ { pyylval->lex.line = yylineno; pyylval->lex.i = strtol(yytext, 0, 0); return(INTCONSTANT); }
{D}+{E} { pyylval->lex.line = yylineno; pyylval->lex.f = static_cast<float>(atof_dot(yytext)); return(FLOATCONSTANT); }
{D}+"."{D}*({E})? { pyylval->lex.line = yylineno; pyylval->lex.f = static_cast<float>(atof_dot(yytext)); return(FLOATCONSTANT); }
"."{D}+({E})? { pyylval->lex.line = yylineno; pyylval->lex.f = static_cast<float>(atof_dot(yytext)); return(FLOATCONSTANT); }
"/*" { int ret = PaParseComment(pyylval->lex.line, parseContext); if (!ret) return ret; }
"+=" { pyylval->lex.line = yylineno; return(ADD_ASSIGN); }
"-=" { pyylval->lex.line = yylineno; return(SUB_ASSIGN); }
"*=" { pyylval->lex.line = yylineno; return(MUL_ASSIGN); }
"/=" { pyylval->lex.line = yylineno; return(DIV_ASSIGN); }
"%=" { pyylval->lex.line = yylineno; return(MOD_ASSIGN); }
"<<=" { pyylval->lex.line = yylineno; return(LEFT_ASSIGN); }
">>=" { pyylval->lex.line = yylineno; return(RIGHT_ASSIGN); }
"&=" { pyylval->lex.line = yylineno; return(AND_ASSIGN); }
"^=" { pyylval->lex.line = yylineno; return(XOR_ASSIGN); }
"|=" { pyylval->lex.line = yylineno; return(OR_ASSIGN); }
"++" { pyylval->lex.line = yylineno; return(INC_OP); }
"--" { pyylval->lex.line = yylineno; return(DEC_OP); }
"&&" { pyylval->lex.line = yylineno; return(AND_OP); }
"||" { pyylval->lex.line = yylineno; return(OR_OP); }
"^^" { pyylval->lex.line = yylineno; return(XOR_OP); }
"<=" { pyylval->lex.line = yylineno; return(LE_OP); }
">=" { pyylval->lex.line = yylineno; return(GE_OP); }
"==" { pyylval->lex.line = yylineno; return(EQ_OP); }
"!=" { pyylval->lex.line = yylineno; return(NE_OP); }
"<<" { pyylval->lex.line = yylineno; return(LEFT_OP); }
">>" { pyylval->lex.line = yylineno; return(RIGHT_OP); }
";" { pyylval->lex.line = yylineno; parseContext.lexAfterType = false; return(SEMICOLON); }
("{"|"<%") { pyylval->lex.line = yylineno; parseContext.lexAfterType = false; return(LEFT_BRACE); }
("}"|"%>") { pyylval->lex.line = yylineno; return(RIGHT_BRACE); }
"," { pyylval->lex.line = yylineno; if (parseContext.inTypeParen) parseContext.lexAfterType = false; return(COMMA); }
":" { pyylval->lex.line = yylineno; return(COLON); }
"=" { pyylval->lex.line = yylineno; parseContext.lexAfterType = false; return(EQUAL); }
"(" { pyylval->lex.line = yylineno; parseContext.lexAfterType = false; parseContext.inTypeParen = true; return(LEFT_PAREN); }
")" { pyylval->lex.line = yylineno; parseContext.inTypeParen = false; return(RIGHT_PAREN); }
("["|"<:") { pyylval->lex.line = yylineno; return(LEFT_BRACKET); }
("]"|":>") { pyylval->lex.line = yylineno; return(RIGHT_BRACKET); }
0[xX]{H}+ { yylval->lex.i = strtol(yytext, 0, 0); return(INTCONSTANT); }
0{O}+ { yylval->lex.i = strtol(yytext, 0, 0); return(INTCONSTANT); }
0{D}+ { context->error(yylineno, "Invalid Octal number.", yytext, "", ""); context->recover(); return 0;}
{D}+ { yylval->lex.i = strtol(yytext, 0, 0); return(INTCONSTANT); }
{D}+{E} { yylval->lex.f = static_cast<float>(atof_dot(yytext)); return(FLOATCONSTANT); }
{D}+"."{D}*({E})? { yylval->lex.f = static_cast<float>(atof_dot(yytext)); return(FLOATCONSTANT); }
"."{D}+({E})? { yylval->lex.f = static_cast<float>(atof_dot(yytext)); return(FLOATCONSTANT); }
"+=" { return(ADD_ASSIGN); }
"-=" { return(SUB_ASSIGN); }
"*=" { return(MUL_ASSIGN); }
"/=" { return(DIV_ASSIGN); }
"%=" { return(MOD_ASSIGN); }
"<<=" { return(LEFT_ASSIGN); }
">>=" { return(RIGHT_ASSIGN); }
"&=" { return(AND_ASSIGN); }
"^=" { return(XOR_ASSIGN); }
"|=" { return(OR_ASSIGN); }
"++" { return(INC_OP); }
"--" { return(DEC_OP); }
"&&" { return(AND_OP); }
"||" { return(OR_OP); }
"^^" { return(XOR_OP); }
"<=" { return(LE_OP); }
">=" { return(GE_OP); }
"==" { return(EQ_OP); }
"!=" { return(NE_OP); }
"<<" { return(LEFT_OP); }
">>" { return(RIGHT_OP); }
";" { context->lexAfterType = false; return(SEMICOLON); }
("{"|"<%") { context->lexAfterType = false; return(LEFT_BRACE); }
("}"|"%>") { return(RIGHT_BRACE); }
"," { if (context->inTypeParen) context->lexAfterType = false; return(COMMA); }
":" { return(COLON); }
"=" { context->lexAfterType = false; return(EQUAL); }
"(" { context->lexAfterType = false; context->inTypeParen = true; return(LEFT_PAREN); }
")" { context->inTypeParen = false; return(RIGHT_PAREN); }
("["|"<:") { return(LEFT_BRACKET); }
("]"|":>") { return(RIGHT_BRACKET); }
"." { BEGIN(FIELDS); return(DOT); }
"!" { pyylval->lex.line = yylineno; return(BANG); }
"-" { pyylval->lex.line = yylineno; return(DASH); }
"~" { pyylval->lex.line = yylineno; return(TILDE); }
"+" { pyylval->lex.line = yylineno; return(PLUS); }
"*" { pyylval->lex.line = yylineno; return(STAR); }
"/" { pyylval->lex.line = yylineno; return(SLASH); }
"%" { pyylval->lex.line = yylineno; return(PERCENT); }
"<" { pyylval->lex.line = yylineno; return(LEFT_ANGLE); }
">" { pyylval->lex.line = yylineno; return(RIGHT_ANGLE); }
"|" { pyylval->lex.line = yylineno; return(VERTICAL_BAR); }
"^" { pyylval->lex.line = yylineno; return(CARET); }
"&" { pyylval->lex.line = yylineno; return(AMPERSAND); }
"?" { pyylval->lex.line = yylineno; return(QUESTION); }
"!" { return(BANG); }
"-" { return(DASH); }
"~" { return(TILDE); }
"+" { return(PLUS); }
"*" { return(STAR); }
"/" { return(SLASH); }
"%" { return(PERCENT); }
"<" { return(LEFT_ANGLE); }
">" { return(RIGHT_ANGLE); }
"|" { return(VERTICAL_BAR); }
"^" { return(CARET); }
"&" { return(AMPERSAND); }
"?" { return(QUESTION); }
<FIELDS>{L}({L}|{D})* {
BEGIN(INITIAL);
pyylval->lex.line = yylineno;
pyylval->lex.string = NewPoolTString(yytext);
return FIELD_SELECTION; }
BEGIN(INITIAL);
yylval->lex.string = NewPoolTString(yytext);
return FIELD_SELECTION;
}
<FIELDS>[ \t\v\f\r] {}
[ \t\v\n\f\r] { }
<*><<EOF>> { (&parseContext)->AfterEOF = true; yy_delete_buffer(YY_CURRENT_BUFFER); yyterminate();}
<*>. { parseContext.infoSink.info << "FLEX: Unknown char " << yytext << "\n";
return 0; }
<*><<EOF>> { context->AfterEOF = true; yyterminate(); }
<*>. { context->warning(yylineno, "Unknown char", yytext, ""); return 0; }
%%
//Including Pre-processor.
extern "C" {
#include "compiler/preprocessor/preprocess.h"
}
//
// The YY_INPUT macro just calls this. Maybe this could be just put into
// the macro directly.
//
int yy_input(char* buf, int max_size)
{
int len;
if ((len = yylex_CPP(buf, max_size)) == 0)
return 0;
if (len >= max_size)
YY_FATAL_ERROR( "input buffer overflow, can't enlarge buffer because scanner uses REJECT" );
buf[len] = ' ';
return len+1;
}
//
// Parse an array of strings using yyparse. We set up globals used by
// yywrap.
//
// Returns 0 for success, as per yyparse().
//
int PaParseStrings(const char* const argv[], const int strLen[], int argc, TParseContext& parseContextLocal)
{
int argv0len;
ScanFromString(argv[0]);
//Storing the Current Compiler Parse context into the cpp structure.
cpp->pC = (void*)&parseContextLocal;
if (!argv || argc == 0)
return 1;
for (int i = 0; i < argc; ++i) {
if (!argv[i]) {
parseContextLocal.error(0, "Null shader source string", "", "");
parseContextLocal.recover();
return 1;
}
}
if (!strLen) {
argv0len = (int) strlen(argv[0]);
strLen = &argv0len;
}
yyrestart(0);
(&parseContextLocal)->AfterEOF = false;
cpp->PaWhichStr = 0;
cpp->PaArgv = argv;
cpp->PaArgc = argc;
cpp->PaStrLen = strLen;
cpp->pastFirstStatement = 0;
yylineno = 1;
if (*cpp->PaStrLen >= 0) {
int ret = yyparse((void*)(&parseContextLocal));
if (ret || cpp->CompileError == 1 || parseContextLocal.recoveredFromError || parseContextLocal.numErrors > 0)
return 1;
else
return 0;
}
else
return 0;
}
void yyerror(const char *reason)
{
if (((TParseContext *)cpp->pC)->AfterEOF) {
if (cpp->tokensBeforeEOF == 1)
GlobalParseContext->error(yylineno, reason, "pre-mature EOF", "");
else
GlobalParseContext->error(yylineno, reason, "unexpected EOF", "");
} else {
GlobalParseContext->error(yylineno, reason, yytext, "");
}
GlobalParseContext->recover();
}
void PaReservedWord()
{
GlobalParseContext->error(yylineno, "Reserved word.", yytext, "", "");
GlobalParseContext->recover();
}
int PaIdentOrType(TString& id, TParseContext& parseContextLocal, TSymbol*& symbol)
{
symbol = parseContextLocal.symbolTable.find(id);
if (parseContextLocal.lexAfterType == false && symbol && symbol->isVariable()) {
TVariable* variable = static_cast<TVariable*>(symbol);
if (variable->isUserType()) {
parseContextLocal.lexAfterType = true;
return TYPE_NAME;
}
}
return IDENTIFIER;
}
// Preprocessor interface.
#include "compiler/preprocessor/preprocess.h"
int PaParseComment(int &lineno, TParseContext& parseContextLocal)
{
int transitionFlag = 0;
int nextChar;
while (transitionFlag != 2) {
nextChar = yyinput();
if (nextChar == '\n')
lineno++;
switch (nextChar) {
case '*' :
transitionFlag = 1;
break;
case '/' : /* if star is the previous character, then it is the end of comment */
if (transitionFlag == 1) {
return 1 ;
}
break;
case EOF :
/* Raise error message here */
parseContextLocal.error(yylineno, "End of shader found before end of comment.", "", "", "");
GlobalParseContext->recover();
return YY_NULL;
default : /* Any other character will be a part of the comment */
transitionFlag = 0;
}
}
return 1;
}
extern "C" {
#define SETUP_CONTEXT(pp) \
TParseContext* context = (TParseContext*) pp->pC; \
struct yyguts_t* yyg = (struct yyguts_t*) context->scanner;
// Preprocessor callbacks.
void CPPDebugLogMsg(const char *msg)
{
((TParseContext *)cpp->pC)->infoSink.debug.message(EPrefixNone, msg);
SETUP_CONTEXT(cpp);
context->infoSink.debug.message(EPrefixNone, msg);
}
void CPPWarningToInfoLog(const char *msg)
{
((TParseContext *)cpp->pC)->infoSink.info.message(EPrefixWarning, msg, yylineno);
SETUP_CONTEXT(cpp);
context->warning(yylineno, msg, "", "");
}
void CPPShInfoLogMsg(const char *msg)
{
((TParseContext *)cpp->pC)->error(yylineno,"", "",msg,"");
GlobalParseContext->recover();
SETUP_CONTEXT(cpp);
context->error(yylineno, msg, "", "");
context->recover();
}
void CPPErrorToInfoLog(char *msg)
{
((TParseContext *)cpp->pC)->error(yylineno,"syntax error", "",msg,"");
GlobalParseContext->recover();
SETUP_CONTEXT(cpp);
context->error(yylineno, msg, "", "");
context->recover();
}
void SetLineNumber(int line)
{
yylineno &= ~SourceLocLineMask;
yylineno |= line;
SETUP_CONTEXT(cpp);
int string = 0;
DecodeSourceLoc(yylineno, &string, NULL);
yylineno = EncodeSourceLoc(string, line);
}
void SetStringNumber(int string)
{
yylineno = (string << SourceLocStringShift) | (yylineno & SourceLocLineMask);
SETUP_CONTEXT(cpp);
int line = 0;
DecodeSourceLoc(yylineno, NULL, &line);
yylineno = EncodeSourceLoc(string, line);
}
int GetStringNumber(void)
int GetStringNumber()
{
return yylineno >> 16;
SETUP_CONTEXT(cpp);
int string = 0;
DecodeSourceLoc(yylineno, &string, NULL);
return string;
}
int GetLineNumber(void)
int GetLineNumber()
{
return yylineno & SourceLocLineMask;
SETUP_CONTEXT(cpp);
int line = 0;
DecodeSourceLoc(yylineno, NULL, &line);
return line;
}
void IncLineNumber(void)
void IncLineNumber()
{
if ((yylineno & SourceLocLineMask) <= SourceLocLineMask)
++yylineno;
SETUP_CONTEXT(cpp);
int string = 0, line = 0;
DecodeSourceLoc(yylineno, &string, &line);
yylineno = EncodeSourceLoc(string, ++line);
}
void DecLineNumber(void)
void DecLineNumber()
{
if ((yylineno & SourceLocLineMask) > 0)
--yylineno;
SETUP_CONTEXT(cpp);
int string = 0, line = 0;
DecodeSourceLoc(yylineno, &string, &line);
yylineno = EncodeSourceLoc(string, --line);
}
void HandlePragma(const char **tokens, int numTokens)
{
SETUP_CONTEXT(cpp);
if (!strcmp(tokens[0], "optimize")) {
if (numTokens != 4) {
CPPShInfoLogMsg("optimize pragma syntax is incorrect");
......@@ -453,9 +344,9 @@ void HandlePragma(const char **tokens, int numTokens)
}
if (!strcmp(tokens[2], "on"))
((TParseContext *)cpp->pC)->contextPragma.optimize = true;
context->contextPragma.optimize = true;
else if (!strcmp(tokens[2], "off"))
((TParseContext *)cpp->pC)->contextPragma.optimize = false;
context->contextPragma.optimize = false;
else {
CPPShInfoLogMsg("\"on\" or \"off\" expected after '(' for 'optimize' pragma");
return;
......@@ -477,9 +368,9 @@ void HandlePragma(const char **tokens, int numTokens)
}
if (!strcmp(tokens[2], "on"))
((TParseContext *)cpp->pC)->contextPragma.debug = true;
context->contextPragma.debug = true;
else if (!strcmp(tokens[2], "off"))
((TParseContext *)cpp->pC)->contextPragma.debug = false;
context->contextPragma.debug = false;
else {
CPPShInfoLogMsg("\"on\" or \"off\" expected after '(' for 'debug' pragma");
return;
......@@ -490,7 +381,6 @@ void HandlePragma(const char **tokens, int numTokens)
return;
}
} else {
#ifdef PRAGMA_TABLE
//
// implementation specific pragma
......@@ -525,21 +415,24 @@ void HandlePragma(const char **tokens, int numTokens)
void StoreStr(char *string)
{
SETUP_CONTEXT(cpp);
TString strSrc;
strSrc = TString(string);
((TParseContext *)cpp->pC)->HashErrMsg = ((TParseContext *)cpp->pC)->HashErrMsg + " " + strSrc;
context->HashErrMsg = context->HashErrMsg + " " + strSrc;
}
const char* GetStrfromTStr(void)
{
cpp->ErrMsg = (((TParseContext *)cpp->pC)->HashErrMsg).c_str();
SETUP_CONTEXT(cpp);
cpp->ErrMsg = context->HashErrMsg.c_str();
return cpp->ErrMsg;
}
void ResetTString(void)
{
((TParseContext *)cpp->pC)->HashErrMsg = "";
SETUP_CONTEXT(cpp);
context->HashErrMsg = "";
}
TBehavior GetBehavior(const char* behavior)
......@@ -560,6 +453,7 @@ TBehavior GetBehavior(const char* behavior)
void updateExtensionBehavior(const char* extName, const char* behavior)
{
SETUP_CONTEXT(cpp);
TBehavior behaviorVal = GetBehavior(behavior);
TMap<TString, TBehavior>:: iterator iter;
TString msg;
......@@ -570,12 +464,12 @@ void updateExtensionBehavior(const char* extName, const char* behavior)
CPPShInfoLogMsg("extension 'all' cannot have 'require' or 'enable' behavior");
return;
} else {
for (iter = ((TParseContext *)cpp->pC)->extensionBehavior.begin(); iter != ((TParseContext *)cpp->pC)->extensionBehavior.end(); ++iter)
for (iter = context->extensionBehavior.begin(); iter != context->extensionBehavior.end(); ++iter)
iter->second = behaviorVal;
}
} else {
iter = ((TParseContext *)cpp->pC)->extensionBehavior.find(TString(extName));
if (iter == ((TParseContext *)cpp->pC)->extensionBehavior.end()) {
iter = context->extensionBehavior.find(TString(extName));
if (iter == context->extensionBehavior.end()) {
switch (behaviorVal) {
case EBhRequire:
CPPShInfoLogMsg((TString("extension '") + extName + "' is not supported").c_str());
......@@ -584,7 +478,7 @@ void updateExtensionBehavior(const char* extName, const char* behavior)
case EBhWarn:
case EBhDisable:
msg = TString("extension '") + extName + "' is not supported";
((TParseContext *)cpp->pC)->infoSink.info.message(EPrefixWarning, msg.c_str(), yylineno);
context->infoSink.info.message(EPrefixWarning, msg.c_str(), yylineno);
break;
}
return;
......@@ -592,10 +486,85 @@ void updateExtensionBehavior(const char* extName, const char* behavior)
iter->second = behaviorVal;
}
}
} // extern "C"
void setInitialState()
{
yy_start = 1;
int string_input(char* buf, int max_size, yyscan_t yyscanner) {
int len;
if ((len = yylex_CPP(buf, max_size)) == 0)
return 0;
if (len >= max_size)
YY_FATAL_ERROR("input buffer overflow, can't enlarge buffer because scanner uses REJECT");
buf[len] = ' ';
return len+1;
}
int check_type(yyscan_t yyscanner) {
struct yyguts_t* yyg = (struct yyguts_t*) yyscanner;
int token = IDENTIFIER;
TSymbol* symbol = yyextra->symbolTable.find(yytext);
if (yyextra->lexAfterType == false && symbol && symbol->isVariable()) {
TVariable* variable = static_cast<TVariable*>(symbol);
if (variable->isUserType()) {
yyextra->lexAfterType = true;
token = TYPE_NAME;
}
}
yylval->lex.symbol = symbol;
return token;
}
int reserved_word(yyscan_t yyscanner) {
struct yyguts_t* yyg = (struct yyguts_t*) yyscanner;
yyextra->error(yylineno, "Illegal use of reserved word", yytext, "");
yyextra->recover();
return 0;
}
void yyerror(TParseContext* context, const char* reason) {
struct yyguts_t* yyg = (struct yyguts_t*) context->scanner;
if (context->AfterEOF) {
context->error(yylineno, reason, "unexpected EOF", "");
} else {
context->error(yylineno, reason, yytext, "");
}
context->recover();
}
int glslang_initialize(TParseContext* context) {
yyscan_t scanner = NULL;
if (yylex_init_extra(context, &scanner))
return 1;
context->scanner = scanner;
return 0;
}
int glslang_finalize(TParseContext* context) {
yyscan_t scanner = context->scanner;
if (scanner == NULL) return 0;
context->scanner = NULL;
return yylex_destroy(scanner);
}
void glslang_scan(int count, const char* const string[], const int length[],
TParseContext* context) {
yyrestart(NULL, context->scanner);
yyset_lineno(EncodeSourceLoc(0, 1), context->scanner);
context->AfterEOF = false;
// Init preprocessor.
cpp->pC = context;
cpp->PaWhichStr = 0;
cpp->PaArgv = string;
cpp->PaArgc = count;
cpp->PaStrLen = length;
cpp->pastFirstStatement = 0;
ScanFromString(string[0]);
}
/*
//
// Copyright (c) 2002-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.
//
/**
* This is bison grammar and production code for parsing the OpenGL 2.0 shading
* languages.
*/
%{
/* Based on:
ANSI C Yacc grammar
This file contains the Yacc grammar for GLSL ES.
Based on ANSI C Yacc grammar:
http://www.lysator.liu.se/c/ANSI-C-grammar-y.html
In 1985, Jeff Lee published his Yacc grammar (which is accompanied by a
matching Lex specification) for the April 30, 1985 draft version of the
ANSI C standard. Tom Stockfisch reposted it to net.sources in 1987; that
original, as mentioned in the answer to question 17.25 of the comp.lang.c
FAQ, can be ftp'ed from ftp.uu.net, file usenet/net.sources/ansi.c.grammar.Z.
IF YOU MODIFY THIS FILE YOU ALSO NEED TO RUN generate_glslang_parser.sh,
WHICH GENERATES THE GLSL ES PARSER (glslang_tab.cpp AND glslang_tab.h).
*/
I intend to keep this version as close to the current C Standard grammar as
possible; please let me know if you discover discrepancies.
%{
//
// Copyright (c) 2002-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.
//
Jutta Degener, 1995
*/
// This file is auto-generated by generate_glslang_parser.sh. DO NOT EDIT!
#include "compiler/SymbolTable.h"
#include "compiler/ParseHelper.h"
#include "GLSLANG/ShaderLang.h"
#define YYPARSE_PARAM parseContextLocal
/*
TODO(alokp): YYPARSE_PARAM_DECL is only here to support old bison.exe in
compiler/tools. Remove it when we can exclusively use the newer version.
*/
#define YYPARSE_PARAM_DECL void*
#define parseContext ((TParseContext*)(parseContextLocal))
#define YYLEX_PARAM parseContextLocal
#define YY_DECL int yylex(YYSTYPE* pyylval, void* parseContextLocal)
extern void yyerror(const char*);
#define FRAG_VERT_ONLY(S, L) { \
if (parseContext->shaderType != SH_FRAGMENT_SHADER && \
parseContext->shaderType != SH_VERTEX_SHADER) { \
parseContext->error(L, " supported in vertex/fragment shaders only ", S, "", ""); \
parseContext->recover(); \
} \
}
#define YYLEX_PARAM context->scanner
%}
#define VERTEX_ONLY(S, L) { \
if (parseContext->shaderType != SH_VERTEX_SHADER) { \
parseContext->error(L, " supported in vertex shaders only ", S, "", ""); \
parseContext->recover(); \
} \
}
%expect 1 /* One shift reduce conflict because of if | else */
%pure-parser
%parse-param {TParseContext* context}
#define FRAG_ONLY(S, L) { \
if (parseContext->shaderType != SH_FRAGMENT_SHADER) { \
parseContext->error(L, " supported in fragment shaders only ", S, "", ""); \
parseContext->recover(); \
} \
}
%}
%union {
struct {
TSourceLoc line;
......@@ -95,11 +66,32 @@ extern void yyerror(const char*);
}
%{
extern int yylex(YYSTYPE*, void*);
extern int yylex(YYSTYPE* yylval_param, void* yyscanner);
extern void yyerror(TParseContext* context, const char* reason);
#define FRAG_VERT_ONLY(S, L) { \
if (context->shaderType != SH_FRAGMENT_SHADER && \
context->shaderType != SH_VERTEX_SHADER) { \
context->error(L, " supported in vertex/fragment shaders only ", S, "", ""); \
context->recover(); \
} \
}
#define VERTEX_ONLY(S, L) { \
if (context->shaderType != SH_VERTEX_SHADER) { \
context->error(L, " supported in vertex shaders only ", S, "", ""); \
context->recover(); \
} \
}
#define FRAG_ONLY(S, L) { \
if (context->shaderType != SH_FRAGMENT_SHADER) { \
context->error(L, " supported in fragment shaders only ", S, "", ""); \
context->recover(); \
} \
}
%}
%pure_parser /* Just in case is called from multiple threads */
%expect 1 /* One shift reduce conflict because of if | else */
%token <lex> INVARIANT HIGH_PRECISION MEDIUM_PRECISION LOW_PRECISION PRECISION
%token <lex> ATTRIBUTE CONST_QUAL BOOL_TYPE FLOAT_TYPE INT_TYPE
%token <lex> BREAK CONTINUE DO ELSE FOR IF DISCARD RETURN
......@@ -163,17 +155,17 @@ variable_identifier
const TSymbol* symbol = $1.symbol;
const TVariable* variable;
if (symbol == 0) {
parseContext->error($1.line, "undeclared identifier", $1.string->c_str(), "");
parseContext->recover();
context->error($1.line, "undeclared identifier", $1.string->c_str(), "");
context->recover();
TType type(EbtFloat, EbpUndefined);
TVariable* fakeVariable = new TVariable($1.string, type);
parseContext->symbolTable.insert(*fakeVariable);
context->symbolTable.insert(*fakeVariable);
variable = fakeVariable;
} else {
// This identifier can only be a variable type symbol
if (! symbol->isVariable()) {
parseContext->error($1.line, "variable expected", $1.string->c_str(), "");
parseContext->recover();
context->error($1.line, "variable expected", $1.string->c_str(), "");
context->recover();
}
variable = static_cast<const TVariable*>(symbol);
}
......@@ -184,9 +176,9 @@ variable_identifier
if (variable->getType().getQualifier() == EvqConst ) {
ConstantUnion* constArray = variable->getConstPointer();
TType t(variable->getType());
$$ = parseContext->intermediate.addConstantUnion(constArray, t, $1.line);
$$ = context->intermediate.addConstantUnion(constArray, t, $1.line);
} else
$$ = parseContext->intermediate.addSymbol(variable->getUniqueId(),
$$ = context->intermediate.addSymbol(variable->getUniqueId(),
variable->getName(),
variable->getType(), $1.line);
}
......@@ -202,22 +194,22 @@ primary_expression
// check for overflow for constants
//
if (abs($1.i) >= (1 << 16)) {
parseContext->error($1.line, " integer constant overflow", "", "");
parseContext->recover();
context->error($1.line, " integer constant overflow", "", "");
context->recover();
}
ConstantUnion *unionArray = new ConstantUnion[1];
unionArray->setIConst($1.i);
$$ = parseContext->intermediate.addConstantUnion(unionArray, TType(EbtInt, EbpUndefined, EvqConst), $1.line);
$$ = context->intermediate.addConstantUnion(unionArray, TType(EbtInt, EbpUndefined, EvqConst), $1.line);
}
| FLOATCONSTANT {
ConstantUnion *unionArray = new ConstantUnion[1];
unionArray->setFConst($1.f);
$$ = parseContext->intermediate.addConstantUnion(unionArray, TType(EbtFloat, EbpUndefined, EvqConst), $1.line);
$$ = context->intermediate.addConstantUnion(unionArray, TType(EbtFloat, EbpUndefined, EvqConst), $1.line);
}
| BOOLCONSTANT {
ConstantUnion *unionArray = new ConstantUnion[1];
unionArray->setBConst($1.b);
$$ = parseContext->intermediate.addConstantUnion(unionArray, TType(EbtBool, EbpUndefined, EvqConst), $1.line);
$$ = context->intermediate.addConstantUnion(unionArray, TType(EbtBool, EbpUndefined, EvqConst), $1.line);
}
| LEFT_PAREN expression RIGHT_PAREN {
$$ = $2;
......@@ -231,57 +223,57 @@ postfix_expression
| postfix_expression LEFT_BRACKET integer_expression RIGHT_BRACKET {
if (!$1->isArray() && !$1->isMatrix() && !$1->isVector()) {
if ($1->getAsSymbolNode())
parseContext->error($2.line, " left of '[' is not of type array, matrix, or vector ", $1->getAsSymbolNode()->getSymbol().c_str(), "");
context->error($2.line, " left of '[' is not of type array, matrix, or vector ", $1->getAsSymbolNode()->getSymbol().c_str(), "");
else
parseContext->error($2.line, " left of '[' is not of type array, matrix, or vector ", "expression", "");
parseContext->recover();
context->error($2.line, " left of '[' is not of type array, matrix, or vector ", "expression", "");
context->recover();
}
if ($1->getType().getQualifier() == EvqConst && $3->getQualifier() == EvqConst) {
if ($1->isArray()) { // constant folding for arrays
$$ = parseContext->addConstArrayNode($3->getAsConstantUnion()->getUnionArrayPointer()->getIConst(), $1, $2.line);
$$ = context->addConstArrayNode($3->getAsConstantUnion()->getUnionArrayPointer()->getIConst(), $1, $2.line);
} else if ($1->isVector()) { // constant folding for vectors
TVectorFields fields;
fields.num = 1;
fields.offsets[0] = $3->getAsConstantUnion()->getUnionArrayPointer()->getIConst(); // need to do it this way because v.xy sends fields integer array
$$ = parseContext->addConstVectorNode(fields, $1, $2.line);
$$ = context->addConstVectorNode(fields, $1, $2.line);
} else if ($1->isMatrix()) { // constant folding for matrices
$$ = parseContext->addConstMatrixNode($3->getAsConstantUnion()->getUnionArrayPointer()->getIConst(), $1, $2.line);
$$ = context->addConstMatrixNode($3->getAsConstantUnion()->getUnionArrayPointer()->getIConst(), $1, $2.line);
}
} else {
if ($3->getQualifier() == EvqConst) {
if (($1->isVector() || $1->isMatrix()) && $1->getType().getNominalSize() <= $3->getAsConstantUnion()->getUnionArrayPointer()->getIConst() && !$1->isArray() ) {
parseContext->error($2.line, "", "[", "field selection out of range '%d'", $3->getAsConstantUnion()->getUnionArrayPointer()->getIConst());
parseContext->recover();
context->error($2.line, "", "[", "field selection out of range '%d'", $3->getAsConstantUnion()->getUnionArrayPointer()->getIConst());
context->recover();
} else {
if ($1->isArray()) {
if ($1->getType().getArraySize() == 0) {
if ($1->getType().getMaxArraySize() <= $3->getAsConstantUnion()->getUnionArrayPointer()->getIConst()) {
if (parseContext->arraySetMaxSize($1->getAsSymbolNode(), $1->getTypePointer(), $3->getAsConstantUnion()->getUnionArrayPointer()->getIConst(), true, $2.line))
parseContext->recover();
if (context->arraySetMaxSize($1->getAsSymbolNode(), $1->getTypePointer(), $3->getAsConstantUnion()->getUnionArrayPointer()->getIConst(), true, $2.line))
context->recover();
} else {
if (parseContext->arraySetMaxSize($1->getAsSymbolNode(), $1->getTypePointer(), 0, false, $2.line))
parseContext->recover();
if (context->arraySetMaxSize($1->getAsSymbolNode(), $1->getTypePointer(), 0, false, $2.line))
context->recover();
}
} else if ( $3->getAsConstantUnion()->getUnionArrayPointer()->getIConst() >= $1->getType().getArraySize()) {
parseContext->error($2.line, "", "[", "array index out of range '%d'", $3->getAsConstantUnion()->getUnionArrayPointer()->getIConst());
parseContext->recover();
context->error($2.line, "", "[", "array index out of range '%d'", $3->getAsConstantUnion()->getUnionArrayPointer()->getIConst());
context->recover();
}
}
$$ = parseContext->intermediate.addIndex(EOpIndexDirect, $1, $3, $2.line);
$$ = context->intermediate.addIndex(EOpIndexDirect, $1, $3, $2.line);
}
} else {
if ($1->isArray() && $1->getType().getArraySize() == 0) {
parseContext->error($2.line, "", "[", "array must be redeclared with a size before being indexed with a variable");
parseContext->recover();
context->error($2.line, "", "[", "array must be redeclared with a size before being indexed with a variable");
context->recover();
}
$$ = parseContext->intermediate.addIndex(EOpIndexIndirect, $1, $3, $2.line);
$$ = context->intermediate.addIndex(EOpIndexIndirect, $1, $3, $2.line);
}
}
if ($$ == 0) {
ConstantUnion *unionArray = new ConstantUnion[1];
unionArray->setFConst(0.0f);
$$ = parseContext->intermediate.addConstantUnion(unionArray, TType(EbtFloat, EbpHigh, EvqConst), $2.line);
$$ = context->intermediate.addConstantUnion(unionArray, TType(EbtFloat, EbpHigh, EvqConst), $2.line);
} else if ($1->isArray()) {
if ($1->getType().getStruct())
$$->setType(TType($1->getType().getStruct(), $1->getType().getTypeName()));
......@@ -306,22 +298,22 @@ postfix_expression
}
| postfix_expression DOT FIELD_SELECTION {
if ($1->isArray()) {
parseContext->error($3.line, "cannot apply dot operator to an array", ".", "");
parseContext->recover();
context->error($3.line, "cannot apply dot operator to an array", ".", "");
context->recover();
}
if ($1->isVector()) {
TVectorFields fields;
if (! parseContext->parseVectorFields(*$3.string, $1->getNominalSize(), fields, $3.line)) {
if (! context->parseVectorFields(*$3.string, $1->getNominalSize(), fields, $3.line)) {
fields.num = 1;
fields.offsets[0] = 0;
parseContext->recover();
context->recover();
}
if ($1->getType().getQualifier() == EvqConst) { // constant folding for vector fields
$$ = parseContext->addConstVectorNode(fields, $1, $3.line);
$$ = context->addConstVectorNode(fields, $1, $3.line);
if ($$ == 0) {
parseContext->recover();
context->recover();
$$ = $1;
}
else
......@@ -330,47 +322,47 @@ postfix_expression
if (fields.num == 1) {
ConstantUnion *unionArray = new ConstantUnion[1];
unionArray->setIConst(fields.offsets[0]);
TIntermTyped* index = parseContext->intermediate.addConstantUnion(unionArray, TType(EbtInt, EbpUndefined, EvqConst), $3.line);
$$ = parseContext->intermediate.addIndex(EOpIndexDirect, $1, index, $2.line);
TIntermTyped* index = context->intermediate.addConstantUnion(unionArray, TType(EbtInt, EbpUndefined, EvqConst), $3.line);
$$ = context->intermediate.addIndex(EOpIndexDirect, $1, index, $2.line);
$$->setType(TType($1->getBasicType(), $1->getPrecision()));
} else {
TString vectorString = *$3.string;
TIntermTyped* index = parseContext->intermediate.addSwizzle(fields, $3.line);
$$ = parseContext->intermediate.addIndex(EOpVectorSwizzle, $1, index, $2.line);
TIntermTyped* index = context->intermediate.addSwizzle(fields, $3.line);
$$ = context->intermediate.addIndex(EOpVectorSwizzle, $1, index, $2.line);
$$->setType(TType($1->getBasicType(), $1->getPrecision(), EvqTemporary, (int) vectorString.size()));
}
}
} else if ($1->isMatrix()) {
TMatrixFields fields;
if (! parseContext->parseMatrixFields(*$3.string, $1->getNominalSize(), fields, $3.line)) {
if (! context->parseMatrixFields(*$3.string, $1->getNominalSize(), fields, $3.line)) {
fields.wholeRow = false;
fields.wholeCol = false;
fields.row = 0;
fields.col = 0;
parseContext->recover();
context->recover();
}
if (fields.wholeRow || fields.wholeCol) {
parseContext->error($2.line, " non-scalar fields not implemented yet", ".", "");
parseContext->recover();
context->error($2.line, " non-scalar fields not implemented yet", ".", "");
context->recover();
ConstantUnion *unionArray = new ConstantUnion[1];
unionArray->setIConst(0);
TIntermTyped* index = parseContext->intermediate.addConstantUnion(unionArray, TType(EbtInt, EbpUndefined, EvqConst), $3.line);
$$ = parseContext->intermediate.addIndex(EOpIndexDirect, $1, index, $2.line);
TIntermTyped* index = context->intermediate.addConstantUnion(unionArray, TType(EbtInt, EbpUndefined, EvqConst), $3.line);
$$ = context->intermediate.addIndex(EOpIndexDirect, $1, index, $2.line);
$$->setType(TType($1->getBasicType(), $1->getPrecision(),EvqTemporary, $1->getNominalSize()));
} else {
ConstantUnion *unionArray = new ConstantUnion[1];
unionArray->setIConst(fields.col * $1->getNominalSize() + fields.row);
TIntermTyped* index = parseContext->intermediate.addConstantUnion(unionArray, TType(EbtInt, EbpUndefined, EvqConst), $3.line);
$$ = parseContext->intermediate.addIndex(EOpIndexDirect, $1, index, $2.line);
TIntermTyped* index = context->intermediate.addConstantUnion(unionArray, TType(EbtInt, EbpUndefined, EvqConst), $3.line);
$$ = context->intermediate.addIndex(EOpIndexDirect, $1, index, $2.line);
$$->setType(TType($1->getBasicType(), $1->getPrecision()));
}
} else if ($1->getBasicType() == EbtStruct) {
bool fieldFound = false;
const TTypeList* fields = $1->getType().getStruct();
if (fields == 0) {
parseContext->error($2.line, "structure has no fields", "Internal Error", "");
parseContext->recover();
context->error($2.line, "structure has no fields", "Internal Error", "");
context->recover();
$$ = $1;
} else {
unsigned int i;
......@@ -382,9 +374,9 @@ postfix_expression
}
if (fieldFound) {
if ($1->getType().getQualifier() == EvqConst) {
$$ = parseContext->addConstStruct(*$3.string, $1, $2.line);
$$ = context->addConstStruct(*$3.string, $1, $2.line);
if ($$ == 0) {
parseContext->recover();
context->recover();
$$ = $1;
}
else {
......@@ -396,40 +388,40 @@ postfix_expression
} else {
ConstantUnion *unionArray = new ConstantUnion[1];
unionArray->setIConst(i);
TIntermTyped* index = parseContext->intermediate.addConstantUnion(unionArray, *(*fields)[i].type, $3.line);
$$ = parseContext->intermediate.addIndex(EOpIndexDirectStruct, $1, index, $2.line);
TIntermTyped* index = context->intermediate.addConstantUnion(unionArray, *(*fields)[i].type, $3.line);
$$ = context->intermediate.addIndex(EOpIndexDirectStruct, $1, index, $2.line);
$$->setType(*(*fields)[i].type);
}
} else {
parseContext->error($2.line, " no such field in structure", $3.string->c_str(), "");
parseContext->recover();
context->error($2.line, " no such field in structure", $3.string->c_str(), "");
context->recover();
$$ = $1;
}
}
} else {
parseContext->error($2.line, " field selection requires structure, vector, or matrix on left hand side", $3.string->c_str(), "");
parseContext->recover();
context->error($2.line, " field selection requires structure, vector, or matrix on left hand side", $3.string->c_str(), "");
context->recover();
$$ = $1;
}
// don't delete $3.string, it's from the pool
}
| postfix_expression INC_OP {
if (parseContext->lValueErrorCheck($2.line, "++", $1))
parseContext->recover();
$$ = parseContext->intermediate.addUnaryMath(EOpPostIncrement, $1, $2.line, parseContext->symbolTable);
if (context->lValueErrorCheck($2.line, "++", $1))
context->recover();
$$ = context->intermediate.addUnaryMath(EOpPostIncrement, $1, $2.line, context->symbolTable);
if ($$ == 0) {
parseContext->unaryOpError($2.line, "++", $1->getCompleteString());
parseContext->recover();
context->unaryOpError($2.line, "++", $1->getCompleteString());
context->recover();
$$ = $1;
}
}
| postfix_expression DEC_OP {
if (parseContext->lValueErrorCheck($2.line, "--", $1))
parseContext->recover();
$$ = parseContext->intermediate.addUnaryMath(EOpPostDecrement, $1, $2.line, parseContext->symbolTable);
if (context->lValueErrorCheck($2.line, "--", $1))
context->recover();
$$ = context->intermediate.addUnaryMath(EOpPostDecrement, $1, $2.line, context->symbolTable);
if ($$ == 0) {
parseContext->unaryOpError($2.line, "--", $1->getCompleteString());
parseContext->recover();
context->unaryOpError($2.line, "--", $1->getCompleteString());
context->recover();
$$ = $1;
}
}
......@@ -437,8 +429,8 @@ postfix_expression
integer_expression
: expression {
if (parseContext->integerErrorCheck($1, "[]"))
parseContext->recover();
if (context->integerErrorCheck($1, "[]"))
context->recover();
$$ = $1;
}
;
......@@ -456,18 +448,18 @@ function_call
// Their parameters will be verified algorithmically.
//
TType type(EbtVoid, EbpUndefined); // use this to get the type back
if (parseContext->constructorErrorCheck($1.line, $1.intermNode, *fnCall, op, &type)) {
if (context->constructorErrorCheck($1.line, $1.intermNode, *fnCall, op, &type)) {
$$ = 0;
} else {
//
// It's a constructor, of type 'type'.
//
$$ = parseContext->addConstructor($1.intermNode, &type, op, fnCall, $1.line);
$$ = context->addConstructor($1.intermNode, &type, op, fnCall, $1.line);
}
if ($$ == 0) {
parseContext->recover();
$$ = parseContext->intermediate.setAggregateOperator(0, op, $1.line);
context->recover();
$$ = context->intermediate.setAggregateOperator(0, op, $1.line);
}
$$->setType(type);
} else {
......@@ -476,14 +468,14 @@ function_call
//
const TFunction* fnCandidate;
bool builtIn;
fnCandidate = parseContext->findFunction($1.line, fnCall, &builtIn);
fnCandidate = context->findFunction($1.line, fnCall, &builtIn);
if (fnCandidate) {
//
// A declared function.
//
if (builtIn && !fnCandidate->getExtension().empty() &&
parseContext->extensionErrorCheck($1.line, fnCandidate->getExtension())) {
parseContext->recover();
context->extensionErrorCheck($1.line, fnCandidate->getExtension())) {
context->recover();
}
op = fnCandidate->getBuiltInOp();
if (builtIn && op != EOpNull) {
......@@ -494,20 +486,20 @@ function_call
//
// Treat it like a built-in unary operator.
//
$$ = parseContext->intermediate.addUnaryMath(op, $1.intermNode, 0, parseContext->symbolTable);
$$ = context->intermediate.addUnaryMath(op, $1.intermNode, 0, context->symbolTable);
if ($$ == 0) {
parseContext->error($1.intermNode->getLine(), " wrong operand type", "Internal Error",
context->error($1.intermNode->getLine(), " wrong operand type", "Internal Error",
"built in unary operator function. Type: %s",
static_cast<TIntermTyped*>($1.intermNode)->getCompleteString().c_str());
YYERROR;
}
} else {
$$ = parseContext->intermediate.setAggregateOperator($1.intermAggregate, op, $1.line);
$$ = context->intermediate.setAggregateOperator($1.intermAggregate, op, $1.line);
}
} else {
// This is a real function call
$$ = parseContext->intermediate.setAggregateOperator($1.intermAggregate, EOpFunctionCall, $1.line);
$$ = context->intermediate.setAggregateOperator($1.intermAggregate, EOpFunctionCall, $1.line);
$$->setType(fnCandidate->getReturnType());
// this is how we know whether the given function is a builtIn function or a user defined function
......@@ -521,9 +513,9 @@ function_call
for (int i = 0; i < fnCandidate->getParamCount(); ++i) {
qual = fnCandidate->getParam(i).type->getQualifier();
if (qual == EvqOut || qual == EvqInOut) {
if (parseContext->lValueErrorCheck($$->getLine(), "assign", $$->getAsAggregate()->getSequence()[i]->getAsTyped())) {
parseContext->error($1.intermNode->getLine(), "Constant value cannot be passed for 'out' or 'inout' parameters.", "Error", "");
parseContext->recover();
if (context->lValueErrorCheck($$->getLine(), "assign", $$->getAsAggregate()->getSequence()[i]->getAsTyped())) {
context->error($1.intermNode->getLine(), "Constant value cannot be passed for 'out' or 'inout' parameters.", "Error", "");
context->recover();
}
}
}
......@@ -534,8 +526,8 @@ function_call
// Put on a dummy node for error recovery
ConstantUnion *unionArray = new ConstantUnion[1];
unionArray->setFConst(0.0f);
$$ = parseContext->intermediate.addConstantUnion(unionArray, TType(EbtFloat, EbpUndefined, EvqConst), $1.line);
parseContext->recover();
$$ = context->intermediate.addConstantUnion(unionArray, TType(EbtFloat, EbpUndefined, EvqConst), $1.line);
context->recover();
}
}
delete fnCall;
......@@ -547,8 +539,8 @@ function_call_or_method
$$ = $1;
}
| postfix_expression DOT function_call_generic {
parseContext->error($3.line, "methods are not supported", "", "");
parseContext->recover();
context->error($3.line, "methods are not supported", "", "");
context->recover();
$$ = $3;
}
;
......@@ -586,7 +578,7 @@ function_call_header_with_parameters
TParameter param = { 0, new TType($3->getType()) };
$1.function->addParameter(param);
$$.function = $1.function;
$$.intermNode = parseContext->intermediate.growAggregate($1.intermNode, $3, $2.line);
$$.intermNode = context->intermediate.growAggregate($1.intermNode, $3, $2.line);
}
;
......@@ -605,8 +597,8 @@ function_identifier
//
if ($1.array) {
// Constructors for arrays are not allowed.
parseContext->error($1.line, "cannot construct this type", "array", "");
parseContext->recover();
context->error($1.line, "cannot construct this type", "array", "");
context->recover();
$1.setArray(false);
}
......@@ -650,8 +642,8 @@ function_identifier
default: break;
}
if (op == EOpNull) {
parseContext->error($1.line, "cannot construct this type", getBasicString($1.type), "");
parseContext->recover();
context->error($1.line, "cannot construct this type", getBasicString($1.type), "");
context->recover();
$1.type = EbtFloat;
op = EOpConstructFloat;
}
......@@ -662,15 +654,15 @@ function_identifier
$$ = function;
}
| IDENTIFIER {
if (parseContext->reservedErrorCheck($1.line, *$1.string))
parseContext->recover();
if (context->reservedErrorCheck($1.line, *$1.string))
context->recover();
TType type(EbtVoid, EbpUndefined);
TFunction *function = new TFunction($1.string, type);
$$ = function;
}
| FIELD_SELECTION {
if (parseContext->reservedErrorCheck($1.line, *$1.string))
parseContext->recover();
if (context->reservedErrorCheck($1.line, *$1.string))
context->recover();
TType type(EbtVoid, EbpUndefined);
TFunction *function = new TFunction($1.string, type);
$$ = function;
......@@ -682,28 +674,28 @@ unary_expression
$$ = $1;
}
| INC_OP unary_expression {
if (parseContext->lValueErrorCheck($1.line, "++", $2))
parseContext->recover();
$$ = parseContext->intermediate.addUnaryMath(EOpPreIncrement, $2, $1.line, parseContext->symbolTable);
if (context->lValueErrorCheck($1.line, "++", $2))
context->recover();
$$ = context->intermediate.addUnaryMath(EOpPreIncrement, $2, $1.line, context->symbolTable);
if ($$ == 0) {
parseContext->unaryOpError($1.line, "++", $2->getCompleteString());
parseContext->recover();
context->unaryOpError($1.line, "++", $2->getCompleteString());
context->recover();
$$ = $2;
}
}
| DEC_OP unary_expression {
if (parseContext->lValueErrorCheck($1.line, "--", $2))
parseContext->recover();
$$ = parseContext->intermediate.addUnaryMath(EOpPreDecrement, $2, $1.line, parseContext->symbolTable);
if (context->lValueErrorCheck($1.line, "--", $2))
context->recover();
$$ = context->intermediate.addUnaryMath(EOpPreDecrement, $2, $1.line, context->symbolTable);
if ($$ == 0) {
parseContext->unaryOpError($1.line, "--", $2->getCompleteString());
parseContext->recover();
context->unaryOpError($1.line, "--", $2->getCompleteString());
context->recover();
$$ = $2;
}
}
| unary_operator unary_expression {
if ($1.op != EOpNull) {
$$ = parseContext->intermediate.addUnaryMath($1.op, $2, $1.line, parseContext->symbolTable);
$$ = context->intermediate.addUnaryMath($1.op, $2, $1.line, context->symbolTable);
if ($$ == 0) {
const char* errorOp = "";
switch($1.op) {
......@@ -711,8 +703,8 @@ unary_expression
case EOpLogicalNot: errorOp = "!"; break;
default: break;
}
parseContext->unaryOpError($1.line, errorOp, $2->getCompleteString());
parseContext->recover();
context->unaryOpError($1.line, errorOp, $2->getCompleteString());
context->recover();
$$ = $2;
}
} else
......@@ -732,19 +724,19 @@ multiplicative_expression
: unary_expression { $$ = $1; }
| multiplicative_expression STAR unary_expression {
FRAG_VERT_ONLY("*", $2.line);
$$ = parseContext->intermediate.addBinaryMath(EOpMul, $1, $3, $2.line, parseContext->symbolTable);
$$ = context->intermediate.addBinaryMath(EOpMul, $1, $3, $2.line, context->symbolTable);
if ($$ == 0) {
parseContext->binaryOpError($2.line, "*", $1->getCompleteString(), $3->getCompleteString());
parseContext->recover();
context->binaryOpError($2.line, "*", $1->getCompleteString(), $3->getCompleteString());
context->recover();
$$ = $1;
}
}
| multiplicative_expression SLASH unary_expression {
FRAG_VERT_ONLY("/", $2.line);
$$ = parseContext->intermediate.addBinaryMath(EOpDiv, $1, $3, $2.line, parseContext->symbolTable);
$$ = context->intermediate.addBinaryMath(EOpDiv, $1, $3, $2.line, context->symbolTable);
if ($$ == 0) {
parseContext->binaryOpError($2.line, "/", $1->getCompleteString(), $3->getCompleteString());
parseContext->recover();
context->binaryOpError($2.line, "/", $1->getCompleteString(), $3->getCompleteString());
context->recover();
$$ = $1;
}
}
......@@ -753,18 +745,18 @@ multiplicative_expression
additive_expression
: multiplicative_expression { $$ = $1; }
| additive_expression PLUS multiplicative_expression {
$$ = parseContext->intermediate.addBinaryMath(EOpAdd, $1, $3, $2.line, parseContext->symbolTable);
$$ = context->intermediate.addBinaryMath(EOpAdd, $1, $3, $2.line, context->symbolTable);
if ($$ == 0) {
parseContext->binaryOpError($2.line, "+", $1->getCompleteString(), $3->getCompleteString());
parseContext->recover();
context->binaryOpError($2.line, "+", $1->getCompleteString(), $3->getCompleteString());
context->recover();
$$ = $1;
}
}
| additive_expression DASH multiplicative_expression {
$$ = parseContext->intermediate.addBinaryMath(EOpSub, $1, $3, $2.line, parseContext->symbolTable);
$$ = context->intermediate.addBinaryMath(EOpSub, $1, $3, $2.line, context->symbolTable);
if ($$ == 0) {
parseContext->binaryOpError($2.line, "-", $1->getCompleteString(), $3->getCompleteString());
parseContext->recover();
context->binaryOpError($2.line, "-", $1->getCompleteString(), $3->getCompleteString());
context->recover();
$$ = $1;
}
}
......@@ -777,43 +769,43 @@ shift_expression
relational_expression
: shift_expression { $$ = $1; }
| relational_expression LEFT_ANGLE shift_expression {
$$ = parseContext->intermediate.addBinaryMath(EOpLessThan, $1, $3, $2.line, parseContext->symbolTable);
$$ = context->intermediate.addBinaryMath(EOpLessThan, $1, $3, $2.line, context->symbolTable);
if ($$ == 0) {
parseContext->binaryOpError($2.line, "<", $1->getCompleteString(), $3->getCompleteString());
parseContext->recover();
context->binaryOpError($2.line, "<", $1->getCompleteString(), $3->getCompleteString());
context->recover();
ConstantUnion *unionArray = new ConstantUnion[1];
unionArray->setBConst(false);
$$ = parseContext->intermediate.addConstantUnion(unionArray, TType(EbtBool, EbpUndefined, EvqConst), $2.line);
$$ = context->intermediate.addConstantUnion(unionArray, TType(EbtBool, EbpUndefined, EvqConst), $2.line);
}
}
| relational_expression RIGHT_ANGLE shift_expression {
$$ = parseContext->intermediate.addBinaryMath(EOpGreaterThan, $1, $3, $2.line, parseContext->symbolTable);
$$ = context->intermediate.addBinaryMath(EOpGreaterThan, $1, $3, $2.line, context->symbolTable);
if ($$ == 0) {
parseContext->binaryOpError($2.line, ">", $1->getCompleteString(), $3->getCompleteString());
parseContext->recover();
context->binaryOpError($2.line, ">", $1->getCompleteString(), $3->getCompleteString());
context->recover();
ConstantUnion *unionArray = new ConstantUnion[1];
unionArray->setBConst(false);
$$ = parseContext->intermediate.addConstantUnion(unionArray, TType(EbtBool, EbpUndefined, EvqConst), $2.line);
$$ = context->intermediate.addConstantUnion(unionArray, TType(EbtBool, EbpUndefined, EvqConst), $2.line);
}
}
| relational_expression LE_OP shift_expression {
$$ = parseContext->intermediate.addBinaryMath(EOpLessThanEqual, $1, $3, $2.line, parseContext->symbolTable);
$$ = context->intermediate.addBinaryMath(EOpLessThanEqual, $1, $3, $2.line, context->symbolTable);
if ($$ == 0) {
parseContext->binaryOpError($2.line, "<=", $1->getCompleteString(), $3->getCompleteString());
parseContext->recover();
context->binaryOpError($2.line, "<=", $1->getCompleteString(), $3->getCompleteString());
context->recover();
ConstantUnion *unionArray = new ConstantUnion[1];
unionArray->setBConst(false);
$$ = parseContext->intermediate.addConstantUnion(unionArray, TType(EbtBool, EbpUndefined, EvqConst), $2.line);
$$ = context->intermediate.addConstantUnion(unionArray, TType(EbtBool, EbpUndefined, EvqConst), $2.line);
}
}
| relational_expression GE_OP shift_expression {
$$ = parseContext->intermediate.addBinaryMath(EOpGreaterThanEqual, $1, $3, $2.line, parseContext->symbolTable);
$$ = context->intermediate.addBinaryMath(EOpGreaterThanEqual, $1, $3, $2.line, context->symbolTable);
if ($$ == 0) {
parseContext->binaryOpError($2.line, ">=", $1->getCompleteString(), $3->getCompleteString());
parseContext->recover();
context->binaryOpError($2.line, ">=", $1->getCompleteString(), $3->getCompleteString());
context->recover();
ConstantUnion *unionArray = new ConstantUnion[1];
unionArray->setBConst(false);
$$ = parseContext->intermediate.addConstantUnion(unionArray, TType(EbtBool, EbpUndefined, EvqConst), $2.line);
$$ = context->intermediate.addConstantUnion(unionArray, TType(EbtBool, EbpUndefined, EvqConst), $2.line);
}
}
;
......@@ -821,23 +813,23 @@ relational_expression
equality_expression
: relational_expression { $$ = $1; }
| equality_expression EQ_OP relational_expression {
$$ = parseContext->intermediate.addBinaryMath(EOpEqual, $1, $3, $2.line, parseContext->symbolTable);
$$ = context->intermediate.addBinaryMath(EOpEqual, $1, $3, $2.line, context->symbolTable);
if ($$ == 0) {
parseContext->binaryOpError($2.line, "==", $1->getCompleteString(), $3->getCompleteString());
parseContext->recover();
context->binaryOpError($2.line, "==", $1->getCompleteString(), $3->getCompleteString());
context->recover();
ConstantUnion *unionArray = new ConstantUnion[1];
unionArray->setBConst(false);
$$ = parseContext->intermediate.addConstantUnion(unionArray, TType(EbtBool, EbpUndefined, EvqConst), $2.line);
$$ = context->intermediate.addConstantUnion(unionArray, TType(EbtBool, EbpUndefined, EvqConst), $2.line);
}
}
| equality_expression NE_OP relational_expression {
$$ = parseContext->intermediate.addBinaryMath(EOpNotEqual, $1, $3, $2.line, parseContext->symbolTable);
$$ = context->intermediate.addBinaryMath(EOpNotEqual, $1, $3, $2.line, context->symbolTable);
if ($$ == 0) {
parseContext->binaryOpError($2.line, "!=", $1->getCompleteString(), $3->getCompleteString());
parseContext->recover();
context->binaryOpError($2.line, "!=", $1->getCompleteString(), $3->getCompleteString());
context->recover();
ConstantUnion *unionArray = new ConstantUnion[1];
unionArray->setBConst(false);
$$ = parseContext->intermediate.addConstantUnion(unionArray, TType(EbtBool, EbpUndefined, EvqConst), $2.line);
$$ = context->intermediate.addConstantUnion(unionArray, TType(EbtBool, EbpUndefined, EvqConst), $2.line);
}
}
;
......@@ -857,13 +849,13 @@ inclusive_or_expression
logical_and_expression
: inclusive_or_expression { $$ = $1; }
| logical_and_expression AND_OP inclusive_or_expression {
$$ = parseContext->intermediate.addBinaryMath(EOpLogicalAnd, $1, $3, $2.line, parseContext->symbolTable);
$$ = context->intermediate.addBinaryMath(EOpLogicalAnd, $1, $3, $2.line, context->symbolTable);
if ($$ == 0) {
parseContext->binaryOpError($2.line, "&&", $1->getCompleteString(), $3->getCompleteString());
parseContext->recover();
context->binaryOpError($2.line, "&&", $1->getCompleteString(), $3->getCompleteString());
context->recover();
ConstantUnion *unionArray = new ConstantUnion[1];
unionArray->setBConst(false);
$$ = parseContext->intermediate.addConstantUnion(unionArray, TType(EbtBool, EbpUndefined, EvqConst), $2.line);
$$ = context->intermediate.addConstantUnion(unionArray, TType(EbtBool, EbpUndefined, EvqConst), $2.line);
}
}
;
......@@ -871,13 +863,13 @@ logical_and_expression
logical_xor_expression
: logical_and_expression { $$ = $1; }
| logical_xor_expression XOR_OP logical_and_expression {
$$ = parseContext->intermediate.addBinaryMath(EOpLogicalXor, $1, $3, $2.line, parseContext->symbolTable);
$$ = context->intermediate.addBinaryMath(EOpLogicalXor, $1, $3, $2.line, context->symbolTable);
if ($$ == 0) {
parseContext->binaryOpError($2.line, "^^", $1->getCompleteString(), $3->getCompleteString());
parseContext->recover();
context->binaryOpError($2.line, "^^", $1->getCompleteString(), $3->getCompleteString());
context->recover();
ConstantUnion *unionArray = new ConstantUnion[1];
unionArray->setBConst(false);
$$ = parseContext->intermediate.addConstantUnion(unionArray, TType(EbtBool, EbpUndefined, EvqConst), $2.line);
$$ = context->intermediate.addConstantUnion(unionArray, TType(EbtBool, EbpUndefined, EvqConst), $2.line);
}
}
;
......@@ -885,13 +877,13 @@ logical_xor_expression
logical_or_expression
: logical_xor_expression { $$ = $1; }
| logical_or_expression OR_OP logical_xor_expression {
$$ = parseContext->intermediate.addBinaryMath(EOpLogicalOr, $1, $3, $2.line, parseContext->symbolTable);
$$ = context->intermediate.addBinaryMath(EOpLogicalOr, $1, $3, $2.line, context->symbolTable);
if ($$ == 0) {
parseContext->binaryOpError($2.line, "||", $1->getCompleteString(), $3->getCompleteString());
parseContext->recover();
context->binaryOpError($2.line, "||", $1->getCompleteString(), $3->getCompleteString());
context->recover();
ConstantUnion *unionArray = new ConstantUnion[1];
unionArray->setBConst(false);
$$ = parseContext->intermediate.addConstantUnion(unionArray, TType(EbtBool, EbpUndefined, EvqConst), $2.line);
$$ = context->intermediate.addConstantUnion(unionArray, TType(EbtBool, EbpUndefined, EvqConst), $2.line);
}
}
;
......@@ -899,16 +891,16 @@ logical_or_expression
conditional_expression
: logical_or_expression { $$ = $1; }
| logical_or_expression QUESTION expression COLON assignment_expression {
if (parseContext->boolErrorCheck($2.line, $1))
parseContext->recover();
if (context->boolErrorCheck($2.line, $1))
context->recover();
$$ = parseContext->intermediate.addSelection($1, $3, $5, $2.line);
$$ = context->intermediate.addSelection($1, $3, $5, $2.line);
if ($3->getType() != $5->getType())
$$ = 0;
if ($$ == 0) {
parseContext->binaryOpError($2.line, ":", $3->getCompleteString(), $5->getCompleteString());
parseContext->recover();
context->binaryOpError($2.line, ":", $3->getCompleteString(), $5->getCompleteString());
context->recover();
$$ = $5;
}
}
......@@ -917,12 +909,12 @@ conditional_expression
assignment_expression
: conditional_expression { $$ = $1; }
| unary_expression assignment_operator assignment_expression {
if (parseContext->lValueErrorCheck($2.line, "assign", $1))
parseContext->recover();
$$ = parseContext->intermediate.addAssign($2.op, $1, $3, $2.line);
if (context->lValueErrorCheck($2.line, "assign", $1))
context->recover();
$$ = context->intermediate.addAssign($2.op, $1, $3, $2.line);
if ($$ == 0) {
parseContext->assignError($2.line, "assign", $1->getCompleteString(), $3->getCompleteString());
parseContext->recover();
context->assignError($2.line, "assign", $1->getCompleteString(), $3->getCompleteString());
context->recover();
$$ = $1;
}
}
......@@ -941,10 +933,10 @@ expression
$$ = $1;
}
| expression COMMA assignment_expression {
$$ = parseContext->intermediate.addComma($1, $3, $2.line);
$$ = context->intermediate.addComma($1, $3, $2.line);
if ($$ == 0) {
parseContext->binaryOpError($2.line, ",", $1->getCompleteString(), $3->getCompleteString());
parseContext->recover();
context->binaryOpError($2.line, ",", $1->getCompleteString(), $3->getCompleteString());
context->recover();
$$ = $3;
}
}
......@@ -952,8 +944,8 @@ expression
constant_expression
: conditional_expression {
if (parseContext->constErrorCheck($1))
parseContext->recover();
if (context->constErrorCheck($1))
context->recover();
$$ = $1;
}
;
......@@ -973,11 +965,11 @@ declaration
{
TVariable *variable = new TVariable(param.name, *param.type);
prototype = parseContext->intermediate.growAggregate(prototype, parseContext->intermediate.addSymbol(variable->getUniqueId(), variable->getName(), variable->getType(), $1.line), $1.line);
prototype = context->intermediate.growAggregate(prototype, context->intermediate.addSymbol(variable->getUniqueId(), variable->getName(), variable->getType(), $1.line), $1.line);
}
else
{
prototype = parseContext->intermediate.growAggregate(prototype, parseContext->intermediate.addSymbol(0, "", *param.type, $1.line), $1.line);
prototype = context->intermediate.growAggregate(prototype, context->intermediate.addSymbol(0, "", *param.type, $1.line), $1.line);
}
}
......@@ -990,7 +982,7 @@ declaration
$$ = $1.intermAggregate;
}
| PRECISION precision_qualifier type_specifier_no_prec SEMICOLON {
parseContext->symbolTable.setDefaultPrecision( $3.type, $2 );
context->symbolTable.setDefaultPrecision( $3.type, $2 );
$$ = 0;
}
;
......@@ -1005,16 +997,16 @@ function_prototype
//
// Redeclarations are allowed. But, return types and parameter qualifiers must match.
//
TFunction* prevDec = static_cast<TFunction*>(parseContext->symbolTable.find($1->getMangledName()));
TFunction* prevDec = static_cast<TFunction*>(context->symbolTable.find($1->getMangledName()));
if (prevDec) {
if (prevDec->getReturnType() != $1->getReturnType()) {
parseContext->error($2.line, "overloaded functions must have the same return type", $1->getReturnType().getBasicString(), "");
parseContext->recover();
context->error($2.line, "overloaded functions must have the same return type", $1->getReturnType().getBasicString(), "");
context->recover();
}
for (int i = 0; i < prevDec->getParamCount(); ++i) {
if (prevDec->getParam(i).type->getQualifier() != $1->getParam(i).type->getQualifier()) {
parseContext->error($2.line, "overloaded functions must have the same parameter qualifiers", $1->getParam(i).type->getQualifierString(), "");
parseContext->recover();
context->error($2.line, "overloaded functions must have the same parameter qualifiers", $1->getParam(i).type->getQualifierString(), "");
context->recover();
}
}
}
......@@ -1027,7 +1019,7 @@ function_prototype
$$.function = $1;
$$.line = $2.line;
parseContext->symbolTable.insert(*$$.function);
context->symbolTable.insert(*$$.function);
}
;
......@@ -1059,8 +1051,8 @@ function_header_with_parameters
//
// This parameter > first is void
//
parseContext->error($2.line, "cannot be an argument type except for '(void)'", "void", "");
parseContext->recover();
context->error($2.line, "cannot be an argument type except for '(void)'", "void", "");
context->recover();
delete $3.param.type;
} else {
// Add the parameter
......@@ -1073,12 +1065,12 @@ function_header_with_parameters
function_header
: fully_specified_type IDENTIFIER LEFT_PAREN {
if ($1.qualifier != EvqGlobal && $1.qualifier != EvqTemporary) {
parseContext->error($2.line, "no qualifiers allowed for function return", getQualifierString($1.qualifier), "");
parseContext->recover();
context->error($2.line, "no qualifiers allowed for function return", getQualifierString($1.qualifier), "");
context->recover();
}
// make sure a sampler is not involved as well...
if (parseContext->structQualifierErrorCheck($2.line, $1))
parseContext->recover();
if (context->structQualifierErrorCheck($2.line, $1))
context->recover();
// Add the function as a prototype after parsing it (we do not support recursion)
TFunction *function;
......@@ -1092,26 +1084,26 @@ parameter_declarator
// Type + name
: type_specifier IDENTIFIER {
if ($1.type == EbtVoid) {
parseContext->error($2.line, "illegal use of type 'void'", $2.string->c_str(), "");
parseContext->recover();
context->error($2.line, "illegal use of type 'void'", $2.string->c_str(), "");
context->recover();
}
if (parseContext->reservedErrorCheck($2.line, *$2.string))
parseContext->recover();
if (context->reservedErrorCheck($2.line, *$2.string))
context->recover();
TParameter param = {$2.string, new TType($1)};
$$.line = $2.line;
$$.param = param;
}
| type_specifier IDENTIFIER LEFT_BRACKET constant_expression RIGHT_BRACKET {
// Check that we can make an array out of this type
if (parseContext->arrayTypeErrorCheck($3.line, $1))
parseContext->recover();
if (context->arrayTypeErrorCheck($3.line, $1))
context->recover();
if (parseContext->reservedErrorCheck($2.line, *$2.string))
parseContext->recover();
if (context->reservedErrorCheck($2.line, *$2.string))
context->recover();
int size;
if (parseContext->arraySizeErrorCheck($3.line, $4, size))
parseContext->recover();
if (context->arraySizeErrorCheck($3.line, $4, size))
context->recover();
$1.setArray(true, size);
TType* type = new TType($1);
......@@ -1132,30 +1124,30 @@ parameter_declaration
//
: type_qualifier parameter_qualifier parameter_declarator {
$$ = $3;
if (parseContext->paramErrorCheck($3.line, $1.qualifier, $2, $$.param.type))
parseContext->recover();
if (context->paramErrorCheck($3.line, $1.qualifier, $2, $$.param.type))
context->recover();
}
| parameter_qualifier parameter_declarator {
$$ = $2;
if (parseContext->parameterSamplerErrorCheck($2.line, $1, *$2.param.type))
parseContext->recover();
if (parseContext->paramErrorCheck($2.line, EvqTemporary, $1, $$.param.type))
parseContext->recover();
if (context->parameterSamplerErrorCheck($2.line, $1, *$2.param.type))
context->recover();
if (context->paramErrorCheck($2.line, EvqTemporary, $1, $$.param.type))
context->recover();
}
//
// Only type
//
| type_qualifier parameter_qualifier parameter_type_specifier {
$$ = $3;
if (parseContext->paramErrorCheck($3.line, $1.qualifier, $2, $$.param.type))
parseContext->recover();
if (context->paramErrorCheck($3.line, $1.qualifier, $2, $$.param.type))
context->recover();
}
| parameter_qualifier parameter_type_specifier {
$$ = $2;
if (parseContext->parameterSamplerErrorCheck($2.line, $1, *$2.param.type))
parseContext->recover();
if (parseContext->paramErrorCheck($2.line, EvqTemporary, $1, $$.param.type))
parseContext->recover();
if (context->parameterSamplerErrorCheck($2.line, $1, *$2.param.type))
context->recover();
if (context->paramErrorCheck($2.line, EvqTemporary, $1, $$.param.type))
context->recover();
}
;
......@@ -1186,83 +1178,83 @@ init_declarator_list
$$ = $1;
if ($$.type.precision == EbpUndefined) {
$$.type.precision = parseContext->symbolTable.getDefaultPrecision($1.type.type);
if (parseContext->precisionErrorCheck($1.line, $$.type.precision, $1.type.type)) {
parseContext->recover();
$$.type.precision = context->symbolTable.getDefaultPrecision($1.type.type);
if (context->precisionErrorCheck($1.line, $$.type.precision, $1.type.type)) {
context->recover();
}
}
}
| init_declarator_list COMMA IDENTIFIER {
$$.intermAggregate = parseContext->intermediate.growAggregate($1.intermNode, parseContext->intermediate.addSymbol(0, *$3.string, TType($1.type), $3.line), $3.line);
$$.intermAggregate = context->intermediate.growAggregate($1.intermNode, context->intermediate.addSymbol(0, *$3.string, TType($1.type), $3.line), $3.line);
if (parseContext->structQualifierErrorCheck($3.line, $$.type))
parseContext->recover();
if (context->structQualifierErrorCheck($3.line, $$.type))
context->recover();
if (parseContext->nonInitConstErrorCheck($3.line, *$3.string, $$.type))
parseContext->recover();
if (context->nonInitConstErrorCheck($3.line, *$3.string, $$.type))
context->recover();
if (parseContext->nonInitErrorCheck($3.line, *$3.string, $$.type))
parseContext->recover();
if (context->nonInitErrorCheck($3.line, *$3.string, $$.type))
context->recover();
}
| init_declarator_list COMMA IDENTIFIER LEFT_BRACKET RIGHT_BRACKET {
if (parseContext->structQualifierErrorCheck($3.line, $1.type))
parseContext->recover();
if (context->structQualifierErrorCheck($3.line, $1.type))
context->recover();
if (parseContext->nonInitConstErrorCheck($3.line, *$3.string, $1.type))
parseContext->recover();
if (context->nonInitConstErrorCheck($3.line, *$3.string, $1.type))
context->recover();
$$ = $1;
if (parseContext->arrayTypeErrorCheck($4.line, $1.type) || parseContext->arrayQualifierErrorCheck($4.line, $1.type))
parseContext->recover();
if (context->arrayTypeErrorCheck($4.line, $1.type) || context->arrayQualifierErrorCheck($4.line, $1.type))
context->recover();
else {
$1.type.setArray(true);
TVariable* variable;
if (parseContext->arrayErrorCheck($4.line, *$3.string, $1.type, variable))
parseContext->recover();
if (context->arrayErrorCheck($4.line, *$3.string, $1.type, variable))
context->recover();
}
}
| init_declarator_list COMMA IDENTIFIER LEFT_BRACKET constant_expression RIGHT_BRACKET {
if (parseContext->structQualifierErrorCheck($3.line, $1.type))
parseContext->recover();
if (context->structQualifierErrorCheck($3.line, $1.type))
context->recover();
if (parseContext->nonInitConstErrorCheck($3.line, *$3.string, $1.type))
parseContext->recover();
if (context->nonInitConstErrorCheck($3.line, *$3.string, $1.type))
context->recover();
$$ = $1;
if (parseContext->arrayTypeErrorCheck($4.line, $1.type) || parseContext->arrayQualifierErrorCheck($4.line, $1.type))
parseContext->recover();
if (context->arrayTypeErrorCheck($4.line, $1.type) || context->arrayQualifierErrorCheck($4.line, $1.type))
context->recover();
else {
int size;
if (parseContext->arraySizeErrorCheck($4.line, $5, size))
parseContext->recover();
if (context->arraySizeErrorCheck($4.line, $5, size))
context->recover();
$1.type.setArray(true, size);
TVariable* variable;
if (parseContext->arrayErrorCheck($4.line, *$3.string, $1.type, variable))
parseContext->recover();
if (context->arrayErrorCheck($4.line, *$3.string, $1.type, variable))
context->recover();
TType type = TType($1.type);
type.setArraySize(size);
$$.intermAggregate = parseContext->intermediate.growAggregate($1.intermNode, parseContext->intermediate.addSymbol(0, *$3.string, type, $3.line), $3.line);
$$.intermAggregate = context->intermediate.growAggregate($1.intermNode, context->intermediate.addSymbol(0, *$3.string, type, $3.line), $3.line);
}
}
| init_declarator_list COMMA IDENTIFIER EQUAL initializer {
if (parseContext->structQualifierErrorCheck($3.line, $1.type))
parseContext->recover();
if (context->structQualifierErrorCheck($3.line, $1.type))
context->recover();
$$ = $1;
TIntermNode* intermNode;
if (!parseContext->executeInitializer($3.line, *$3.string, $1.type, $5, intermNode)) {
if (!context->executeInitializer($3.line, *$3.string, $1.type, $5, intermNode)) {
//
// build the intermediate representation
//
if (intermNode)
$$.intermAggregate = parseContext->intermediate.growAggregate($1.intermNode, intermNode, $4.line);
$$.intermAggregate = context->intermediate.growAggregate($1.intermNode, intermNode, $4.line);
else
$$.intermAggregate = $1.intermAggregate;
} else {
parseContext->recover();
context->recover();
$$.intermAggregate = 0;
}
}
......@@ -1271,88 +1263,88 @@ init_declarator_list
single_declaration
: fully_specified_type {
$$.type = $1;
$$.intermAggregate = parseContext->intermediate.makeAggregate(parseContext->intermediate.addSymbol(0, "", TType($1), $1.line), $1.line);
$$.intermAggregate = context->intermediate.makeAggregate(context->intermediate.addSymbol(0, "", TType($1), $1.line), $1.line);
}
| fully_specified_type IDENTIFIER {
$$.intermAggregate = parseContext->intermediate.makeAggregate(parseContext->intermediate.addSymbol(0, *$2.string, TType($1), $2.line), $2.line);
$$.intermAggregate = context->intermediate.makeAggregate(context->intermediate.addSymbol(0, *$2.string, TType($1), $2.line), $2.line);
if (parseContext->structQualifierErrorCheck($2.line, $$.type))
parseContext->recover();
if (context->structQualifierErrorCheck($2.line, $$.type))
context->recover();
if (parseContext->nonInitConstErrorCheck($2.line, *$2.string, $$.type))
parseContext->recover();
if (context->nonInitConstErrorCheck($2.line, *$2.string, $$.type))
context->recover();
$$.type = $1;
if (parseContext->nonInitErrorCheck($2.line, *$2.string, $$.type))
parseContext->recover();
if (context->nonInitErrorCheck($2.line, *$2.string, $$.type))
context->recover();
}
| fully_specified_type IDENTIFIER LEFT_BRACKET RIGHT_BRACKET {
$$.intermAggregate = parseContext->intermediate.makeAggregate(parseContext->intermediate.addSymbol(0, *$2.string, TType($1), $2.line), $2.line);
$$.intermAggregate = context->intermediate.makeAggregate(context->intermediate.addSymbol(0, *$2.string, TType($1), $2.line), $2.line);
if (parseContext->structQualifierErrorCheck($2.line, $1))
parseContext->recover();
if (context->structQualifierErrorCheck($2.line, $1))
context->recover();
if (parseContext->nonInitConstErrorCheck($2.line, *$2.string, $1))
parseContext->recover();
if (context->nonInitConstErrorCheck($2.line, *$2.string, $1))
context->recover();
$$.type = $1;
if (parseContext->arrayTypeErrorCheck($3.line, $1) || parseContext->arrayQualifierErrorCheck($3.line, $1))
parseContext->recover();
if (context->arrayTypeErrorCheck($3.line, $1) || context->arrayQualifierErrorCheck($3.line, $1))
context->recover();
else {
$1.setArray(true);
TVariable* variable;
if (parseContext->arrayErrorCheck($3.line, *$2.string, $1, variable))
parseContext->recover();
if (context->arrayErrorCheck($3.line, *$2.string, $1, variable))
context->recover();
}
}
| fully_specified_type IDENTIFIER LEFT_BRACKET constant_expression RIGHT_BRACKET {
TType type = TType($1);
int size;
if (parseContext->arraySizeErrorCheck($2.line, $4, size))
parseContext->recover();
if (context->arraySizeErrorCheck($2.line, $4, size))
context->recover();
type.setArraySize(size);
$$.intermAggregate = parseContext->intermediate.makeAggregate(parseContext->intermediate.addSymbol(0, *$2.string, type, $2.line), $2.line);
$$.intermAggregate = context->intermediate.makeAggregate(context->intermediate.addSymbol(0, *$2.string, type, $2.line), $2.line);
if (parseContext->structQualifierErrorCheck($2.line, $1))
parseContext->recover();
if (context->structQualifierErrorCheck($2.line, $1))
context->recover();
if (parseContext->nonInitConstErrorCheck($2.line, *$2.string, $1))
parseContext->recover();
if (context->nonInitConstErrorCheck($2.line, *$2.string, $1))
context->recover();
$$.type = $1;
if (parseContext->arrayTypeErrorCheck($3.line, $1) || parseContext->arrayQualifierErrorCheck($3.line, $1))
parseContext->recover();
if (context->arrayTypeErrorCheck($3.line, $1) || context->arrayQualifierErrorCheck($3.line, $1))
context->recover();
else {
int size;
if (parseContext->arraySizeErrorCheck($3.line, $4, size))
parseContext->recover();
if (context->arraySizeErrorCheck($3.line, $4, size))
context->recover();
$1.setArray(true, size);
TVariable* variable;
if (parseContext->arrayErrorCheck($3.line, *$2.string, $1, variable))
parseContext->recover();
if (context->arrayErrorCheck($3.line, *$2.string, $1, variable))
context->recover();
}
}
| fully_specified_type IDENTIFIER EQUAL initializer {
if (parseContext->structQualifierErrorCheck($2.line, $1))
parseContext->recover();
if (context->structQualifierErrorCheck($2.line, $1))
context->recover();
$$.type = $1;
TIntermNode* intermNode;
if (!parseContext->executeInitializer($2.line, *$2.string, $1, $4, intermNode)) {
if (!context->executeInitializer($2.line, *$2.string, $1, $4, intermNode)) {
//
// Build intermediate representation
//
if(intermNode)
$$.intermAggregate = parseContext->intermediate.makeAggregate(intermNode, $3.line);
$$.intermAggregate = context->intermediate.makeAggregate(intermNode, $3.line);
else
$$.intermAggregate = 0;
} else {
parseContext->recover();
context->recover();
$$.intermAggregate = 0;
}
}
......@@ -1384,14 +1376,14 @@ single_declaration
//
//input_or_output
// : INPUT {
// if (parseContext->globalErrorCheck($1.line, parseContext->symbolTable.atGlobalLevel(), "input"))
// parseContext->recover();
// if (context->globalErrorCheck($1.line, context->symbolTable.atGlobalLevel(), "input"))
// context->recover();
// UNPACK_ONLY("input", $1.line);
// $$.qualifier = EvqInput;
// }
// | OUTPUT {
// if (parseContext->globalErrorCheck($1.line, parseContext->symbolTable.atGlobalLevel(), "output"))
// parseContext->recover();
// if (context->globalErrorCheck($1.line, context->symbolTable.atGlobalLevel(), "output"))
// context->recover();
// PACK_ONLY("output", $1.line);
// $$.qualifier = EvqOutput;
// }
......@@ -1420,12 +1412,12 @@ single_declaration
//
//buffer_declaration
// : type_specifier IDENTIFIER COLON constant_expression SEMICOLON {
// if (parseContext->reservedErrorCheck($2.line, *$2.string, parseContext))
// parseContext->recover();
// if (context->reservedErrorCheck($2.line, *$2.string, context))
// context->recover();
// $$.variable = new TVariable($2.string, $1);
// if (! parseContext->symbolTable.insert(*$$.variable)) {
// parseContext->error($2.line, "redefinition", $$.variable->getName().c_str(), "");
// parseContext->recover();
// if (! context->symbolTable.insert(*$$.variable)) {
// context->error($2.line, "redefinition", $$.variable->getName().c_str(), "");
// context->recover();
// // don't have to delete $$.variable, the pool pop will take care of it
// }
// }
......@@ -1436,27 +1428,27 @@ fully_specified_type
$$ = $1;
if ($1.array) {
parseContext->error($1.line, "not supported", "first-class array", "");
parseContext->recover();
context->error($1.line, "not supported", "first-class array", "");
context->recover();
$1.setArray(false);
}
}
| type_qualifier type_specifier {
if ($2.array) {
parseContext->error($2.line, "not supported", "first-class array", "");
parseContext->recover();
context->error($2.line, "not supported", "first-class array", "");
context->recover();
$2.setArray(false);
}
if ($1.qualifier == EvqAttribute &&
($2.type == EbtBool || $2.type == EbtInt)) {
parseContext->error($2.line, "cannot be bool or int", getQualifierString($1.qualifier), "");
parseContext->recover();
context->error($2.line, "cannot be bool or int", getQualifierString($1.qualifier), "");
context->recover();
}
if (($1.qualifier == EvqVaryingIn || $1.qualifier == EvqVaryingOut) &&
($2.type == EbtBool || $2.type == EbtInt)) {
parseContext->error($2.line, "cannot be bool or int", getQualifierString($1.qualifier), "");
parseContext->recover();
context->error($2.line, "cannot be bool or int", getQualifierString($1.qualifier), "");
context->recover();
}
$$ = $2;
$$.qualifier = $1.qualifier;
......@@ -1469,29 +1461,29 @@ type_qualifier
}
| ATTRIBUTE {
VERTEX_ONLY("attribute", $1.line);
if (parseContext->globalErrorCheck($1.line, parseContext->symbolTable.atGlobalLevel(), "attribute"))
parseContext->recover();
if (context->globalErrorCheck($1.line, context->symbolTable.atGlobalLevel(), "attribute"))
context->recover();
$$.setBasic(EbtVoid, EvqAttribute, $1.line);
}
| VARYING {
if (parseContext->globalErrorCheck($1.line, parseContext->symbolTable.atGlobalLevel(), "varying"))
parseContext->recover();
if (parseContext->shaderType == SH_VERTEX_SHADER)
if (context->globalErrorCheck($1.line, context->symbolTable.atGlobalLevel(), "varying"))
context->recover();
if (context->shaderType == SH_VERTEX_SHADER)
$$.setBasic(EbtVoid, EvqVaryingOut, $1.line);
else
$$.setBasic(EbtVoid, EvqVaryingIn, $1.line);
}
| INVARIANT VARYING {
if (parseContext->globalErrorCheck($1.line, parseContext->symbolTable.atGlobalLevel(), "invariant varying"))
parseContext->recover();
if (parseContext->shaderType == SH_VERTEX_SHADER)
if (context->globalErrorCheck($1.line, context->symbolTable.atGlobalLevel(), "invariant varying"))
context->recover();
if (context->shaderType == SH_VERTEX_SHADER)
$$.setBasic(EbtVoid, EvqInvariantVaryingOut, $1.line);
else
$$.setBasic(EbtVoid, EvqInvariantVaryingIn, $1.line);
}
| UNIFORM {
if (parseContext->globalErrorCheck($1.line, parseContext->symbolTable.atGlobalLevel(), "uniform"))
parseContext->recover();
if (context->globalErrorCheck($1.line, context->symbolTable.atGlobalLevel(), "uniform"))
context->recover();
$$.setBasic(EbtVoid, EvqUniform, $1.line);
}
;
......@@ -1525,12 +1517,12 @@ type_specifier_no_prec
| type_specifier_nonarray LEFT_BRACKET constant_expression RIGHT_BRACKET {
$$ = $1;
if (parseContext->arrayTypeErrorCheck($2.line, $1))
parseContext->recover();
if (context->arrayTypeErrorCheck($2.line, $1))
context->recover();
else {
int size;
if (parseContext->arraySizeErrorCheck($2.line, $3, size))
parseContext->recover();
if (context->arraySizeErrorCheck($2.line, $3, size))
context->recover();
$$.setArray(true, size);
}
}
......@@ -1538,103 +1530,103 @@ type_specifier_no_prec
type_specifier_nonarray
: VOID_TYPE {
TQualifier qual = parseContext->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
$$.setBasic(EbtVoid, qual, $1.line);
}
| FLOAT_TYPE {
TQualifier qual = parseContext->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
$$.setBasic(EbtFloat, qual, $1.line);
}
| INT_TYPE {
TQualifier qual = parseContext->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
$$.setBasic(EbtInt, qual, $1.line);
}
| BOOL_TYPE {
TQualifier qual = parseContext->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
$$.setBasic(EbtBool, qual, $1.line);
}
// | UNSIGNED INT_TYPE {
// PACK_UNPACK_ONLY("unsigned", $1.line);
// TQualifier qual = parseContext->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
// TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
// $$.setBasic(EbtInt, qual, $1.line);
// }
| VEC2 {
TQualifier qual = parseContext->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
$$.setBasic(EbtFloat, qual, $1.line);
$$.setAggregate(2);
}
| VEC3 {
TQualifier qual = parseContext->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
$$.setBasic(EbtFloat, qual, $1.line);
$$.setAggregate(3);
}
| VEC4 {
TQualifier qual = parseContext->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
$$.setBasic(EbtFloat, qual, $1.line);
$$.setAggregate(4);
}
| BVEC2 {
TQualifier qual = parseContext->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
$$.setBasic(EbtBool, qual, $1.line);
$$.setAggregate(2);
}
| BVEC3 {
TQualifier qual = parseContext->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
$$.setBasic(EbtBool, qual, $1.line);
$$.setAggregate(3);
}
| BVEC4 {
TQualifier qual = parseContext->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
$$.setBasic(EbtBool, qual, $1.line);
$$.setAggregate(4);
}
| IVEC2 {
TQualifier qual = parseContext->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
$$.setBasic(EbtInt, qual, $1.line);
$$.setAggregate(2);
}
| IVEC3 {
TQualifier qual = parseContext->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
$$.setBasic(EbtInt, qual, $1.line);
$$.setAggregate(3);
}
| IVEC4 {
TQualifier qual = parseContext->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
$$.setBasic(EbtInt, qual, $1.line);
$$.setAggregate(4);
}
| MATRIX2 {
FRAG_VERT_ONLY("mat2", $1.line);
TQualifier qual = parseContext->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
$$.setBasic(EbtFloat, qual, $1.line);
$$.setAggregate(2, true);
}
| MATRIX3 {
FRAG_VERT_ONLY("mat3", $1.line);
TQualifier qual = parseContext->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
$$.setBasic(EbtFloat, qual, $1.line);
$$.setAggregate(3, true);
}
| MATRIX4 {
FRAG_VERT_ONLY("mat4", $1.line);
TQualifier qual = parseContext->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
$$.setBasic(EbtFloat, qual, $1.line);
$$.setAggregate(4, true);
}
| SAMPLER2D {
FRAG_VERT_ONLY("sampler2D", $1.line);
TQualifier qual = parseContext->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
$$.setBasic(EbtSampler2D, qual, $1.line);
}
| SAMPLERCUBE {
FRAG_VERT_ONLY("samplerCube", $1.line);
TQualifier qual = parseContext->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
$$.setBasic(EbtSamplerCube, qual, $1.line);
}
| struct_specifier {
FRAG_VERT_ONLY("struct", $1.line);
$$ = $1;
$$.qualifier = parseContext->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
$$.qualifier = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
}
| TYPE_NAME {
//
......@@ -1642,7 +1634,7 @@ type_specifier_nonarray
// type.
//
TType& structure = static_cast<TVariable*>($1.symbol)->getType();
TQualifier qual = parseContext->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
$$.setBasic(EbtStruct, qual, $1.line);
$$.userDef = &structure;
}
......@@ -1650,14 +1642,14 @@ type_specifier_nonarray
struct_specifier
: STRUCT IDENTIFIER LEFT_BRACE struct_declaration_list RIGHT_BRACE {
if (parseContext->reservedErrorCheck($2.line, *$2.string))
parseContext->recover();
if (context->reservedErrorCheck($2.line, *$2.string))
context->recover();
TType* structure = new TType($4, *$2.string);
TVariable* userTypeDef = new TVariable($2.string, *structure, true);
if (! parseContext->symbolTable.insert(*userTypeDef)) {
parseContext->error($2.line, "redefinition", $2.string->c_str(), "struct");
parseContext->recover();
if (! context->symbolTable.insert(*userTypeDef)) {
context->error($2.line, "redefinition", $2.string->c_str(), "struct");
context->recover();
}
$$.setBasic(EbtStruct, EvqTemporary, $1.line);
$$.userDef = structure;
......@@ -1678,8 +1670,8 @@ struct_declaration_list
for (unsigned int i = 0; i < $2->size(); ++i) {
for (unsigned int j = 0; j < $$->size(); ++j) {
if ((*$$)[j].type->getFieldName() == (*$2)[i].type->getFieldName()) {
parseContext->error((*$2)[i].line, "duplicate field name in structure:", "struct", (*$2)[i].type->getFieldName().c_str());
parseContext->recover();
context->error((*$2)[i].line, "duplicate field name in structure:", "struct", (*$2)[i].type->getFieldName().c_str());
context->recover();
}
}
$$->push_back((*$2)[i]);
......@@ -1691,8 +1683,8 @@ struct_declaration
: type_specifier struct_declarator_list SEMICOLON {
$$ = $2;
if (parseContext->voidErrorCheck($1.line, (*$2)[0].type->getFieldName(), $1)) {
parseContext->recover();
if (context->voidErrorCheck($1.line, (*$2)[0].type->getFieldName(), $1)) {
context->recover();
}
for (unsigned int i = 0; i < $$->size(); ++i) {
//
......@@ -1705,8 +1697,8 @@ struct_declaration
// don't allow arrays of arrays
if (type->isArray()) {
if (parseContext->arrayTypeErrorCheck($1.line, $1))
parseContext->recover();
if (context->arrayTypeErrorCheck($1.line, $1))
context->recover();
}
if ($1.array)
type->setArraySize($1.arraySize);
......@@ -1730,24 +1722,24 @@ struct_declarator_list
struct_declarator
: IDENTIFIER {
if (parseContext->reservedErrorCheck($1.line, *$1.string))
parseContext->recover();
if (context->reservedErrorCheck($1.line, *$1.string))
context->recover();
$$.type = new TType(EbtVoid, EbpUndefined);
$$.line = $1.line;
$$.type->setFieldName(*$1.string);
}
| IDENTIFIER LEFT_BRACKET constant_expression RIGHT_BRACKET {
if (parseContext->reservedErrorCheck($1.line, *$1.string))
parseContext->recover();
if (context->reservedErrorCheck($1.line, *$1.string))
context->recover();
$$.type = new TType(EbtVoid, EbpUndefined);
$$.line = $1.line;
$$.type->setFieldName(*$1.string);
int size;
if (parseContext->arraySizeErrorCheck($2.line, $3, size))
parseContext->recover();
if (context->arraySizeErrorCheck($2.line, $3, size))
context->recover();
$$.type->setArraySize(size);
}
;
......@@ -1777,7 +1769,7 @@ simple_statement
compound_statement
: LEFT_BRACE RIGHT_BRACE { $$ = 0; }
| LEFT_BRACE { parseContext->symbolTable.push(); } statement_list { parseContext->symbolTable.pop(); } RIGHT_BRACE {
| LEFT_BRACE { context->symbolTable.push(); } statement_list { context->symbolTable.pop(); } RIGHT_BRACE {
if ($3 != 0)
$3->setOp(EOpSequence);
$$ = $3;
......@@ -1803,10 +1795,10 @@ compound_statement_no_new_scope
statement_list
: statement {
$$ = parseContext->intermediate.makeAggregate($1, 0);
$$ = context->intermediate.makeAggregate($1, 0);
}
| statement_list statement {
$$ = parseContext->intermediate.growAggregate($1, $2, 0);
$$ = context->intermediate.growAggregate($1, $2, 0);
}
;
......@@ -1817,9 +1809,9 @@ expression_statement
selection_statement
: IF LEFT_PAREN expression RIGHT_PAREN selection_rest_statement {
if (parseContext->boolErrorCheck($1.line, $3))
parseContext->recover();
$$ = parseContext->intermediate.addSelection($3, $5, $1.line);
if (context->boolErrorCheck($1.line, $3))
context->recover();
$$ = context->intermediate.addSelection($3, $5, $1.line);
}
;
......@@ -1840,42 +1832,42 @@ condition
// In 1996 c++ draft, conditions can include single declarations
: expression {
$$ = $1;
if (parseContext->boolErrorCheck($1->getLine(), $1))
parseContext->recover();
if (context->boolErrorCheck($1->getLine(), $1))
context->recover();
}
| fully_specified_type IDENTIFIER EQUAL initializer {
TIntermNode* intermNode;
if (parseContext->structQualifierErrorCheck($2.line, $1))
parseContext->recover();
if (parseContext->boolErrorCheck($2.line, $1))
parseContext->recover();
if (context->structQualifierErrorCheck($2.line, $1))
context->recover();
if (context->boolErrorCheck($2.line, $1))
context->recover();
if (!parseContext->executeInitializer($2.line, *$2.string, $1, $4, intermNode))
if (!context->executeInitializer($2.line, *$2.string, $1, $4, intermNode))
$$ = $4;
else {
parseContext->recover();
context->recover();
$$ = 0;
}
}
;
iteration_statement
: WHILE LEFT_PAREN { parseContext->symbolTable.push(); ++parseContext->loopNestingLevel; } condition RIGHT_PAREN statement_no_new_scope {
parseContext->symbolTable.pop();
$$ = parseContext->intermediate.addLoop(0, $6, $4, 0, true, $1.line);
--parseContext->loopNestingLevel;
: WHILE LEFT_PAREN { context->symbolTable.push(); ++context->loopNestingLevel; } condition RIGHT_PAREN statement_no_new_scope {
context->symbolTable.pop();
$$ = context->intermediate.addLoop(0, $6, $4, 0, true, $1.line);
--context->loopNestingLevel;
}
| DO { ++parseContext->loopNestingLevel; } statement WHILE LEFT_PAREN expression RIGHT_PAREN SEMICOLON {
if (parseContext->boolErrorCheck($8.line, $6))
parseContext->recover();
| DO { ++context->loopNestingLevel; } statement WHILE LEFT_PAREN expression RIGHT_PAREN SEMICOLON {
if (context->boolErrorCheck($8.line, $6))
context->recover();
$$ = parseContext->intermediate.addLoop(0, $3, $6, 0, false, $4.line);
--parseContext->loopNestingLevel;
$$ = context->intermediate.addLoop(0, $3, $6, 0, false, $4.line);
--context->loopNestingLevel;
}
| FOR LEFT_PAREN { parseContext->symbolTable.push(); ++parseContext->loopNestingLevel; } for_init_statement for_rest_statement RIGHT_PAREN statement_no_new_scope {
parseContext->symbolTable.pop();
$$ = parseContext->intermediate.addLoop($4, $7, reinterpret_cast<TIntermTyped*>($5.node1), reinterpret_cast<TIntermTyped*>($5.node2), true, $1.line);
--parseContext->loopNestingLevel;
| FOR LEFT_PAREN { context->symbolTable.push(); ++context->loopNestingLevel; } for_init_statement for_rest_statement RIGHT_PAREN statement_no_new_scope {
context->symbolTable.pop();
$$ = context->intermediate.addLoop($4, $7, reinterpret_cast<TIntermTyped*>($5.node1), reinterpret_cast<TIntermTyped*>($5.node2), true, $1.line);
--context->loopNestingLevel;
}
;
......@@ -1910,40 +1902,40 @@ for_rest_statement
jump_statement
: CONTINUE SEMICOLON {
if (parseContext->loopNestingLevel <= 0) {
parseContext->error($1.line, "continue statement only allowed in loops", "", "");
parseContext->recover();
if (context->loopNestingLevel <= 0) {
context->error($1.line, "continue statement only allowed in loops", "", "");
context->recover();
}
$$ = parseContext->intermediate.addBranch(EOpContinue, $1.line);
$$ = context->intermediate.addBranch(EOpContinue, $1.line);
}
| BREAK SEMICOLON {
if (parseContext->loopNestingLevel <= 0) {
parseContext->error($1.line, "break statement only allowed in loops", "", "");
parseContext->recover();
if (context->loopNestingLevel <= 0) {
context->error($1.line, "break statement only allowed in loops", "", "");
context->recover();
}
$$ = parseContext->intermediate.addBranch(EOpBreak, $1.line);
$$ = context->intermediate.addBranch(EOpBreak, $1.line);
}
| RETURN SEMICOLON {
$$ = parseContext->intermediate.addBranch(EOpReturn, $1.line);
if (parseContext->currentFunctionType->getBasicType() != EbtVoid) {
parseContext->error($1.line, "non-void function must return a value", "return", "");
parseContext->recover();
$$ = context->intermediate.addBranch(EOpReturn, $1.line);
if (context->currentFunctionType->getBasicType() != EbtVoid) {
context->error($1.line, "non-void function must return a value", "return", "");
context->recover();
}
}
| RETURN expression SEMICOLON {
$$ = parseContext->intermediate.addBranch(EOpReturn, $2, $1.line);
parseContext->functionReturnsValue = true;
if (parseContext->currentFunctionType->getBasicType() == EbtVoid) {
parseContext->error($1.line, "void function cannot return a value", "return", "");
parseContext->recover();
} else if (*(parseContext->currentFunctionType) != $2->getType()) {
parseContext->error($1.line, "function return is not matching type:", "return", "");
parseContext->recover();
$$ = context->intermediate.addBranch(EOpReturn, $2, $1.line);
context->functionReturnsValue = true;
if (context->currentFunctionType->getBasicType() == EbtVoid) {
context->error($1.line, "void function cannot return a value", "return", "");
context->recover();
} else if (*(context->currentFunctionType) != $2->getType()) {
context->error($1.line, "function return is not matching type:", "return", "");
context->recover();
}
}
| DISCARD SEMICOLON {
FRAG_ONLY("discard", $1.line);
$$ = parseContext->intermediate.addBranch(EOpKill, $1.line);
$$ = context->intermediate.addBranch(EOpKill, $1.line);
}
;
......@@ -1952,11 +1944,11 @@ jump_statement
translation_unit
: external_declaration {
$$ = $1;
parseContext->treeRoot = $$;
context->treeRoot = $$;
}
| translation_unit external_declaration {
$$ = parseContext->intermediate.growAggregate($1, $2, 0);
parseContext->treeRoot = $$;
$$ = context->intermediate.growAggregate($1, $2, 0);
context->treeRoot = $$;
}
;
......@@ -1972,7 +1964,7 @@ external_declaration
function_definition
: function_prototype {
TFunction* function = $1.function;
TFunction* prevDec = static_cast<TFunction*>(parseContext->symbolTable.find(function->getMangledName()));
TFunction* prevDec = static_cast<TFunction*>(context->symbolTable.find(function->getMangledName()));
//
// Note: 'prevDec' could be 'function' if this is the first time we've seen function
// as it would have just been put in the symbol table. Otherwise, we're looking up
......@@ -1982,8 +1974,8 @@ function_definition
//
// Then this function already has a body.
//
parseContext->error($1.line, "function already has a body", function->getName().c_str(), "");
parseContext->recover();
context->error($1.line, "function already has a body", function->getName().c_str(), "");
context->recover();
}
prevDec->setDefined();
......@@ -1992,25 +1984,25 @@ function_definition
//
if (function->getName() == "main") {
if (function->getParamCount() > 0) {
parseContext->error($1.line, "function cannot take any parameter(s)", function->getName().c_str(), "");
parseContext->recover();
context->error($1.line, "function cannot take any parameter(s)", function->getName().c_str(), "");
context->recover();
}
if (function->getReturnType().getBasicType() != EbtVoid) {
parseContext->error($1.line, "", function->getReturnType().getBasicString(), "main function cannot return a value");
parseContext->recover();
context->error($1.line, "", function->getReturnType().getBasicString(), "main function cannot return a value");
context->recover();
}
}
//
// New symbol table scope for body of function plus its arguments
//
parseContext->symbolTable.push();
context->symbolTable.push();
//
// Remember the return type for later checking for RETURN statements.
//
parseContext->currentFunctionType = &(prevDec->getReturnType());
parseContext->functionReturnsValue = false;
context->currentFunctionType = &(prevDec->getReturnType());
context->functionReturnsValue = false;
//
// Insert parameters into the symbol table.
......@@ -2028,48 +2020,53 @@ function_definition
//
// Insert the parameters with name in the symbol table.
//
if (! parseContext->symbolTable.insert(*variable)) {
parseContext->error($1.line, "redefinition", variable->getName().c_str(), "");
parseContext->recover();
if (! context->symbolTable.insert(*variable)) {
context->error($1.line, "redefinition", variable->getName().c_str(), "");
context->recover();
delete variable;
}
//
// Add the parameter to the HIL
//
paramNodes = parseContext->intermediate.growAggregate(
paramNodes = context->intermediate.growAggregate(
paramNodes,
parseContext->intermediate.addSymbol(variable->getUniqueId(),
context->intermediate.addSymbol(variable->getUniqueId(),
variable->getName(),
variable->getType(), $1.line),
$1.line);
} else {
paramNodes = parseContext->intermediate.growAggregate(paramNodes, parseContext->intermediate.addSymbol(0, "", *param.type, $1.line), $1.line);
paramNodes = context->intermediate.growAggregate(paramNodes, context->intermediate.addSymbol(0, "", *param.type, $1.line), $1.line);
}
}
parseContext->intermediate.setAggregateOperator(paramNodes, EOpParameters, $1.line);
context->intermediate.setAggregateOperator(paramNodes, EOpParameters, $1.line);
$1.intermAggregate = paramNodes;
parseContext->loopNestingLevel = 0;
context->loopNestingLevel = 0;
}
compound_statement_no_new_scope {
//?? Check that all paths return a value if return type != void ?
// May be best done as post process phase on intermediate code
if (parseContext->currentFunctionType->getBasicType() != EbtVoid && ! parseContext->functionReturnsValue) {
parseContext->error($1.line, "function does not return a value:", "", $1.function->getName().c_str());
parseContext->recover();
if (context->currentFunctionType->getBasicType() != EbtVoid && ! context->functionReturnsValue) {
context->error($1.line, "function does not return a value:", "", $1.function->getName().c_str());
context->recover();
}
parseContext->symbolTable.pop();
$$ = parseContext->intermediate.growAggregate($1.intermAggregate, $3, 0);
parseContext->intermediate.setAggregateOperator($$, EOpFunction, $1.line);
context->symbolTable.pop();
$$ = context->intermediate.growAggregate($1.intermAggregate, $3, 0);
context->intermediate.setAggregateOperator($$, EOpFunction, $1.line);
$$->getAsAggregate()->setName($1.function->getMangledName().c_str());
$$->getAsAggregate()->setType($1.function->getReturnType());
// store the pragma information for debug and optimize and other vendor specific
// information. This information can be queried from the parse tree
$$->getAsAggregate()->setOptimize(parseContext->contextPragma.optimize);
$$->getAsAggregate()->setDebug(parseContext->contextPragma.debug);
$$->getAsAggregate()->addToPragmaTable(parseContext->contextPragma.pragmaTable);
$$->getAsAggregate()->setOptimize(context->contextPragma.optimize);
$$->getAsAggregate()->setDebug(context->contextPragma.debug);
$$->getAsAggregate()->addToPragmaTable(context->contextPragma.pragmaTable);
}
;
%%
int glslang_parse(TParseContext* context) {
return yyparse(context);
}
#line 17 "compiler/glslang.l"
//
// 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.
//
// This file is auto-generated by generate_glslang_lexer.sh. DO NOT EDIT!
#line 13 "compiler/glslang_lex.cpp"
#define YY_INT_ALIGNED short int
/* A lexical scanner generated by flex */
#define FLEX_SCANNER
#define YY_FLEX_MAJOR_VERSION 2
#define YY_FLEX_MINOR_VERSION 5
#define YY_FLEX_SUBMINOR_VERSION 35
#if YY_FLEX_SUBMINOR_VERSION > 0
#define FLEX_BETA
#endif
/* First, we deal with platform-specific or compiler-specific issues. */
/* begin standard C headers. */
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <stdlib.h>
/* end standard C headers. */
/* flex integer type definitions */
#ifndef FLEXINT_H
#define FLEXINT_H
/* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */
#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h,
* if you want the limit (max/min) macros for int types.
*/
#ifndef __STDC_LIMIT_MACROS
#define __STDC_LIMIT_MACROS 1
#endif
#include <inttypes.h>
typedef int8_t flex_int8_t;
typedef uint8_t flex_uint8_t;
typedef int16_t flex_int16_t;
typedef uint16_t flex_uint16_t;
typedef int32_t flex_int32_t;
typedef uint32_t flex_uint32_t;
#else
typedef signed char flex_int8_t;
typedef short int flex_int16_t;
typedef int flex_int32_t;
typedef unsigned char flex_uint8_t;
typedef unsigned short int flex_uint16_t;
typedef unsigned int flex_uint32_t;
#endif /* ! C99 */
/* Limits of integral types. */
#ifndef INT8_MIN
#define INT8_MIN (-128)
#endif
#ifndef INT16_MIN
#define INT16_MIN (-32767-1)
#endif
#ifndef INT32_MIN
#define INT32_MIN (-2147483647-1)
#endif
#ifndef INT8_MAX
#define INT8_MAX (127)
#endif
#ifndef INT16_MAX
#define INT16_MAX (32767)
#endif
#ifndef INT32_MAX
#define INT32_MAX (2147483647)
#endif
#ifndef UINT8_MAX
#define UINT8_MAX (255U)
#endif
#ifndef UINT16_MAX
#define UINT16_MAX (65535U)
#endif
#ifndef UINT32_MAX
#define UINT32_MAX (4294967295U)
#endif
#endif /* ! FLEXINT_H */
#ifdef __cplusplus
/* The "const" storage-class-modifier is valid. */
#define YY_USE_CONST
#else /* ! __cplusplus */
/* C99 requires __STDC__ to be defined as 1. */
#if defined (__STDC__)
#define YY_USE_CONST
#endif /* defined (__STDC__) */
#endif /* ! __cplusplus */
#ifdef YY_USE_CONST
#define yyconst const
#else
#define yyconst
#endif
/* Returned upon end-of-file. */
#define YY_NULL 0
/* Promotes a possibly negative, possibly signed char to an unsigned
* integer for use as an array index. If the signed char is negative,
* we want to instead treat it as an 8-bit unsigned char, hence the
* double cast.
*/
#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c)
/* An opaque pointer. */
#ifndef YY_TYPEDEF_YY_SCANNER_T
#define YY_TYPEDEF_YY_SCANNER_T
typedef void* yyscan_t;
#endif
/* For convenience, these vars (plus the bison vars far below)
are macros in the reentrant scanner. */
#define yyin yyg->yyin_r
#define yyout yyg->yyout_r
#define yyextra yyg->yyextra_r
#define yyleng yyg->yyleng_r
#define yytext yyg->yytext_r
#define yylineno (YY_CURRENT_BUFFER_LVALUE->yy_bs_lineno)
#define yycolumn (YY_CURRENT_BUFFER_LVALUE->yy_bs_column)
#define yy_flex_debug yyg->yy_flex_debug_r
/* Enter a start condition. This macro really ought to take a parameter,
* but we do it the disgusting crufty way forced on us by the ()-less
* definition of BEGIN.
*/
#define BEGIN yyg->yy_start = 1 + 2 *
/* Translate the current start state into a value that can be later handed
* to BEGIN to return to the state. The YYSTATE alias is for lex
* compatibility.
*/
#define YY_START ((yyg->yy_start - 1) / 2)
#define YYSTATE YY_START
/* Action number for EOF rule of a given start state. */
#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
/* Special action meaning "start processing a new file". */
#define YY_NEW_FILE yyrestart(yyin ,yyscanner )
#define YY_END_OF_BUFFER_CHAR 0
/* Size of default input buffer. */
#ifndef YY_BUF_SIZE
#define YY_BUF_SIZE 16384
#endif
/* The state buf must be large enough to hold one state per character in the main buffer.
*/
#define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type))
#ifndef YY_TYPEDEF_YY_BUFFER_STATE
#define YY_TYPEDEF_YY_BUFFER_STATE
typedef struct yy_buffer_state *YY_BUFFER_STATE;
#endif
#define EOB_ACT_CONTINUE_SCAN 0
#define EOB_ACT_END_OF_FILE 1
#define EOB_ACT_LAST_MATCH 2
/* Note: We specifically omit the test for yy_rule_can_match_eol because it requires
* access to the local variable yy_act. Since yyless() is a macro, it would break
* existing scanners that call yyless() from OUTSIDE yylex.
* One obvious solution it to make yy_act a global. I tried that, and saw
* a 5% performance hit in a non-yylineno scanner, because yy_act is
* normally declared as a register variable-- so it is not worth it.
*/
#define YY_LESS_LINENO(n) \
do { \
int yyl;\
for ( yyl = n; yyl < yyleng; ++yyl )\
if ( yytext[yyl] == '\n' )\
--yylineno;\
}while(0)
/* Return all but the first "n" matched characters back to the input stream. */
#define yyless(n) \
do \
{ \
/* Undo effects of setting up yytext. */ \
int yyless_macro_arg = (n); \
YY_LESS_LINENO(yyless_macro_arg);\
*yy_cp = yyg->yy_hold_char; \
YY_RESTORE_YY_MORE_OFFSET \
yyg->yy_c_buf_p = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \
YY_DO_BEFORE_ACTION; /* set up yytext again */ \
} \
while ( 0 )
#define unput(c) yyunput( c, yyg->yytext_ptr , yyscanner )
#ifndef YY_TYPEDEF_YY_SIZE_T
#define YY_TYPEDEF_YY_SIZE_T
typedef size_t yy_size_t;
#endif
#ifndef YY_STRUCT_YY_BUFFER_STATE
#define YY_STRUCT_YY_BUFFER_STATE
struct yy_buffer_state
{
FILE *yy_input_file;
char *yy_ch_buf; /* input buffer */
char *yy_buf_pos; /* current position in input buffer */
/* Size of input buffer in bytes, not including room for EOB
* characters.
*/
yy_size_t yy_buf_size;
/* Number of characters read into yy_ch_buf, not including EOB
* characters.
*/
int yy_n_chars;
/* Whether we "own" the buffer - i.e., we know we created it,
* and can realloc() it to grow it, and should free() it to
* delete it.
*/
int yy_is_our_buffer;
/* Whether this is an "interactive" input source; if so, and
* if we're using stdio for input, then we want to use getc()
* instead of fread(), to make sure we stop fetching input after
* each newline.
*/
int yy_is_interactive;
/* Whether we're considered to be at the beginning of a line.
* If so, '^' rules will be active on the next match, otherwise
* not.
*/
int yy_at_bol;
int yy_bs_lineno; /**< The line count. */
int yy_bs_column; /**< The column count. */
/* Whether to try to fill the input buffer when we reach the
* end of it.
*/
int yy_fill_buffer;
int yy_buffer_status;
#define YY_BUFFER_NEW 0
#define YY_BUFFER_NORMAL 1
/* When an EOF's been seen but there's still some text to process
* then we mark the buffer as YY_EOF_PENDING, to indicate that we
* shouldn't try reading from the input source any more. We might
* still have a bunch of tokens to match, though, because of
* possible backing-up.
*
* When we actually see the EOF, we change the status to "new"
* (via yyrestart()), so that the user can continue scanning by
* just pointing yyin at a new input file.
*/
#define YY_BUFFER_EOF_PENDING 2
};
#endif /* !YY_STRUCT_YY_BUFFER_STATE */
/* We provide macros for accessing buffer states in case in the
* future we want to put the buffer states in a more general
* "scanner state".
*
* Returns the top of the stack, or NULL.
*/
#define YY_CURRENT_BUFFER ( yyg->yy_buffer_stack \
? yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] \
: NULL)
/* Same as previous macro, but useful when we know that the buffer stack is not
* NULL or when we need an lvalue. For internal use only.
*/
#define YY_CURRENT_BUFFER_LVALUE yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]
void yyrestart (FILE *input_file ,yyscan_t yyscanner );
void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner );
YY_BUFFER_STATE yy_create_buffer (FILE *file,int size ,yyscan_t yyscanner );
void yy_delete_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner );
void yy_flush_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner );
void yypush_buffer_state (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner );
void yypop_buffer_state (yyscan_t yyscanner );
static void yyensure_buffer_stack (yyscan_t yyscanner );
static void yy_load_buffer_state (yyscan_t yyscanner );
static void yy_init_buffer (YY_BUFFER_STATE b,FILE *file ,yyscan_t yyscanner );
#define YY_FLUSH_BUFFER yy_flush_buffer(YY_CURRENT_BUFFER ,yyscanner)
YY_BUFFER_STATE yy_scan_buffer (char *base,yy_size_t size ,yyscan_t yyscanner );
YY_BUFFER_STATE yy_scan_string (yyconst char *yy_str ,yyscan_t yyscanner );
YY_BUFFER_STATE yy_scan_bytes (yyconst char *bytes,int len ,yyscan_t yyscanner );
void *yyalloc (yy_size_t ,yyscan_t yyscanner );
void *yyrealloc (void *,yy_size_t ,yyscan_t yyscanner );
void yyfree (void * ,yyscan_t yyscanner );
#define yy_new_buffer yy_create_buffer
#define yy_set_interactive(is_interactive) \
{ \
if ( ! YY_CURRENT_BUFFER ){ \
yyensure_buffer_stack (yyscanner); \
YY_CURRENT_BUFFER_LVALUE = \
yy_create_buffer(yyin,YY_BUF_SIZE ,yyscanner); \
} \
YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \
}
#define yy_set_bol(at_bol) \
{ \
if ( ! YY_CURRENT_BUFFER ){\
yyensure_buffer_stack (yyscanner); \
YY_CURRENT_BUFFER_LVALUE = \
yy_create_buffer(yyin,YY_BUF_SIZE ,yyscanner); \
} \
YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \
}
#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol)
/* Begin user sect3 */
#define yywrap(n) 1
#define YY_SKIP_YYWRAP
typedef unsigned char YY_CHAR;
typedef int yy_state_type;
#define yytext_ptr yytext_r
static yy_state_type yy_get_previous_state (yyscan_t yyscanner );
static yy_state_type yy_try_NUL_trans (yy_state_type current_state ,yyscan_t yyscanner);
static int yy_get_next_buffer (yyscan_t yyscanner );
static void yy_fatal_error (yyconst char msg[] ,yyscan_t yyscanner );
/* Done after the current pattern has been matched and before the
* corresponding action - sets up yytext.
*/
#define YY_DO_BEFORE_ACTION \
yyg->yytext_ptr = yy_bp; \
yyleng = (size_t) (yy_cp - yy_bp); \
yyg->yy_hold_char = *yy_cp; \
*yy_cp = '\0'; \
yyg->yy_c_buf_p = yy_cp;
#define YY_NUM_RULES 145
#define YY_END_OF_BUFFER 146
/* This struct is not used in this scanner,
but its presence is necessary. */
struct yy_trans_info
{
flex_int32_t yy_verify;
flex_int32_t yy_nxt;
};
static yyconst flex_int16_t yy_accept[411] =
{ 0,
0, 0, 0, 0, 0, 0, 146, 144, 143, 143,
128, 134, 139, 123, 124, 132, 131, 120, 129, 127,
133, 92, 92, 121, 117, 135, 122, 136, 140, 88,
125, 126, 138, 88, 88, 88, 88, 88, 88, 88,
88, 88, 88, 88, 88, 88, 88, 88, 88, 88,
88, 88, 88, 118, 137, 119, 130, 3, 4, 3,
142, 145, 141, 114, 100, 119, 108, 103, 98, 106,
96, 107, 97, 95, 2, 1, 99, 94, 90, 91,
0, 0, 92, 126, 118, 125, 115, 111, 113, 112,
116, 88, 104, 110, 88, 88, 88, 88, 88, 88,
88, 88, 88, 88, 17, 88, 88, 88, 88, 88,
88, 88, 88, 88, 88, 88, 88, 88, 20, 22,
88, 88, 88, 88, 88, 88, 88, 88, 88, 88,
88, 88, 88, 88, 88, 88, 88, 88, 88, 88,
88, 88, 88, 88, 88, 88, 105, 109, 5, 141,
0, 1, 94, 0, 0, 93, 89, 101, 102, 48,
88, 88, 88, 88, 88, 88, 88, 88, 88, 88,
88, 88, 88, 88, 88, 88, 88, 18, 88, 88,
88, 88, 88, 88, 88, 88, 26, 88, 88, 88,
88, 88, 88, 88, 88, 23, 88, 88, 88, 88,
88, 88, 88, 88, 88, 88, 88, 88, 88, 88,
88, 88, 88, 88, 88, 88, 88, 88, 0, 95,
0, 94, 88, 28, 88, 88, 85, 88, 88, 88,
88, 88, 88, 88, 21, 51, 88, 88, 88, 88,
88, 56, 70, 88, 88, 88, 88, 88, 88, 88,
88, 67, 9, 33, 34, 35, 88, 88, 88, 88,
88, 88, 88, 88, 88, 88, 88, 88, 88, 88,
88, 54, 29, 88, 88, 88, 88, 88, 88, 36,
37, 38, 27, 88, 88, 88, 15, 42, 43, 44,
49, 12, 88, 88, 88, 88, 81, 82, 83, 88,
30, 71, 25, 78, 79, 80, 7, 75, 76, 77,
88, 24, 73, 88, 88, 39, 40, 41, 88, 88,
88, 88, 88, 88, 88, 88, 88, 68, 88, 88,
88, 88, 88, 88, 88, 50, 88, 87, 88, 88,
19, 88, 88, 88, 88, 69, 64, 59, 88, 88,
88, 88, 88, 74, 55, 88, 62, 32, 88, 84,
63, 47, 57, 88, 88, 88, 88, 88, 88, 88,
88, 58, 31, 88, 88, 88, 8, 88, 88, 88,
88, 88, 52, 13, 88, 14, 88, 88, 16, 65,
88, 88, 88, 60, 88, 88, 88, 53, 72, 61,
11, 66, 6, 86, 10, 45, 88, 88, 46, 0
} ;
static yyconst flex_int32_t yy_ec[256] =
{ 0,
1, 1, 1, 1, 1, 1, 1, 1, 2, 3,
2, 2, 2, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 2, 4, 1, 1, 1, 5, 6, 1, 7,
8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
18, 19, 16, 16, 16, 20, 20, 21, 22, 23,
24, 25, 26, 1, 27, 27, 28, 29, 30, 27,
31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
31, 31, 31, 31, 31, 31, 31, 32, 31, 31,
33, 1, 34, 35, 31, 1, 36, 37, 38, 39,
40, 41, 42, 43, 44, 31, 45, 46, 47, 48,
49, 50, 31, 51, 52, 53, 54, 55, 56, 57,
58, 59, 60, 61, 62, 63, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1
} ;
static yyconst flex_int32_t yy_meta[64] =
{ 0,
1, 1, 2, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 3, 3, 3, 3, 3, 3,
1, 1, 1, 1, 1, 1, 3, 3, 3, 3,
4, 4, 1, 1, 1, 3, 3, 3, 3, 3,
3, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 1,
1, 1, 1
} ;
static yyconst flex_int16_t yy_base[416] =
{ 0,
0, 0, 61, 62, 71, 0, 606, 607, 607, 607,
581, 42, 129, 607, 607, 580, 126, 607, 125, 123,
137, 149, 157, 578, 607, 175, 578, 44, 607, 0,
607, 607, 120, 95, 103, 142, 146, 136, 156, 552,
168, 162, 551, 120, 158, 545, 173, 558, 172, 178,
111, 186, 554, 607, 159, 607, 607, 607, 607, 582,
607, 607, 0, 607, 607, 607, 607, 607, 607, 607,
607, 607, 607, 222, 607, 0, 607, 228, 254, 262,
281, 0, 290, 607, 607, 607, 571, 607, 607, 607,
570, 0, 607, 607, 546, 539, 542, 550, 549, 536,
551, 538, 544, 532, 529, 542, 529, 526, 526, 532,
520, 527, 524, 534, 520, 526, 529, 530, 0, 204,
529, 207, 515, 528, 519, 521, 511, 525, 522, 524,
507, 512, 509, 498, 183, 512, 508, 510, 499, 502,
212, 507, 499, 511, 186, 504, 607, 607, 607, 0,
306, 0, 316, 332, 270, 342, 0, 607, 607, 0,
496, 500, 509, 506, 490, 490, 161, 505, 502, 502,
500, 497, 489, 495, 482, 493, 496, 0, 493, 481,
488, 485, 489, 482, 471, 470, 483, 486, 483, 478,
469, 294, 474, 477, 468, 465, 469, 475, 466, 457,
460, 458, 468, 454, 452, 452, 454, 451, 462, 461,
278, 456, 451, 440, 320, 458, 460, 449, 348, 354,
360, 366, 450, 0, 448, 336, 0, 440, 438, 446,
435, 452, 441, 370, 0, 0, 435, 445, 445, 430,
373, 0, 0, 432, 376, 433, 427, 426, 427, 426,
379, 0, 0, 0, 0, 0, 422, 423, 428, 419,
432, 427, 426, 418, 422, 414, 417, 421, 426, 425,
416, 0, 0, 422, 411, 411, 416, 415, 412, 0,
0, 0, 0, 402, 414, 416, 0, 0, 0, 0,
0, 0, 404, 405, 399, 409, 0, 0, 0, 400,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
407, 0, 0, 405, 401, 0, 0, 0, 397, 393,
398, 388, 401, 387, 400, 389, 396, 0, 394, 396,
380, 389, 395, 390, 378, 0, 380, 0, 379, 382,
0, 371, 370, 370, 383, 0, 385, 0, 384, 383,
368, 381, 368, 0, 0, 371, 0, 0, 363, 0,
0, 0, 0, 360, 371, 364, 368, 303, 297, 288,
300, 0, 0, 283, 290, 269, 0, 277, 274, 255,
232, 255, 0, 0, 244, 0, 236, 226, 0, 0,
225, 208, 211, 0, 185, 202, 131, 0, 0, 0,
0, 0, 0, 0, 0, 0, 134, 117, 0, 607,
398, 400, 402, 406, 142
} ;
static yyconst flex_int16_t yy_def[416] =
{ 0,
410, 1, 411, 411, 410, 5, 410, 410, 410, 410,
410, 410, 410, 410, 410, 410, 410, 410, 410, 410,
410, 410, 410, 410, 410, 410, 410, 410, 410, 412,
410, 410, 410, 412, 412, 412, 412, 412, 412, 412,
412, 412, 412, 412, 412, 412, 412, 412, 412, 412,
412, 412, 412, 410, 410, 410, 410, 410, 410, 410,
410, 410, 413, 410, 410, 410, 410, 410, 410, 410,
410, 410, 410, 410, 410, 414, 410, 410, 410, 410,
410, 415, 410, 410, 410, 410, 410, 410, 410, 410,
410, 412, 410, 410, 412, 412, 412, 412, 412, 412,
412, 412, 412, 412, 412, 412, 412, 412, 412, 412,
412, 412, 412, 412, 412, 412, 412, 412, 412, 412,
412, 412, 412, 412, 412, 412, 412, 412, 412, 412,
412, 412, 412, 412, 412, 412, 412, 412, 412, 412,
412, 412, 412, 412, 412, 412, 410, 410, 410, 413,
410, 414, 410, 410, 410, 410, 415, 410, 410, 412,
412, 412, 412, 412, 412, 412, 412, 412, 412, 412,
412, 412, 412, 412, 412, 412, 412, 412, 412, 412,
412, 412, 412, 412, 412, 412, 412, 412, 412, 412,
412, 412, 412, 412, 412, 412, 412, 412, 412, 412,
412, 412, 412, 412, 412, 412, 412, 412, 412, 412,
412, 412, 412, 412, 412, 412, 412, 412, 410, 410,
410, 410, 412, 412, 412, 412, 412, 412, 412, 412,
412, 412, 412, 412, 412, 412, 412, 412, 412, 412,
412, 412, 412, 412, 412, 412, 412, 412, 412, 412,
412, 412, 412, 412, 412, 412, 412, 412, 412, 412,
412, 412, 412, 412, 412, 412, 412, 412, 412, 412,
412, 412, 412, 412, 412, 412, 412, 412, 412, 412,
412, 412, 412, 412, 412, 412, 412, 412, 412, 412,
412, 412, 412, 412, 412, 412, 412, 412, 412, 412,
412, 412, 412, 412, 412, 412, 412, 412, 412, 412,
412, 412, 412, 412, 412, 412, 412, 412, 412, 412,
412, 412, 412, 412, 412, 412, 412, 412, 412, 412,
412, 412, 412, 412, 412, 412, 412, 412, 412, 412,
412, 412, 412, 412, 412, 412, 412, 412, 412, 412,
412, 412, 412, 412, 412, 412, 412, 412, 412, 412,
412, 412, 412, 412, 412, 412, 412, 412, 412, 412,
412, 412, 412, 412, 412, 412, 412, 412, 412, 412,
412, 412, 412, 412, 412, 412, 412, 412, 412, 412,
412, 412, 412, 412, 412, 412, 412, 412, 412, 412,
412, 412, 412, 412, 412, 412, 412, 412, 412, 0,
410, 410, 410, 410, 410
} ;
static yyconst flex_int16_t yy_nxt[671] =
{ 0,
8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
18, 19, 20, 21, 22, 23, 23, 23, 23, 23,
24, 25, 26, 27, 28, 29, 30, 30, 30, 30,
30, 30, 31, 32, 33, 34, 35, 36, 37, 38,
39, 40, 41, 42, 30, 43, 44, 45, 46, 47,
48, 49, 50, 51, 52, 53, 30, 30, 30, 54,
55, 56, 57, 59, 59, 65, 66, 90, 91, 60,
60, 8, 61, 62, 8, 8, 8, 8, 8, 8,
8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
8, 8, 8, 8, 8, 8, 8, 63, 63, 63,
63, 63, 63, 8, 8, 8, 63, 63, 63, 63,
63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
8, 8, 8, 8, 67, 70, 72, 74, 74, 74,
74, 74, 74, 93, 157, 75, 95, 96, 73, 71,
76, 97, 68, 98, 94, 123, 409, 99, 141, 124,
77, 78, 142, 79, 79, 79, 79, 79, 80, 78,
408, 83, 83, 83, 83, 83, 83, 100, 81, 85,
82, 107, 147, 108, 407, 103, 81, 101, 81, 104,
102, 110, 109, 125, 105, 86, 81, 87, 88, 111,
106, 112, 119, 116, 113, 82, 126, 132, 128, 120,
114, 117, 229, 230, 133, 134, 121, 137, 204, 148,
138, 143, 118, 129, 135, 144, 130, 136, 139, 216,
406, 217, 405, 205, 145, 140, 74, 74, 74, 74,
74, 74, 153, 153, 153, 153, 153, 153, 396, 184,
404, 151, 185, 186, 190, 211, 187, 154, 188, 397,
403, 151, 191, 212, 402, 401, 78, 154, 79, 79,
79, 79, 79, 80, 78, 400, 80, 80, 80, 80,
80, 80, 399, 81, 156, 156, 156, 156, 156, 156,
155, 81, 155, 81, 398, 156, 156, 156, 156, 156,
156, 81, 78, 395, 83, 83, 83, 83, 83, 83,
254, 255, 256, 394, 393, 219, 392, 219, 275, 81,
220, 220, 220, 220, 220, 220, 276, 391, 390, 81,
153, 153, 153, 153, 153, 153, 280, 281, 282, 389,
388, 221, 387, 221, 386, 154, 222, 222, 222, 222,
222, 222, 288, 289, 290, 154, 156, 156, 156, 156,
156, 156, 220, 220, 220, 220, 220, 220, 220, 220,
220, 220, 220, 220, 222, 222, 222, 222, 222, 222,
222, 222, 222, 222, 222, 222, 297, 298, 299, 304,
305, 306, 308, 309, 310, 316, 317, 318, 58, 58,
58, 58, 92, 92, 150, 150, 152, 385, 152, 152,
384, 383, 382, 381, 380, 379, 378, 377, 376, 375,
374, 373, 372, 371, 370, 369, 368, 367, 366, 365,
364, 363, 362, 361, 360, 359, 358, 357, 356, 355,
354, 353, 352, 351, 350, 349, 348, 347, 346, 345,
344, 343, 342, 341, 340, 339, 338, 337, 336, 335,
334, 333, 332, 331, 330, 329, 328, 327, 326, 325,
324, 323, 322, 321, 320, 319, 315, 314, 313, 312,
311, 307, 303, 302, 301, 300, 296, 295, 294, 293,
292, 291, 287, 286, 285, 284, 283, 279, 278, 277,
274, 273, 272, 271, 270, 269, 268, 267, 266, 265,
264, 263, 262, 261, 260, 259, 258, 257, 253, 252,
251, 250, 249, 248, 247, 246, 245, 244, 243, 242,
241, 240, 239, 238, 237, 236, 235, 234, 233, 232,
231, 228, 227, 226, 225, 224, 223, 218, 215, 214,
213, 210, 209, 208, 207, 206, 203, 202, 201, 200,
199, 198, 197, 196, 195, 194, 193, 192, 189, 183,
182, 181, 180, 179, 178, 177, 176, 175, 174, 173,
172, 171, 170, 169, 168, 167, 166, 165, 164, 163,
162, 161, 160, 159, 158, 149, 146, 131, 127, 122,
115, 89, 84, 69, 64, 410, 7, 410, 410, 410,
410, 410, 410, 410, 410, 410, 410, 410, 410, 410,
410, 410, 410, 410, 410, 410, 410, 410, 410, 410,
410, 410, 410, 410, 410, 410, 410, 410, 410, 410,
410, 410, 410, 410, 410, 410, 410, 410, 410, 410,
410, 410, 410, 410, 410, 410, 410, 410, 410, 410,
410, 410, 410, 410, 410, 410, 410, 410, 410, 410
} ;
static yyconst flex_int16_t yy_chk[671] =
{ 0,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 3, 4, 12, 12, 28, 28, 3,
4, 5, 5, 5, 5, 5, 5, 5, 5, 5,
5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
5, 5, 5, 5, 13, 17, 19, 20, 20, 20,
20, 20, 20, 33, 415, 21, 34, 34, 19, 17,
21, 35, 13, 35, 33, 44, 408, 35, 51, 44,
21, 22, 51, 22, 22, 22, 22, 22, 22, 23,
407, 23, 23, 23, 23, 23, 23, 36, 22, 26,
22, 38, 55, 38, 397, 37, 23, 36, 22, 37,
36, 39, 38, 45, 37, 26, 23, 26, 26, 39,
37, 39, 42, 41, 39, 22, 45, 49, 47, 42,
39, 41, 167, 167, 49, 49, 42, 50, 135, 55,
50, 52, 41, 47, 49, 52, 47, 49, 50, 145,
396, 145, 395, 135, 52, 50, 74, 74, 74, 74,
74, 74, 78, 78, 78, 78, 78, 78, 381, 120,
393, 74, 120, 120, 122, 141, 120, 78, 120, 381,
392, 74, 122, 141, 391, 388, 79, 78, 79, 79,
79, 79, 79, 79, 80, 387, 80, 80, 80, 80,
80, 80, 385, 79, 155, 155, 155, 155, 155, 155,
81, 80, 81, 79, 382, 81, 81, 81, 81, 81,
81, 80, 83, 380, 83, 83, 83, 83, 83, 83,
192, 192, 192, 379, 378, 151, 376, 151, 211, 83,
151, 151, 151, 151, 151, 151, 211, 375, 374, 83,
153, 153, 153, 153, 153, 153, 215, 215, 215, 371,
370, 154, 369, 154, 368, 153, 154, 154, 154, 154,
154, 154, 226, 226, 226, 153, 156, 156, 156, 156,
156, 156, 219, 219, 219, 219, 219, 219, 220, 220,
220, 220, 220, 220, 221, 221, 221, 221, 221, 221,
222, 222, 222, 222, 222, 222, 234, 234, 234, 241,
241, 241, 245, 245, 245, 251, 251, 251, 411, 411,
411, 411, 412, 412, 413, 413, 414, 367, 414, 414,
366, 365, 364, 359, 356, 353, 352, 351, 350, 349,
347, 345, 344, 343, 342, 340, 339, 337, 335, 334,
333, 332, 331, 330, 329, 327, 326, 325, 324, 323,
322, 321, 320, 319, 315, 314, 311, 300, 296, 295,
294, 293, 286, 285, 284, 279, 278, 277, 276, 275,
274, 271, 270, 269, 268, 267, 266, 265, 264, 263,
262, 261, 260, 259, 258, 257, 250, 249, 248, 247,
246, 244, 240, 239, 238, 237, 233, 232, 231, 230,
229, 228, 225, 223, 218, 217, 216, 214, 213, 212,
210, 209, 208, 207, 206, 205, 204, 203, 202, 201,
200, 199, 198, 197, 196, 195, 194, 193, 191, 190,
189, 188, 187, 186, 185, 184, 183, 182, 181, 180,
179, 177, 176, 175, 174, 173, 172, 171, 170, 169,
168, 166, 165, 164, 163, 162, 161, 146, 144, 143,
142, 140, 139, 138, 137, 136, 134, 133, 132, 131,
130, 129, 128, 127, 126, 125, 124, 123, 121, 118,
117, 116, 115, 114, 113, 112, 111, 110, 109, 108,
107, 106, 105, 104, 103, 102, 101, 100, 99, 98,
97, 96, 95, 91, 87, 60, 53, 48, 46, 43,
40, 27, 24, 16, 11, 7, 410, 410, 410, 410,
410, 410, 410, 410, 410, 410, 410, 410, 410, 410,
410, 410, 410, 410, 410, 410, 410, 410, 410, 410,
410, 410, 410, 410, 410, 410, 410, 410, 410, 410,
410, 410, 410, 410, 410, 410, 410, 410, 410, 410,
410, 410, 410, 410, 410, 410, 410, 410, 410, 410,
410, 410, 410, 410, 410, 410, 410, 410, 410, 410
} ;
/* Table of booleans, true if rule could match eol. */
static yyconst flex_int32_t yy_rule_can_match_eol[146] =
{ 0,
0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 1, 0, 0, };
/* The intent behind this definition is that it'll catch
* any uses of REJECT which flex missed.
*/
#define REJECT reject_used_but_not_detected
#define yymore() yymore_used_but_not_detected
#define YY_MORE_ADJ 0
#define YY_RESTORE_YY_MORE_OFFSET
/*
//
// Copyright (c) 2002-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.
//
This file contains the Lex specification for GLSL ES.
Based on ANSI C grammar, Lex specification:
http://www.lysator.liu.se/c/ANSI-C-grammar-l.html
IF YOU MODIFY THIS FILE YOU ALSO NEED TO RUN generate_glslang_lexer.sh,
WHICH GENERATES THE GLSL ES LEXER (glslang_lex.cpp).
*/
#include "compiler/glslang.h"
#include "compiler/ParseHelper.h"
#include "compiler/util.h"
#include "glslang_tab.h"
/* windows only pragma */
#ifdef _MSC_VER
#pragma warning(disable : 4102)
#endif
#define YY_USER_ACTION yylval->lex.line = yylineno;
#define YY_INPUT(buf, result, max_size) \
result = string_input(buf, max_size, yyscanner);
static int string_input(char* buf, int max_size, yyscan_t yyscanner);
static int check_type(yyscan_t yyscanner);
static int reserved_word(yyscan_t yyscanner);
#define INITIAL 0
#define COMMENT 1
#define FIELDS 2
#define YY_EXTRA_TYPE TParseContext*
/* Holds the entire state of the reentrant scanner. */
struct yyguts_t
{
/* User-defined. Not touched by flex. */
YY_EXTRA_TYPE yyextra_r;
/* The rest are the same as the globals declared in the non-reentrant scanner. */
FILE *yyin_r, *yyout_r;
size_t yy_buffer_stack_top; /**< index of top of stack. */
size_t yy_buffer_stack_max; /**< capacity of stack. */
YY_BUFFER_STATE * yy_buffer_stack; /**< Stack as an array. */
char yy_hold_char;
int yy_n_chars;
int yyleng_r;
char *yy_c_buf_p;
int yy_init;
int yy_start;
int yy_did_buffer_switch_on_eof;
int yy_start_stack_ptr;
int yy_start_stack_depth;
int *yy_start_stack;
yy_state_type yy_last_accepting_state;
char* yy_last_accepting_cpos;
int yylineno_r;
int yy_flex_debug_r;
char *yytext_r;
int yy_more_flag;
int yy_more_len;
YYSTYPE * yylval_r;
}; /* end struct yyguts_t */
static int yy_init_globals (yyscan_t yyscanner );
/* This must go here because YYSTYPE and YYLTYPE are included
* from bison output in section 1.*/
# define yylval yyg->yylval_r
int yylex_init (yyscan_t* scanner);
int yylex_init_extra (YY_EXTRA_TYPE user_defined,yyscan_t* scanner);
/* Accessor methods to globals.
These are made visible to non-reentrant scanners for convenience. */
int yylex_destroy (yyscan_t yyscanner );
int yyget_debug (yyscan_t yyscanner );
void yyset_debug (int debug_flag ,yyscan_t yyscanner );
YY_EXTRA_TYPE yyget_extra (yyscan_t yyscanner );
void yyset_extra (YY_EXTRA_TYPE user_defined ,yyscan_t yyscanner );
FILE *yyget_in (yyscan_t yyscanner );
void yyset_in (FILE * in_str ,yyscan_t yyscanner );
FILE *yyget_out (yyscan_t yyscanner );
void yyset_out (FILE * out_str ,yyscan_t yyscanner );
int yyget_leng (yyscan_t yyscanner );
char *yyget_text (yyscan_t yyscanner );
int yyget_lineno (yyscan_t yyscanner );
void yyset_lineno (int line_number ,yyscan_t yyscanner );
YYSTYPE * yyget_lval (yyscan_t yyscanner );
void yyset_lval (YYSTYPE * yylval_param ,yyscan_t yyscanner );
/* Macros after this point can all be overridden by user definitions in
* section 1.
*/
#ifndef YY_SKIP_YYWRAP
#ifdef __cplusplus
extern "C" int yywrap (yyscan_t yyscanner );
#else
extern int yywrap (yyscan_t yyscanner );
#endif
#endif
#ifndef yytext_ptr
static void yy_flex_strncpy (char *,yyconst char *,int ,yyscan_t yyscanner);
#endif
#ifdef YY_NEED_STRLEN
static int yy_flex_strlen (yyconst char * ,yyscan_t yyscanner);
#endif
#ifndef YY_NO_INPUT
#ifdef __cplusplus
static int yyinput (yyscan_t yyscanner );
#else
static int input (yyscan_t yyscanner );
#endif
#endif
static void yy_push_state (int new_state ,yyscan_t yyscanner);
static void yy_pop_state (yyscan_t yyscanner );
static int yy_top_state (yyscan_t yyscanner );
/* Amount of stuff to slurp up with each read. */
#ifndef YY_READ_BUF_SIZE
#define YY_READ_BUF_SIZE 8192
#endif
/* Copy whatever the last rule matched to the standard output. */
#ifndef ECHO
/* This used to be an fputs(), but since the string might contain NUL's,
* we now use fwrite().
*/
#define ECHO fwrite( yytext, yyleng, 1, yyout )
#endif
/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
* is returned in "result".
*/
#ifndef YY_INPUT
#define YY_INPUT(buf,result,max_size) \
if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \
{ \
int c = '*'; \
int n; \
for ( n = 0; n < max_size && \
(c = getc( yyin )) != EOF && c != '\n'; ++n ) \
buf[n] = (char) c; \
if ( c == '\n' ) \
buf[n++] = (char) c; \
if ( c == EOF && ferror( yyin ) ) \
YY_FATAL_ERROR( "input in flex scanner failed" ); \
result = n; \
} \
else \
{ \
errno=0; \
while ( (result = fread(buf, 1, max_size, yyin))==0 && ferror(yyin)) \
{ \
if( errno != EINTR) \
{ \
YY_FATAL_ERROR( "input in flex scanner failed" ); \
break; \
} \
errno=0; \
clearerr(yyin); \
} \
}\
\
#endif
/* No semi-colon after return; correct usage is to write "yyterminate();" -
* we don't want an extra ';' after the "return" because that will cause
* some compilers to complain about unreachable statements.
*/
#ifndef yyterminate
#define yyterminate() return YY_NULL
#endif
/* Number of entries by which start-condition stack grows. */
#ifndef YY_START_STACK_INCR
#define YY_START_STACK_INCR 25
#endif
/* Report a fatal error. */
#ifndef YY_FATAL_ERROR
#define YY_FATAL_ERROR(msg) yy_fatal_error( msg , yyscanner)
#endif
/* end tables serialization structures and prototypes */
/* Default declaration of generated scanner - a define so the user can
* easily add parameters.
*/
#ifndef YY_DECL
#define YY_DECL_IS_OURS 1
extern int yylex \
(YYSTYPE * yylval_param ,yyscan_t yyscanner);
#define YY_DECL int yylex \
(YYSTYPE * yylval_param , yyscan_t yyscanner)
#endif /* !YY_DECL */
/* Code executed at the beginning of each rule, after yytext and yyleng
* have been set up.
*/
#ifndef YY_USER_ACTION
#define YY_USER_ACTION
#endif
/* Code executed at the end of each rule. */
#ifndef YY_BREAK
#define YY_BREAK break;
#endif
#define YY_RULE_SETUP \
YY_USER_ACTION
/** The main scanner function which does all the work.
*/
YY_DECL
{
register yy_state_type yy_current_state;
register char *yy_cp, *yy_bp;
register int yy_act;
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
TParseContext* context = yyextra;
/* Single-line comments */
yylval = yylval_param;
if ( !yyg->yy_init )
{
yyg->yy_init = 1;
#ifdef YY_USER_INIT
YY_USER_INIT;
#endif
if ( ! yyg->yy_start )
yyg->yy_start = 1; /* first start state */
if ( ! yyin )
yyin = stdin;
if ( ! yyout )
yyout = stdout;
if ( ! YY_CURRENT_BUFFER ) {
yyensure_buffer_stack (yyscanner);
YY_CURRENT_BUFFER_LVALUE =
yy_create_buffer(yyin,YY_BUF_SIZE ,yyscanner);
}
yy_load_buffer_state(yyscanner );
}
while ( 1 ) /* loops until end-of-file is reached */
{
yy_cp = yyg->yy_c_buf_p;
/* Support of yytext. */
*yy_cp = yyg->yy_hold_char;
/* yy_bp points to the position in yy_ch_buf of the start of
* the current run.
*/
yy_bp = yy_cp;
yy_current_state = yyg->yy_start;
yy_match:
do
{
register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)];
if ( yy_accept[yy_current_state] )
{
yyg->yy_last_accepting_state = yy_current_state;
yyg->yy_last_accepting_cpos = yy_cp;
}
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
{
yy_current_state = (int) yy_def[yy_current_state];
if ( yy_current_state >= 411 )
yy_c = yy_meta[(unsigned int) yy_c];
}
yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
++yy_cp;
}
while ( yy_current_state != 410 );
yy_cp = yyg->yy_last_accepting_cpos;
yy_current_state = yyg->yy_last_accepting_state;
yy_find_action:
yy_act = yy_accept[yy_current_state];
YY_DO_BEFORE_ACTION;
if ( yy_act != YY_END_OF_BUFFER && yy_rule_can_match_eol[yy_act] )
{
int yyl;
for ( yyl = 0; yyl < yyleng; ++yyl )
if ( yytext[yyl] == '\n' )
do{ yylineno++;
yycolumn=0;
}while(0)
;
}
do_action: /* This label is used only to access EOF actions. */
switch ( yy_act )
{ /* beginning of action switch */
case 0: /* must back up */
/* undo the effects of YY_DO_BEFORE_ACTION */
*yy_cp = yyg->yy_hold_char;
yy_cp = yyg->yy_last_accepting_cpos;
yy_current_state = yyg->yy_last_accepting_state;
goto yy_find_action;
case 1:
YY_RULE_SETUP
;
YY_BREAK
/* Multi-line comments */
case 2:
YY_RULE_SETUP
{ yy_push_state(COMMENT, yyscanner); }
YY_BREAK
case 3:
case 4:
/* rule 4 can match eol */
YY_RULE_SETUP
;
YY_BREAK
case 5:
YY_RULE_SETUP
{ yy_pop_state(yyscanner); }
YY_BREAK
case 6:
YY_RULE_SETUP
{ return(INVARIANT); }
YY_BREAK
case 7:
YY_RULE_SETUP
{ return(HIGH_PRECISION); }
YY_BREAK
case 8:
YY_RULE_SETUP
{ return(MEDIUM_PRECISION); }
YY_BREAK
case 9:
YY_RULE_SETUP
{ return(LOW_PRECISION); }
YY_BREAK
case 10:
YY_RULE_SETUP
{ return(PRECISION); }
YY_BREAK
case 11:
YY_RULE_SETUP
{ return(ATTRIBUTE); }
YY_BREAK
case 12:
YY_RULE_SETUP
{ return(CONST_QUAL); }
YY_BREAK
case 13:
YY_RULE_SETUP
{ return(UNIFORM); }
YY_BREAK
case 14:
YY_RULE_SETUP
{ return(VARYING); }
YY_BREAK
case 15:
YY_RULE_SETUP
{ return(BREAK); }
YY_BREAK
case 16:
YY_RULE_SETUP
{ return(CONTINUE); }
YY_BREAK
case 17:
YY_RULE_SETUP
{ return(DO); }
YY_BREAK
case 18:
YY_RULE_SETUP
{ return(FOR); }
YY_BREAK
case 19:
YY_RULE_SETUP
{ return(WHILE); }
YY_BREAK
case 20:
YY_RULE_SETUP
{ return(IF); }
YY_BREAK
case 21:
YY_RULE_SETUP
{ return(ELSE); }
YY_BREAK
case 22:
YY_RULE_SETUP
{ return(IN_QUAL); }
YY_BREAK
case 23:
YY_RULE_SETUP
{ return(OUT_QUAL); }
YY_BREAK
case 24:
YY_RULE_SETUP
{ return(INOUT_QUAL); }
YY_BREAK
case 25:
YY_RULE_SETUP
{ context->lexAfterType = true; return(FLOAT_TYPE); }
YY_BREAK
case 26:
YY_RULE_SETUP
{ context->lexAfterType = true; return(INT_TYPE); }
YY_BREAK
case 27:
YY_RULE_SETUP
{ context->lexAfterType = true; return(VOID_TYPE); }
YY_BREAK
case 28:
YY_RULE_SETUP
{ context->lexAfterType = true; return(BOOL_TYPE); }
YY_BREAK
case 29:
YY_RULE_SETUP
{ yylval->lex.b = true; return(BOOLCONSTANT); }
YY_BREAK
case 30:
YY_RULE_SETUP
{ yylval->lex.b = false; return(BOOLCONSTANT); }
YY_BREAK
case 31:
YY_RULE_SETUP
{ return(DISCARD); }
YY_BREAK
case 32:
YY_RULE_SETUP
{ return(RETURN); }
YY_BREAK
case 33:
YY_RULE_SETUP
{ context->lexAfterType = true; return(MATRIX2); }
YY_BREAK
case 34:
YY_RULE_SETUP
{ context->lexAfterType = true; return(MATRIX3); }
YY_BREAK
case 35:
YY_RULE_SETUP
{ context->lexAfterType = true; return(MATRIX4); }
YY_BREAK
case 36:
YY_RULE_SETUP
{ context->lexAfterType = true; return (VEC2); }
YY_BREAK
case 37:
YY_RULE_SETUP
{ context->lexAfterType = true; return (VEC3); }
YY_BREAK
case 38:
YY_RULE_SETUP
{ context->lexAfterType = true; return (VEC4); }
YY_BREAK
case 39:
YY_RULE_SETUP
{ context->lexAfterType = true; return (IVEC2); }
YY_BREAK
case 40:
YY_RULE_SETUP
{ context->lexAfterType = true; return (IVEC3); }
YY_BREAK
case 41:
YY_RULE_SETUP
{ context->lexAfterType = true; return (IVEC4); }
YY_BREAK
case 42:
YY_RULE_SETUP
{ context->lexAfterType = true; return (BVEC2); }
YY_BREAK
case 43:
YY_RULE_SETUP
{ context->lexAfterType = true; return (BVEC3); }
YY_BREAK
case 44:
YY_RULE_SETUP
{ context->lexAfterType = true; return (BVEC4); }
YY_BREAK
case 45:
YY_RULE_SETUP
{ context->lexAfterType = true; return SAMPLER2D; }
YY_BREAK
case 46:
YY_RULE_SETUP
{ context->lexAfterType = true; return SAMPLERCUBE; }
YY_BREAK
case 47:
YY_RULE_SETUP
{ context->lexAfterType = true; return(STRUCT); }
YY_BREAK
case 48:
YY_RULE_SETUP
{ return reserved_word(yyscanner); }
YY_BREAK
case 49:
YY_RULE_SETUP
{ return reserved_word(yyscanner); }
YY_BREAK
case 50:
YY_RULE_SETUP
{ return reserved_word(yyscanner); }
YY_BREAK
case 51:
YY_RULE_SETUP
{ return reserved_word(yyscanner); }
YY_BREAK
case 52:
YY_RULE_SETUP
{ return reserved_word(yyscanner); }
YY_BREAK
case 53:
YY_RULE_SETUP
{ return reserved_word(yyscanner); }
YY_BREAK
case 54:
YY_RULE_SETUP
{ return reserved_word(yyscanner); }
YY_BREAK
case 55:
YY_RULE_SETUP
{ return reserved_word(yyscanner); }
YY_BREAK
case 56:
YY_RULE_SETUP
{ return reserved_word(yyscanner); }
YY_BREAK
case 57:
YY_RULE_SETUP
{ return reserved_word(yyscanner); }
YY_BREAK
case 58:
YY_RULE_SETUP
{ return reserved_word(yyscanner); }
YY_BREAK
case 59:
YY_RULE_SETUP
{ return reserved_word(yyscanner); }
YY_BREAK
case 60:
YY_RULE_SETUP
{ return reserved_word(yyscanner); }
YY_BREAK
case 61:
YY_RULE_SETUP
{ return reserved_word(yyscanner); }
YY_BREAK
case 62:
YY_RULE_SETUP
{ return reserved_word(yyscanner); }
YY_BREAK
case 63:
YY_RULE_SETUP
{ return reserved_word(yyscanner); }
YY_BREAK
case 64:
YY_RULE_SETUP
{ return reserved_word(yyscanner); }
YY_BREAK
case 65:
YY_RULE_SETUP
{ return reserved_word(yyscanner); }
YY_BREAK
case 66:
YY_RULE_SETUP
{ return reserved_word(yyscanner); }
YY_BREAK
case 67:
YY_RULE_SETUP
{ return reserved_word(yyscanner); }
YY_BREAK
case 68:
YY_RULE_SETUP
{ return reserved_word(yyscanner); }
YY_BREAK
case 69:
YY_RULE_SETUP
{ return reserved_word(yyscanner); }
YY_BREAK
case 70:
YY_RULE_SETUP
{ return reserved_word(yyscanner); }
YY_BREAK
case 71:
YY_RULE_SETUP
{ return reserved_word(yyscanner); }
YY_BREAK
case 72:
YY_RULE_SETUP
{ return reserved_word(yyscanner); }
YY_BREAK
case 73:
YY_RULE_SETUP
{ return reserved_word(yyscanner); }
YY_BREAK
case 74:
YY_RULE_SETUP
{ return reserved_word(yyscanner); }
YY_BREAK
case 75:
YY_RULE_SETUP
{ return reserved_word(yyscanner); }
YY_BREAK
case 76:
YY_RULE_SETUP
{ return reserved_word(yyscanner); }
YY_BREAK
case 77:
YY_RULE_SETUP
{ return reserved_word(yyscanner); }
YY_BREAK
case 78:
YY_RULE_SETUP
{ return reserved_word(yyscanner); }
YY_BREAK
case 79:
YY_RULE_SETUP
{ return reserved_word(yyscanner); }
YY_BREAK
case 80:
YY_RULE_SETUP
{ return reserved_word(yyscanner); }
YY_BREAK
case 81:
YY_RULE_SETUP
{ return reserved_word(yyscanner); }
YY_BREAK
case 82:
YY_RULE_SETUP
{ return reserved_word(yyscanner); }
YY_BREAK
case 83:
YY_RULE_SETUP
{ return reserved_word(yyscanner); }
YY_BREAK
case 84:
YY_RULE_SETUP
{ return reserved_word(yyscanner); }
YY_BREAK
case 85:
YY_RULE_SETUP
{ return reserved_word(yyscanner); }
YY_BREAK
case 86:
YY_RULE_SETUP
{ return reserved_word(yyscanner); }
YY_BREAK
case 87:
YY_RULE_SETUP
{ return reserved_word(yyscanner); }
YY_BREAK
case 88:
YY_RULE_SETUP
{
yylval->lex.string = NewPoolTString(yytext);
return check_type(yyscanner);
}
YY_BREAK
case 89:
YY_RULE_SETUP
{ yylval->lex.i = strtol(yytext, 0, 0); return(INTCONSTANT); }
YY_BREAK
case 90:
YY_RULE_SETUP
{ yylval->lex.i = strtol(yytext, 0, 0); return(INTCONSTANT); }
YY_BREAK
case 91:
YY_RULE_SETUP
{ context->error(yylineno, "Invalid Octal number.", yytext, "", ""); context->recover(); return 0;}
YY_BREAK
case 92:
YY_RULE_SETUP
{ yylval->lex.i = strtol(yytext, 0, 0); return(INTCONSTANT); }
YY_BREAK
case 93:
YY_RULE_SETUP
{ yylval->lex.f = static_cast<float>(atof_dot(yytext)); return(FLOATCONSTANT); }
YY_BREAK
case 94:
YY_RULE_SETUP
{ yylval->lex.f = static_cast<float>(atof_dot(yytext)); return(FLOATCONSTANT); }
YY_BREAK
case 95:
YY_RULE_SETUP
{ yylval->lex.f = static_cast<float>(atof_dot(yytext)); return(FLOATCONSTANT); }
YY_BREAK
case 96:
YY_RULE_SETUP
{ return(ADD_ASSIGN); }
YY_BREAK
case 97:
YY_RULE_SETUP
{ return(SUB_ASSIGN); }
YY_BREAK
case 98:
YY_RULE_SETUP
{ return(MUL_ASSIGN); }
YY_BREAK
case 99:
YY_RULE_SETUP
{ return(DIV_ASSIGN); }
YY_BREAK
case 100:
YY_RULE_SETUP
{ return(MOD_ASSIGN); }
YY_BREAK
case 101:
YY_RULE_SETUP
{ return(LEFT_ASSIGN); }
YY_BREAK
case 102:
YY_RULE_SETUP
{ return(RIGHT_ASSIGN); }
YY_BREAK
case 103:
YY_RULE_SETUP
{ return(AND_ASSIGN); }
YY_BREAK
case 104:
YY_RULE_SETUP
{ return(XOR_ASSIGN); }
YY_BREAK
case 105:
YY_RULE_SETUP
{ return(OR_ASSIGN); }
YY_BREAK
case 106:
YY_RULE_SETUP
{ return(INC_OP); }
YY_BREAK
case 107:
YY_RULE_SETUP
{ return(DEC_OP); }
YY_BREAK
case 108:
YY_RULE_SETUP
{ return(AND_OP); }
YY_BREAK
case 109:
YY_RULE_SETUP
{ return(OR_OP); }
YY_BREAK
case 110:
YY_RULE_SETUP
{ return(XOR_OP); }
YY_BREAK
case 111:
YY_RULE_SETUP
{ return(LE_OP); }
YY_BREAK
case 112:
YY_RULE_SETUP
{ return(GE_OP); }
YY_BREAK
case 113:
YY_RULE_SETUP
{ return(EQ_OP); }
YY_BREAK
case 114:
YY_RULE_SETUP
{ return(NE_OP); }
YY_BREAK
case 115:
YY_RULE_SETUP
{ return(LEFT_OP); }
YY_BREAK
case 116:
YY_RULE_SETUP
{ return(RIGHT_OP); }
YY_BREAK
case 117:
YY_RULE_SETUP
{ context->lexAfterType = false; return(SEMICOLON); }
YY_BREAK
case 118:
YY_RULE_SETUP
{ context->lexAfterType = false; return(LEFT_BRACE); }
YY_BREAK
case 119:
YY_RULE_SETUP
{ return(RIGHT_BRACE); }
YY_BREAK
case 120:
YY_RULE_SETUP
{ if (context->inTypeParen) context->lexAfterType = false; return(COMMA); }
YY_BREAK
case 121:
YY_RULE_SETUP
{ return(COLON); }
YY_BREAK
case 122:
YY_RULE_SETUP
{ context->lexAfterType = false; return(EQUAL); }
YY_BREAK
case 123:
YY_RULE_SETUP
{ context->lexAfterType = false; context->inTypeParen = true; return(LEFT_PAREN); }
YY_BREAK
case 124:
YY_RULE_SETUP
{ context->inTypeParen = false; return(RIGHT_PAREN); }
YY_BREAK
case 125:
YY_RULE_SETUP
{ return(LEFT_BRACKET); }
YY_BREAK
case 126:
YY_RULE_SETUP
{ return(RIGHT_BRACKET); }
YY_BREAK
case 127:
YY_RULE_SETUP
{ BEGIN(FIELDS); return(DOT); }
YY_BREAK
case 128:
YY_RULE_SETUP
{ return(BANG); }
YY_BREAK
case 129:
YY_RULE_SETUP
{ return(DASH); }
YY_BREAK
case 130:
YY_RULE_SETUP
{ return(TILDE); }
YY_BREAK
case 131:
YY_RULE_SETUP
{ return(PLUS); }
YY_BREAK
case 132:
YY_RULE_SETUP
{ return(STAR); }
YY_BREAK
case 133:
YY_RULE_SETUP
{ return(SLASH); }
YY_BREAK
case 134:
YY_RULE_SETUP
{ return(PERCENT); }
YY_BREAK
case 135:
YY_RULE_SETUP
{ return(LEFT_ANGLE); }
YY_BREAK
case 136:
YY_RULE_SETUP
{ return(RIGHT_ANGLE); }
YY_BREAK
case 137:
YY_RULE_SETUP
{ return(VERTICAL_BAR); }
YY_BREAK
case 138:
YY_RULE_SETUP
{ return(CARET); }
YY_BREAK
case 139:
YY_RULE_SETUP
{ return(AMPERSAND); }
YY_BREAK
case 140:
YY_RULE_SETUP
{ return(QUESTION); }
YY_BREAK
case 141:
YY_RULE_SETUP
{
BEGIN(INITIAL);
yylval->lex.string = NewPoolTString(yytext);
return FIELD_SELECTION;
}
YY_BREAK
case 142:
YY_RULE_SETUP
{}
YY_BREAK
case 143:
/* rule 143 can match eol */
YY_RULE_SETUP
{ }
YY_BREAK
case YY_STATE_EOF(INITIAL):
case YY_STATE_EOF(COMMENT):
case YY_STATE_EOF(FIELDS):
{ context->AfterEOF = true; yyterminate(); }
YY_BREAK
case 144:
YY_RULE_SETUP
{ context->warning(yylineno, "Unknown char", yytext, ""); return 0; }
YY_BREAK
case 145:
YY_RULE_SETUP
ECHO;
YY_BREAK
case YY_END_OF_BUFFER:
{
/* Amount of text matched not including the EOB char. */
int yy_amount_of_matched_text = (int) (yy_cp - yyg->yytext_ptr) - 1;
/* Undo the effects of YY_DO_BEFORE_ACTION. */
*yy_cp = yyg->yy_hold_char;
YY_RESTORE_YY_MORE_OFFSET
if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW )
{
/* We're scanning a new file or input source. It's
* possible that this happened because the user
* just pointed yyin at a new source and called
* yylex(). If so, then we have to assure
* consistency between YY_CURRENT_BUFFER and our
* globals. Here is the right place to do so, because
* this is the first action (other than possibly a
* back-up) that will match for the new input source.
*/
yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin;
YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL;
}
/* Note that here we test for yy_c_buf_p "<=" to the position
* of the first EOB in the buffer, since yy_c_buf_p will
* already have been incremented past the NUL character
* (since all states make transitions on EOB to the
* end-of-buffer state). Contrast this with the test
* in input().
*/
if ( yyg->yy_c_buf_p <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] )
{ /* This was really a NUL. */
yy_state_type yy_next_state;
yyg->yy_c_buf_p = yyg->yytext_ptr + yy_amount_of_matched_text;
yy_current_state = yy_get_previous_state( yyscanner );
/* Okay, we're now positioned to make the NUL
* transition. We couldn't have
* yy_get_previous_state() go ahead and do it
* for us because it doesn't know how to deal
* with the possibility of jamming (and we don't
* want to build jamming into it because then it
* will run more slowly).
*/
yy_next_state = yy_try_NUL_trans( yy_current_state , yyscanner);
yy_bp = yyg->yytext_ptr + YY_MORE_ADJ;
if ( yy_next_state )
{
/* Consume the NUL. */
yy_cp = ++yyg->yy_c_buf_p;
yy_current_state = yy_next_state;
goto yy_match;
}
else
{
yy_cp = yyg->yy_last_accepting_cpos;
yy_current_state = yyg->yy_last_accepting_state;
goto yy_find_action;
}
}
else switch ( yy_get_next_buffer( yyscanner ) )
{
case EOB_ACT_END_OF_FILE:
{
yyg->yy_did_buffer_switch_on_eof = 0;
if ( yywrap(yyscanner ) )
{
/* Note: because we've taken care in
* yy_get_next_buffer() to have set up
* yytext, we can now set up
* yy_c_buf_p so that if some total
* hoser (like flex itself) wants to
* call the scanner after we return the
* YY_NULL, it'll still work - another
* YY_NULL will get returned.
*/
yyg->yy_c_buf_p = yyg->yytext_ptr + YY_MORE_ADJ;
yy_act = YY_STATE_EOF(YY_START);
goto do_action;
}
else
{
if ( ! yyg->yy_did_buffer_switch_on_eof )
YY_NEW_FILE;
}
break;
}
case EOB_ACT_CONTINUE_SCAN:
yyg->yy_c_buf_p =
yyg->yytext_ptr + yy_amount_of_matched_text;
yy_current_state = yy_get_previous_state( yyscanner );
yy_cp = yyg->yy_c_buf_p;
yy_bp = yyg->yytext_ptr + YY_MORE_ADJ;
goto yy_match;
case EOB_ACT_LAST_MATCH:
yyg->yy_c_buf_p =
&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars];
yy_current_state = yy_get_previous_state( yyscanner );
yy_cp = yyg->yy_c_buf_p;
yy_bp = yyg->yytext_ptr + YY_MORE_ADJ;
goto yy_find_action;
}
break;
}
default:
YY_FATAL_ERROR(
"fatal flex scanner internal error--no action found" );
} /* end of action switch */
} /* end of scanning one token */
} /* end of yylex */
/* yy_get_next_buffer - try to read in a new buffer
*
* Returns a code representing an action:
* EOB_ACT_LAST_MATCH -
* EOB_ACT_CONTINUE_SCAN - continue scanning from current position
* EOB_ACT_END_OF_FILE - end of file
*/
static int yy_get_next_buffer (yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf;
register char *source = yyg->yytext_ptr;
register int number_to_move, i;
int ret_val;
if ( yyg->yy_c_buf_p > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] )
YY_FATAL_ERROR(
"fatal flex scanner internal error--end of buffer missed" );
if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 )
{ /* Don't try to fill the buffer, so this is an EOF. */
if ( yyg->yy_c_buf_p - yyg->yytext_ptr - YY_MORE_ADJ == 1 )
{
/* We matched a single character, the EOB, so
* treat this as a final EOF.
*/
return EOB_ACT_END_OF_FILE;
}
else
{
/* We matched some text prior to the EOB, first
* process it.
*/
return EOB_ACT_LAST_MATCH;
}
}
/* Try to read more data. */
/* First move last chars to start of buffer. */
number_to_move = (int) (yyg->yy_c_buf_p - yyg->yytext_ptr) - 1;
for ( i = 0; i < number_to_move; ++i )
*(dest++) = *(source++);
if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING )
/* don't do the read, it's not guaranteed to return an EOF,
* just force an EOF
*/
YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars = 0;
else
{
int num_to_read =
YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;
while ( num_to_read <= 0 )
{ /* Not enough room in the buffer - grow it. */
/* just a shorter name for the current buffer */
YY_BUFFER_STATE b = YY_CURRENT_BUFFER;
int yy_c_buf_p_offset =
(int) (yyg->yy_c_buf_p - b->yy_ch_buf);
if ( b->yy_is_our_buffer )
{
int new_size = b->yy_buf_size * 2;
if ( new_size <= 0 )
b->yy_buf_size += b->yy_buf_size / 8;
else
b->yy_buf_size *= 2;
b->yy_ch_buf = (char *)
/* Include room in for 2 EOB chars. */
yyrealloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 ,yyscanner );
}
else
/* Can't grow it, we don't own it. */
b->yy_ch_buf = 0;
if ( ! b->yy_ch_buf )
YY_FATAL_ERROR(
"fatal error - scanner input buffer overflow" );
yyg->yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset];
num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size -
number_to_move - 1;
}
if ( num_to_read > YY_READ_BUF_SIZE )
num_to_read = YY_READ_BUF_SIZE;
/* Read in more data. */
YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]),
yyg->yy_n_chars, (size_t) num_to_read );
YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars;
}
if ( yyg->yy_n_chars == 0 )
{
if ( number_to_move == YY_MORE_ADJ )
{
ret_val = EOB_ACT_END_OF_FILE;
yyrestart(yyin ,yyscanner);
}
else
{
ret_val = EOB_ACT_LAST_MATCH;
YY_CURRENT_BUFFER_LVALUE->yy_buffer_status =
YY_BUFFER_EOF_PENDING;
}
}
else
ret_val = EOB_ACT_CONTINUE_SCAN;
if ((yy_size_t) (yyg->yy_n_chars + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) {
/* Extend the array by 50%, plus the number we really need. */
yy_size_t new_size = yyg->yy_n_chars + number_to_move + (yyg->yy_n_chars >> 1);
YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size ,yyscanner );
if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" );
}
yyg->yy_n_chars += number_to_move;
YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] = YY_END_OF_BUFFER_CHAR;
YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR;
yyg->yytext_ptr = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0];
return ret_val;
}
/* yy_get_previous_state - get the state just before the EOB char was reached */
static yy_state_type yy_get_previous_state (yyscan_t yyscanner)
{
register yy_state_type yy_current_state;
register char *yy_cp;
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
yy_current_state = yyg->yy_start;
for ( yy_cp = yyg->yytext_ptr + YY_MORE_ADJ; yy_cp < yyg->yy_c_buf_p; ++yy_cp )
{
register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
if ( yy_accept[yy_current_state] )
{
yyg->yy_last_accepting_state = yy_current_state;
yyg->yy_last_accepting_cpos = yy_cp;
}
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
{
yy_current_state = (int) yy_def[yy_current_state];
if ( yy_current_state >= 411 )
yy_c = yy_meta[(unsigned int) yy_c];
}
yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
}
return yy_current_state;
}
/* yy_try_NUL_trans - try to make a transition on the NUL character
*
* synopsis
* next_state = yy_try_NUL_trans( current_state );
*/
static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state , yyscan_t yyscanner)
{
register int yy_is_jam;
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* This var may be unused depending upon options. */
register char *yy_cp = yyg->yy_c_buf_p;
register YY_CHAR yy_c = 1;
if ( yy_accept[yy_current_state] )
{
yyg->yy_last_accepting_state = yy_current_state;
yyg->yy_last_accepting_cpos = yy_cp;
}
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
{
yy_current_state = (int) yy_def[yy_current_state];
if ( yy_current_state >= 411 )
yy_c = yy_meta[(unsigned int) yy_c];
}
yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
yy_is_jam = (yy_current_state == 410);
return yy_is_jam ? 0 : yy_current_state;
}
#ifndef YY_NO_INPUT
#ifdef __cplusplus
static int yyinput (yyscan_t yyscanner)
#else
static int input (yyscan_t yyscanner)
#endif
{
int c;
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
*yyg->yy_c_buf_p = yyg->yy_hold_char;
if ( *yyg->yy_c_buf_p == YY_END_OF_BUFFER_CHAR )
{
/* yy_c_buf_p now points to the character we want to return.
* If this occurs *before* the EOB characters, then it's a
* valid NUL; if not, then we've hit the end of the buffer.
*/
if ( yyg->yy_c_buf_p < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] )
/* This was really a NUL. */
*yyg->yy_c_buf_p = '\0';
else
{ /* need more input */
int offset = yyg->yy_c_buf_p - yyg->yytext_ptr;
++yyg->yy_c_buf_p;
switch ( yy_get_next_buffer( yyscanner ) )
{
case EOB_ACT_LAST_MATCH:
/* This happens because yy_g_n_b()
* sees that we've accumulated a
* token and flags that we need to
* try matching the token before
* proceeding. But for input(),
* there's no matching to consider.
* So convert the EOB_ACT_LAST_MATCH
* to EOB_ACT_END_OF_FILE.
*/
/* Reset buffer status. */
yyrestart(yyin ,yyscanner);
/*FALLTHROUGH*/
case EOB_ACT_END_OF_FILE:
{
if ( yywrap(yyscanner ) )
return EOF;
if ( ! yyg->yy_did_buffer_switch_on_eof )
YY_NEW_FILE;
#ifdef __cplusplus
return yyinput(yyscanner);
#else
return input(yyscanner);
#endif
}
case EOB_ACT_CONTINUE_SCAN:
yyg->yy_c_buf_p = yyg->yytext_ptr + offset;
break;
}
}
}
c = *(unsigned char *) yyg->yy_c_buf_p; /* cast for 8-bit char's */
*yyg->yy_c_buf_p = '\0'; /* preserve yytext */
yyg->yy_hold_char = *++yyg->yy_c_buf_p;
if ( c == '\n' )
do{ yylineno++;
yycolumn=0;
}while(0)
;
return c;
}
#endif /* ifndef YY_NO_INPUT */
/** Immediately switch to a different input stream.
* @param input_file A readable stream.
* @param yyscanner The scanner object.
* @note This function does not reset the start condition to @c INITIAL .
*/
void yyrestart (FILE * input_file , yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
if ( ! YY_CURRENT_BUFFER ){
yyensure_buffer_stack (yyscanner);
YY_CURRENT_BUFFER_LVALUE =
yy_create_buffer(yyin,YY_BUF_SIZE ,yyscanner);
}
yy_init_buffer(YY_CURRENT_BUFFER,input_file ,yyscanner);
yy_load_buffer_state(yyscanner );
}
/** Switch to a different input buffer.
* @param new_buffer The new input buffer.
* @param yyscanner The scanner object.
*/
void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
/* TODO. We should be able to replace this entire function body
* with
* yypop_buffer_state();
* yypush_buffer_state(new_buffer);
*/
yyensure_buffer_stack (yyscanner);
if ( YY_CURRENT_BUFFER == new_buffer )
return;
if ( YY_CURRENT_BUFFER )
{
/* Flush out information for old buffer. */
*yyg->yy_c_buf_p = yyg->yy_hold_char;
YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p;
YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars;
}
YY_CURRENT_BUFFER_LVALUE = new_buffer;
yy_load_buffer_state(yyscanner );
/* We don't actually know whether we did this switch during
* EOF (yywrap()) processing, but the only time this flag
* is looked at is after yywrap() is called, so it's safe
* to go ahead and always set it.
*/
yyg->yy_did_buffer_switch_on_eof = 1;
}
static void yy_load_buffer_state (yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
yyg->yytext_ptr = yyg->yy_c_buf_p = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos;
yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file;
yyg->yy_hold_char = *yyg->yy_c_buf_p;
}
/** Allocate and initialize an input buffer state.
* @param file A readable stream.
* @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE.
* @param yyscanner The scanner object.
* @return the allocated buffer state.
*/
YY_BUFFER_STATE yy_create_buffer (FILE * file, int size , yyscan_t yyscanner)
{
YY_BUFFER_STATE b;
b = (YY_BUFFER_STATE) yyalloc(sizeof( struct yy_buffer_state ) ,yyscanner );
if ( ! b )
YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
b->yy_buf_size = size;
/* yy_ch_buf has to be 2 characters longer than the size given because
* we need to put in 2 end-of-buffer characters.
*/
b->yy_ch_buf = (char *) yyalloc(b->yy_buf_size + 2 ,yyscanner );
if ( ! b->yy_ch_buf )
YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
b->yy_is_our_buffer = 1;
yy_init_buffer(b,file ,yyscanner);
return b;
}
/** Destroy the buffer.
* @param b a buffer created with yy_create_buffer()
* @param yyscanner The scanner object.
*/
void yy_delete_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
if ( ! b )
return;
if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */
YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0;
if ( b->yy_is_our_buffer )
yyfree((void *) b->yy_ch_buf ,yyscanner );
yyfree((void *) b ,yyscanner );
}
/* Initializes or reinitializes a buffer.
* This function is sometimes called more than once on the same buffer,
* such as during a yyrestart() or at EOF.
*/
static void yy_init_buffer (YY_BUFFER_STATE b, FILE * file , yyscan_t yyscanner)
{
int oerrno = errno;
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
yy_flush_buffer(b ,yyscanner);
b->yy_input_file = file;
b->yy_fill_buffer = 1;
/* If b is the current buffer, then yy_init_buffer was _probably_
* called from yyrestart() or through yy_get_next_buffer.
* In that case, we don't want to reset the lineno or column.
*/
if (b != YY_CURRENT_BUFFER){
b->yy_bs_lineno = 1;
b->yy_bs_column = 0;
}
b->yy_is_interactive = 0;
errno = oerrno;
}
/** Discard all buffered characters. On the next scan, YY_INPUT will be called.
* @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER.
* @param yyscanner The scanner object.
*/
void yy_flush_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
if ( ! b )
return;
b->yy_n_chars = 0;
/* We always need two end-of-buffer characters. The first causes
* a transition to the end-of-buffer state. The second causes
* a jam in that state.
*/
b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR;
b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
b->yy_buf_pos = &b->yy_ch_buf[0];
b->yy_at_bol = 1;
b->yy_buffer_status = YY_BUFFER_NEW;
if ( b == YY_CURRENT_BUFFER )
yy_load_buffer_state(yyscanner );
}
/** Pushes the new state onto the stack. The new state becomes
* the current state. This function will allocate the stack
* if necessary.
* @param new_buffer The new state.
* @param yyscanner The scanner object.
*/
void yypush_buffer_state (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
if (new_buffer == NULL)
return;
yyensure_buffer_stack(yyscanner);
/* This block is copied from yy_switch_to_buffer. */
if ( YY_CURRENT_BUFFER )
{
/* Flush out information for old buffer. */
*yyg->yy_c_buf_p = yyg->yy_hold_char;
YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p;
YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars;
}
/* Only push if top exists. Otherwise, replace top. */
if (YY_CURRENT_BUFFER)
yyg->yy_buffer_stack_top++;
YY_CURRENT_BUFFER_LVALUE = new_buffer;
/* copied from yy_switch_to_buffer. */
yy_load_buffer_state(yyscanner );
yyg->yy_did_buffer_switch_on_eof = 1;
}
/** Removes and deletes the top of the stack, if present.
* The next element becomes the new top.
* @param yyscanner The scanner object.
*/
void yypop_buffer_state (yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
if (!YY_CURRENT_BUFFER)
return;
yy_delete_buffer(YY_CURRENT_BUFFER ,yyscanner);
YY_CURRENT_BUFFER_LVALUE = NULL;
if (yyg->yy_buffer_stack_top > 0)
--yyg->yy_buffer_stack_top;
if (YY_CURRENT_BUFFER) {
yy_load_buffer_state(yyscanner );
yyg->yy_did_buffer_switch_on_eof = 1;
}
}
/* Allocates the stack if it does not exist.
* Guarantees space for at least one push.
*/
static void yyensure_buffer_stack (yyscan_t yyscanner)
{
int num_to_alloc;
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
if (!yyg->yy_buffer_stack) {
/* First allocation is just for 2 elements, since we don't know if this
* scanner will even need a stack. We use 2 instead of 1 to avoid an
* immediate realloc on the next call.
*/
num_to_alloc = 1;
yyg->yy_buffer_stack = (struct yy_buffer_state**)yyalloc
(num_to_alloc * sizeof(struct yy_buffer_state*)
, yyscanner);
if ( ! yyg->yy_buffer_stack )
YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" );
memset(yyg->yy_buffer_stack, 0, num_to_alloc * sizeof(struct yy_buffer_state*));
yyg->yy_buffer_stack_max = num_to_alloc;
yyg->yy_buffer_stack_top = 0;
return;
}
if (yyg->yy_buffer_stack_top >= (yyg->yy_buffer_stack_max) - 1){
/* Increase the buffer to prepare for a possible push. */
int grow_size = 8 /* arbitrary grow size */;
num_to_alloc = yyg->yy_buffer_stack_max + grow_size;
yyg->yy_buffer_stack = (struct yy_buffer_state**)yyrealloc
(yyg->yy_buffer_stack,
num_to_alloc * sizeof(struct yy_buffer_state*)
, yyscanner);
if ( ! yyg->yy_buffer_stack )
YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" );
/* zero only the new slots.*/
memset(yyg->yy_buffer_stack + yyg->yy_buffer_stack_max, 0, grow_size * sizeof(struct yy_buffer_state*));
yyg->yy_buffer_stack_max = num_to_alloc;
}
}
/** Setup the input buffer state to scan directly from a user-specified character buffer.
* @param base the character buffer
* @param size the size in bytes of the character buffer
* @param yyscanner The scanner object.
* @return the newly allocated buffer state object.
*/
YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size , yyscan_t yyscanner)
{
YY_BUFFER_STATE b;
if ( size < 2 ||
base[size-2] != YY_END_OF_BUFFER_CHAR ||
base[size-1] != YY_END_OF_BUFFER_CHAR )
/* They forgot to leave room for the EOB's. */
return 0;
b = (YY_BUFFER_STATE) yyalloc(sizeof( struct yy_buffer_state ) ,yyscanner );
if ( ! b )
YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" );
b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */
b->yy_buf_pos = b->yy_ch_buf = base;
b->yy_is_our_buffer = 0;
b->yy_input_file = 0;
b->yy_n_chars = b->yy_buf_size;
b->yy_is_interactive = 0;
b->yy_at_bol = 1;
b->yy_fill_buffer = 0;
b->yy_buffer_status = YY_BUFFER_NEW;
yy_switch_to_buffer(b ,yyscanner );
return b;
}
/** Setup the input buffer state to scan a string. The next call to yylex() will
* scan from a @e copy of @a str.
* @param yystr a NUL-terminated string to scan
* @param yyscanner The scanner object.
* @return the newly allocated buffer state object.
* @note If you want to scan bytes that may contain NUL values, then use
* yy_scan_bytes() instead.
*/
YY_BUFFER_STATE yy_scan_string (yyconst char * yystr , yyscan_t yyscanner)
{
return yy_scan_bytes(yystr,strlen(yystr) ,yyscanner);
}
/** Setup the input buffer state to scan the given bytes. The next call to yylex() will
* scan from a @e copy of @a bytes.
* @param bytes the byte buffer to scan
* @param len the number of bytes in the buffer pointed to by @a bytes.
* @param yyscanner The scanner object.
* @return the newly allocated buffer state object.
*/
YY_BUFFER_STATE yy_scan_bytes (yyconst char * yybytes, int _yybytes_len , yyscan_t yyscanner)
{
YY_BUFFER_STATE b;
char *buf;
yy_size_t n;
int i;
/* Get memory for full buffer, including space for trailing EOB's. */
n = _yybytes_len + 2;
buf = (char *) yyalloc(n ,yyscanner );
if ( ! buf )
YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" );
for ( i = 0; i < _yybytes_len; ++i )
buf[i] = yybytes[i];
buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR;
b = yy_scan_buffer(buf,n ,yyscanner);
if ( ! b )
YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" );
/* It's okay to grow etc. this buffer, and we should throw it
* away when we're done.
*/
b->yy_is_our_buffer = 1;
return b;
}
static void yy_push_state (int new_state , yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
if ( yyg->yy_start_stack_ptr >= yyg->yy_start_stack_depth )
{
yy_size_t new_size;
yyg->yy_start_stack_depth += YY_START_STACK_INCR;
new_size = yyg->yy_start_stack_depth * sizeof( int );
if ( ! yyg->yy_start_stack )
yyg->yy_start_stack = (int *) yyalloc(new_size ,yyscanner );
else
yyg->yy_start_stack = (int *) yyrealloc((void *) yyg->yy_start_stack,new_size ,yyscanner );
if ( ! yyg->yy_start_stack )
YY_FATAL_ERROR( "out of memory expanding start-condition stack" );
}
yyg->yy_start_stack[yyg->yy_start_stack_ptr++] = YY_START;
BEGIN(new_state);
}
static void yy_pop_state (yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
if ( --yyg->yy_start_stack_ptr < 0 )
YY_FATAL_ERROR( "start-condition stack underflow" );
BEGIN(yyg->yy_start_stack[yyg->yy_start_stack_ptr]);
}
static int yy_top_state (yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
return yyg->yy_start_stack[yyg->yy_start_stack_ptr - 1];
}
#ifndef YY_EXIT_FAILURE
#define YY_EXIT_FAILURE 2
#endif
static void yy_fatal_error (yyconst char* msg , yyscan_t yyscanner)
{
(void) fprintf( stderr, "%s\n", msg );
exit( YY_EXIT_FAILURE );
}
/* Redefine yyless() so it works in section 3 code. */
#undef yyless
#define yyless(n) \
do \
{ \
/* Undo effects of setting up yytext. */ \
int yyless_macro_arg = (n); \
YY_LESS_LINENO(yyless_macro_arg);\
yytext[yyleng] = yyg->yy_hold_char; \
yyg->yy_c_buf_p = yytext + yyless_macro_arg; \
yyg->yy_hold_char = *yyg->yy_c_buf_p; \
*yyg->yy_c_buf_p = '\0'; \
yyleng = yyless_macro_arg; \
} \
while ( 0 )
/* Accessor methods (get/set functions) to struct members. */
/** Get the user-defined data for this scanner.
* @param yyscanner The scanner object.
*/
YY_EXTRA_TYPE yyget_extra (yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
return yyextra;
}
/** Get the current line number.
* @param yyscanner The scanner object.
*/
int yyget_lineno (yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
if (! YY_CURRENT_BUFFER)
return 0;
return yylineno;
}
/** Get the current column number.
* @param yyscanner The scanner object.
*/
int yyget_column (yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
if (! YY_CURRENT_BUFFER)
return 0;
return yycolumn;
}
/** Get the input stream.
* @param yyscanner The scanner object.
*/
FILE *yyget_in (yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
return yyin;
}
/** Get the output stream.
* @param yyscanner The scanner object.
*/
FILE *yyget_out (yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
return yyout;
}
/** Get the length of the current token.
* @param yyscanner The scanner object.
*/
int yyget_leng (yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
return yyleng;
}
/** Get the current token.
* @param yyscanner The scanner object.
*/
char *yyget_text (yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
return yytext;
}
/** Set the user-defined data. This data is never touched by the scanner.
* @param user_defined The data to be associated with this scanner.
* @param yyscanner The scanner object.
*/
void yyset_extra (YY_EXTRA_TYPE user_defined , yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
yyextra = user_defined ;
}
/** Set the current line number.
* @param line_number
* @param yyscanner The scanner object.
*/
void yyset_lineno (int line_number , yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
/* lineno is only valid if an input buffer exists. */
if (! YY_CURRENT_BUFFER )
yy_fatal_error( "yyset_lineno called with no buffer" , yyscanner);
yylineno = line_number;
}
/** Set the current column.
* @param line_number
* @param yyscanner The scanner object.
*/
void yyset_column (int column_no , yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
/* column is only valid if an input buffer exists. */
if (! YY_CURRENT_BUFFER )
yy_fatal_error( "yyset_column called with no buffer" , yyscanner);
yycolumn = column_no;
}
/** Set the input stream. This does not discard the current
* input buffer.
* @param in_str A readable stream.
* @param yyscanner The scanner object.
* @see yy_switch_to_buffer
*/
void yyset_in (FILE * in_str , yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
yyin = in_str ;
}
void yyset_out (FILE * out_str , yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
yyout = out_str ;
}
int yyget_debug (yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
return yy_flex_debug;
}
void yyset_debug (int bdebug , yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
yy_flex_debug = bdebug ;
}
/* Accessor methods for yylval and yylloc */
YYSTYPE * yyget_lval (yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
return yylval;
}
void yyset_lval (YYSTYPE * yylval_param , yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
yylval = yylval_param;
}
/* User-visible API */
/* yylex_init is special because it creates the scanner itself, so it is
* the ONLY reentrant function that doesn't take the scanner as the last argument.
* That's why we explicitly handle the declaration, instead of using our macros.
*/
int yylex_init(yyscan_t* ptr_yy_globals)
{
if (ptr_yy_globals == NULL){
errno = EINVAL;
return 1;
}
*ptr_yy_globals = (yyscan_t) yyalloc ( sizeof( struct yyguts_t ), NULL );
if (*ptr_yy_globals == NULL){
errno = ENOMEM;
return 1;
}
/* By setting to 0xAA, we expose bugs in yy_init_globals. Leave at 0x00 for releases. */
memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t));
return yy_init_globals ( *ptr_yy_globals );
}
/* yylex_init_extra has the same functionality as yylex_init, but follows the
* convention of taking the scanner as the last argument. Note however, that
* this is a *pointer* to a scanner, as it will be allocated by this call (and
* is the reason, too, why this function also must handle its own declaration).
* The user defined value in the first argument will be available to yyalloc in
* the yyextra field.
*/
int yylex_init_extra(YY_EXTRA_TYPE yy_user_defined,yyscan_t* ptr_yy_globals )
{
struct yyguts_t dummy_yyguts;
yyset_extra (yy_user_defined, &dummy_yyguts);
if (ptr_yy_globals == NULL){
errno = EINVAL;
return 1;
}
*ptr_yy_globals = (yyscan_t) yyalloc ( sizeof( struct yyguts_t ), &dummy_yyguts );
if (*ptr_yy_globals == NULL){
errno = ENOMEM;
return 1;
}
/* By setting to 0xAA, we expose bugs in
yy_init_globals. Leave at 0x00 for releases. */
memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t));
yyset_extra (yy_user_defined, *ptr_yy_globals);
return yy_init_globals ( *ptr_yy_globals );
}
static int yy_init_globals (yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
/* Initialization is the same as for the non-reentrant scanner.
* This function is called from yylex_destroy(), so don't allocate here.
*/
yyg->yy_buffer_stack = 0;
yyg->yy_buffer_stack_top = 0;
yyg->yy_buffer_stack_max = 0;
yyg->yy_c_buf_p = (char *) 0;
yyg->yy_init = 0;
yyg->yy_start = 0;
yyg->yy_start_stack_ptr = 0;
yyg->yy_start_stack_depth = 0;
yyg->yy_start_stack = NULL;
/* Defined in main.c */
#ifdef YY_STDINIT
yyin = stdin;
yyout = stdout;
#else
yyin = (FILE *) 0;
yyout = (FILE *) 0;
#endif
/* For future reference: Set errno on error, since we are called by
* yylex_init()
*/
return 0;
}
/* yylex_destroy is for both reentrant and non-reentrant scanners. */
int yylex_destroy (yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
/* Pop the buffer stack, destroying each element. */
while(YY_CURRENT_BUFFER){
yy_delete_buffer(YY_CURRENT_BUFFER ,yyscanner );
YY_CURRENT_BUFFER_LVALUE = NULL;
yypop_buffer_state(yyscanner);
}
/* Destroy the stack itself. */
yyfree(yyg->yy_buffer_stack ,yyscanner);
yyg->yy_buffer_stack = NULL;
/* Destroy the start condition stack. */
yyfree(yyg->yy_start_stack ,yyscanner );
yyg->yy_start_stack = NULL;
/* Reset the globals. This is important in a non-reentrant scanner so the next time
* yylex() is called, initialization will occur. */
yy_init_globals( yyscanner);
/* Destroy the main struct (reentrant only). */
yyfree ( yyscanner , yyscanner );
yyscanner = NULL;
return 0;
}
/*
* Internal utility routines.
*/
#ifndef yytext_ptr
static void yy_flex_strncpy (char* s1, yyconst char * s2, int n , yyscan_t yyscanner)
{
register int i;
for ( i = 0; i < n; ++i )
s1[i] = s2[i];
}
#endif
#ifdef YY_NEED_STRLEN
static int yy_flex_strlen (yyconst char * s , yyscan_t yyscanner)
{
register int n;
for ( n = 0; s[n]; ++n )
;
return n;
}
#endif
void *yyalloc (yy_size_t size , yyscan_t yyscanner)
{
return (void *) malloc( size );
}
void *yyrealloc (void * ptr, yy_size_t size , yyscan_t yyscanner)
{
/* The cast to (char *) in the following accommodates both
* implementations that use char* generic pointers, and those
* that use void* generic pointers. It works with the latter
* because both ANSI C and C++ allow castless assignment from
* any pointer type to void*, and deal with argument conversions
* as though doing an assignment.
*/
return (void *) realloc( (char *) ptr, size );
}
void yyfree (void * ptr , yyscan_t yyscanner)
{
free( (char *) ptr ); /* see yyrealloc() for (char *) cast */
}
#define YYTABLES_NAME "yytables"
extern "C" {
// Preprocessor interface.
#include "compiler/preprocessor/preprocess.h"
#define SETUP_CONTEXT(pp) \
TParseContext* context = (TParseContext*) pp->pC; \
struct yyguts_t* yyg = (struct yyguts_t*) context->scanner;
// Preprocessor callbacks.
void CPPDebugLogMsg(const char *msg)
{
SETUP_CONTEXT(cpp);
context->infoSink.debug.message(EPrefixNone, msg);
}
void CPPWarningToInfoLog(const char *msg)
{
SETUP_CONTEXT(cpp);
context->warning(yylineno, msg, "", "");
}
void CPPShInfoLogMsg(const char *msg)
{
SETUP_CONTEXT(cpp);
context->error(yylineno, msg, "", "");
context->recover();
}
void CPPErrorToInfoLog(char *msg)
{
SETUP_CONTEXT(cpp);
context->error(yylineno, msg, "", "");
context->recover();
}
void SetLineNumber(int line)
{
SETUP_CONTEXT(cpp);
int string = 0;
DecodeSourceLoc(yylineno, &string, NULL);
yylineno = EncodeSourceLoc(string, line);
}
void SetStringNumber(int string)
{
SETUP_CONTEXT(cpp);
int line = 0;
DecodeSourceLoc(yylineno, NULL, &line);
yylineno = EncodeSourceLoc(string, line);
}
int GetStringNumber()
{
SETUP_CONTEXT(cpp);
int string = 0;
DecodeSourceLoc(yylineno, &string, NULL);
return string;
}
int GetLineNumber()
{
SETUP_CONTEXT(cpp);
int line = 0;
DecodeSourceLoc(yylineno, NULL, &line);
return line;
}
void IncLineNumber()
{
SETUP_CONTEXT(cpp);
int string = 0, line = 0;
DecodeSourceLoc(yylineno, &string, &line);
yylineno = EncodeSourceLoc(string, ++line);
}
void DecLineNumber()
{
SETUP_CONTEXT(cpp);
int string = 0, line = 0;
DecodeSourceLoc(yylineno, &string, &line);
yylineno = EncodeSourceLoc(string, --line);
}
void HandlePragma(const char **tokens, int numTokens)
{
SETUP_CONTEXT(cpp);
if (!strcmp(tokens[0], "optimize")) {
if (numTokens != 4) {
CPPShInfoLogMsg("optimize pragma syntax is incorrect");
return;
}
if (strcmp(tokens[1], "(")) {
CPPShInfoLogMsg("\"(\" expected after 'optimize' keyword");
return;
}
if (!strcmp(tokens[2], "on"))
context->contextPragma.optimize = true;
else if (!strcmp(tokens[2], "off"))
context->contextPragma.optimize = false;
else {
CPPShInfoLogMsg("\"on\" or \"off\" expected after '(' for 'optimize' pragma");
return;
}
if (strcmp(tokens[3], ")")) {
CPPShInfoLogMsg("\")\" expected to end 'optimize' pragma");
return;
}
} else if (!strcmp(tokens[0], "debug")) {
if (numTokens != 4) {
CPPShInfoLogMsg("debug pragma syntax is incorrect");
return;
}
if (strcmp(tokens[1], "(")) {
CPPShInfoLogMsg("\"(\" expected after 'debug' keyword");
return;
}
if (!strcmp(tokens[2], "on"))
context->contextPragma.debug = true;
else if (!strcmp(tokens[2], "off"))
context->contextPragma.debug = false;
else {
CPPShInfoLogMsg("\"on\" or \"off\" expected after '(' for 'debug' pragma");
return;
}
if (strcmp(tokens[3], ")")) {
CPPShInfoLogMsg("\")\" expected to end 'debug' pragma");
return;
}
} else {
#ifdef PRAGMA_TABLE
//
// implementation specific pragma
// use ((TParseContext *)cpp->pC)->contextPragma.pragmaTable to store the information about pragma
// For now, just ignore the pragma that the implementation cannot recognize
// An Example of one such implementation for a pragma that has a syntax like
// #pragma pragmaname(pragmavalue)
// This implementation stores the current pragmavalue against the pragma name in pragmaTable.
//
if (numTokens == 4 && !strcmp(tokens[1], "(") && !strcmp(tokens[3], ")")) {
TPragmaTable& pragmaTable = ((TParseContext *)cpp->pC)->contextPragma.pragmaTable;
TPragmaTable::iterator iter;
iter = pragmaTable.find(TString(tokens[0]));
if (iter != pragmaTable.end()) {
iter->second = tokens[2];
} else {
pragmaTable[ tokens[0] ] = tokens[2];
}
} else if (numTokens >= 2) {
TPragmaTable& pragmaTable = ((TParseContext *)cpp->pC)->contextPragma.pragmaTable;
TPragmaTable::iterator iter;
iter = pragmaTable.find(TString(tokens[0]));
if (iter != pragmaTable.end()) {
iter->second = tokens[1];
} else {
pragmaTable[ tokens[0] ] = tokens[1];
}
}
#endif // PRAGMA_TABLE
}
}
void StoreStr(char *string)
{
SETUP_CONTEXT(cpp);
TString strSrc;
strSrc = TString(string);
context->HashErrMsg = context->HashErrMsg + " " + strSrc;
}
const char* GetStrfromTStr(void)
{
SETUP_CONTEXT(cpp);
cpp->ErrMsg = context->HashErrMsg.c_str();
return cpp->ErrMsg;
}
void ResetTString(void)
{
SETUP_CONTEXT(cpp);
context->HashErrMsg = "";
}
TBehavior GetBehavior(const char* behavior)
{
if (!strcmp("require", behavior))
return EBhRequire;
else if (!strcmp("enable", behavior))
return EBhEnable;
else if (!strcmp("disable", behavior))
return EBhDisable;
else if (!strcmp("warn", behavior))
return EBhWarn;
else {
CPPShInfoLogMsg((TString("behavior '") + behavior + "' is not supported").c_str());
return EBhDisable;
}
}
void updateExtensionBehavior(const char* extName, const char* behavior)
{
SETUP_CONTEXT(cpp);
TBehavior behaviorVal = GetBehavior(behavior);
TMap<TString, TBehavior>:: iterator iter;
TString msg;
// special cased for all extension
if (!strcmp(extName, "all")) {
if (behaviorVal == EBhRequire || behaviorVal == EBhEnable) {
CPPShInfoLogMsg("extension 'all' cannot have 'require' or 'enable' behavior");
return;
} else {
for (iter = context->extensionBehavior.begin(); iter != context->extensionBehavior.end(); ++iter)
iter->second = behaviorVal;
}
} else {
iter = context->extensionBehavior.find(TString(extName));
if (iter == context->extensionBehavior.end()) {
switch (behaviorVal) {
case EBhRequire:
CPPShInfoLogMsg((TString("extension '") + extName + "' is not supported").c_str());
break;
case EBhEnable:
case EBhWarn:
case EBhDisable:
msg = TString("extension '") + extName + "' is not supported";
context->infoSink.info.message(EPrefixWarning, msg.c_str(), yylineno);
break;
}
return;
} else
iter->second = behaviorVal;
}
}
} // extern "C"
int string_input(char* buf, int max_size, yyscan_t yyscanner) {
int len;
if ((len = yylex_CPP(buf, max_size)) == 0)
return 0;
if (len >= max_size)
YY_FATAL_ERROR("input buffer overflow, can't enlarge buffer because scanner uses REJECT");
buf[len] = ' ';
return len+1;
}
int check_type(yyscan_t yyscanner) {
struct yyguts_t* yyg = (struct yyguts_t*) yyscanner;
int token = IDENTIFIER;
TSymbol* symbol = yyextra->symbolTable.find(yytext);
if (yyextra->lexAfterType == false && symbol && symbol->isVariable()) {
TVariable* variable = static_cast<TVariable*>(symbol);
if (variable->isUserType()) {
yyextra->lexAfterType = true;
token = TYPE_NAME;
}
}
yylval->lex.symbol = symbol;
return token;
}
int reserved_word(yyscan_t yyscanner) {
struct yyguts_t* yyg = (struct yyguts_t*) yyscanner;
yyextra->error(yylineno, "Illegal use of reserved word", yytext, "");
yyextra->recover();
return 0;
}
void yyerror(TParseContext* context, const char* reason) {
struct yyguts_t* yyg = (struct yyguts_t*) context->scanner;
if (context->AfterEOF) {
context->error(yylineno, reason, "unexpected EOF", "");
} else {
context->error(yylineno, reason, yytext, "");
}
context->recover();
}
int glslang_initialize(TParseContext* context) {
yyscan_t scanner = NULL;
if (yylex_init_extra(context,&scanner))
return 1;
context->scanner = scanner;
return 0;
}
int glslang_finalize(TParseContext* context) {
yyscan_t scanner = context->scanner;
if (scanner == NULL) return 0;
context->scanner = NULL;
return yylex_destroy(scanner);
}
void glslang_scan(int count, const char* const string[], const int length[],
TParseContext* context) {
yyrestart(NULL,context->scanner);
yyset_lineno(EncodeSourceLoc(0, 1),context->scanner);
context->AfterEOF = false;
// Init preprocessor.
cpp->pC = context;
cpp->PaWhichStr = 0;
cpp->PaArgv = string;
cpp->PaArgc = count;
cpp->PaStrLen = length;
cpp->pastFirstStatement = 0;
ScanFromString(string[0]);
}
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 {
......
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
675 Mass Ave, Cambridge, MA 02139, USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Library General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
Appendix: How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) 19yy <name of author>
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 of the License, 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., 675 Mass Ave, Cambridge, MA 02139, USA.
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) 19yy name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Library General
Public License instead of this License.
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;
}
$
/* -*-C-*- Note some compilers choke on comments on `#line' lines. */
/* Skeleton output parser for bison,
Copyright (C) 1984, 1989, 1990 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., 675 Mass Ave, Cambridge, MA 02139, USA. */
/* As a special exception, when this file is copied by Bison into a
Bison output file, you may use that output file without restriction.
This special exception was added by the Free Software Foundation
in version 1.24 of Bison. */
#ifdef __GNUC__
#define alloca __builtin_alloca
#else /* not __GNUC__ */
#if HAVE_ALLOCA_H
#include <alloca.h>
#else /* not HAVE_ALLOCA_H */
#ifdef _AIX
#pragma alloca
#else /* not _AIX */
char *alloca ();
#endif /* not _AIX */
#endif /* not HAVE_ALLOCA_H */
#endif /* not __GNUC__ */
extern void yyerror(char* s);
#ifndef alloca
#ifdef __GNUC__
#define alloca __builtin_alloca
#else /* not GNU C. */
#if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi)
#include <alloca.h>
#else /* not sparc */
#if (defined (MSDOS) && !defined (__TURBOC__)) || defined (WIN32)
#include <malloc.h>
#else /* not MSDOS, or __TURBOC__ */
#if defined(_AIX)
#include <malloc.h>
#pragma alloca
#else /* not MSDOS, __TURBOC__, or _AIX */
#ifdef __hpux
#ifdef __cplusplus
extern "C" {
void *alloca (unsigned int);
};
#else /* not __cplusplus */
void *alloca ();
#endif /* not __cplusplus */
#endif /* __hpux */
#endif /* not _AIX */
#endif /* not MSDOS, or __TURBOC__ */
#endif /* not sparc. */
#endif /* not GNU C. */
#endif /* alloca not defined. */
/* This is the parser code that is written into each bison parser
when the %semantic_parser declaration is not specified in the grammar.
It was written by Richard Stallman by simplifying the hairy parser
used when %semantic_parser is specified. */
/* Note: there must be only one dollar sign in this file.
It is replaced by the list of actions, each action
as one case of the switch. */
#define yyerrok (yyerrstatus = 0)
#define yyclearin (yychar = YYEMPTY)
#define YYEMPTY -2
#define YYEOF 0
#define YYACCEPT return(0)
#define YYABORT return(1)
#define YYERROR goto yyerrlab1
/* Like YYERROR except do call yyerror.
This remains here temporarily to ease the
transition to the new meaning of YYERROR, for GCC.
Once GCC version 2 has supplanted version 1, this can go. */
#define YYFAIL goto yyerrlab
#define YYRECOVERING() (!!yyerrstatus)
#define YYBACKUP(token, value) \
do \
if (yychar == YYEMPTY && yylen == 1) \
{ yychar = (token), yylval = (value); \
yychar1 = YYTRANSLATE (yychar); \
YYPOPSTACK; \
goto yybackup; \
} \
else \
{ yyerror ("syntax error: cannot back up"); YYERROR; } \
while (0)
#define YYTERROR 1
#define YYERRCODE 256
#ifndef YYPURE
#define YYLEX yylex()
#endif
#ifdef YYPURE
#ifdef YYLSP_NEEDED
#ifdef YYLEX_PARAM
#define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM)
#else
#define YYLEX yylex(&yylval, &yylloc)
#endif
#else /* not YYLSP_NEEDED */
#ifdef YYLEX_PARAM
#define YYLEX yylex(&yylval, YYLEX_PARAM)
#else
#define YYLEX yylex(&yylval)
#endif
#endif /* not YYLSP_NEEDED */
#endif
/* If nonreentrant, generate the variables here */
#ifndef YYPURE
int yychar; /* the lookahead symbol */
YYSTYPE yylval; /* the semantic value of the */
/* lookahead symbol */
#ifdef YYLSP_NEEDED
YYLTYPE yylloc; /* location data for the lookahead */
/* symbol */
#endif
int yynerrs; /* number of parse errors so far */
#endif /* not YYPURE */
#if YYDEBUG != 0
int yydebug; /* nonzero means print parse trace */
/* Since this is uninitialized, it does not stop multiple parsers
from coexisting. */
#endif
/* YYINITDEPTH indicates the initial size of the parser's stacks */
#ifndef YYINITDEPTH
#define YYINITDEPTH 200
#endif
/* YYMAXDEPTH is the maximum size the stacks can grow to
(effective only if the built-in stack extension method is used). */
#if YYMAXDEPTH == 0
#undef YYMAXDEPTH
#endif
#ifndef YYMAXDEPTH
#define YYMAXDEPTH 10000
#endif
/* Prevent warning if -Wstrict-prototypes. */
#ifdef __GNUC__
int yyparse (void);
#endif
#if __GNUC__ > 1 /* GNU C and GNU C++ define this. */
#define __yy_memcpy(FROM,TO,COUNT) __builtin_memcpy(TO,FROM,COUNT)
#else /* not GNU C or C++ */
#ifndef __cplusplus
/* This is the most reliable way to avoid incompatibilities
in available built-in functions on various systems. */
static void
__yy_memcpy (from, to, count)
char *from;
char *to;
size_t count;
{
register char *f = from;
register char *t = to;
register size_t i = count;
while (i-- > 0)
*t++ = *f++;
}
#else /* __cplusplus */
/* This is the most reliable way to avoid incompatibilities
in available built-in functions on various systems. */
static void
__yy_memcpy (char *from, char *to, size_t count)
{
register char *f = from;
register char *t = to;
register size_t i = count;
while (i-- > 0)
*t++ = *f++;
}
#endif
#endif
/* The user can define YYPARSE_PARAM as the name of an argument to be passed
into yyparse. The argument should have type void *.
It should actually point to an object.
Grammar actions can access the variable by casting it
to the proper pointer type. */
#ifdef YYPARSE_PARAM
#ifndef YYPARSE_PARAM_DECL
#define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
#endif
#else
#define YYPARSE_PARAM
#define YYPARSE_PARAM_DECL
#endif
extern YY_DECL;
int
yyparse(YYPARSE_PARAM_DECL YYPARSE_PARAM) {
register int yystate;
register int yyn;
register short *yyssp;
register YYSTYPE *yyvsp;
int yyerrstatus; /* number of tokens to shift before error messages enabled */
int yychar1 = 0; /* lookahead token as an internal (translated) token number */
short yyssa[YYINITDEPTH]; /* the state stack */
YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */
short *yyss = yyssa; /* refer to the stacks thru separate pointers */
YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */
#ifdef YYLSP_NEEDED
YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */
YYLTYPE *yyls = yylsa;
YYLTYPE *yylsp;
#define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
#else
#define YYPOPSTACK (yyvsp--, yyssp--)
#endif
size_t yystacksize = YYINITDEPTH;
#ifdef YYPURE
int yychar;
YYSTYPE yylval;
int yynerrs;
#ifdef YYLSP_NEEDED
YYLTYPE yylloc;
#endif
#endif
YYSTYPE yyval; /* the variable used to return */
/* semantic values from the action */
/* routines */
int yylen;
#if YYDEBUG != 0
if (yydebug)
fprintf(stderr, "Starting parse\n");
#endif
yystate = 0;
yyerrstatus = 0;
yynerrs = 0;
yychar = YYEMPTY; /* Cause a token to be read. */
/* Initialize stack pointers.
Waste one element of value and location stack
so that they stay on the same level as the state stack.
The wasted elements are never initialized. */
yyssp = yyss - 1;
yyvsp = yyvs;
#ifdef YYLSP_NEEDED
yylsp = yyls;
#endif
/* Push a new state, which is found in yystate . */
/* In all cases, when you get here, the value and location stacks
have just been pushed. so pushing a state here evens the stacks. */
yynewstate:
*++yyssp = yystate;
if (yyssp >= yyss + yystacksize - 1)
{
/* Give user a chance to reallocate the stack */
/* Use copies of these so that the &'s don't force the real ones into memory. */
YYSTYPE *yyvs1 = yyvs;
short *yyss1 = yyss;
#ifdef YYLSP_NEEDED
YYLTYPE *yyls1 = yyls;
#endif
/* Get the current used size of the three stacks, in elements. */
size_t size = yyssp - yyss + 1;
#ifdef yyoverflow
/* Each stack pointer address is followed by the size of
the data in use in that stack, in bytes. */
#ifdef YYLSP_NEEDED
/* This used to be a conditional around just the two extra args,
but that might be undefined if yyoverflow is a macro. */
yyoverflow("parser stack overflow",
&yyss1, size * sizeof (*yyssp),
&yyvs1, size * sizeof (*yyvsp),
&yyls1, size * sizeof (*yylsp),
&yystacksize);
#else
yyoverflow("parser stack overflow",
&yyss1, size * sizeof (*yyssp),
&yyvs1, size * sizeof (*yyvsp),
&yystacksize);
#endif
yyss = yyss1; yyvs = yyvs1;
#ifdef YYLSP_NEEDED
yyls = yyls1;
#endif
#else /* no yyoverflow */
/* Extend the stack our own way. */
if (yystacksize >= YYMAXDEPTH)
{
yyerror("parser stack overflow");
return 2;
}
yystacksize *= 2;
if (yystacksize > YYMAXDEPTH)
yystacksize = YYMAXDEPTH;
yyss = (short *) alloca (yystacksize * sizeof (*yyssp));
__yy_memcpy ((char *)yyss1, (char *)yyss, size * sizeof (*yyssp));
yyvs = (YYSTYPE *) alloca (yystacksize * sizeof (*yyvsp));
__yy_memcpy ((char *)yyvs1, (char *)yyvs, size * sizeof (*yyvsp));
#ifdef YYLSP_NEEDED
yyls = (YYLTYPE *) alloca (yystacksize * sizeof (*yylsp));
__yy_memcpy ((char *)yyls1, (char *)yyls, size * sizeof (*yylsp));
#endif
#endif /* no yyoverflow */
yyssp = yyss + size - 1;
yyvsp = yyvs + size - 1;
#ifdef YYLSP_NEEDED
yylsp = yyls + size - 1;
#endif
#if YYDEBUG != 0
if (yydebug)
fprintf(stderr, "Stack size increased to %d\n", yystacksize);
#endif
if (yyssp >= yyss + yystacksize - 1)
YYABORT;
}
#if YYDEBUG != 0
if (yydebug)
fprintf(stderr, "Entering state %d\n", yystate);
#endif
goto yybackup;
yybackup:
/* Do appropriate processing given the current state. */
/* Read a lookahead token if we need one and don't already have one. */
/* yyresume: */
/* First try to decide what to do without reference to lookahead token. */
yyn = yypact[yystate];
if (yyn == YYFLAG)
goto yydefault;
/* Not known => get a lookahead token if don't already have one. */
/* yychar is either YYEMPTY or YYEOF
or a valid token in external form. */
if (yychar == YYEMPTY)
{
#if YYDEBUG != 0
if (yydebug)
fprintf(stderr, "Reading a token: ");
#endif
yychar = YYLEX;
}
/* Convert token to internal form (in yychar1) for indexing tables with */
if (yychar <= 0) /* This means end of input. */
{
yychar1 = 0;
yychar = YYEOF; /* Don't call YYLEX any more */
#if YYDEBUG != 0
if (yydebug)
fprintf(stderr, "Now at end of input.\n");
#endif
}
else
{
yychar1 = YYTRANSLATE(yychar);
#if YYDEBUG != 0
if (yydebug)
{
fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
/* Give the individual parser a way to print the precise meaning
of a token, for further debugging info. */
#ifdef YYPRINT
YYPRINT (stderr, yychar, yylval);
#endif
fprintf (stderr, ")\n");
}
#endif
}
yyn += yychar1;
if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
goto yydefault;
yyn = yytable[yyn];
/* yyn is what to do for this token type in this state.
Negative => reduce, -yyn is rule number.
Positive => shift, yyn is new state.
New state is final state => don't bother to shift,
just return success.
0, or most negative number => error. */
if (yyn < 0)
{
if (yyn == YYFLAG)
goto yyerrlab;
yyn = -yyn;
goto yyreduce;
}
else if (yyn == 0)
goto yyerrlab;
if (yyn == YYFINAL)
YYACCEPT;
/* Shift the lookahead token. */
#if YYDEBUG != 0
if (yydebug)
fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
#endif
/* Discard the token being shifted unless it is eof. */
if (yychar != YYEOF)
yychar = YYEMPTY;
*++yyvsp = yylval;
#ifdef YYLSP_NEEDED
*++yylsp = yylloc;
#endif
/* count tokens shifted since error; after three, turn off error status. */
if (yyerrstatus) yyerrstatus--;
yystate = yyn;
goto yynewstate;
/* Do the default action for the current state. */
yydefault:
yyn = yydefact[yystate];
if (yyn == 0)
goto yyerrlab;
/* Do a reduction. yyn is the number of a rule to reduce with. */
yyreduce:
yylen = yyr2[yyn];
if (yylen > 0)
yyval = yyvsp[1-yylen]; /* implement default value of the action */
#if YYDEBUG != 0
if (yydebug)
{
int i;
fprintf (stderr, "Reducing via rule %d (line %d), ",
yyn, yyrline[yyn]);
/* Print the symbols being reduced, and their result. */
for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
fprintf (stderr, "%s ", yytname[yyrhs[i]]);
fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
}
#endif
$ /* the action file gets copied in in place of this dollarsign */
yyvsp -= yylen;
yyssp -= yylen;
#ifdef YYLSP_NEEDED
yylsp -= yylen;
#endif
#if YYDEBUG != 0
if (yydebug)
{
short *ssp1 = yyss - 1;
fprintf (stderr, "state stack now");
while (ssp1 != yyssp)
fprintf (stderr, " %d", *++ssp1);
fprintf (stderr, "\n");
}
#endif
*++yyvsp = yyval;
#ifdef YYLSP_NEEDED
yylsp++;
if (yylen == 0)
{
yylsp->first_line = yylloc.first_line;
yylsp->first_column = yylloc.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;
}
#endif
/* Now "shift" the result of the reduction.
Determine what state that goes to,
based on the state we popped back to
and the rule number reduced by. */
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;
yyerrlab: /* here on detecting error */
if (! yyerrstatus)
/* If not already recovering from an error, report this error. */
{
++yynerrs;
#ifdef YYERROR_VERBOSE
yyn = yypact[yystate];
if (yyn > YYFLAG && yyn < YYLAST)
{
int size = 0;
char *msg;
int x, count;
count = 0;
/* Start X at -yyn if nec to avoid negative indexes in yycheck. */
for (x = (yyn < 0 ? -yyn : 0);
x < (sizeof(yytname) / sizeof(char *)); x++)
if (yycheck[x + yyn] == x)
size += strlen(yytname[x]) + 15, count++;
msg = (char *) malloc(size + 15);
if (msg != 0)
{
strcpy(msg, "parse error");
if (count < 5)
{
count = 0;
for (x = (yyn < 0 ? -yyn : 0);
x < (sizeof(yytname) / sizeof(char *)); x++)
if (yycheck[x + yyn] == x)
{
strcat(msg, count == 0 ? ", expecting `" : " or `");
strcat(msg, yytname[x]);
strcat(msg, "'");
count++;
}
}
yyerror(msg);
free(msg);
}
else
yyerror ("parse error; also virtual memory exceeded");
}
else
#endif /* YYERROR_VERBOSE */
yyerror("parse error");
}
goto yyerrlab1;
yyerrlab1: /* here on error raised explicitly by an action */
if (yyerrstatus == 3)
{
/* if just tried and failed to reuse lookahead token after an error, discard it. */
/* return failure if at end of input */
if (yychar == YYEOF)
YYABORT;
#if YYDEBUG != 0
if (yydebug)
fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
#endif
yychar = YYEMPTY;
}
/* Else will try to reuse lookahead token
after shifting the error token. */
yyerrstatus = 3; /* Each real token shifted decrements this */
goto yyerrhandle;
yyerrdefault: /* current state does not do anything special for the error token. */
#if 0
/* This is wrong; only states that explicitly want error tokens
should shift them. */
yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/
if (yyn) goto yydefault;
#endif
yyerrpop: /* pop the current state because it cannot handle the error token */
if (yyssp == yyss) YYABORT;
yyvsp--;
yystate = *--yyssp;
#ifdef YYLSP_NEEDED
yylsp--;
#endif
#if YYDEBUG != 0
if (yydebug)
{
short *ssp1 = yyss - 1;
fprintf (stderr, "Error: state stack now");
while (ssp1 != yyssp)
fprintf (stderr, " %d", *++ssp1);
fprintf (stderr, "\n");
}
#endif
yyerrhandle:
yyn = yypact[yystate];
if (yyn == YYFLAG)
goto yyerrdefault;
yyn += YYTERROR;
if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
goto yyerrdefault;
yyn = yytable[yyn];
if (yyn < 0)
{
if (yyn == YYFLAG)
goto yyerrpop;
yyn = -yyn;
goto yyreduce;
}
else if (yyn == 0)
goto yyerrpop;
if (yyn == YYFINAL)
YYACCEPT;
#if YYDEBUG != 0
if (yydebug)
fprintf(stderr, "Shifting error token, ");
#endif
*++yyvsp = yylval;
#ifdef YYLSP_NEEDED
*++yylsp = yylloc;
#endif
yystate = yyn;
goto yynewstate;
}
......@@ -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