#include "InitializeDll.h"
#include "Include/InitializeGlobals.h"
-#include "Include/InitializeParseContext.h"
#include "Public/ShaderLang.h"
return false;
}
-
- if (!InitializePoolIndex()) {
+ if (! InitializePoolIndex()) {
assert(0 && "InitProcess(): Failed to initalize global pool");
return false;
}
- if (!InitializeParseContextIndex()) {
- assert(0 && "InitProcess(): Failed to initalize parse context");
- return false;
- }
-
InitThread();
+
return true;
}
InitializeGlobalPools();
- if (!InitializeThreadParseContext())
- return false;
-
- if (!OS_SetTLSValue(ThreadInitializeIndex, (void *)1)) {
+ if (! OS_SetTLSValue(ThreadInitializeIndex, (void *)1)) {
assert(0 && "InitThread(): Unable to set init flag.");
return false;
}
FreeGlobalPools();
- if (!FreeParseContext())
- success = false;
}
return success;
FreePoolIndex();
- if (!FreeParseContextIndex())
- success = false;
-
OS_FreeTLSIndex(ThreadInitializeIndex);
ThreadInitializeIndex = OS_INVALID_TLS_INDEX;
</ItemDefinitionGroup>\r
<ItemGroup>\r
<ClCompile Include="glslang\MachineIndependent\Constant.cpp" />\r
- <ClCompile Include="glslang\MachineIndependent\glslang_tab.cpp" />\r
+ <ClCompile Include="glslang\MachineIndependent\glslang_tab.cpp">\r
+ <DisableSpecificWarnings Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">4065</DisableSpecificWarnings>\r
+ </ClCompile>\r
<ClCompile Include="glslang\MachineIndependent\InfoSink.cpp" />\r
<ClCompile Include="glslang\MachineIndependent\Initialize.cpp" />\r
+ <ClCompile Include="glslang\MachineIndependent\preprocessor\Pp.cpp" />\r
+ <ClCompile Include="glslang\MachineIndependent\preprocessor\PpAtom.cpp" />\r
+ <ClCompile Include="glslang\MachineIndependent\preprocessor\PpMemory.cpp" />\r
+ <ClCompile Include="glslang\MachineIndependent\preprocessor\PpScanner.cpp" />\r
+ <ClCompile Include="glslang\MachineIndependent\preprocessor\PpContext.cpp" />\r
+ <ClCompile Include="glslang\MachineIndependent\preprocessor\PpSymbols.cpp" />\r
+ <ClCompile Include="glslang\MachineIndependent\preprocessor\PpTokens.cpp" />\r
<ClCompile Include="glslang\MachineIndependent\Scan.cpp" />\r
<ClCompile Include="glslang\MachineIndependent\Versions.cpp" />\r
<ClCompile Include="OGLCompilersDLL\InitializeDll.cpp" />\r
<ClCompile Include="glslang\MachineIndependent\SymbolTable.cpp" />\r
<ClCompile Include="glslang\MachineIndependent\intermOut.cpp" />\r
<ClCompile Include="glslang\MachineIndependent\parseConst.cpp" />\r
- <ClCompile Include="glslang\MachineIndependent\preprocessor\atom.c" />\r
- <ClCompile Include="glslang\MachineIndependent\preprocessor\cpp.c" />\r
- <ClCompile Include="glslang\MachineIndependent\preprocessor\cppstruct.c" />\r
- <ClCompile Include="glslang\MachineIndependent\preprocessor\memory.c" />\r
- <ClCompile Include="glslang\MachineIndependent\preprocessor\scanner.c" />\r
- <ClCompile Include="glslang\MachineIndependent\preprocessor\symbols.c" />\r
- <ClCompile Include="glslang\MachineIndependent\preprocessor\tokens.c" />\r
<ClCompile Include="glslang\OSDependent\Windows\main.cpp" />\r
<ClCompile Include="glslang\OSDependent\Windows\ossource.cpp" />\r
<ClCompile Include="glslang\OSDependent\Linux\ossource.cpp">\r
<ClInclude Include="glslang\MachineIndependent\Initialize.h" />\r
<ClInclude Include="glslang\MachineIndependent\MMap.h" />\r
<ClInclude Include="glslang\MachineIndependent\ParseHelper.h" />\r
+ <ClInclude Include="glslang\MachineIndependent\preprocessor\PpContext.h" />\r
+ <ClInclude Include="glslang\MachineIndependent\preprocessor\PpTokens.h" />\r
<ClInclude Include="glslang\MachineIndependent\QualifierAlive.h" />\r
<ClInclude Include="glslang\MachineIndependent\RemoveTree.h" />\r
<ClInclude Include="glslang\MachineIndependent\localintermediate.h" />\r
- <ClInclude Include="glslang\MachineIndependent\preprocessor\atom.h" />\r
- <ClInclude Include="glslang\MachineIndependent\preprocessor\cpp.h" />\r
- <ClInclude Include="glslang\MachineIndependent\preprocessor\memory.h" />\r
- <ClInclude Include="glslang\MachineIndependent\preprocessor\parser.h" />\r
- <ClInclude Include="glslang\MachineIndependent\preprocessor\preprocess.h" />\r
- <ClInclude Include="glslang\MachineIndependent\preprocessor\scanner.h" />\r
- <ClInclude Include="glslang\MachineIndependent\preprocessor\slglobals.h" />\r
- <ClInclude Include="glslang\MachineIndependent\preprocessor\symbols.h" />\r
- <ClInclude Include="glslang\MachineIndependent\preprocessor\tokens.h" />\r
<ClInclude Include="glslang\Include\BaseTypes.h" />\r
<ClInclude Include="glslang\Include\Common.h" />\r
<ClInclude Include="glslang\Include\ConstantUnion.h" />\r
<ClInclude Include="glslang\MachineIndependent\Versions.h" />\r
<ClInclude Include="OGLCompilersDLL\InitializeDll.h" />\r
<ClInclude Include="glslang\Include\InitializeGlobals.h" />\r
- <ClInclude Include="glslang\Include\InitializeParseContext.h" />\r
<ClInclude Include="glslang\Include\PoolAlloc.h" />\r
<ClInclude Include="glslang\Include\ResourceLimits.h" />\r
<ClInclude Include="glslang\Include\ShHandle.h" />\r
<Filter Include="Machine Independent\Generated Source">\r
<UniqueIdentifier>{564543b5-6302-49ab-9d24-bd6bef91274a}</UniqueIdentifier>\r
</Filter>\r
- <Filter Include="Machine Independent\CPP">\r
- <UniqueIdentifier>{5d320e20-4d64-4db1-9d8c-e7fdc234be36}</UniqueIdentifier>\r
- </Filter>\r
<Filter Include="Header Files">\r
<UniqueIdentifier>{d4faa328-f693-4b77-9fcb-9629ca0d8ee8}</UniqueIdentifier>\r
</Filter>\r
<Filter Include="OSDependent\Linux">\r
<UniqueIdentifier>{0c27903f-6ef2-4725-9d9c-70f50aeaa7a1}</UniqueIdentifier>\r
</Filter>\r
+ <Filter Include="Machine Independent\Preprocessor">\r
+ <UniqueIdentifier>{f25a01e9-79ce-49bf-b79a-d10de89a0fec}</UniqueIdentifier>\r
+ </Filter>\r
</ItemGroup>\r
<ItemGroup>\r
<ClCompile Include="glslang\MachineIndependent\InfoSink.cpp">\r
<ClCompile Include="glslang\MachineIndependent\parseConst.cpp">\r
<Filter>Machine Independent</Filter>\r
</ClCompile>\r
- <ClCompile Include="glslang\MachineIndependent\preprocessor\atom.c">\r
- <Filter>Machine Independent\CPP</Filter>\r
- </ClCompile>\r
- <ClCompile Include="glslang\MachineIndependent\preprocessor\cpp.c">\r
- <Filter>Machine Independent\CPP</Filter>\r
- </ClCompile>\r
- <ClCompile Include="glslang\MachineIndependent\preprocessor\cppstruct.c">\r
- <Filter>Machine Independent\CPP</Filter>\r
- </ClCompile>\r
- <ClCompile Include="glslang\MachineIndependent\preprocessor\memory.c">\r
- <Filter>Machine Independent\CPP</Filter>\r
- </ClCompile>\r
- <ClCompile Include="glslang\MachineIndependent\preprocessor\scanner.c">\r
- <Filter>Machine Independent\CPP</Filter>\r
- </ClCompile>\r
- <ClCompile Include="glslang\MachineIndependent\preprocessor\symbols.c">\r
- <Filter>Machine Independent\CPP</Filter>\r
- </ClCompile>\r
- <ClCompile Include="glslang\MachineIndependent\preprocessor\tokens.c">\r
- <Filter>Machine Independent\CPP</Filter>\r
- </ClCompile>\r
<ClCompile Include="glslang\OSDependent\Windows\main.cpp">\r
<Filter>OSDependent\Windows</Filter>\r
</ClCompile>\r
<ClCompile Include="glslang\MachineIndependent\Scan.cpp">\r
<Filter>Machine Independent</Filter>\r
</ClCompile>\r
+ <ClCompile Include="glslang\MachineIndependent\preprocessor\Pp.cpp">\r
+ <Filter>Machine Independent\Preprocessor</Filter>\r
+ </ClCompile>\r
+ <ClCompile Include="glslang\MachineIndependent\preprocessor\PpAtom.cpp">\r
+ <Filter>Machine Independent\Preprocessor</Filter>\r
+ </ClCompile>\r
+ <ClCompile Include="glslang\MachineIndependent\preprocessor\PpMemory.cpp">\r
+ <Filter>Machine Independent\Preprocessor</Filter>\r
+ </ClCompile>\r
+ <ClCompile Include="glslang\MachineIndependent\preprocessor\PpScanner.cpp">\r
+ <Filter>Machine Independent\Preprocessor</Filter>\r
+ </ClCompile>\r
+ <ClCompile Include="glslang\MachineIndependent\preprocessor\PpSymbols.cpp">\r
+ <Filter>Machine Independent\Preprocessor</Filter>\r
+ </ClCompile>\r
+ <ClCompile Include="glslang\MachineIndependent\preprocessor\PpTokens.cpp">\r
+ <Filter>Machine Independent\Preprocessor</Filter>\r
+ </ClCompile>\r
+ <ClCompile Include="glslang\MachineIndependent\preprocessor\PpContext.cpp">\r
+ <Filter>Machine Independent\Preprocessor</Filter>\r
+ </ClCompile>\r
</ItemGroup>\r
<ItemGroup>\r
<ClInclude Include="glslang\MachineIndependent\Initialize.h">\r
<ClInclude Include="glslang\MachineIndependent\localintermediate.h">\r
<Filter>Machine Independent</Filter>\r
</ClInclude>\r
- <ClInclude Include="glslang\MachineIndependent\preprocessor\atom.h">\r
- <Filter>Machine Independent\CPP</Filter>\r
- </ClInclude>\r
- <ClInclude Include="glslang\MachineIndependent\preprocessor\cpp.h">\r
- <Filter>Machine Independent\CPP</Filter>\r
- </ClInclude>\r
- <ClInclude Include="glslang\MachineIndependent\preprocessor\memory.h">\r
- <Filter>Machine Independent\CPP</Filter>\r
- </ClInclude>\r
- <ClInclude Include="glslang\MachineIndependent\preprocessor\parser.h">\r
- <Filter>Machine Independent\CPP</Filter>\r
- </ClInclude>\r
- <ClInclude Include="glslang\MachineIndependent\preprocessor\preprocess.h">\r
- <Filter>Machine Independent\CPP</Filter>\r
- </ClInclude>\r
- <ClInclude Include="glslang\MachineIndependent\preprocessor\scanner.h">\r
- <Filter>Machine Independent\CPP</Filter>\r
- </ClInclude>\r
- <ClInclude Include="glslang\MachineIndependent\preprocessor\slglobals.h">\r
- <Filter>Machine Independent\CPP</Filter>\r
- </ClInclude>\r
- <ClInclude Include="glslang\MachineIndependent\preprocessor\symbols.h">\r
- <Filter>Machine Independent\CPP</Filter>\r
- </ClInclude>\r
- <ClInclude Include="glslang\MachineIndependent\preprocessor\tokens.h">\r
- <Filter>Machine Independent\CPP</Filter>\r
- </ClInclude>\r
<ClInclude Include="glslang\Include\BaseTypes.h">\r
<Filter>Header Files</Filter>\r
</ClInclude>\r
<ClInclude Include="glslang\Include\InitializeGlobals.h">\r
<Filter>Header Files</Filter>\r
</ClInclude>\r
- <ClInclude Include="glslang\Include\InitializeParseContext.h">\r
- <Filter>Header Files</Filter>\r
- </ClInclude>\r
<ClInclude Include="glslang\Include\PoolAlloc.h">\r
<Filter>Header Files</Filter>\r
</ClInclude>\r
<ClInclude Include="glslang\MachineIndependent\ScanContext.h">\r
<Filter>Machine Independent</Filter>\r
</ClInclude>\r
+ <ClInclude Include="glslang\MachineIndependent\preprocessor\PpContext.h">\r
+ <Filter>Machine Independent\Preprocessor</Filter>\r
+ </ClInclude>\r
+ <ClInclude Include="glslang\MachineIndependent\preprocessor\PpTokens.h">\r
+ <Filter>Machine Independent\Preprocessor</Filter>\r
+ </ClInclude>\r
</ItemGroup>\r
<ItemGroup>\r
<CustomBuild Include="glslang\MachineIndependent\glslang.y">\r
+++ /dev/null
-//
-//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
-//All rights reserved.
-//
-//Redistribution and use in source and binary forms, with or without
-//modification, are permitted provided that the following conditions
-//are met:
-//
-// Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//
-// Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following
-// disclaimer in the documentation and/or other materials provided
-// with the distribution.
-//
-// Neither the name of 3Dlabs Inc. Ltd. 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 BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
-//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
-//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
-//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
-//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
-//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-//POSSIBILITY OF SUCH DAMAGE.
-//
-
-#ifndef __INITIALIZE_PARSE_CONTEXT_INCLUDED_
-#define __INITIALIZE_PARSE_CONTEXT_INCLUDED_
-#include "osinclude.h"
-
-bool InitializeParseContextIndex();
-bool InitializeThreadParseContext();
-bool FreeParseContext();
-bool FreeParseContextIndex();
-
-
-#endif // __INITIALIZE_PARSE_CONTEXT_INCLUDED_
RemoveTree.o ShaderLang.o intermOut.o parseConst.o SymbolTable.o \
InfoSink.o Versions.o Constant.o Scan.o
-SRCS= gen_glslang.cpp gen_glslang_tab.cpp Initialize.cpp IntermTraverse.cpp \
+SRCS= gen_glslang_tab.cpp Initialize.cpp IntermTraverse.cpp \
Intermediate.cpp ParseHelper.cpp PoolAlloc.cp QualifierAlive.cpp \
RemoveTree.cpp ShaderLang.cpp SymbolTable.cpp intermOut.cpp \
parseConst.cpp InfoSink.cpp Versions.cpp Constant.cpp Scan.cpp
all: $(SHAREDOBJECT)
-$(SHAREDOBJECT): gen_glslang.o gen_glslang_tab.o $(OBJECTS) \
+$(SHAREDOBJECT): gen_glslang_tab.o $(OBJECTS) \
$(LIBPREPROCESSOR) $(LIBCODEGEN) $(LIBOSDEPENDENT) $(LIBINITIALISATION)
- $(CC) -fPIC -shared -o $@ -rdynamic -Wl,-whole-archive $(OBJECTS) $(LIBPREPROCESSOR) $(LIBCODEGEN) $(LIBOSDEPENDENT) $(LIBINITIALISATION) gen_glslang.o gen_glslang_tab.o -Wl,-no-whole-archive
-
-gen_glslang.o : gen_glslang.cpp glslang_tab.h
- $(CC) -fPIC -c $(INCLUDE) gen_glslang.cpp -o $@
+ $(CC) -fPIC -shared -o $@ -rdynamic -Wl,-whole-archive $(OBJECTS) $(LIBPREPROCESSOR) $(LIBCODEGEN) $(LIBOSDEPENDENT) $(LIBINITIALISATION) gen_glslang_tab.o -Wl,-no-whole-archive
gen_glslang_tab.o : gen_glslang_tab.cpp
$(CC) -fPIC -c $(INCLUDE) gen_glslang_tab.cpp -o $@
-gen_glslang.cpp: glslang.l
- @echo Generating gen_glslang.cpp
- @dos2unix glslang.l
- flex glslang.l
-
gen_glslang_tab.cpp glslang_tab.h: glslang.y
@echo Generating gen_glslang_tab.cpp
@dos2unix glslang.y
#
.PHONY : clean
clean :
- $(RM) *.o *.a gen_glslang_tab.cpp glslang_tab.cpp glslang_tab.cpp.h gen_glslang.cpp glslang_tab.h glslang.output
+ $(RM) *.o *.a gen_glslang_tab.cpp glslang_tab.cpp glslang_tab.cpp.h glslang_tab.h glslang.output
$(RM) ./lib/*.so
cd $(INCPREPROCESSOR); make clean
cd $(INCCODEGEN); make clean
# DO NOT DELETE
-gen_glslang.o: ParseHelper.h ../Include/ShHandle.h
-gen_glslang.o: ../Public/ShaderLang.h ../Include/InfoSink.h
-gen_glslang.o: ../Include/Common.h ../Include/PoolAlloc.h SymbolTable.h
-gen_glslang.o: ../Include/Common.h ../Include/intermediate.h
-gen_glslang.o: ../Include/Types.h ../Include/BaseTypes.h
-gen_glslang.o: ../Include/ConstantUnion.h ../Include/InfoSink.h
-gen_glslang.o: localintermediate.h ../Include/intermediate.h
-gen_glslang.o: ../Public/ShaderLang.h glslang_tab.h ./unistd.h
-gen_glslang.o: ./preprocessor/preprocess.h ./preprocessor/slglobals.h
-gen_glslang.o: ./preprocessor/memory.h ./preprocessor/atom.h
-gen_glslang.o: ./preprocessor/scanner.h ./preprocessor/parser.h
-gen_glslang.o: ./preprocessor/cpp.h ./preprocessor/tokens.h
-gen_glslang.o: ./preprocessor/symbols.h ./preprocessor/compile.h
gen_glslang_tab.o: SymbolTable.h ../Include/Common.h
gen_glslang_tab.o: ../Include/intermediate.h ../Include/Common.h
gen_glslang_tab.o: ../Include/PoolAlloc.h ../Include/Types.h
ParseHelper.o: ../Include/Types.h ../Include/BaseTypes.h
ParseHelper.o: ../Include/ConstantUnion.h ../Include/InfoSink.h
ParseHelper.o: localintermediate.h ../Include/intermediate.h
-ParseHelper.o: ../Public/ShaderLang.h ../Include/InitializeParseContext.h
+ParseHelper.o: ../Public/ShaderLang.h
ParseHelper.o: ../OSDependent/Linux/osinclude.h
ParseHelper.o: ../Include/InitializeGlobals.h ../Include/PoolAlloc.h
QualifierAlive.o: ../Include/intermediate.h
+Scan.o: Scan.h
+Scan.o: ParseHelper.h SymbolTable.h
+Scan.o: glslang_tab.cpp.h
+Scan.o: ../Include/Types.h
+Scan.o: ScanContext.h preprocessor/PpContext.h preprocessor/PpTokens.h
RemoveTree.o: ../Include/intermediate.h RemoveTree.h
ShaderLang.o: SymbolTable.h ../Include/Common.h ../Include/intermediate.h
ShaderLang.o: ../Include/Common.h ../Include/PoolAlloc.h ../Include/Types.h
InfoSink.o: ../Include/InfoSink.h
Versions.o: ParseHelper.h Versions.h ../Include/ShHandle.h SymbolTable.h localintermediate.h
Constant.o: localintermediate.h ../Include/intermediate.h ../Public/ShaderLang.h SymbolTable.h Versions.h
-Scan.o: Scan.h Versions.h
//
#include "ParseHelper.h"
-#include "Include/InitializeParseContext.h"
#include "osinclude.h"
#include <stdarg.h>
#include <algorithm>
-extern "C" {
- #include "./preprocessor/preprocess.h"
-}
+#include "preprocessor/PpContext.h"
TParseContext::TParseContext(TSymbolTable& symt, TIntermediate& interm, bool pb, int v, EProfile p, EShLanguage L, TInfoSink& is,
bool fc, EShMessages m) :
numErrors(0), loopNestingLevel(0),
structNestingLevel(0), inTypeParen(false), parsingBuiltins(pb),
version(v), profile(p), forwardCompatible(fc), messages(m),
- contextPragma(true, false)
+ contextPragma(true, false), afterEOF(false), tokensBeforeEOF(false)
{
+ currentLoc.line = 1;
+ currentLoc.string = 0;
+
// set all precision defaults to EpqNone, which is correct for all desktop types
// and for ES types that don't have defaults (thus getting an error on use)
for (int type = 0; type < EbtNumTypes; ++type)
return 0;
}
-TSourceLoc currentLine; // TODO: thread: get this into the scan context, sort out with return from PP
-#ifdef _WIN32
- extern int yyparse(TParseContext&);
-#else
- extern int yyparse(void*);
- #define parseContext (*((TParseContext*)(parseContextLocal)))
-#endif
+extern int yyparse(void*);
//
-// Parse an array of strings using yyparse. We set up globals used by
-// yywrap.
+// Parse an array of strings using yyparse, going through the
+// preprocessor to tokenize the shader strings, then through
+// the GLSL scanner.
//
-// Returns true for success, false for failure.
+// Returns true for successful acceptance of the shader, false if any errors.
//
-bool TParseContext::parseShaderStrings(char* strings[], int strLen[], int numStrings)
+bool TParseContext::parseShaderStrings(TPpContext& ppContext, char* strings[], int lengths[], int numStrings)
{
- if (! strings || numStrings == 0)
- return false;
+ // empty shaders are okay
+ if (! strings || numStrings == 0 || lengths[0] == 0)
+ return true;
for (int i = 0; i < numStrings; ++i) {
if (! strings[i]) {
}
}
- // set up all the cpp fields...
- // TODO: thread safety: don't move 'this' into the global
- cpp->pC = (void*)this;
- const char* preamble = getPreamble();
- char *writeablePreamble = 0;
- if (preamble) {
- // preAmble could be a hard-coded string; make writable copy
- // TODO: efficiency PP: make it not need writable strings
- int size = strlen(preamble) + 1;
- writeablePreamble = new char[size];
- memcpy(writeablePreamble, preamble, size);
- ScanFromString(writeablePreamble);
- cpp->PaWhichStr = -1;
- } else {
- ScanFromString(strings[0]);
- cpp->PaWhichStr = 0;
- }
-
- afterEOF = false;
- cpp->PaArgv = strings;
- cpp->PaArgc = numStrings;
- int string0len;
- if (! strLen) {
- string0len = (int) strlen(strings[0]);
- cpp->PaStrLen = &string0len;
- } else
- cpp->PaStrLen = strLen;
- cpp->notAVersionToken = 0;
- currentLine.string = 0;
- currentLine.line = 1;
+ if (getPreamble())
+ ppContext.setPreamble(getPreamble(), strlen(getPreamble()));
+ ppContext.setShaderStrings(strings, lengths, numStrings);
// TODO: desktop PP: a shader containing nothing but white space and comments is valid, even though it has no parse tokens
int len = 0;
strings[0][len] == '\t' ||
strings[0][len] == '\n' ||
strings[0][len] == '\r') {
- if (++len >= strLen[0]) {
- delete writeablePreamble;
+ if (++len >= lengths[0])
return true;
- }
}
- if (*cpp->PaStrLen > 0) {
- int ret;
- #ifdef _WIN32
- ret = yyparse(*this);
- #else
- ret = yyparse((void*)this);
- #endif
- delete writeablePreamble;
- if (cpp->CompileError == 1 || numErrors > 0)
- return false;
- else
- return true;
- }
+ yyparse((void*)this);
- delete writeablePreamble;
-
- return true;
+ return numErrors == 0;
}
-// TODO: fix this for threads
-void yyerror(const char *s)
+// This is called from bison when it has a parse (syntax) error
+void TParseContext::parserError(const char *s)
{
- TParseContext& pc = *((TParseContext *)cpp->pC);
-
- if (pc.afterEOF) {
- if (cpp->tokensBeforeEOF == 1)
- ThreadLocalParseContext()->error(currentLine, "", "pre-mature EOF", s, "");
+ if (afterEOF) {
+ if (tokensBeforeEOF == 1)
+ error(currentLoc, "", "pre-mature EOF", s, "");
} else
- ThreadLocalParseContext()->error(currentLine, "", "", s, "");
-}
-
-
-extern "C" {
-
-// Communications with the preprocess.
-// TODO: threads: this all needs redoing for thread safety
-
-void ShPpDebugLogMsg(const char *msg)
-{
- TParseContext& pc = *((TParseContext *)cpp->pC);
-
- pc.infoSink.debug.message(EPrefixNone, msg);
-}
-
-void ShPpWarningToInfoLog(const char *msg)
-{
- TParseContext& pc = *((TParseContext *)cpp->pC);
-
- pc.warn(currentLine, msg, "Preprocessor", "");
-}
-
-void ShPpErrorToInfoLog(const char *msg)
-{
- TParseContext& pc = *((TParseContext *)cpp->pC);
-
- pc.error(currentLine, msg, "Preprocessor", "");
-}
-
-// return 1 if error
-// return 0 if no error
-int ShPpMacrosMustBeDefinedError()
-{
- TParseContext& pc = *((TParseContext *)cpp->pC);
-
- if (pc.profile == EEsProfile) {
- if (pc.messages & EShMsgRelaxedErrors)
- ShPpWarningToInfoLog("undefined macro in expression not allowed in es profile");
- else {
- ShPpErrorToInfoLog("undefined macro in expression");
-
- return 1;
- }
- }
-
- return 0;
-}
-
-// TODO: PP/threads: integrate this with location from token
-void SetLineNumber(int line)
-{
- currentLine.line = line;
-}
-
-void SetStringNumber(int string)
-{
- currentLine.string = string;
-}
-
-int GetStringNumber(void)
-{
- return currentLine.string;
-}
-
-int GetLineNumber(void)
-{
- return currentLine.line;
+ error(currentLoc, "", "", s, "");
}
-void IncLineNumber(void)
+void TParseContext::handlePragma(const char **tokens, int numTokens)
{
- ++currentLine.line;
-}
-
-void DecLineNumber(void)
-{
- --currentLine.line;
-}
-
-void HandlePragma(const char **tokens, int numTokens)
-{
- TParseContext& pc = *((TParseContext *)cpp->pC);
-
if (!strcmp(tokens[0], "optimize")) {
if (numTokens != 4) {
- ShPpErrorToInfoLog("optimize pragma syntax is incorrect");
+ error(currentLoc, "optimize pragma syntax is incorrect", "#pragma", "");
return;
}
if (strcmp(tokens[1], "(")) {
- ShPpErrorToInfoLog("\"(\" expected after 'optimize' keyword");
+ error(currentLoc, "\"(\" expected after 'optimize' keyword", "#pragma", "");
return;
}
if (!strcmp(tokens[2], "on"))
- pc.contextPragma.optimize = true;
+ contextPragma.optimize = true;
else if (!strcmp(tokens[2], "off"))
- pc.contextPragma.optimize = false;
+ contextPragma.optimize = false;
else {
- ShPpErrorToInfoLog("\"on\" or \"off\" expected after '(' for 'optimize' pragma");
+ error(currentLoc, "\"on\" or \"off\" expected after '(' for 'optimize' pragma", "#pragma", "");
return;
}
if (strcmp(tokens[3], ")")) {
- ShPpErrorToInfoLog("\")\" expected to end 'optimize' pragma");
+ error(currentLoc, "\")\" expected to end 'optimize' pragma", "#pragma", "");
return;
}
} else if (!strcmp(tokens[0], "debug")) {
if (numTokens != 4) {
- ShPpErrorToInfoLog("debug pragma syntax is incorrect");
+ error(currentLoc, "debug pragma syntax is incorrect", "#pragma", "");
return;
}
if (strcmp(tokens[1], "(")) {
- ShPpErrorToInfoLog("\"(\" expected after 'debug' keyword");
+ error(currentLoc, "\"(\" expected after 'debug' keyword", "#pragma", "");
return;
}
if (!strcmp(tokens[2], "on"))
- pc.contextPragma.debug = true;
+ contextPragma.debug = true;
else if (!strcmp(tokens[2], "off"))
- pc.contextPragma.debug = false;
+ contextPragma.debug = false;
else {
- ShPpErrorToInfoLog("\"on\" or \"off\" expected after '(' for 'debug' pragma");
+ error(currentLoc, "\"on\" or \"off\" expected after '(' for 'debug' pragma", "#pragma", "");
return;
}
if (strcmp(tokens[3], ")")) {
- ShPpErrorToInfoLog("\")\" expected to end 'debug' pragma");
+ error(currentLoc, "\")\" expected to end 'debug' pragma", "#pragma", "");
return;
}
} else {
}
}
-void StoreStr(const char *string)
-{
- TParseContext& pc = *((TParseContext *)cpp->pC);
-
- TString strSrc;
- strSrc = TString(string);
-
- pc.HashErrMsg = pc.HashErrMsg + " " + strSrc;
-}
-
-const char* GetStrfromTStr(void)
-{
- TParseContext& pc = *((TParseContext *)cpp->pC);
-
- cpp->ErrMsg = pc.HashErrMsg.c_str();
- return cpp->ErrMsg;
-}
-
-void ResetTString(void)
-{
- TParseContext& pc = *((TParseContext *)cpp->pC);
-
- pc.HashErrMsg = "";
-}
-
-void SetVersion(int version)
-{
- // called by the CPP, but this functionality is currently
- // taken over by ScanVersion() before parsing starts
-
- // CPP should still report errors in semantics
-}
-
-int GetShaderVersion(void* cppPc)
-{
- TParseContext& pc = *((TParseContext *)cppPc);
-
- return pc.version;
-}
-
-TBehavior GetBehavior(const char* behavior)
+TBehavior TParseContext::getExtensionBehavior(const char* behavior)
{
if (!strcmp("require", behavior))
return EBhRequire;
else if (!strcmp("warn", behavior))
return EBhWarn;
else {
- ShPpErrorToInfoLog((TString("behavior '") + behavior + "' is not supported").c_str());
+ error(currentLoc, "behavior not supported", "#extension", behavior);
return EBhDisable;
}
}
-void updateExtensionBehavior(const char* extName, const char* behavior)
+void TParseContext::updateExtensionBehavior(const char* extName, const char* behavior)
{
- TParseContext& pc = *((TParseContext *)cpp->pC);
- TBehavior behaviorVal = GetBehavior(behavior);
+ TBehavior behaviorVal = getExtensionBehavior(behavior);
TMap<TString, TBehavior>:: iterator iter;
TString msg;
// special cased for all extension
if (!strcmp(extName, "all")) {
if (behaviorVal == EBhRequire || behaviorVal == EBhEnable) {
- ShPpErrorToInfoLog("extension 'all' cannot have 'require' or 'enable' behavior");
+ error(currentLoc, "extension 'all' cannot have 'require' or 'enable' behavior", "#extension", "");
return;
} else {
- for (iter = pc.extensionBehavior.begin(); iter != pc.extensionBehavior.end(); ++iter)
+ for (iter = extensionBehavior.begin(); iter != extensionBehavior.end(); ++iter)
iter->second = behaviorVal;
}
} else {
- iter = pc.extensionBehavior.find(TString(extName));
- if (iter == pc.extensionBehavior.end()) {
+ iter = extensionBehavior.find(TString(extName));
+ if (iter == extensionBehavior.end()) {
switch (behaviorVal) {
case EBhRequire:
- ShPpErrorToInfoLog((TString("extension '") + extName + "' is not supported").c_str());
+ error(currentLoc, "extension not supported", "#extension", extName);
break;
case EBhEnable:
case EBhWarn:
case EBhDisable:
- pc.warn(currentLine, "extension not supported", extName, "");
+ warn(currentLoc, "extension not supported", "#extension", extName);
break;
default:
assert(0 && "unexpected behaviorVal");
}
}
-} // extern "C"
-
-
///////////////////////////////////////////////////////////////////////
//
// Sub- vector and matrix fields
symbolTable.insert(*fakeVariable);
// substitute a symbol node for this new variable
- nodePtr = intermediate.addSymbol(fakeVariable->getUniqueId(),
- fakeVariable->getName(),
+ nodePtr = intermediate.addSymbol(fakeVariable->getUniqueId(),
+ fakeVariable->getName(),
fakeVariable->getType(), symbol->getLoc());
} else {
switch (symbol->getQualifier().storage) {
extensionBehavior["GL_ARB_texture_rectangle"] = EBhDisable;
extensionBehavior["GL_3DL_array_objects"] = EBhDisable;
}
-
-OS_TLSIndex GlobalParseContextIndex = OS_INVALID_TLS_INDEX;
-
-bool InitializeParseContextIndex()
-{
- if (GlobalParseContextIndex != OS_INVALID_TLS_INDEX) {
- assert(0 && "InitializeParseContextIndex(): Parse Context already initialised");
- return false;
- }
-
- //
- // Allocate a TLS index.
- //
- GlobalParseContextIndex = OS_AllocTLSIndex();
-
- if (GlobalParseContextIndex == OS_INVALID_TLS_INDEX) {
- assert(0 && "InitializeParseContextIndex(): Parse Context already initialised");
- return false;
- }
-
- return true;
-}
-
-bool InitializeThreadParseContext()
-{
- if (GlobalParseContextIndex == OS_INVALID_TLS_INDEX) {
- assert(0 && "InitializeThreadParseContext(): Parse Context index not initialized");
- return false;
- }
-
- TThreadParseContext *lpParseContext = static_cast<TThreadParseContext *>(OS_GetTLSValue(GlobalParseContextIndex));
- if (lpParseContext != 0) {
- assert(0 && "InitializeParseContextIndex(): Parse Context already initialized");
- return false;
- }
-
- TThreadParseContext *lpThreadData = new TThreadParseContext();
- if (lpThreadData == 0) {
- assert(0 && "InitializeThreadParseContext(): Unable to create thread parse context");
- return false;
- }
-
- lpThreadData->lpGlobalParseContext = 0;
- OS_SetTLSValue(GlobalParseContextIndex, lpThreadData);
-
- return true;
-}
-
-TParseContextPointer& ThreadLocalParseContext()
-{
- //
- // Minimal error checking for speed
- //
-
- TThreadParseContext *lpParseContext = static_cast<TThreadParseContext *>(OS_GetTLSValue(GlobalParseContextIndex));
-
- return lpParseContext->lpGlobalParseContext;
-}
-
-bool FreeParseContext()
-{
- if (GlobalParseContextIndex == OS_INVALID_TLS_INDEX) {
- assert(0 && "FreeParseContext(): Parse Context index not initialized");
- return false;
- }
-
- TThreadParseContext *lpParseContext = static_cast<TThreadParseContext *>(OS_GetTLSValue(GlobalParseContextIndex));
- if (lpParseContext)
- delete lpParseContext;
-
- return true;
-}
-
-bool FreeParseContextIndex()
-{
- OS_TLSIndex tlsiIndex = GlobalParseContextIndex;
-
- if (GlobalParseContextIndex == OS_INVALID_TLS_INDEX) {
- assert(0 && "FreeParseContextIndex(): Parse Context index not initialized");
- return false;
- }
-
- GlobalParseContextIndex = OS_INVALID_TLS_INDEX;
-
- return OS_FreeTLSIndex(tlsiIndex);
-}
TPragmaTable pragmaTable;
};
+class TPpContext;
+
namespace glslang {
class TScanContext;
};
// The following are extra variables needed during parsing, grouped together so
// they can be passed to the parser without needing a global.
//
-struct TParseContext {
+class TParseContext {
+public:
TParseContext(TSymbolTable&, TIntermediate&, bool parsingBuiltins, int version, EProfile, EShLanguage, TInfoSink&,
bool forwardCompatible = false, EShMessages messages = EShMsgDefault);
- glslang::TScanContext *scanContext;
+
+ glslang::TScanContext* scanContext;
+ TPpContext* ppContext;
TIntermediate& intermediate; // to hold and build a parse tree
TSymbolTable& symbolTable; // symbol table that goes with the current language, version, and profile
TInfoSink& infoSink;
TPrecisionQualifier defaultPrecision[EbtNumTypes];
static const int maxSamplerIndex = EsdNumDims * (EbtNumTypes * (2 * 2)); // see computeSamplerTypeIndex()
TPrecisionQualifier defaultSamplerPrecision[maxSamplerIndex];
- TString HashErrMsg;
bool afterEOF;
+ bool tokensBeforeEOF;
+ TSourceLoc currentLoc;
const TString* blockName;
TQualifier globalUniformDefaults;
TQualifier globalInputDefaults;
void initializeExtensionBehavior();
const char* getPreamble();
- bool parseShaderStrings(char* strings[], int strLen[], int numStrings);
+ bool parseShaderStrings(TPpContext&, char* strings[], int strLen[], int numStrings);
+ void parserError(const char *s);
+
+ void handlePragma(const char **tokens, int numTokens);
+ TBehavior getExtensionBehavior(const char* behavior);
+ void updateExtensionBehavior(const char* extName, const char* behavior);
void C_DECL error(TSourceLoc, const char *szReason, const char *szToken,
const char *szExtraInfoFormat, ...);
void doubleCheck(TSourceLoc, const char* op);
};
-typedef TParseContext* TParseContextPointer;
-TParseContextPointer& ThreadLocalParseContext();
-
-// TODO: threading:
-typedef struct TThreadParseContextRec
-{
- TParseContext *lpGlobalParseContext;
-} TThreadParseContext;
-
#endif // _PARSER_HELPER_INCLUDED_
void InitializeGlobalPools()
{
- TThreadGlobalPools* globalPools= static_cast<TThreadGlobalPools*>(OS_GetTLSValue(PoolIndex));
+ TThreadGlobalPools* globalPools = static_cast<TThreadGlobalPools*>(OS_GetTLSValue(PoolIndex));
if (globalPools)
return;
#include "ScanContext.h"
// preprocessor includes
-extern "C" {
- #include "preprocessor/parser.h"
- #include "preprocessor/preprocess.h"
-}
+#include "preprocessor/PpContext.h"
+#include "preprocessor/PpTokens.h"
namespace glslang {
namespace glslang {
-// This gets filled in by the preprocessor scanner.
-class TPpToken{
-public:
- yystypepp lexer;
-};
-
// Fill this in when doing glslang-level scanning, to hand back to the parser.
class TParserToken {
public:
{
glslang::TParserToken token(*glslangTokenDesc);
- return parseContext.scanContext->tokenize(token);
+ return parseContext.scanContext->tokenize(parseContext.ppContext, token);
}
namespace {
ReservedSet->insert("using");
}
-int TScanContext::tokenize(TParserToken& token)
+int TScanContext::tokenize(TPpContext* pp, TParserToken& token)
{
parserToken = &token;
- TPpToken ppTokenStorage;
- ppToken = &ppTokenStorage;
- tokenText = PpTokenize(&ppToken->lexer);
+ TPpToken ppToken;
+ tokenText = pp->tokenize(&ppToken);
- loc.string = cpp->tokenLoc->file;
- loc.line = cpp->tokenLoc->line;
+ loc = ppToken.loc;
parserToken->sType.lex.loc = loc;
- switch (ppToken->lexer.ppToken) {
+ switch (ppToken.ppToken) {
case ';': afterType = false; return SEMICOLON;
case ',': afterType = false; return COMMA;
case ':': return COLON;
case CPP_OR_ASSIGN: return OR_ASSIGN;
case CPP_XOR_ASSIGN: return XOR_ASSIGN;
- case CPP_INTCONSTANT: parserToken->sType.lex.i = ppToken->lexer.sc_int; return INTCONSTANT;
- case CPP_UINTCONSTANT: parserToken->sType.lex.i = ppToken->lexer.sc_int; return UINTCONSTANT;
- case CPP_FLOATCONSTANT: parserToken->sType.lex.d = ppToken->lexer.sc_dval; return FLOATCONSTANT;
- case CPP_DOUBLECONSTANT: parserToken->sType.lex.d = ppToken->lexer.sc_dval; return DOUBLECONSTANT;
+ case CPP_INTCONSTANT: parserToken->sType.lex.i = ppToken.ival; return INTCONSTANT;
+ case CPP_UINTCONSTANT: parserToken->sType.lex.i = ppToken.ival; return UINTCONSTANT;
+ case CPP_FLOATCONSTANT: parserToken->sType.lex.d = ppToken.dval; return FLOATCONSTANT;
+ case CPP_DOUBLECONSTANT: parserToken->sType.lex.d = ppToken.dval; return DOUBLECONSTANT;
case CPP_IDENTIFIER: return tokenizeIdentifier();
case EOF: return 0;
int TScanContext::reservedWord()
{
- ThreadLocalParseContext()->error(loc, "Reserved word.", tokenText, "", "");
+ parseContext.error(loc, "Reserved word.", tokenText, "", "");
return 0;
}
#include "ParseHelper.h"
+class TPpContext;
+class TPpToken;
+
namespace glslang {
class TParserToken;
-class TPpToken;
class TScanContext {
public:
virtual ~TScanContext() { }
static void fillInKeywordMap();
- int tokenize(TParserToken&);
+ int tokenize(TPpContext*, TParserToken&);
protected:
int tokenizeIdentifier();
#include "../Include/ShHandle.h"
#include "InitializeDll.h"
-extern "C" {
-#include "preprocessor/preprocess.h"
-}
+#include "preprocessor/PpContext.h"
#define SH_EXPORTING
#include "../Public/ShaderLang.h"
// Each has a different set of built-ins, and we want to preserve that from
// compile to compile.
//
-// TODO: quality: thread safety: ensure the built-in symbol table levels are read only.
TSymbolTable* SharedSymbolTables[VersionCount][EProfileCount][EShLangCount] = {};
TPoolAllocator* PerProcessGPA = 0;
symbolTable = &symbolTables[language];
TParseContext parseContext(*symbolTable, intermediate, true, version, profile, language, infoSink);
- ThreadLocalParseContext() = &parseContext;
+ TPpContext ppContext(parseContext);
glslang::TScanContext scanContext(parseContext);
parseContext.scanContext = &scanContext;
+ parseContext.ppContext = &ppContext;
assert(symbolTable->isEmpty() || symbolTable->atSharedBuiltInLevel());
symbolTable->push();
-
- //Initialize the Preprocessor
- int ret = InitPreprocessor();
- if (ret) {
- infoSink.info.message(EPrefixInternalError, "Unable to intialize the Preprocessor");
- return false;
- }
-
for (TBuiltInStrings::iterator i = BuiltInStrings[parseContext.language].begin();
i != BuiltInStrings[parseContext.language].end(); ++i) {
const char* builtInShaders[1];
builtInShaders[0] = (*i).c_str();
builtInLengths[0] = (int) (*i).size();
- if (! parseContext.parseShaderStrings(const_cast<char**>(builtInShaders), builtInLengths, 1) != 0) {
+ if (! parseContext.parseShaderStrings(ppContext, const_cast<char**>(builtInShaders), builtInLengths, 1) != 0) {
infoSink.info.message(EPrefixInternalError, "Unable to parse built-ins");
printf("Unable to parse built-ins\n");
return false;
}
}
- FinalizePreprocessor();
if (resources) {
IdentifyBuiltIns(version, profile, parseContext.language, *symbolTable, *resources);
TParseContext parseContext(symbolTable, intermediate, false, version, profile, compiler->getLanguage(), compiler->infoSink, forwardCompatible, messages);
glslang::TScanContext scanContext(parseContext);
+ TPpContext ppContext(parseContext);
parseContext.scanContext = &scanContext;
+ parseContext.ppContext = &ppContext;
TSourceLoc beginning;
beginning.line = 1;
else if (profile == EEsProfile && version >= 300 && versionNotFirst)
parseContext.error(beginning, "statement must appear first in ESSL shader; before comments or newlines", "#version", "");
- ThreadLocalParseContext() = &parseContext;
-
- InitPreprocessor();
-
//
// Parse the application's shaders. All the following symbol table
// work will be throw-away, so push a new allocation scope that can
if (parseContext.insertBuiltInArrayAtGlobalLevel())
success = false;
- bool ret = parseContext.parseShaderStrings(const_cast<char**>(shaderStrings), lengths, numStrings);
+ bool ret = parseContext.parseShaderStrings(ppContext, const_cast<char**>(shaderStrings), lengths, numStrings);
if (! ret)
success = false;
intermediate.addSymbolLinkageNodes(parseContext.treeRoot, parseContext.linkage, parseContext.language, symbolTable);
while (! symbolTable.atSharedBuiltInLevel())
symbolTable.pop(0);
- FinalizePreprocessor();
//
// Throw away all the temporary memory used by the compilation process.
//
#include "ParseHelper.h"\r
#include "../Public/ShaderLang.h"\r
\r
-#ifdef _WIN32\r
- #define YYPARSE_PARAM parseContext\r
- #define YYPARSE_PARAM_DECL TParseContext&\r
- #define YY_DECL int yylex(YYSTYPE* pyylval, TParseContext& parseContext)\r
- #define YYLEX_PARAM parseContext\r
-#else\r
- #define YYPARSE_PARAM parseContextLocal\r
- #define parseContext (*((TParseContext*)(parseContextLocal)))\r
- #define YY_DECL int yylex(YYSTYPE* pyylval, void* parseContextLocal)\r
- #define YYLEX_PARAM (void*)(parseContextLocal)\r
-#endif\r
-\r
-extern void yyerror(const char*);\r
-\r
%}\r
\r
%union {\r
}\r
\r
%{\r
-#ifndef _WIN32\r
- extern int yylex(YYSTYPE*, void*);\r
-#endif\r
+\r
+#define YYPARSE_PARAM voidParseContext\r
+#define parseContext (*(TParseContext*)voidParseContext)\r
+#define YYLEX_PARAM parseContext\r
+#define yyerror(msg) parseContext.parserError(msg)\r
+\r
+extern int yylex(YYSTYPE*, TParseContext&);\r
+\r
%}\r
\r
-%pure_parser /* Just in case is called from multiple threads */\r
-%expect 1 /* One shift reduce conflict because of if | else */\r
+%pure_parser // enable thread safety\r
+%expect 1 // One shift reduce conflict because of if | else\r
\r
%token <lex> ATTRIBUTE VARYING\r
%token <lex> CONST BOOL FLOAT DOUBLE INT UINT\r
CPPFLAGS=$(DEFINE) $(INCLUDE) -fPIC
-OBJECTS = atom.o cpp.o cppstruct.o memory.o scanner.o symbols.o tokens.o
+OBJECTS = PpAtom.o PpScanner.o PpTokens.o Pp.o PpContext.o PpMemory.o PpSymbols.o
AR=ar
-SRCS=scanner.c atom.c memory.c tokens. cpp.c cppstruct.c symbols.c
+SRCS = PpAtom.cpp PpScanner.cpp PpTokens.cpp Pp.cpp PpContext.cpp PpMemory.cpp PpSymbols.cpp
+
default: all
all : libPreprocessor.a
# DO NOT DELETE
-scanner.o: slglobals.h memory.h atom.h scanner.h parser.h cpp.h tokens.h
-scanner.o: symbols.h compile.h
-atom.o: slglobals.h memory.h atom.h scanner.h parser.h cpp.h tokens.h
-atom.o: symbols.h compile.h
-memory.o: memory.h
-cpp.o: slglobals.h memory.h atom.h scanner.h parser.h cpp.h tokens.h
-cpp.o: symbols.h compile.h
-cppstruct.o: slglobals.h memory.h atom.h scanner.h parser.h cpp.h tokens.h
-cppstruct.o: symbols.h compile.h
-symbols.o: slglobals.h memory.h atom.h scanner.h parser.h cpp.h tokens.h
-symbols.o: symbols.h compile.h
+PpAtom.o: PpContext.h PpToken.h
+PpScanner.o: PpContext.h PpToken.h
+PpTokens.o: PpContext.h PpToken.h
+Pp.o: PpContext.h PpToken.h
+PpContext.o: PpContext.h PpToken.h
+PpMemory.o: PpContext.h PpToken.h
+PpSymbols.o: PpContext.h PpToken.h
--- /dev/null
+//
+//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
+//Copyright (C) 2013 LunarG, Inc.
+//All rights reserved.
+//
+//Redistribution and use in source and binary forms, with or without
+//modification, are permitted provided that the following conditions
+//are met:
+//
+// Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+//
+// Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following
+// disclaimer in the documentation and/or other materials provided
+// with the distribution.
+//
+// Neither the name of 3Dlabs Inc. Ltd. 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 BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+//POSSIBILITY OF SUCH DAMAGE.
+//
+/****************************************************************************\
+Copyright (c) 2002, NVIDIA Corporation.
+
+NVIDIA Corporation("NVIDIA") supplies this software to you in
+consideration of your agreement to the following terms, and your use,
+installation, modification or redistribution of this NVIDIA software
+constitutes acceptance of these terms. If you do not agree with these
+terms, please do not use, install, modify or redistribute this NVIDIA
+software.
+
+In consideration of your agreement to abide by the following terms, and
+subject to these terms, NVIDIA grants you a personal, non-exclusive
+license, under NVIDIA's copyrights in this original NVIDIA software (the
+"NVIDIA Software"), to use, reproduce, modify and redistribute the
+NVIDIA Software, with or without modifications, in source and/or binary
+forms; provided that if you redistribute the NVIDIA Software, you must
+retain the copyright notice of NVIDIA, this notice and the following
+text and disclaimers in all such redistributions of the NVIDIA Software.
+Neither the name, trademarks, service marks nor logos of NVIDIA
+Corporation may be used to endorse or promote products derived from the
+NVIDIA Software without specific prior written permission from NVIDIA.
+Except as expressly stated in this notice, no other rights or licenses
+express or implied, are granted by NVIDIA herein, including but not
+limited to any patent rights that may be infringed by your derivative
+works or by other works in which the NVIDIA Software may be
+incorporated. No hardware is licensed hereunder.
+
+THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
+WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,
+NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
+ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER
+PRODUCTS.
+
+IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,
+INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY
+OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE
+NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
+TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
+NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+\****************************************************************************/
+//
+// cpp.c
+//
+
+#define _CRT_SECURE_NO_WARNINGS
+
+#include <stdarg.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+
+#include "PpContext.h"
+#include "PpTokens.h"
+
+/* Don't use memory.c's replacements, as we clean up properly here */
+#undef malloc
+#undef free
+
+int TPpContext::InitCPP()
+{
+ TPpContext::AtomTable* atable = &atomTable;
+ // Add various atoms needed by the CPP line scanner:
+ bindAtom = LookUpAddString(atable, "bind");
+ constAtom = LookUpAddString(atable, "const");
+ defaultAtom = LookUpAddString(atable, "default");
+ defineAtom = LookUpAddString(atable, "define");
+ definedAtom = LookUpAddString(atable, "defined");
+ elifAtom = LookUpAddString(atable, "elif");
+ elseAtom = LookUpAddString(atable, "else");
+ endifAtom = LookUpAddString(atable, "endif");
+ ifAtom = LookUpAddString(atable, "if");
+ ifdefAtom = LookUpAddString(atable, "ifdef");
+ ifndefAtom = LookUpAddString(atable, "ifndef");
+ includeAtom = LookUpAddString(atable, "include");
+ lineAtom = LookUpAddString(atable, "line");
+ pragmaAtom = LookUpAddString(atable, "pragma");
+ texunitAtom = LookUpAddString(atable, "texunit");
+ undefAtom = LookUpAddString(atable, "undef");
+ errorAtom = LookUpAddString(atable, "error");
+ __LINE__Atom = LookUpAddString(atable, "__LINE__");
+ __FILE__Atom = LookUpAddString(atable, "__FILE__");
+ __VERSION__Atom = LookUpAddString(atable, "__VERSION__");
+ versionAtom = LookUpAddString(atable, "version");
+ coreAtom = LookUpAddString(atable, "core");
+ compatibilityAtom = LookUpAddString(atable, "compatibility");
+ esAtom = LookUpAddString(atable, "es");
+ extensionAtom = LookUpAddString(atable, "extension");
+ macros = NewScopeInPool(mem_CreatePool(0, 0));
+
+ return 1;
+} // InitCPP
+
+int TPpContext::FreeCPP()
+{
+ if (macros) {
+ mem_FreePool(macros->pool);
+ macros = 0;
+ }
+
+ return 1;
+}
+
+int TPpContext::FinalCPP()
+{
+ if (ifdepth)
+ parseContext.error(parseContext.currentLoc, "missing #endif", "#if", "");
+ return 1;
+}
+
+int TPpContext::CPPdefine(TPpToken * yylvalpp)
+{
+ int token, name, args[maxMacroArgs], argc;
+ MacroSymbol mac;
+ Symbol *symb;
+ memset(&mac, 0, sizeof(mac));
+ token = currentInput->scan(this, currentInput, yylvalpp);
+ if (token != CPP_IDENTIFIER) {
+ parseContext.error(yylvalpp->loc, "must be followed by macro name", "#define", "");
+ return token;
+ }
+ name = yylvalpp->atom;
+ token = currentInput->scan(this, currentInput, yylvalpp);
+ if (token == '(' && !yylvalpp->ival) {
+ // gather arguments
+ argc = 0;
+ do {
+ token = currentInput->scan(this, currentInput, yylvalpp);
+ if (argc == 0 && token == ')')
+ break;
+ if (token != CPP_IDENTIFIER) {
+ parseContext.error(yylvalpp->loc, "bad argument", "#define", "");
+
+ return token;
+ }
+ if (argc < maxMacroArgs)
+ args[argc++] = yylvalpp->atom;
+ token = currentInput->scan(this, currentInput, yylvalpp);
+ } while (token == ',');
+ if (token != ')') {
+ parseContext.error(yylvalpp->loc, "missing parenthesis", "#define", "");
+
+ return token;
+ }
+ mac.argc = argc;
+ mac.args = (int*)mem_Alloc(macros->pool, argc * sizeof(int));
+ memcpy(mac.args, args, argc * sizeof(int));
+ token = currentInput->scan(this, currentInput, yylvalpp);
+ }
+ mac.body = NewTokenStream(GetAtomString(&atomTable, name), macros->pool);
+ while (token != '\n') {
+ while (token == '\\') {
+ token = currentInput->scan(this, currentInput, yylvalpp);
+ if (token == '\n')
+ token = currentInput->scan(this, currentInput, yylvalpp);
+ else
+ RecordToken(mac.body, '\\', yylvalpp);
+ }
+ RecordToken(mac.body, token, yylvalpp);
+ token = currentInput->scan(this, currentInput, yylvalpp);
+ };
+
+ symb = LookUpSymbol(macros, name);
+ if (symb) {
+ if (!symb->details.mac.undef) {
+ // already defined -- need to make sure they are identical
+ if (symb->details.mac.argc != mac.argc)
+ goto error;
+ for (argc=0; argc < mac.argc; argc++)
+ if (symb->details.mac.args[argc] != mac.args[argc])
+ goto error;
+ RewindTokenStream(symb->details.mac.body);
+ RewindTokenStream(mac.body);
+ do {
+ int old_lval, old_token;
+ old_token = ReadToken(symb->details.mac.body, yylvalpp);
+ old_lval = yylvalpp->ival;
+ token = ReadToken(mac.body, yylvalpp);
+ if (token != old_token || yylvalpp->ival != old_lval) {
+error:
+ parseContext.error(yylvalpp->loc, "Macro Redefined", "#define", GetStringOfAtom(&atomTable, name));
+ break;
+ }
+ } while (token > 0);
+ }
+ //FreeMacro(&symb->details.mac);
+ } else {
+ symb = AddSymbol(&yylvalpp->loc, macros, name, MACRO_S);
+ }
+ symb->details.mac = mac;
+
+ return '\n';
+} // CPPdefine
+
+int TPpContext::CPPundef(TPpToken * yylvalpp)
+{
+ int token = currentInput->scan(this, currentInput, yylvalpp);
+ Symbol *symb;
+ if (token == '\n') {
+ parseContext.error(yylvalpp->loc, "must be followed by macro name", "#undef", "");
+
+ return token;
+ }
+ if (token != CPP_IDENTIFIER) {
+ parseContext.error(yylvalpp->loc, "must be followed by macro name", "#undef", "");
+
+ return token;
+ }
+
+ symb = LookUpSymbol(macros, yylvalpp->atom);
+ if (symb) {
+ symb->details.mac.undef = 1;
+ }
+ token = currentInput->scan(this, currentInput, yylvalpp);
+ if (token != '\n')
+ parseContext.error(yylvalpp->loc, "can only be followed by a single macro name", "#undef", "");
+
+ return token;
+} // CPPundef
+
+/* CPPelse -- skip forward to appropriate spot. This is actually used
+** to skip to a #endif after seeing an #else, AND to skip to a #else,
+** #elif, or #endif after a #if/#ifdef/#ifndef/#elif test was false
+*/
+
+int TPpContext::CPPelse(int matchelse, TPpToken * yylvalpp)
+{
+ int atom;
+ int depth = 0;
+ int token = currentInput->scan(this, currentInput, yylvalpp);
+
+ while (token > 0) {
+ if (token != '#') {
+ while (token != '\n')
+ token = currentInput->scan(this, currentInput, yylvalpp);
+
+ token = currentInput->scan(this, currentInput, yylvalpp);
+ continue;
+ }
+
+ if ((token = currentInput->scan(this, currentInput, yylvalpp)) != CPP_IDENTIFIER)
+ continue;
+
+ atom = yylvalpp->atom;
+ if (atom == ifAtom || atom == ifdefAtom || atom == ifndefAtom) {
+ depth++;
+ ifdepth++;
+ elsetracker++;
+ } else if (atom == endifAtom) {
+ elsedepth[elsetracker] = 0;
+ --elsetracker;
+ if (depth == 0) {
+ // found the #endif we are looking for
+ if (ifdepth)
+ --ifdepth;
+ break;
+ }
+ --depth;
+ --ifdepth;
+ } else if (matchelse && depth == 0) {
+ if (atom == elseAtom ) {
+ // found the #else we are looking for
+ token = currentInput->scan(this, currentInput, yylvalpp);
+ if (token != '\n') {
+ parseContext.warn(yylvalpp->loc, "#else", "unexpected tokens following #else directive - expected a newline", "");
+ while (token != '\n')
+ token = currentInput->scan(this, currentInput, yylvalpp);
+ }
+ break;
+ } else if (atom == elifAtom) {
+ /* we decrement ifdepth here, because CPPif will increment
+ * it and we really want to leave it alone */
+ if (ifdepth) {
+ --ifdepth;
+ elsedepth[elsetracker] = 0;
+ --elsetracker;
+ }
+
+ return CPPif (yylvalpp);
+ }
+ } else if ((atom == elseAtom) && (!ChkCorrectElseNesting()))
+ parseContext.error(yylvalpp->loc, "#else after #else", "#else", "");
+ }; // end while
+
+ return token;
+}
+
+enum eval_prec {
+ MIN_PREC,
+ COND, LOGOR, LOGAND, OR, XOR, AND, EQUAL, RELATION, SHIFT, ADD, MUL, UNARY,
+ MAX_PREC
+};
+
+namespace {
+
+ int op_logor(int a, int b) { return a || b; }
+ int op_logand(int a, int b) { return a && b; }
+ int op_or(int a, int b) { return a | b; }
+ int op_xor(int a, int b) { return a ^ b; }
+ int op_and(int a, int b) { return a & b; }
+ int op_eq(int a, int b) { return a == b; }
+ int op_ne(int a, int b) { return a != b; }
+ int op_ge(int a, int b) { return a >= b; }
+ int op_le(int a, int b) { return a <= b; }
+ int op_gt(int a, int b) { return a > b; }
+ int op_lt(int a, int b) { return a < b; }
+ int op_shl(int a, int b) { return a << b; }
+ int op_shr(int a, int b) { return a >> b; }
+ int op_add(int a, int b) { return a + b; }
+ int op_sub(int a, int b) { return a - b; }
+ int op_mul(int a, int b) { return a * b; }
+ int op_div(int a, int b) { return a / b; }
+ int op_mod(int a, int b) { return a % b; }
+ int op_pos(int a) { return a; }
+ int op_neg(int a) { return -a; }
+ int op_cmpl(int a) { return ~a; }
+ int op_not(int a) { return !a; }
+
+};
+
+struct Tbinops {
+ int token, prec, (*op)(int, int);
+} binop[] = {
+ { CPP_OR_OP, LOGOR, op_logor },
+ { CPP_AND_OP, LOGAND, op_logand },
+ { '|', OR, op_or },
+ { '^', XOR, op_xor },
+ { '&', AND, op_and },
+ { CPP_EQ_OP, EQUAL, op_eq },
+ { CPP_NE_OP, EQUAL, op_ne },
+ { '>', RELATION, op_gt },
+ { CPP_GE_OP, RELATION, op_ge },
+ { '<', RELATION, op_lt },
+ { CPP_LE_OP, RELATION, op_le },
+ { CPP_LEFT_OP, SHIFT, op_shl },
+ { CPP_RIGHT_OP, SHIFT, op_shr },
+ { '+', ADD, op_add },
+ { '-', ADD, op_sub },
+ { '*', MUL, op_mul },
+ { '/', MUL, op_div },
+ { '%', MUL, op_mod },
+};
+
+struct tunops {
+ int token, (*op)(int);
+} unop[] = {
+ { '+', op_pos },
+ { '-', op_neg },
+ { '~', op_cmpl },
+ { '!', op_not },
+};
+
+#define ALEN(A) (sizeof(A)/sizeof(A[0]))
+
+int TPpContext::eval(int token, int prec, int *res, int *err, TPpToken * yylvalpp)
+{
+ int i, val;
+ Symbol *s;
+
+ if (token == CPP_IDENTIFIER) {
+ if (yylvalpp->atom == definedAtom) {
+ bool needclose = 0;
+ token = currentInput->scan(this, currentInput, yylvalpp);
+ if (token == '(') {
+ needclose = true;
+ token = currentInput->scan(this, currentInput, yylvalpp);
+ }
+ if (token != CPP_IDENTIFIER) {
+ parseContext.error(yylvalpp->loc, "incorrect directive, expected identifier", "preprocessor", "");
+ *err = 1;
+ *res = 0;
+
+ return token;
+ }
+ *res = (s = LookUpSymbol(macros, yylvalpp->atom))
+ ? !s->details.mac.undef : 0;
+ token = currentInput->scan(this, currentInput, yylvalpp);
+ if (needclose) {
+ if (token != ')') {
+ parseContext.error(yylvalpp->loc, "#else after #else", "", "");
+ *err = 1;
+ *res = 0;
+
+ return token;
+ }
+ token = currentInput->scan(this, currentInput, yylvalpp);
+ }
+ } else {
+ int macroReturn = MacroExpand(yylvalpp->atom, yylvalpp, 1);
+ if (macroReturn == 0) {
+ parseContext.error(yylvalpp->loc, "can't evaluate expression", "preprocessor", "");
+ *err = 1;
+ *res = 0;
+
+ return token;
+ } else {
+ if (macroReturn == -1) {
+ if (parseContext.profile == EEsProfile) {
+ if (parseContext.messages & EShMsgRelaxedErrors)
+ parseContext.warn(yylvalpp->loc, "undefined macro in expression not allowed in es profile", "preprocessor", "");
+ else {
+ parseContext.error(yylvalpp->loc, "undefined macro in expression", "preprocessor", "");
+
+ *err = 1;
+ }
+ }
+ }
+ token = currentInput->scan(this, currentInput, yylvalpp);
+
+ return eval(token, prec, res, err, yylvalpp);
+ }
+ }
+ } else if (token == CPP_INTCONSTANT) {
+ *res = yylvalpp->ival;
+ token = currentInput->scan(this, currentInput, yylvalpp);
+ } else if (token == '(') {
+ token = currentInput->scan(this, currentInput, yylvalpp);
+ token = eval(token, MIN_PREC, res, err, yylvalpp);
+ if (!*err) {
+ if (token != ')') {
+ parseContext.error(yylvalpp->loc, "expected ')'", "preprocessor", "");
+ *err = 1;
+ *res = 0;
+
+ return token;
+ }
+ token = currentInput->scan(this, currentInput, yylvalpp);
+ }
+ } else {
+ for (i = ALEN(unop) - 1; i >= 0; i--) {
+ if (unop[i].token == token)
+ break;
+ }
+ if (i >= 0) {
+ token = currentInput->scan(this, currentInput, yylvalpp);
+ token = eval(token, UNARY, res, err, yylvalpp);
+ *res = unop[i].op(*res);
+ } else {
+ parseContext.error(yylvalpp->loc, "", "bad expression", "");
+ *err = 1;
+ *res = 0;
+
+ return token;
+ }
+ }
+ while (!*err) {
+ if (token == ')' || token == '\n')
+ break;
+ for (i = ALEN(binop) - 1; i >= 0; i--) {
+ if (binop[i].token == token)
+ break;
+ }
+ if (i < 0 || binop[i].prec <= prec)
+ break;
+ val = *res;
+ token = currentInput->scan(this, currentInput, yylvalpp);
+ token = eval(token, binop[i].prec, res, err, yylvalpp);
+ *res = binop[i].op(val, *res);
+ }
+
+ return token;
+} // eval
+
+int TPpContext::CPPif (TPpToken * yylvalpp)
+{
+ int token = currentInput->scan(this, currentInput, yylvalpp);
+ int res = 0, err = 0;
+ elsetracker++;
+ if (! ifdepth++)
+ ifloc = yylvalpp->loc;
+ if (ifdepth > maxIfNesting) {
+ parseContext.error(yylvalpp->loc, "maximum nesting depth exceeded", "#if", "");
+ return 0;
+ }
+ token = eval(token, MIN_PREC, &res, &err, yylvalpp);
+ if (token != '\n') {
+ parseContext.warn(yylvalpp->loc, "unexpected tokens following #if directive - expected a newline", "#if", "");
+ while (token != '\n')
+ token = currentInput->scan(this, currentInput, yylvalpp);
+ }
+ if (!res && !err) {
+ token = CPPelse(1, yylvalpp);
+ }
+
+ return token;
+} // CPPif
+
+int TPpContext::CPPifdef(int defined, TPpToken * yylvalpp)
+{
+ int token = currentInput->scan(this, currentInput, yylvalpp);
+ int name = yylvalpp->atom;
+ if (++ifdepth > maxIfNesting) {
+ parseContext.error(yylvalpp->loc, "maximum nesting depth exceededextension name not specified", "#ifdef", "");
+ return 0;
+ }
+ elsetracker++;
+ if (token != CPP_IDENTIFIER) {
+ if (defined)
+ parseContext.error(yylvalpp->loc, "must be followed by macro name", "#ifdef", "");
+ else
+ parseContext.error(yylvalpp->loc, "must be followed by macro name", "#ifndef", "");
+ } else {
+ Symbol *s = LookUpSymbol(macros, name);
+ token = currentInput->scan(this, currentInput, yylvalpp);
+ if (token != '\n') {
+ parseContext.error(yylvalpp->loc, "unexpected tokens following #ifdef directive - expected a newline", "#ifdef", "");
+ while (token != '\n')
+ token = currentInput->scan(this, currentInput, yylvalpp);
+ }
+ if (((s && !s->details.mac.undef) ? 1 : 0) != defined)
+ token = CPPelse(1, yylvalpp);
+ }
+ return token;
+} // CPPifdef
+
+// Handle #line
+int TPpContext::CPPline(TPpToken * yylvalpp)
+{
+ int token = currentInput->scan(this, currentInput, yylvalpp);
+ if (token == '\n') {
+ parseContext.error(yylvalpp->loc, "must by followed by an integral literal", "#line", "");
+ return token;
+ }
+ else if (token == CPP_INTCONSTANT) {
+ parseContext.currentLoc.line = atoi(yylvalpp->name);
+ token = currentInput->scan(this, currentInput, yylvalpp);
+
+ if (token == CPP_INTCONSTANT) {
+ parseContext.currentLoc.string = atoi(yylvalpp->name);
+ token = currentInput->scan(this, currentInput, yylvalpp);
+ if (token != '\n')
+ parseContext.error(parseContext.currentLoc, "cannot be followed by more than two integral literals", "#line", "");
+ } else if (token == '\n')
+
+ return token;
+ else
+ parseContext.error(parseContext.currentLoc, "second argument can only be an integral literal", "#line", "");
+ } else
+ parseContext.error(parseContext.currentLoc, "first argument can only be an integral literal", "#line", "");
+
+ return token;
+}
+
+// Handle #error
+int TPpContext::CPPerror(TPpToken * yylvalpp)
+{
+ int token = currentInput->scan(this, currentInput, yylvalpp);
+ std::string message;
+ TSourceLoc loc = yylvalpp->loc;
+
+ while (token != '\n') {
+ if (token == CPP_INTCONSTANT || token == CPP_UINTCONSTANT ||
+ token == CPP_FLOATCONSTANT || token == CPP_DOUBLECONSTANT) {
+ message.append(yylvalpp->name);
+ } else if (token == CPP_IDENTIFIER || token == CPP_STRCONSTANT) {
+ message.append(GetStringOfAtom(&atomTable, yylvalpp->atom));
+ } else {
+ message.append(GetStringOfAtom(&atomTable, token));
+ }
+ message.append(" ");
+ token = currentInput->scan(this, currentInput, yylvalpp);
+ }
+ //store this msg into the shader's information log..set the Compile Error flag!!!!
+ parseContext.error(loc, message.c_str(), "#error", "");
+
+ return '\n';
+}
+
+int TPpContext::CPPpragma(TPpToken * yylvalpp)
+{
+ char SrcStrName[2];
+ char** allTokens;
+ int tokenCount = 0;
+ int maxTokenCount = 10;
+ const char* SrcStr;
+ int i;
+
+ int token = currentInput->scan(this, currentInput, yylvalpp);
+
+ if (token=='\n') {
+ parseContext.error(yylvalpp->loc, "must be followed by pragma arguments", "#pragma", "");
+ return token;
+ }
+
+ allTokens = (char**)malloc(sizeof(char*) * maxTokenCount);
+
+ while (token != '\n') {
+ if (tokenCount >= maxTokenCount) {
+ maxTokenCount *= 2;
+ allTokens = (char**)realloc((char**)allTokens, sizeof(char*) * maxTokenCount);
+ }
+ switch (token) {
+ case CPP_IDENTIFIER:
+ SrcStr = GetAtomString(&atomTable, yylvalpp->atom);
+ allTokens[tokenCount] = (char*)malloc(strlen(SrcStr) + 1);
+ strcpy(allTokens[tokenCount++], SrcStr);
+ break;
+ case CPP_INTCONSTANT:
+ case CPP_UINTCONSTANT:
+ case CPP_FLOATCONSTANT:
+ case CPP_DOUBLECONSTANT:
+ SrcStr = yylvalpp->name;
+ allTokens[tokenCount] = (char*)malloc(strlen(SrcStr) + 1);
+ strcpy(allTokens[tokenCount++], SrcStr);
+ break;
+ case EOF:
+ parseContext.error(yylvalpp->loc, "directive must end with a newline", "#pragma", "");
+ return token;
+ default:
+ SrcStrName[0] = token;
+ SrcStrName[1] = '\0';
+ allTokens[tokenCount] = (char*)malloc(2);
+ strcpy(allTokens[tokenCount++], SrcStrName);
+ }
+ token = currentInput->scan(this, currentInput, yylvalpp);
+ }
+
+ currentInput->ungetch(this, currentInput, token, yylvalpp);
+ parseContext.handlePragma((const char**)allTokens, tokenCount);
+ token = currentInput->scan(this, currentInput, yylvalpp);
+
+ for (i = 0; i < tokenCount; ++i) {
+ free (allTokens[i]);
+ }
+ free (allTokens);
+
+ return token;
+} // CPPpragma
+
+// This is just for error checking: the version and profile are decided before preprocessing starts
+int TPpContext::CPPversion(TPpToken * yylvalpp)
+{
+ int token = currentInput->scan(this, currentInput, yylvalpp);
+
+ if (notAVersionToken)
+ parseContext.error(yylvalpp->loc, "must occur before any other statement in the program", "#version", "");
+
+ if (token == '\n') {
+ parseContext.error(yylvalpp->loc, "must be followed by version number", "#version", "");
+
+ return token;
+ }
+
+ if (token != CPP_INTCONSTANT)
+ parseContext.error(yylvalpp->loc, "must be followed by version number", "#version", "");
+
+ yylvalpp->ival = atoi(yylvalpp->name);
+
+ token = currentInput->scan(this, currentInput, yylvalpp);
+
+ if (token == '\n')
+ return token;
+ else {
+ if (yylvalpp->atom != coreAtom &&
+ yylvalpp->atom != compatibilityAtom &&
+ yylvalpp->atom != esAtom)
+ parseContext.error(yylvalpp->loc, "bad profile name; use es, core, or compatibility", "#version", "");
+
+ token = currentInput->scan(this, currentInput, yylvalpp);
+
+ if (token == '\n')
+ return token;
+ else
+ parseContext.error(yylvalpp->loc, "bad tokens following profile -- expected newline", "#version", "");
+ }
+
+ return token;
+} // CPPversion
+
+int TPpContext::CPPextension(TPpToken * yylvalpp)
+{
+
+ int token = currentInput->scan(this, currentInput, yylvalpp);
+ char extensionName[80];
+
+ if (token=='\n') {
+ parseContext.error(yylvalpp->loc, "extension name not specified", "#extension", "");
+ return token;
+ }
+
+ if (token != CPP_IDENTIFIER)
+ parseContext.error(yylvalpp->loc, "extension name expected", "#extension", "");
+
+ strcpy(extensionName, GetAtomString(&atomTable, yylvalpp->atom));
+
+ token = currentInput->scan(this, currentInput, yylvalpp);
+ if (token != ':') {
+ parseContext.error(yylvalpp->loc, "':' missing after extension name", "#extension", "");
+ return token;
+ }
+
+ token = currentInput->scan(this, currentInput, yylvalpp);
+ if (token != CPP_IDENTIFIER) {
+ parseContext.error(yylvalpp->loc, "behavior for extension not specified", "#extension", "");
+ return token;
+ }
+
+ parseContext.updateExtensionBehavior(extensionName, GetAtomString(&atomTable, yylvalpp->atom));
+
+ token = currentInput->scan(this, currentInput, yylvalpp);
+ if (token == '\n')
+ return token;
+ else
+ parseContext.error(yylvalpp->loc, "extra tokens -- expected newline", "#extension","");
+
+ return token;
+} // CPPextension
+
+int TPpContext::readCPPline(TPpToken * yylvalpp)
+{
+ int token = currentInput->scan(this, currentInput, yylvalpp);
+ bool isVersion = false;
+
+ if (token == CPP_IDENTIFIER) {
+ if (yylvalpp->atom == defineAtom) {
+ token = CPPdefine(yylvalpp);
+ } else if (yylvalpp->atom == elseAtom) {
+ if (ChkCorrectElseNesting()) {
+ if (! ifdepth) {
+ parseContext.error(yylvalpp->loc, "mismatched statements", "#else", "");
+ }
+ token = currentInput->scan(this, currentInput, yylvalpp);
+ if (token != '\n') {
+ parseContext.warn(yylvalpp->loc, "unexpected tokens following #else directive - expected a newline", "#else", "");
+ while (token != '\n')
+ token = currentInput->scan(this, currentInput, yylvalpp);
+ }
+ token = CPPelse(0, yylvalpp);
+ } else {
+ parseContext.error(yylvalpp->loc, "#else after a #else", "#else", "");
+ ifdepth = 0;
+ notAVersionToken = true;
+ return 0;
+ }
+ } else if (yylvalpp->atom == elifAtom) {
+ if (! ifdepth) {
+ parseContext.error(yylvalpp->loc, "mismatched statements", "#elif", "");
+ }
+ // this token is really a dont care, but we still need to eat the tokens
+ token = currentInput->scan(this, currentInput, yylvalpp);
+ while (token != '\n')
+ token = currentInput->scan(this, currentInput, yylvalpp);
+ token = CPPelse(0, yylvalpp);
+ } else if (yylvalpp->atom == endifAtom) {
+ elsedepth[elsetracker] = 0;
+ --elsetracker;
+ if (! ifdepth)
+ parseContext.error(yylvalpp->loc, "mismatched statements", "#endif", "");
+ else
+ --ifdepth;
+ } else if (yylvalpp->atom == ifAtom) {
+ token = CPPif (yylvalpp);
+ } else if (yylvalpp->atom == ifdefAtom) {
+ token = CPPifdef(1, yylvalpp);
+ } else if (yylvalpp->atom == ifndefAtom) {
+ token = CPPifdef(0, yylvalpp);
+ } else if (yylvalpp->atom == lineAtom) {
+ token = CPPline(yylvalpp);
+ } else if (yylvalpp->atom == pragmaAtom) {
+ token = CPPpragma(yylvalpp);
+ } else if (yylvalpp->atom == undefAtom) {
+ token = CPPundef(yylvalpp);
+ } else if (yylvalpp->atom == errorAtom) {
+ token = CPPerror(yylvalpp);
+ } else if (yylvalpp->atom == versionAtom) {
+ token = CPPversion(yylvalpp);
+ isVersion = true;
+ } else if (yylvalpp->atom == extensionAtom) {
+ token = CPPextension(yylvalpp);
+ } else {
+ parseContext.error(yylvalpp->loc, "Invalid Directive", "#", GetStringOfAtom(&atomTable, yylvalpp->atom));
+ }
+ }
+ while (token != '\n' && token != 0 && token != EOF) {
+ token = currentInput->scan(this, currentInput, yylvalpp);
+ }
+
+ notAVersionToken = ! isVersion;
+
+ return token;
+} // readCPPline
+
+void TPpContext::FreeMacro(MacroSymbol *s) {
+ DeleteTokenStream(s->body);
+}
+
+static int eof_scan(TPpContext*, TPpContext::InputSrc* in, TPpToken* yylvalpp) { return -1; }
+static void noop(TPpContext*, TPpContext::InputSrc* in, int ch, TPpToken* yylvalpp) { }
+
+void TPpContext::PushEofSrc()
+{
+ InputSrc *in = (InputSrc*)malloc(sizeof(InputSrc));
+ memset(in, 0, sizeof(InputSrc));
+ in->scan = eof_scan;
+ in->getch = eof_scan;
+ in->ungetch = noop;
+ in->prev = currentInput;
+ currentInput = in;
+}
+
+void TPpContext::PopEofSrc()
+{
+ if (currentInput->scan == eof_scan) {
+ InputSrc *in = currentInput;
+ currentInput = in->prev;
+ free(in);
+ }
+}
+
+TPpContext::TokenStream* TPpContext::PrescanMacroArg(TokenStream *a, TPpToken * yylvalpp)
+{
+ int token;
+ TokenStream *n;
+ RewindTokenStream(a);
+ do {
+ token = ReadToken(a, yylvalpp);
+ if (token == CPP_IDENTIFIER && LookUpSymbol(macros, yylvalpp->atom))
+ break;
+ } while (token > 0);
+ if (token <= 0) return a;
+ n = NewTokenStream("macro arg", 0);
+ PushEofSrc();
+ ReadFromTokenStream(a, 0, 0);
+ while ((token = currentInput->scan(this, currentInput, yylvalpp)) > 0) {
+ if (token == CPP_IDENTIFIER && MacroExpand(yylvalpp->atom, yylvalpp, 0) == 1)
+ continue;
+ RecordToken(n, token, yylvalpp);
+ }
+ PopEofSrc();
+ DeleteTokenStream(a);
+ return n;
+} // PrescanMacroArg
+
+//
+// These are called through function pointers
+//
+
+/* macro_scan ---
+** return the next token for a macro expansion, handling macro args
+*/
+int TPpContext::macro_scan(TPpContext* pp, TPpContext::InputSrc* inInput, TPpToken* yylvalpp)
+{
+ TPpContext::MacroInputSrc* in = (TPpContext::MacroInputSrc*)inInput;
+
+ int i;
+ int token = pp->ReadToken(in->mac->body, yylvalpp);
+ if (token == CPP_IDENTIFIER) {
+ for (i = in->mac->argc-1; i>=0; i--)
+ if (in->mac->args[i] == yylvalpp->atom)
+ break;
+ if (i >= 0) {
+ pp->ReadFromTokenStream(in->args[i], yylvalpp->atom, 0);
+
+ return pp->currentInput->scan(pp, pp->currentInput, yylvalpp);
+ }
+ }
+
+ if (token > 0)
+ return token;
+
+ in->mac->busy = 0;
+ pp->currentInput = in->base.prev;
+ if (in->args) {
+ for (i=in->mac->argc-1; i>=0; i--)
+ pp->DeleteTokenStream(in->args[i]);
+ free(in->args);
+ }
+ free(in);
+
+ return pp->currentInput->scan(pp, pp->currentInput, yylvalpp);
+} // macro_scan
+
+// return a zero, for scanning a macro that was never defined
+int TPpContext::zero_scan(TPpContext* pp, InputSrc *inInput, TPpToken* yylvalpp)
+{
+ MacroInputSrc* in = (MacroInputSrc*)inInput;
+
+ strcpy(yylvalpp->name, "0");
+ yylvalpp->ival = 0;
+
+ // pop input
+ pp->currentInput = in->base.prev;
+ free(in);
+
+ return CPP_INTCONSTANT;
+}
+
+/* MacroExpand
+** Check an identifier (atom) to see if it is a macro that should be expanded.
+** If it is, push an InputSrc that will produce the appropriate expansion
+** and return 1.
+** If it is, but undefined, it should expand to 0, push an InputSrc that will
+** expand to 0 and return -1.
+** Otherwise, return 0.
+*/
+int TPpContext::MacroExpand(int atom, TPpToken* yylvalpp, int expandUndef)
+{
+ Symbol *sym = LookUpSymbol(macros, atom);
+ MacroInputSrc *in;
+ int i, j, token;
+ int depth = 0;
+
+ if (atom == __LINE__Atom) {
+ yylvalpp->ival = parseContext.currentLoc.line;
+ sprintf(yylvalpp->name, "%d", yylvalpp->ival);
+ UngetToken(CPP_INTCONSTANT, yylvalpp);
+
+ return 1;
+ }
+
+ if (atom == __FILE__Atom) {
+ yylvalpp->ival = parseContext.currentLoc.string;
+ sprintf(yylvalpp->name, "%d", yylvalpp->ival);
+ UngetToken(CPP_INTCONSTANT, yylvalpp);
+
+ return 1;
+ }
+
+ if (atom == __VERSION__Atom) {
+ yylvalpp->ival = parseContext.version;
+ sprintf(yylvalpp->name, "%d", yylvalpp->ival);
+ UngetToken(CPP_INTCONSTANT, yylvalpp);
+
+ return 1;
+ }
+
+ // no recursive expansions
+ if (sym && sym->details.mac.busy)
+ return 0;
+
+ // not expanding of undefined symbols
+ if ((! sym || sym->details.mac.undef) && ! expandUndef)
+ return 0;
+
+ in = (MacroInputSrc*)malloc(sizeof(*in));
+ memset(in, 0, sizeof(*in));
+ in->base.line = currentInput->line;
+ in->base.name = currentInput->name;
+
+ if ((! sym || sym->details.mac.undef) && expandUndef) {
+ // push input
+ in->base.scan = zero_scan;
+ in->base.prev = currentInput;
+ currentInput = &in->base;
+
+ return -1;
+ }
+
+ in->base.scan = macro_scan;
+ in->mac = &sym->details.mac;
+ if (sym->details.mac.args) {
+ token = currentInput->scan(this, currentInput, yylvalpp);
+ if (token != '(') {
+ UngetToken(token, yylvalpp);
+ yylvalpp->atom = atom;
+
+ return 0;
+ }
+ in->args = (TokenStream**)malloc(in->mac->argc * sizeof(TokenStream *));
+ for (i = 0; i < in->mac->argc; i++)
+ in->args[i] = NewTokenStream("macro arg", 0);
+ i = 0;
+ j = 0;
+ do {
+ depth = 0;
+ while (1) {
+ token = currentInput->scan(this, currentInput, yylvalpp);
+ if (token <= 0) {
+ parseContext.error(yylvalpp->loc, "EOF in macro", "preprocessor", GetStringOfAtom(&atomTable, atom));
+
+ return 1;
+ }
+ if ((in->mac->argc==0) && (token!=')')) break;
+ if (depth == 0 && (token == ',' || token == ')')) break;
+ if (token == '(') depth++;
+ if (token == ')') depth--;
+ RecordToken(in->args[i], token, yylvalpp);
+ j=1;
+ }
+ if (token == ')') {
+ if ((in->mac->argc==1) &&j==0)
+ break;
+ i++;
+ break;
+ }
+ i++;
+ } while (i < in->mac->argc);
+
+ if (i < in->mac->argc)
+ parseContext.error(yylvalpp->loc, "Too few args in Macro", "preprocessor", GetStringOfAtom(&atomTable, atom));
+ else if (token != ')') {
+ depth=0;
+ while (token >= 0 && (depth > 0 || token != ')')) {
+ if (token == ')')
+ depth--;
+ token = currentInput->scan(this, currentInput, yylvalpp);
+ if (token == '(')
+ depth++;
+ }
+
+ if (token <= 0) {
+ parseContext.error(yylvalpp->loc, "EOF in macro", "preprocessor", GetStringOfAtom(&atomTable, atom));
+
+ return 1;
+ }
+ parseContext.error(yylvalpp->loc, "Too many args in Macro", "preprocessor", GetStringOfAtom(&atomTable, atom));
+ }
+ for (i = 0; i<in->mac->argc; i++) {
+ in->args[i] = PrescanMacroArg(in->args[i], yylvalpp);
+ }
+ }
+#if 0
+ printf(" <%s:%d>found macro %s\n", GetAtomString(atable, loc.file),
+ loc.line, GetAtomString(atable, atom));
+ for (i = 0; i<in->mac->argc; i++) {
+ printf("\targ %s = '", GetAtomString(atable, in->mac->args[i]));
+ DumpTokenStream(stdout, in->args[i]);
+ printf("'\n");
+ }
+#endif
+ /*retain the input source*/
+ in->base.prev = currentInput;
+ sym->details.mac.busy = 1;
+ RewindTokenStream(sym->details.mac.body);
+ currentInput = &in->base;
+
+ return 1;
+} // MacroExpand
+
+int TPpContext::ChkCorrectElseNesting()
+{
+ if (elsedepth[elsetracker] == 0) {
+ elsedepth[elsetracker] = 1;
+
+ return 1;
+ }
+
+ return 0;
+}
//
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
+//Copyright (C) 2013 LunarG, Inc.
//All rights reserved.
//
//Redistribution and use in source and binary forms, with or without
#include <stdio.h>
#include <string.h>
-#include "slglobals.h"
+#include "PpContext.h"
+#include "PpTokens.h"
#undef malloc
#undef realloc
#define INIT_STRING_TABLE_SIZE 16384
-typedef struct StringTable_Rec {
- char *strings;
- int nextFree;
- int size;
-} StringTable;
-
/*
- * InitStringTable() - Initialize the string table.
- *
- */
+* InitStringTable() - Initialize the string table.
+*
+*/
-static int InitStringTable(StringTable *stable)
+int InitStringTable(TPpContext::StringTable *stable)
{
stable->strings = (char *) malloc(INIT_STRING_TABLE_SIZE);
if (!stable->strings)
} // InitStringTable
/*
- * FreeStringTable() - Free the string table.
- *
- */
+* FreeStringTable() - Free the string table.
+*
+*/
-static void FreeStringTable(StringTable *stable)
+void FreeStringTable(TPpContext::StringTable *stable)
{
if (stable->strings)
free(stable->strings);
} // FreeStringTable
/*
- * HashString() - Hash a string with the base hash function.
- *
- */
+* HashString() - Hash a string with the base hash function.
+*
+*/
static int HashString(const char *s)
{
} // HashString
/*
- * HashString2() - Hash a string with the incrimenting hash function.
- *
- */
+* HashString2() - Hash a string with the incrimenting hash function.
+*
+*/
static int HashString2(const char *s)
{
} // HashString2
/*
- * AddString() - Add a string to a string table. Return it's offset.
- *
- */
+* AddString() - Add a string to a string table. Return it's offset.
+*
+*/
-static int AddString(StringTable *stable, const char *s)
+static int AddString(TPpContext::StringTable *stable, const char *s)
{
int len, loc;
char *str;
///////////////////////////////////////////////////////////////////////////////////////////////
#define INIT_HASH_TABLE_SIZE 2047
-#define HASH_TABLE_MAX_COLLISIONS 3
-
-typedef struct HashEntry_Rec {
- int index; // String table offset of string representation
- int value; // Atom (symbol) value
-} HashEntry;
-
-typedef struct HashTable_Rec {
- HashEntry *entry;
- int size;
- int entries;
- int counts[HASH_TABLE_MAX_COLLISIONS + 1];
-} HashTable;
/*
- * InitHashTable() - Initialize the hash table.
- *
- */
+* InitHashTable() - Initialize the hash table.
+*
+*/
-static int InitHashTable(HashTable *htable, int fsize)
+static int InitHashTable(TPpContext::HashTable *htable, int fsize)
{
int ii;
- htable->entry = (HashEntry *) malloc(sizeof(HashEntry)*fsize);
- if (!htable->entry)
+ htable->entry = (TPpContext::HashEntry *) malloc(sizeof(TPpContext::HashEntry)*fsize);
+ if (! htable->entry)
return 0;
htable->size = fsize;
for (ii = 0; ii < fsize; ii++) {
htable->entry[ii].value = 0;
}
htable->entries = 0;
- for (ii = 0; ii <= HASH_TABLE_MAX_COLLISIONS; ii++)
+ for (ii = 0; ii <= TPpContext::hashTableMaxCollisions; ii++)
htable->counts[ii] = 0;
return 1;
} // InitHashTable
/*
- * FreeHashTable() - Free the hash table.
- *
- */
+* FreeHashTable() - Free the hash table.
+*
+*/
-static void FreeHashTable(HashTable *htable)
+static void FreeHashTable(TPpContext::HashTable *htable)
{
if (htable->entry)
free(htable->entry);
} // FreeHashTable
/*
- * Empty() - See if a hash table entry is empty.
- *
- */
+* Empty() - See if a hash table entry is empty.
+*
+*/
-static int Empty(HashTable *htable, int hashloc)
+static int Empty(TPpContext::HashTable *htable, int hashloc)
{
assert(hashloc >= 0 && hashloc < htable->size);
if (htable->entry[hashloc].index == 0) {
} // Empty
/*
- * Match() - See if a hash table entry is matches a string.
- *
- */
+* Match() - See if a hash table entry is matches a string.
+*
+*/
-static int Match(HashTable *htable, StringTable *stable, const char *s, int hashloc)
+static int Match(TPpContext::HashTable *htable, TPpContext::StringTable *stable, const char *s, int hashloc)
{
int strloc;
#define INIT_ATOM_TABLE_SIZE 1024
-
-struct AtomTable_Rec {
- StringTable stable; // String table.
- HashTable htable; // Hashes string to atom number and token value. Multiple strings can
- // have the same token value but each unique string is a unique atom.
- int *amap; // Maps atom value to offset in string table. Atoms all map to unique
- // strings except for some undefined values in the lower, fixed part
- // of the atom table that map to "<undefined>". The lowest 256 atoms
- // correspond to single character ASCII values except for alphanumeric
- // characters and '_', which can be other tokens. Next come the
- // language tokens with their atom values equal to the token value.
- // Then come predefined atoms, followed by user specified identifiers.
- int *arev; // Reversed atom for symbol table use.
- int nextFree;
- int size;
-};
-
-static AtomTable latable = { { 0 } };
-AtomTable *atable = &latable;
-
-static int AddAtomFixed(AtomTable *atable, const char *s, int atom);
-
/*
- * GrowAtomTable() - Grow the atom table to at least "size" if it's smaller.
- *
- */
+* GrowAtomTable() - Grow the atom table to at least "size" if it's smaller.
+*
+*/
-static int GrowAtomTable(AtomTable *atable, int size)
+int GrowAtomTable(TPpContext::AtomTable *atable, int size)
{
int *newmap, *newrev;
} // GrowAtomTable
/*
- * lReverse() - Reverse the bottom 20 bits of a 32 bit int.
- *
- */
+* lReverse() - Reverse the bottom 20 bits of a 32 bit int.
+*
+*/
static int lReverse(int fval)
{
} // lReverse
/*
- * AllocateAtom() - Allocate a new atom. Associated with the "undefined" value of -1.
- *
- */
+* AllocateAtom() - Allocate a new atom. Associated with the "undefined" value of -1.
+*
+*/
-static int AllocateAtom(AtomTable *atable)
+int AllocateAtom(TPpContext::AtomTable *atable)
{
if (atable->nextFree >= atable->size)
GrowAtomTable(atable, atable->nextFree*2);
} // AllocateAtom
/*
- * SetAtomValue() - Allocate a new atom associated with "hashindex".
- *
- */
+* SetAtomValue() - Allocate a new atom associated with "hashindex".
+*
+*/
-static void SetAtomValue(AtomTable *atable, int atomnumber, int hashindex)
+void SetAtomValue(TPpContext::AtomTable *atable, int atomnumber, int hashindex)
{
atable->amap[atomnumber] = atable->htable.entry[hashindex].index;
atable->htable.entry[hashindex].value = atomnumber;
} // SetAtomValue
/*
- * FindHashLoc() - Find the hash location for this string. Return -1 it hash table is full.
- *
- */
+* FindHashLoc() - Find the hash location for this string. Return -1 it hash table is full.
+*
+*/
-static int FindHashLoc(AtomTable *atable, const char *s)
+int FindHashLoc(TPpContext::AtomTable *atable, const char *s)
{
int hashloc, hashdelta, count;
int FoundEmptySlot = 0;
- int collision[HASH_TABLE_MAX_COLLISIONS + 1];
+ int collision[TPpContext::hashTableMaxCollisions + 1];
hashloc = HashString(s) % atable->htable.size;
if (!Empty(&atable->htable, hashloc)) {
collision[0] = hashloc;
hashdelta = HashString2(s);
count = 0;
- while (count < HASH_TABLE_MAX_COLLISIONS) {
+ while (count < TPpContext::hashTableMaxCollisions) {
hashloc = ((hashloc + hashdelta) & 0x7fffffff) % atable->htable.size;
if (!Empty(&atable->htable, hashloc)) {
if (Match(&atable->htable, &atable->stable, s, hashloc)) {
collision[count] = hashloc;
}
- if (!FoundEmptySlot) {
- if (cpp->options.DumpAtomTable) {
+ if (! FoundEmptySlot) {
+#ifdef DUMP_TABLE
+ {
int ii;
char str[200];
- sprintf(str, "*** Hash failed with more than %d collisions. Must increase hash table size. ***",
- HASH_TABLE_MAX_COLLISIONS);
- ShPpErrorToInfoLog(str);
-
- sprintf(str, "*** New string \"%s\", hash=%04x, delta=%04x", s, collision[0], hashdelta);
- ShPpErrorToInfoLog(str);
- for (ii = 0; ii <= HASH_TABLE_MAX_COLLISIONS; ii++) {
- sprintf(str, "*** Collides on try %d at hash entry %04x with \"%s\"",
- ii + 1, collision[ii], GetAtomString(atable, atable->htable.entry[collision[ii]].value));
- ShPpErrorToInfoLog(str);
+ printf(str, "*** Hash failed with more than %d collisions. Must increase hash table size. ***",
+ hashTableMaxCollisions);
+ printf(str, "*** New string \"%s\", hash=%04x, delta=%04x", s, collision[0], hashdelta);
+ for (ii = 0; ii <= hashTableMaxCollisions; ii++) {
+ printf(str, "*** Collides on try %d at hash entry %04x with \"%s\"",
+ ii + 1, collision[ii], GetAtomString(atable, atable->htable.entry[collision[ii]].value));
}
}
+#endif
return -1;
} else {
atable->htable.counts[count]++;
} // FindHashLoc
/*
- * IncreaseHashTableSize()
- *
- */
+* IncreaseHashTableSize()
+*
+*/
-static int IncreaseHashTableSize(AtomTable *atable)
+int TPpContext::IncreaseHashTableSize(AtomTable *atable)
{
int ii, strloc, oldhashloc, value, size;
AtomTable oldtable;
oldtable = *atable;
size = oldtable.htable.size*2 + 1;
- if (!InitAtomTable(atable, size))
+ if (! InitAtomTable(atable, size))
return 0;
// Add all the existing values to the new atom table preserving their atom values:
AddAtomFixed(atable, s, value);
}
FreeAtomTable(&oldtable);
+
return 1;
} // IncreaseHashTableSize
/*
- * LookUpAddStringHash() - Lookup a string in the hash table. If it's not there, add it and
- * initialize the atom value in the hash table to 0. Return the hash table index.
- */
+* LookUpAddStringHash() - Lookup a string in the hash table. If it's not there, add it and
+* initialize the atom value in the hash table to 0. Return the hash table index.
+*/
-static int LookUpAddStringHash(AtomTable *atable, const char *s)
+int TPpContext::LookUpAddStringHash(AtomTable *atable, const char *s)
{
int hashloc, strloc;
} // LookUpAddStringHash
/*
- * LookUpAddString() - Lookup a string in the hash table. If it's not there, add it and
- * initialize the atom value in the hash table to the next atom number.
- * Return the atom value of string.
- */
+* LookUpAddString() - Lookup a string in the hash table. If it's not there, add it and
+* initialize the atom value in the hash table to the next atom number.
+* Return the atom value of string.
+*/
-int LookUpAddString(AtomTable *atable, const char *s)
+int TPpContext::LookUpAddString(AtomTable *atable, const char *s)
{
int hashindex, atom;
} // LookUpAddString
/*
- * GetAtomString()
- *
- */
+* GetAtomString()
+*
+*/
-const char *GetAtomString(AtomTable *atable, int atom)
+const char *TPpContext::GetAtomString(AtomTable *atable, int atom)
{
int soffset;
} // GetAtomString
/*
- * GetReversedAtom()
- *
- */
+* GetReversedAtom()
+*
+*/
-int GetReversedAtom(AtomTable *atable, int atom)
+int TPpContext::GetReversedAtom(TPpContext::AtomTable *atable, int atom)
{
- if (atom > 0 && atom < atable->nextFree) {
+ if (atom > 0 && atom < atable->nextFree)
return atable->arev[atom];
- } else {
+ else
return 0;
- }
} // GetReversedAtom
/*
- * AddAtom() - Add a string to the atom, hash and string tables if it isn't already there.
- * Return it's atom index.
- */
+* AddAtom() - Add a string to the atom, hash and string tables if it isn't already there.
+* Return it's atom index.
+*/
-int AddAtom(AtomTable *atable, const char *s)
+int TPpContext::AddAtom(TPpContext::AtomTable *atable, const char *s)
{
- int atom;
-
- atom = LookUpAddString(atable, s);
+ int atom = LookUpAddString(atable, s);
return atom;
} // AddAtom
/*
- * AddAtomFixed() - Add an atom to the hash and string tables if it isn't already there.
- * Assign it the atom value of "atom".
- */
+* AddAtomFixed() - Add an atom to the hash and string tables if it isn't already there.
+* Assign it the atom value of "atom".
+*/
-static int AddAtomFixed(AtomTable *atable, const char *s, int atom)
+int TPpContext::AddAtomFixed(AtomTable *atable, const char *s, int atom)
{
int hashindex, lsize;
} // AddAtomFixed
/*
- * InitAtomTable() - Initialize the atom table.
- *
- */
+* InitAtomTable() - Initialize the atom table.
+*
+*/
-int InitAtomTable(AtomTable *atable, int htsize)
+int TPpContext::InitAtomTable(AtomTable *atable, int htsize)
{
int ii;
htsize = htsize <= 0 ? INIT_HASH_TABLE_SIZE : htsize;
- if (!InitStringTable(&atable->stable))
+ if (! InitStringTable(&atable->stable))
return 0;
- if (!InitHashTable(&atable->htable, htsize))
+ if (! InitHashTable(&atable->htable, htsize))
return 0;
atable->nextFree = 0;
atable->amap = NULL;
atable->size = 0;
+ atable->arev = 0;
GrowAtomTable(atable, INIT_ATOM_TABLE_SIZE);
if (!atable->amap)
return 0;
// Add single character tokens to the atom table:
{
- const char *s = "~!%^&*()-+=|,.<>/?;:[]{}#";
+ const char *s = "~!%^&*()-+=|,.<>/?;:[]{}#";
char t[2];
t[1] = '\0';
for (ii = 0; ii < sizeof(tokens)/sizeof(tokens[0]); ii++)
AddAtomFixed(atable, tokens[ii].str, tokens[ii].val);
- // Add error symbol if running in error mode:
-
- if (cpp->options.ErrorMode)
- AddAtomFixed(atable, "error", CPP_ERROR_SY);
-
AddAtom(atable, "<*** end fixed atoms ***>");
return 1;
///////////////////////////////////////////////////////////////////////////////////////////////
/*
- * PrintAtomTable()
- *
- */
+* PrintAtomTable()
+*
+*/
-void PrintAtomTable(AtomTable *atable)
+void TPpContext::PrintAtomTable(AtomTable *atable)
{
int ii;
char str[200];
for (ii = 0; ii < atable->nextFree; ii++) {
- sprintf(str, "%d: \"%s\"", ii, &atable->stable.strings[atable->amap[ii]]);
- ShPpDebugLogMsg(str);
+ printf(str, "%d: \"%s\"", ii, &atable->stable.strings[atable->amap[ii]]);
}
- sprintf(str, "Hash table: size=%d, entries=%d, collisions=",
- atable->htable.size, atable->htable.entries);
- ShPpDebugLogMsg(str);
- for (ii = 0; ii < HASH_TABLE_MAX_COLLISIONS; ii++) {
- sprintf(str, " %d", atable->htable.counts[ii]);
- ShPpDebugLogMsg(str);
+ printf(str, "Hash table: size=%d, entries=%d, collisions=",
+ atable->htable.size, atable->htable.entries);
+ for (ii = 0; ii < hashTableMaxCollisions; ii++) {
+ printf(str, " %d", atable->htable.counts[ii]);
}
} // PrintAtomTable
/*
- * GetStringOfAtom()
- *
- */
+* GetStringOfAtom()
+*
+*/
-char* GetStringOfAtom(AtomTable *atable, int atom)
+char* TPpContext::GetStringOfAtom(AtomTable *atable, int atom)
{
- char* chr_str;
- chr_str=&atable->stable.strings[atable->amap[atom]];
- return chr_str;
+ char* chr_str;
+ chr_str=&atable->stable.strings[atable->amap[atom]];
+ return chr_str;
} // GetStringOfAtom
/*
- * FreeAtomTable() - Free the atom table and associated memory
- *
- */
+* FreeAtomTable() - Free the atom table and associated memory
+*
+*/
-void FreeAtomTable(AtomTable *atable)
+void TPpContext::FreeAtomTable(AtomTable *atable)
{
FreeStringTable(&atable->stable);
FreeHashTable(&atable->htable);
//
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
+//Copyright (C) 2013 LunarG, Inc.
//All rights reserved.
//
//Redistribution and use in source and binary forms, with or without
TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
\****************************************************************************/
-//
-// scanner.h
-//
-
-#if !defined(__SCANNER_H)
-#define __SCANNER_H 1
-#include "preprocess.h"
-#include "parser.h"
+#include <stdio.h>
+#include <stdlib.h>
-// Not really atom table stuff but needed first...
-#ifdef __cplusplus
-extern "C" {
-#endif
+#include "PpContext.h"
-int yyparse (void);
+TPpContext::TPpContext(TParseContext& pc) :
+ parseContext(pc), preamble(0), strings(0), notAVersionToken(false),
+ ScopeList(0), CurrentScope(0), GlobalScope(0)
+{
+ InitAtomTable(&atomTable, 0);
+ InitScanner(this);
-int InitScanner(CPPStruct *cpp); // Intialise the cpp scanner.
-int ScanFromString(char *); // Start scanning the input from the string mentioned.
-int check_EOF(int); // check if we hit a EOF abruptly
-void ShPpErrorToInfoLog(const char *); // sticking the msg,line into the Shader's.Info.log
-void SetLineNumber(int);
-void SetStringNumber(int);
-void IncLineNumber(void);
-void DecLineNumber(void);
-int FreeScanner(void); // Free the cpp scanner
+ ifdepth = 0;
+ for (elsetracker = 0; elsetracker < maxIfNesting; elsetracker++)
+ elsedepth[elsetracker] = 0;
+ elsetracker = 0;
+}
-#ifdef __cplusplus
+TPpContext::~TPpContext()
+{
+ delete [] preamble;
+ FreeAtomTable(&atomTable);
+ FreeScanner();
}
-#endif
-#endif // !(defined(__SCANNER_H)
+void TPpContext::setPreamble(const char* p, int l)
+{
+ if (p && l > 0) {
+ // preAmble could be a hard-coded string; make writable copy
+ // TODO: efficiency PP: make it not need writable strings
+ preambleLength = l;
+ preamble = new char[preambleLength + 1];
+ memcpy(preamble, p, preambleLength + 1); // TODO: PP: assuming nul-terminated strings
+ ScanFromString(preamble);
+ currentString = -1;
+ }
+}
+void TPpContext::setShaderStrings(char* s[], int l[], int n)
+{
+ strings = s;
+ lengths = l;
+ numStrings = n;
+ if (! preamble) {
+ ScanFromString(strings[0]);
+ currentString = 0;
+ }
+}
--- /dev/null
+//
+//Copyright (C) 2013 LunarG, Inc.
+//All rights reserved.
+//
+//Redistribution and use in source and binary forms, with or without
+//modification, are permitted provided that the following conditions
+//are met:
+//
+// Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+//
+// Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following
+// disclaimer in the documentation and/or other materials provided
+// with the distribution.
+//
+// Neither the name of 3Dlabs Inc. Ltd. 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 BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+//POSSIBILITY OF SUCH DAMAGE.
+//
+/****************************************************************************\
+Copyright (c) 2002, NVIDIA Corporation.
+
+NVIDIA Corporation("NVIDIA") supplies this software to you in
+consideration of your agreement to the following terms, and your use,
+installation, modification or redistribution of this NVIDIA software
+constitutes acceptance of these terms. If you do not agree with these
+terms, please do not use, install, modify or redistribute this NVIDIA
+software.
+
+In consideration of your agreement to abide by the following terms, and
+subject to these terms, NVIDIA grants you a personal, non-exclusive
+license, under NVIDIA's copyrights in this original NVIDIA software (the
+"NVIDIA Software"), to use, reproduce, modify and redistribute the
+NVIDIA Software, with or without modifications, in source and/or binary
+forms; provided that if you redistribute the NVIDIA Software, you must
+retain the copyright notice of NVIDIA, this notice and the following
+text and disclaimers in all such redistributions of the NVIDIA Software.
+Neither the name, trademarks, service marks nor logos of NVIDIA
+Corporation may be used to endorse or promote products derived from the
+NVIDIA Software without specific prior written permission from NVIDIA.
+Except as expressly stated in this notice, no other rights or licenses
+express or implied, are granted by NVIDIA herein, including but not
+limited to any patent rights that may be infringed by your derivative
+works or by other works in which the NVIDIA Software may be
+incorporated. No hardware is licensed hereunder.
+
+THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
+WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,
+NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
+ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER
+PRODUCTS.
+
+IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,
+INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY
+OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE
+NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
+TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
+NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+\****************************************************************************/
+
+#ifndef PPCONTEXT_H
+#define PPCONTEXT_H
+
+#include "../ParseHelper.h"
+
+class TPpToken {
+public:
+ static const int maxTokenLength = 1024;
+
+ TSourceLoc loc;
+ int ppToken;
+ int ival;
+ double dval;
+ int atom;
+ char name[maxTokenLength+1];
+};
+
+// This class is the result of turning a huge pile of C code communicating through globals
+// into a class. This was done to allowing instancing to attain thread safety.
+// Don't expect too much in terms of OO design.
+class TPpContext {
+public:
+ TPpContext(TParseContext&);
+ virtual ~TPpContext();
+
+ void setPreamble(const char* preamble, int length);
+ void setShaderStrings(char* strings[], int lengths[], int numStrings);
+
+ const char* tokenize(TPpToken* yylvalpp);
+
+ struct InputSrc {
+ struct InputSrc *prev;
+ int (*scan)(TPpContext*, struct InputSrc *, TPpToken *);
+ int (*getch)(TPpContext*, struct InputSrc *, TPpToken *);
+ void (*ungetch)(TPpContext*, struct InputSrc *, int, TPpToken *);
+ int name; /* atom */
+ int line;
+ };
+
+ struct TokenBlock {
+ TokenBlock *next;
+ int current;
+ int count;
+ int max;
+ unsigned char *data;
+ };
+
+ struct TokenStream {
+ TokenStream *next;
+ char *name;
+ TokenBlock *head;
+ TokenBlock *current;
+ };
+
+ struct MemoryPool {
+ struct chunk *next;
+ uintptr_t free, end;
+ size_t chunksize;
+ uintptr_t alignmask;
+ struct cleanup *cleanup;
+ };
+
+ //
+ // From PpAtom.cpp
+ //
+ struct StringTable {
+ char *strings;
+ int nextFree;
+ int size;
+ };
+ typedef struct HashEntry_Rec {
+ int index; // String table offset of string representation
+ int value; // Atom (symbol) value
+ } HashEntry;
+
+ static const int hashTableMaxCollisions = 3;
+
+ typedef struct HashTable_Rec {
+ HashEntry *entry;
+ int size;
+ int entries;
+ int counts[hashTableMaxCollisions + 1];
+ } HashTable;
+ struct AtomTable {
+ StringTable stable; // String table.
+ HashTable htable; // Hashes string to atom number and token value. Multiple strings can
+ // have the same token value but each unique string is a unique atom.
+ int *amap; // Maps atom value to offset in string table. Atoms all map to unique
+ // strings except for some undefined values in the lower, fixed part
+ // of the atom table that map to "<undefined>". The lowest 256 atoms
+ // correspond to single character ASCII values except for alphanumeric
+ // characters and '_', which can be other tokens. Next come the
+ // language tokens with their atom values equal to the token value.
+ // Then come predefined atoms, followed by user specified identifiers.
+ int *arev; // Reversed atom for symbol table use.
+ int nextFree;
+ int size;
+ };
+
+ struct MacroSymbol {
+ int argc;
+ int *args;
+ TokenStream *body;
+ unsigned busy:1;
+ unsigned undef:1;
+ };
+
+ typedef enum symbolkind {
+ MACRO_S
+ } symbolkind;
+
+ struct Symbol {
+ Symbol *left, *right;
+ Symbol *next;
+ int name; // Name atom
+ TSourceLoc loc;
+ symbolkind kind;
+ union {
+ MacroSymbol mac;
+ } details;
+ };
+
+ typedef struct SymbolList {
+ struct SymbolList_Rec *next;
+ Symbol *symb;
+ };
+
+ struct Scope {
+ Scope *next, *prev; // doubly-linked list of all scopes
+ Scope *parent;
+ Scope *funScope; // Points to base scope of enclosing function
+ MemoryPool *pool; // pool used for allocation in this scope
+ Symbol *symbols;
+
+ int level; // 0 = super globals, 1 = globals, etc.
+
+ // Only used at global scope (level 1):
+ SymbolList *programs; // List of programs for this compilation.
+ };
+
+protected:
+ char* preamble; // string to parse, all before line 1 of string 0, it is 0 if no preamble
+ int preambleLength;
+ char** strings; // official strings of shader, starting a string 0 line 1
+ int* lengths;
+ int numStrings; // how many official strings there are
+ int currentString; // which string we're currently parsing (-1 for preamble)
+
+ // Scanner data:
+ int mostRecentToken; // Most recent token seen by the scanner
+ int previous_token;
+ bool notAVersionToken; // used to make sure that #version is the first token seen in the file, if present
+ TParseContext& parseContext;
+
+ static const int maxMacroArgs = 64;
+ static const int maxIfNesting = 64;
+
+ int ifdepth; // current #if-#else-#endif nesting in the cpp.c file (pre-processor)
+ int elsedepth[maxIfNesting]; // Keep a track of #if depth..Max allowed is 64.
+ int elsetracker; // #if-#else and #endif constructs...Counter.
+ const char *ErrMsg;
+
+ typedef struct MacroInputSrc {
+ InputSrc base;
+ MacroSymbol *mac;
+ TokenStream **args;
+ } MacroInputSrc;
+
+ InputSrc *currentInput;
+
+ //
+ // from Pp.cpp
+ //
+ int bindAtom;
+ int constAtom;
+ int defaultAtom;
+ int defineAtom;
+ int definedAtom;
+ int elseAtom;
+ int elifAtom;
+ int endifAtom;
+ int ifAtom;
+ int ifdefAtom;
+ int ifndefAtom;
+ int includeAtom;
+ int lineAtom;
+ int pragmaAtom;
+ int texunitAtom;
+ int undefAtom;
+ int errorAtom;
+ int __LINE__Atom;
+ int __FILE__Atom;
+ int __VERSION__Atom;
+ int versionAtom;
+ int coreAtom;
+ int compatibilityAtom;
+ int esAtom;
+ int extensionAtom;
+ Scope *macros;
+ TSourceLoc ifloc; /* outermost #if */
+
+ int InitCPP();
+ int FreeCPP();
+ int FinalCPP();
+ int CPPdefine(TPpToken * yylvalpp);
+ int CPPundef(TPpToken * yylvalpp);
+ int CPPelse(int matchelse, TPpToken * yylvalpp);
+ int eval(int token, int prec, int *res, int *err, TPpToken * yylvalpp);
+ int CPPif (TPpToken * yylvalpp);
+ int CPPifdef(int defined, TPpToken * yylvalpp);
+ int CPPline(TPpToken * yylvalpp);
+ int CPPerror(TPpToken * yylvalpp);
+ int CPPpragma(TPpToken * yylvalpp);
+ int CPPversion(TPpToken * yylvalpp);
+ int CPPextension(TPpToken * yylvalpp);
+ int readCPPline(TPpToken * yylvalpp);
+ void FreeMacro(MacroSymbol *s);
+ void PushEofSrc();
+ void PopEofSrc();
+ TokenStream* PrescanMacroArg(TokenStream *a, TPpToken * yylvalpp);
+ static int macro_scan(TPpContext* pp, InputSrc *inInput, TPpToken * yylvalpp);
+ static int zero_scan(TPpContext* pp, InputSrc *inInput, TPpToken * yylvalpp);
+ int MacroExpand(int atom, TPpToken* yylvalpp, int expandUndef);
+ int ChkCorrectElseNesting();
+
+ //
+ // from PpSymbols.cpp
+ //
+ Scope *ScopeList;
+ Scope *CurrentScope;
+ Scope *GlobalScope;
+
+ Scope *NewScopeInPool(MemoryPool *pool);
+ void PushScope(Scope *fScope);
+ Scope *PopScope(void);
+ Symbol *NewSymbol(TSourceLoc *loc, Scope *fScope, int name, symbolkind kind);
+ void lAddToTree(Symbol **fSymbols, Symbol *fSymb, AtomTable *atable);
+ Symbol *AddSymbol(TSourceLoc *loc, Scope *fScope, int atom, symbolkind kind);
+ Symbol *LookUpLocalSymbol(Scope *fScope, int atom);
+ Symbol *LookUpSymbol(Scope *fScope, int atom);
+
+ //
+ // From PpTokens.cpp
+ //
+ char* idstr(const char *fstr, MemoryPool *pool);
+ TPpContext::TokenBlock* lNewBlock(TokenStream *fTok, MemoryPool *pool);
+ void lAddByte(TokenStream *fTok, unsigned char fVal);
+ int lReadByte(TokenStream *pTok);
+ TokenStream *NewTokenStream(const char *name, MemoryPool *pool);
+ void DeleteTokenStream(TokenStream *pTok);
+ void RecordToken(TokenStream *pTok, int token, TPpToken * yylvalpp);
+ void RewindTokenStream(TokenStream *pTok);
+ int ReadToken(TokenStream *pTok, TPpToken * yylvalpp);
+ int ReadFromTokenStream(TokenStream *ts, int name, int (*final)(TPpContext *));
+ void UngetToken(int token, TPpToken * yylvalpp);
+ void DumpTokenStream(FILE *fp, TokenStream *s, TPpToken * yylvalpp);
+ struct TokenInputSrc {
+ InputSrc base;
+ TokenStream *tokens;
+ int (*final)(TPpContext *);
+ };
+ static int scan_token(TPpContext*, TokenInputSrc *in, TPpToken * yylvalpp);
+ struct UngotToken {
+ InputSrc base;
+ int token;
+ TPpToken lval;
+ };
+ static int reget_token(TPpContext *, UngotToken *t, TPpToken * yylvalpp);
+
+ //
+ // From PpScanner.cpp
+ //
+ struct StringInputSrc {
+ InputSrc base;
+ char *p;
+ };
+ int InitScanner(TPpContext *cpp);
+ int FreeScanner(void);
+ static int str_getch(TPpContext*, StringInputSrc *in);
+ static void str_ungetch(TPpContext*, StringInputSrc *in, int ch, TPpToken *type);
+ int ScanFromString(char *s);
+ int check_EOF(int token);
+ int lFloatConst(char *str, int len, int ch, TPpToken * yylvalpp);
+ static int byte_scan(TPpContext*, InputSrc *in, TPpToken * yylvalpp);
+
+ //
+ // From PpAtom.cpp
+ //
+ AtomTable atomTable;
+ int InitAtomTable(AtomTable *atable, int htsize);
+ void FreeAtomTable(AtomTable *atable);
+ int AddAtom(AtomTable *atable, const char *s);
+ int AddAtomFixed(AtomTable *atable, const char *s, int atom);
+ void PrintAtomTable(AtomTable *atable);
+ int IncreaseHashTableSize(TPpContext::AtomTable *atable);
+ int LookUpAddStringHash(AtomTable *atable, const char *s);
+ int LookUpAddString(AtomTable *atable, const char *s);
+ const char *GetAtomString(AtomTable *atable, int atom);
+ int GetReversedAtom(AtomTable *atable, int atom);
+ char* GetStringOfAtom(AtomTable *atable, int atom);
+
+ //
+ // From PpMemory.cpp
+ //
+ MemoryPool *mem_CreatePool(size_t chunksize, unsigned align);
+ void mem_FreePool(MemoryPool *);
+ void *mem_Alloc(MemoryPool *p, size_t size);
+ int mem_AddCleanup(MemoryPool *p, void (*fn)(void *, void*), void *arg1, void* arg2);
+};
+
+#endif // PPCONTEXT_H
+
//
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
+//Copyright (C) 2013 LunarG, Inc.
//All rights reserved.
//
//Redistribution and use in source and binary forms, with or without
#include <string.h>
#include <stdint.h>
-#include "memory.h"
+#include "PpContext.h"
// default alignment and chunksize, if called with 0 arguments
#define CHUNKSIZE (64*1024)
struct cleanup {
struct cleanup *next;
- void (*fn)(void *);
- void *arg;
+ void (*fn)(void *, void *);
+ void *arg1;
+ void *arg2;
};
-struct MemoryPool_rec {
- struct chunk *next;
- uintptr_t free, end;
- size_t chunksize;
- uintptr_t alignmask;
- struct cleanup *cleanup;
-};
-
-MemoryPool *mem_CreatePool(size_t chunksize, unsigned int align)
+TPpContext::MemoryPool* TPpContext::mem_CreatePool(size_t chunksize, unsigned int align)
{
MemoryPool *pool;
- if (align == 0) align = ALIGN;
- if (chunksize == 0) chunksize = CHUNKSIZE;
- if (align & (align-1)) return 0;
- if (chunksize < sizeof(MemoryPool)) return 0;
- if (chunksize & (align-1)) return 0;
- if (!(pool = (MemoryPool*)malloc(chunksize))) return 0;
+ if (align == 0)
+ align = ALIGN;
+ if (chunksize == 0)
+ chunksize = CHUNKSIZE;
+ if (align & (align-1))
+ return 0;
+ if (chunksize < sizeof(MemoryPool))
+ return 0;
+ if (chunksize & (align-1))
+ return 0;
+ if (!(pool = (MemoryPool*)malloc(chunksize)))
+ return 0;
+
pool->next = 0;
pool->chunksize = chunksize;
pool->alignmask = (uintptr_t)(align)-1;
return pool;
}
-void mem_FreePool(MemoryPool *pool)
+void TPpContext::mem_FreePool(MemoryPool *pool)
{
struct cleanup *cleanup;
struct chunk *p, *next;
for (cleanup = pool->cleanup; cleanup; cleanup = cleanup->next) {
- cleanup->fn(cleanup->arg);
+ cleanup->fn(cleanup->arg1, cleanup->arg2);
}
for (p = (struct chunk *)pool; p; p = next) {
next = p->next;
}
}
-void *mem_Alloc(MemoryPool *pool, size_t size)
+void* TPpContext::mem_Alloc(MemoryPool *pool, size_t size)
{
struct chunk *ch;
void *rv = (void *)pool->free;
if (size <= 0) size = pool->alignmask;
pool->free += size;
if (pool->free > pool->end || pool->free < (uintptr_t)rv) {
- size_t minreq = (size + sizeof(struct chunk) + pool->alignmask)
- & ~pool->alignmask;
+ size_t minreq = (size + sizeof(struct chunk) + pool->alignmask) & ~pool->alignmask;
pool->free = (uintptr_t)rv;
if (minreq >= pool->chunksize) {
// request size is too big for the chunksize, so allocate it as
return rv;
}
-int mem_AddCleanup(MemoryPool *pool, void (*fn)(void *), void *arg) {
+int TPpContext::mem_AddCleanup(MemoryPool *pool, void (*fn)(void *, void*), void* arg1, void* arg2)
+{
struct cleanup *cleanup;
pool->free = (pool->free + sizeof(void *) - 1) & ~(sizeof(void *)-1);
if (!cleanup) return -1;
cleanup->next = pool->cleanup;
cleanup->fn = fn;
- cleanup->arg = arg;
+ cleanup->arg1 = arg1;
+ cleanup->arg2 = arg2;
pool->cleanup = cleanup;
return 0;
}
//
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
+//Copyright (C) 2013 LunarG, Inc.
//All rights reserved.
//
//Redistribution and use in source and binary forms, with or without
#include <string.h>
#if 0
- #include <ieeefp.h>
- #else
- #define isinff(x) (((*(int *)&(x) & 0x7f800000L)==0x7f800000L) && \
- ((*(int *)&(x) & 0x007fffffL)==0000000000L))
+#include <ieeefp.h>
+#else
+#define isinff(x) (((*(int *)&(x) & 0x7f800000L)==0x7f800000L) && \
+ ((*(int *)&(x) & 0x007fffffL)==0000000000L))
#endif
-#include "slglobals.h"
+#include "PpContext.h"
+#include "PpTokens.h"
-
-typedef struct StringInputSrc {
- InputSrc base;
- char *p;
-} StringInputSrc;
-
-static int eof_scan(InputSrc *is, yystypepp * yylvalpp)
+static int eof_scan(TPpContext*, TPpContext::InputSrc*, TPpToken*)
{
return EOF;
} // eof_scan
-static void noop(InputSrc *in, int ch, yystypepp * yylvalpp) {}
-
-static InputSrc eof_inputsrc = { 0, &eof_scan, &eof_scan, &noop };
-
-static int byte_scan(InputSrc *, yystypepp * yylvalpp);
-
-#define EOL_SY '\n'
-
-#if defined(_WIN32)
- #define DBG_BREAKPOINT() __asm int 3
- #elif defined(_M_AMD64)
- #define DBG_BREAKPOINT() assert(!"Dbg_Breakpoint");
- #else
- #define DBG_BREAKPOINT()
- #endif
-
- #if defined(_WIN32) && !defined(_M_AMD64)
- __int64 RDTSC ( void ) {
-
- __int64 v;
-
- __asm __emit 0x0f
- __asm __emit 0x31
- __asm mov dword ptr v, eax
- __asm mov dword ptr v+4, edx
-
- return v;
- }
-#endif
+static void noop(TPpContext*, TPpContext::InputSrc *in, int ch, TPpToken * yylvalpp) {}
+static TPpContext::InputSrc eof_inputsrc = { 0, &eof_scan, &eof_scan, &noop };
-
-int InitScanner(CPPStruct *cpp)
+int TPpContext::InitScanner(TPpContext *cpp)
{
// Add various atoms needed by the CPP line scanner:
if (!InitCPP())
return 0;
- cpp->mostRecentToken = 0;
- cpp->tokenLoc = &cpp->ltokenLoc;
-
- cpp->ltokenLoc.file = 0;
- cpp->ltokenLoc.line = 0;
-
- cpp->currentInput = &eof_inputsrc;
- cpp->previous_token = '\n';
- cpp->notAVersionToken = 0;
+ mostRecentToken = 0;
+ currentInput = &eof_inputsrc;
+ previous_token = '\n';
+ notAVersionToken = false;
return 1;
} // InitScanner
-int FreeScanner(void)
+int TPpContext::FreeScanner(void)
{
return (FreeCPP());
}
/*
- * str_getch()
- * takes care of reading from multiple strings.
- * returns the next-char from the input stream.
- * returns EOF when the complete shader is parsed.
- */
-static int str_getch(StringInputSrc *in)
+* str_getch()
+* takes care of reading from multiple strings.
+* returns the next-char from the input stream.
+* returns EOF when the complete shader is parsed.
+*/
+int TPpContext::str_getch(TPpContext* pp, StringInputSrc *in)
{
- for(;;) {
- if (*in->p) {
- if (*in->p == '\n') {
- in->base.line++;
- IncLineNumber();
- }
- return *in->p++;
- }
- if (cpp->PaWhichStr < 0) {
- // we only parsed the built-in pre-amble; start with clean slate for user code
- cpp->notAVersionToken = 0;
- }
- if (++(cpp->PaWhichStr) < cpp->PaArgc) {
- free(in);
- SetStringNumber(cpp->PaWhichStr);
- SetLineNumber(1);
- ScanFromString(cpp->PaArgv[cpp->PaWhichStr]);
- in=(StringInputSrc*)cpp->currentInput;
- continue;
- } else {
- cpp->currentInput = in->base.prev;
- cpp->PaWhichStr=0;
- free(in);
- return EOF;
- }
- }
+ for(;;) {
+ if (*in->p) {
+ if (*in->p == '\n') {
+ in->base.line++;
+ ++pp->parseContext.currentLoc.line;
+ }
+ return *in->p++;
+ }
+ if (pp->currentString < 0) {
+ // we only parsed the built-in pre-amble; start with clean slate for user code
+ pp->notAVersionToken = false;
+ }
+ if (++(pp->currentString) < pp->numStrings) {
+ free(in);
+ pp->parseContext.currentLoc.string = pp->currentString;
+ pp->parseContext.currentLoc.line = 1;
+ pp->ScanFromString(pp->strings[pp->currentString]);
+ in=(StringInputSrc*)pp->currentInput;
+ continue;
+ } else {
+ pp->currentInput = in->base.prev;
+ pp->currentString = 0;
+ free(in);
+ return EOF;
+ }
+ }
} // str_getch
-static void str_ungetch(StringInputSrc *in, int ch, yystypepp *type) {
+void TPpContext::str_ungetch(TPpContext* pp, StringInputSrc *in, int ch, TPpToken *type)
+{
if (in->p[-1] == ch)in->p--;
- else {
- *(in->p)='\0'; //this would take care of shifting to the previous string.
- cpp->PaWhichStr--;
- }
- if (ch == '\n') {
+ else {
+ *(in->p)='\0'; //this would take care of shifting to the previous string.
+ pp->currentString--;
+ pp->parseContext.currentLoc.string = pp->currentString;
+ }
+ if (ch == '\n') {
in->base.line--;
- DecLineNumber();
+ --pp->parseContext.currentLoc.line;
}
} // str_ungetch
-int ScanFromString(char *s)
+int TPpContext::ScanFromString(char *s)
{
-
- StringInputSrc *in = (StringInputSrc *)malloc(sizeof(StringInputSrc));
+
+ StringInputSrc *in = (StringInputSrc *)malloc(sizeof(StringInputSrc));
memset(in, 0, sizeof(StringInputSrc));
- in->p = s;
+ in->p = s;
in->base.line = 1;
in->base.scan = byte_scan;
- in->base.getch = (int (*)(InputSrc *, yystypepp *))str_getch;
- in->base.ungetch = (void (*)(InputSrc *, int, yystypepp *))str_ungetch;
- in->base.prev = cpp->currentInput;
- cpp->currentInput = &in->base;
+ in->base.getch = (int (*)(TPpContext*, InputSrc *, TPpToken *))str_getch;
+ in->base.ungetch = (void (*)(TPpContext*, InputSrc *, int, TPpToken *))str_ungetch;
+ in->base.prev = currentInput;
+ currentInput = &in->base;
return 1;
}
///////////////////////////////////////////////////////////////////////////////////////////////
/*
- * lFloatConst() - Scan a single- or double-precision floating point constant. Assumes that the scanner
- * has seen at least one digit, followed by either a decimal '.' or the
- * letter 'e'.
- */
+* lFloatConst() - Scan a single- or double-precision floating point constant. Assumes that the scanner
+* has seen at least one digit, followed by either a decimal '.' or the
+* letter 'e'.
+*/
-static int lFloatConst(char *str, int len, int ch, yystypepp * yylvalpp)
+int TPpContext::lFloatConst(char *str, int len, int ch, TPpToken * yylvalpp)
{
int HasDecimal, declen, exp, ExpSign;
int str_len;
int isDouble = 0;
-
+
HasDecimal = 0;
declen = 0;
exp = 0;
-
+
str_len=len;
if (ch == '.') {
- str[len++]=ch;
+ str[len++]=ch;
HasDecimal = 1;
- ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
+ ch = currentInput->getch(this, currentInput, yylvalpp);
while (ch >= '0' && ch <= '9') {
- if (len < MAX_TOKEN_LENGTH) {
+ if (len < TPpToken::maxTokenLength) {
declen++;
if (len > 0 || ch != '0') {
str[len] = ch;
len++;str_len++;
}
- ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
+ ch = currentInput->getch(this, currentInput, yylvalpp);
} else {
- ShPpErrorToInfoLog("floating-point literal too long");
+ parseContext.error(yylvalpp->loc,"float literal too long", "", "");
len = 1,str_len=1;
}
}
// Exponent:
if (ch == 'e' || ch == 'E') {
- if (len >= MAX_TOKEN_LENGTH) {
- ShPpErrorToInfoLog("floating-point literal too long");
+ if (len >= TPpToken::maxTokenLength) {
+ parseContext.error(yylvalpp->loc,"float literal too long", "", "");
len = 1,str_len=1;
} else {
ExpSign = 1;
- str[len++]=ch;
- ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
+ str[len++]=ch;
+ ch = currentInput->getch(this, currentInput, yylvalpp);
if (ch == '+') {
str[len++]=ch;
- ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
+ ch = currentInput->getch(this, currentInput, yylvalpp);
} else if (ch == '-') {
ExpSign = -1;
- str[len++]=ch;
- ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
+ str[len++]=ch;
+ ch = currentInput->getch(this, currentInput, yylvalpp);
}
if (ch >= '0' && ch <= '9') {
while (ch >= '0' && ch <= '9') {
- if (len < MAX_TOKEN_LENGTH) {
+ if (len < TPpToken::maxTokenLength) {
exp = exp*10 + ch - '0';
- str[len++]=ch;
- ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
+ str[len++]=ch;
+ ch = currentInput->getch(this, currentInput, yylvalpp);
} else {
- ShPpErrorToInfoLog("floating-point literal too long");
+ parseContext.error(yylvalpp->loc,"float literal too long", "", "");
len = 1,str_len=1;
}
}
} else {
- ShPpErrorToInfoLog("bad character in exponent");
+ parseContext.error(yylvalpp->loc,"bad character in float exponent", "", "");
}
exp *= ExpSign;
}
}
-
+
if (len == 0) {
- yylvalpp->sc_dval = 0.0;
- strcpy(str, "0.0");
+ yylvalpp->dval = 0.0;
+ strcpy(str, "0.0");
} else {
if (ch == 'l' || ch == 'L') {
- int ch2 = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
+ int ch2 = currentInput->getch(this, currentInput, yylvalpp);
if (ch2 != 'f' && ch2 != 'F') {
- cpp->currentInput->ungetch(cpp->currentInput, ch2, yylvalpp);
- cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp);
+ currentInput->ungetch(this, currentInput, ch2, yylvalpp);
+ currentInput->ungetch(this, currentInput, ch, yylvalpp);
} else {
- if (len < MAX_TOKEN_LENGTH) {
+ if (len < TPpToken::maxTokenLength) {
str[len++] = ch;
str[len++] = ch2;
isDouble = 1;
} else {
- ShPpErrorToInfoLog("floating-point literal too long");
+ parseContext.error(yylvalpp->loc,"float literal too long", "", "");
len = 1,str_len=1;
}
}
} else if (ch == 'f' || ch == 'F') {
- if (len < MAX_TOKEN_LENGTH)
+ if (len < TPpToken::maxTokenLength)
str[len++] = ch;
else {
- ShPpErrorToInfoLog("floating-point literal too long");
+ parseContext.error(yylvalpp->loc,"float literal too long", "", "");
len = 1,str_len=1;
}
} else
- cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp);
+ currentInput->ungetch(this, currentInput, ch, yylvalpp);
str[len]='\0';
-
- yylvalpp->sc_dval = strtod(str, 0);
+
+ yylvalpp->dval = strtod(str, 0);
}
// Suffix:
- strcpy(yylvalpp->symbol_name, str);
+ strcpy(yylvalpp->name, str);
if (isDouble)
return CPP_DOUBLECONSTANT;
///////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////// Normal Scanner //////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////
-
-static int byte_scan(InputSrc *in, yystypepp * yylvalpp)
+
+int TPpContext::byte_scan(TPpContext* pp, InputSrc *in, TPpToken * yylvalpp)
{
- char tokenText[MAX_TOKEN_LENGTH + 1];
+ char tokenText[TPpToken::maxTokenLength + 1];
int AlreadyComplained = 0;
int len, ch, ii;
unsigned ival = 0;
for (;;) {
- yylvalpp->sc_int = 0;
- ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
-
+ yylvalpp->ival = 0;
+ ch = pp->currentInput->getch(pp, pp->currentInput, yylvalpp);
+
while (ch == ' ' || ch == '\t' || ch == '\r') {
- yylvalpp->sc_int = 1;
- ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
+ yylvalpp->ival = 1;
+ ch = pp->currentInput->getch(pp, pp->currentInput, yylvalpp);
}
-
- cpp->ltokenLoc.file = cpp->currentInput->name;
- cpp->ltokenLoc.line = cpp->currentInput->line;
+
+ yylvalpp->loc = pp->parseContext.currentLoc;
len = 0;
switch (ch) {
default:
- return ch; // Single character token
+ return ch; // Single character token
case EOF:
return EOF;
- case 'A': case 'B': case 'C': case 'D': case 'E':
+ case 'A': case 'B': case 'C': case 'D': case 'E':
case 'F': case 'G': case 'H': case 'I': case 'J':
case 'K': case 'L': case 'M': case 'N': case 'O':
case 'P': case 'Q': case 'R': case 'S': case 'T':
do {
if (ch == '\\') {
// escaped character
- ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
+ ch = pp->currentInput->getch(pp, pp->currentInput, yylvalpp);
if (ch == '\r' || ch == '\n') {
- int nextch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
+ int nextch = pp->currentInput->getch(pp, pp->currentInput, yylvalpp);
if (ch == '\r' && nextch == '\n')
- ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
+ ch = pp->currentInput->getch(pp, pp->currentInput, yylvalpp);
else
ch = nextch;
} else
- ShPpErrorToInfoLog("can only escape newlines");
- } else if (len < MAX_TOKEN_LENGTH) {
+ pp->parseContext.error(yylvalpp->loc,"can only escape newlines", "\\", "");
+ } else if (len < TPpToken::maxTokenLength) {
tokenText[len++] = ch;
- ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
+ ch = pp->currentInput->getch(pp, pp->currentInput, yylvalpp);
} else {
if (! AlreadyComplained) {
- ShPpErrorToInfoLog("name too long");
+ pp->parseContext.error(yylvalpp->loc,"name too long", "", "");
AlreadyComplained = 1;
}
- ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
+ ch = pp->currentInput->getch(pp, pp->currentInput, yylvalpp);
}
} while ((ch >= 'a' && ch <= 'z') ||
- (ch >= 'A' && ch <= 'Z') ||
- (ch >= '0' && ch <= '9') ||
- ch == '_' ||
- ch == '\\');
+ (ch >= 'A' && ch <= 'Z') ||
+ (ch >= '0' && ch <= '9') ||
+ ch == '_' ||
+ ch == '\\');
tokenText[len] = '\0';
- cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp);
- yylvalpp->sc_ident = LookUpAddString(atable, tokenText);
+ pp->currentInput->ungetch(pp, pp->currentInput, ch, yylvalpp);
+ yylvalpp->atom = pp->LookUpAddString(&pp->atomTable, tokenText);
return CPP_IDENTIFIER;
case '0':
- yylvalpp->symbol_name[len++] = ch;
- ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
+ yylvalpp->name[len++] = ch;
+ ch = pp->currentInput->getch(pp, pp->currentInput, yylvalpp);
if (ch == 'x' || ch == 'X') {
int uint = 0;
- yylvalpp->symbol_name[len++] = ch;
- ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
+ yylvalpp->name[len++] = ch;
+ ch = pp->currentInput->getch(pp, pp->currentInput, yylvalpp);
if ((ch >= '0' && ch <= '9') ||
(ch >= 'A' && ch <= 'F') ||
(ch >= 'a' && ch <= 'f'))
ival = 0;
do {
if (ival <= 0x0fffffff) {
- yylvalpp->symbol_name[len++] = ch;
+ yylvalpp->name[len++] = ch;
if (ch >= '0' && ch <= '9') {
ii = ch - '0';
} else if (ch >= 'A' && ch <= 'F') {
} else if (ch >= 'a' && ch <= 'f') {
ii = ch - 'a' + 10;
} else
- ShPpErrorToInfoLog("bad digit in hexidecimal literal");
+ pp->parseContext.error(yylvalpp->loc,"bad digit in hexidecimal literal", "", "");
ival = (ival << 4) | ii;
} else {
if (! AlreadyComplained) {
- ShPpErrorToInfoLog("hexidecimal literal too big");
+ pp->parseContext.error(yylvalpp->loc,"hexidecimal literal too big literal", "", "");
AlreadyComplained = 1;
}
ival = 0xffffffff;
}
- ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
+ ch = pp->currentInput->getch(pp, pp->currentInput, yylvalpp);
} while ((ch >= '0' && ch <= '9') ||
- (ch >= 'A' && ch <= 'F') ||
- (ch >= 'a' && ch <= 'f'));
+ (ch >= 'A' && ch <= 'F') ||
+ (ch >= 'a' && ch <= 'f'));
} else {
- ShPpErrorToInfoLog("bad digit in hexidecimal literal");
+ pp->parseContext.error(yylvalpp->loc,"bad digit in hexidecimal literal", "", "");
}
if (ch == 'u' || ch == 'U') {
- if (len < MAX_TOKEN_LENGTH)
- yylvalpp->symbol_name[len++] = ch;
+ if (len < TPpToken::maxTokenLength)
+ yylvalpp->name[len++] = ch;
uint = 1;
} else
- cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp);
- yylvalpp->symbol_name[len] = '\0';
- yylvalpp->sc_int = (int)ival;
+ pp->currentInput->ungetch(pp, pp->currentInput, ch, yylvalpp);
+ yylvalpp->name[len] = '\0';
+ yylvalpp->ival = (int)ival;
if (uint)
return CPP_UINTCONSTANT;
ival = 0;
do {
if (ival <= 0x1fffffff) {
- yylvalpp->symbol_name[len++] = ch;
+ yylvalpp->name[len++] = ch;
ii = ch - '0';
ival = (ival << 3) | ii;
} else {
if (!AlreadyComplained) {
- ShPpErrorToInfoLog("octal literal too big");
+ pp->parseContext.error(yylvalpp->loc,"octal literal too big", "", "");
AlreadyComplained = 1;
}
ival = 0xffffffff;
}
- ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
+ ch = pp->currentInput->getch(pp, pp->currentInput, yylvalpp);
} while (ch >= '0' && ch <= '7');
if (ch == '.' || ch == 'e' || ch == 'f' || ch == 'h' || ch == 'x'|| ch == 'E' || ch == 'F' || ch == 'l' || ch == 'L')
- return lFloatConst(yylvalpp->symbol_name, len, ch, yylvalpp);
+ return pp->lFloatConst(yylvalpp->name, len, ch, yylvalpp);
else if (ch == 'u' || ch == 'U') {
- if (len < MAX_TOKEN_LENGTH)
- yylvalpp->symbol_name[len++] = ch;
+ if (len < TPpToken::maxTokenLength)
+ yylvalpp->name[len++] = ch;
uint = 1;
} else
- cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp);
- yylvalpp->symbol_name[len] = '\0';
- yylvalpp->sc_int = (int)ival;
+ pp->currentInput->ungetch(pp, pp->currentInput, ch, yylvalpp);
+ yylvalpp->name[len] = '\0';
+ yylvalpp->ival = (int)ival;
if (uint)
return CPP_UINTCONSTANT;
else
return CPP_INTCONSTANT;
} else {
- cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp);
- ch = '0';
+ pp->currentInput->ungetch(pp, pp->currentInput, ch, yylvalpp);
+ ch = '0';
}
// Fall through...
case '1': case '2': case '3': case '4':
case '5': case '6': case '7': case '8': case '9':
do {
- if (len < MAX_TOKEN_LENGTH) {
+ if (len < TPpToken::maxTokenLength) {
if (len > 0 || ch != '0') {
- yylvalpp->symbol_name[len] = ch;
+ yylvalpp->name[len] = ch;
len++;
}
} else {
if (! AlreadyComplained) {
- ShPpErrorToInfoLog("integer literal too long");
+ pp->parseContext.error(yylvalpp->loc,"numeric literal too long", "", "");
AlreadyComplained = 1;
}
}
- ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
+ ch = pp->currentInput->getch(pp, pp->currentInput, yylvalpp);
} while (ch >= '0' && ch <= '9');
if (ch == '.' || ch == 'e' || ch == 'f' || ch == 'h' || ch == 'x'|| ch == 'E' || ch == 'F' || ch == 'l' || ch == 'L') {
- return lFloatConst(yylvalpp->symbol_name, len, ch, yylvalpp);
+ return pp->lFloatConst(yylvalpp->name, len, ch, yylvalpp);
} else {
// Finish handling signed and unsigned integers
int numericLen = len;
int uint = 0;
if (ch == 'u' || ch == 'U') {
- if (len < MAX_TOKEN_LENGTH)
- yylvalpp->symbol_name[len++] = ch;
+ if (len < TPpToken::maxTokenLength)
+ yylvalpp->name[len++] = ch;
uint = 1;
} else
- cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp);
+ pp->currentInput->ungetch(pp, pp->currentInput, ch, yylvalpp);
- yylvalpp->symbol_name[len] = '\0';
+ yylvalpp->name[len] = '\0';
ival = 0;
for (ii = 0; ii < numericLen; ii++) {
- ch = yylvalpp->symbol_name[ii] - '0';
+ ch = yylvalpp->name[ii] - '0';
if ((ival > 429496729) || (ival == 429496729 && ch >= 6)) {
- ShPpErrorToInfoLog("integral literal too big");
+ pp->parseContext.error(yylvalpp->loc,"numeric literal too big", "", "");
ival = -1;
break;
} else
ival = ival * 10 + ch;
}
- yylvalpp->sc_int = (int)ival;
+ yylvalpp->ival = (int)ival;
if (uint)
return CPP_UINTCONSTANT;
}
break;
case '-':
- ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
+ ch = pp->currentInput->getch(pp, pp->currentInput, yylvalpp);
if (ch == '-') {
return CPP_DEC_OP;
} else if (ch == '=') {
return CPP_SUB_ASSIGN;
} else {
- cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp);
+ pp->currentInput->ungetch(pp, pp->currentInput, ch, yylvalpp);
return '-';
}
case '+':
- ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
+ ch = pp->currentInput->getch(pp, pp->currentInput, yylvalpp);
if (ch == '+') {
return CPP_INC_OP;
} else if (ch == '=') {
return CPP_ADD_ASSIGN;
} else {
- cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp);
+ pp->currentInput->ungetch(pp, pp->currentInput, ch, yylvalpp);
return '+';
}
case '*':
- ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
+ ch = pp->currentInput->getch(pp, pp->currentInput, yylvalpp);
if (ch == '=') {
return CPP_MUL_ASSIGN;
} else {
- cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp);
+ pp->currentInput->ungetch(pp, pp->currentInput, ch, yylvalpp);
return '*';
}
case '%':
- ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
+ ch = pp->currentInput->getch(pp, pp->currentInput, yylvalpp);
if (ch == '=') {
return CPP_MOD_ASSIGN;
} else if (ch == '>'){
return CPP_RIGHT_BRACE;
} else {
- cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp);
+ pp->currentInput->ungetch(pp, pp->currentInput, ch, yylvalpp);
return '%';
}
case ':':
- ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
+ ch = pp->currentInput->getch(pp, pp->currentInput, yylvalpp);
if (ch == '>') {
return CPP_RIGHT_BRACKET;
} else {
- cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp);
+ pp->currentInput->ungetch(pp, pp->currentInput, ch, yylvalpp);
return ':';
}
case '^':
- ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
+ ch = pp->currentInput->getch(pp, pp->currentInput, yylvalpp);
if (ch == '^') {
return CPP_XOR_OP;
} else {
if (ch == '=')
return CPP_XOR_ASSIGN;
else{
- cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp);
- return '^';
+ pp->currentInput->ungetch(pp, pp->currentInput, ch, yylvalpp);
+ return '^';
}
}
-
+
case '=':
- ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
+ ch = pp->currentInput->getch(pp, pp->currentInput, yylvalpp);
if (ch == '=') {
return CPP_EQ_OP;
} else {
- cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp);
+ pp->currentInput->ungetch(pp, pp->currentInput, ch, yylvalpp);
return '=';
}
case '!':
- ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
+ ch = pp->currentInput->getch(pp, pp->currentInput, yylvalpp);
if (ch == '=') {
return CPP_NE_OP;
} else {
- cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp);
+ pp->currentInput->ungetch(pp, pp->currentInput, ch, yylvalpp);
return '!';
}
case '|':
- ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
+ ch = pp->currentInput->getch(pp, pp->currentInput, yylvalpp);
if (ch == '|') {
return CPP_OR_OP;
} else {
if (ch == '=')
return CPP_OR_ASSIGN;
else{
- cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp);
- return '|';
+ pp->currentInput->ungetch(pp, pp->currentInput, ch, yylvalpp);
+ return '|';
}
}
case '&':
- ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
+ ch = pp->currentInput->getch(pp, pp->currentInput, yylvalpp);
if (ch == '&') {
return CPP_AND_OP;
} else {
if (ch == '=')
return CPP_AND_ASSIGN;
else{
- cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp);
- return '&';
+ pp->currentInput->ungetch(pp, pp->currentInput, ch, yylvalpp);
+ return '&';
}
}
case '<':
- ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
+ ch = pp->currentInput->getch(pp, pp->currentInput, yylvalpp);
if (ch == '<') {
- ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
- if(ch == '=')
+ ch = pp->currentInput->getch(pp, pp->currentInput, yylvalpp);
+ if (ch == '=')
return CPP_LEFT_ASSIGN;
else{
- cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp);
+ pp->currentInput->ungetch(pp, pp->currentInput, ch, yylvalpp);
return CPP_LEFT_OP;
}
} else {
else if (ch == ':')
return CPP_LEFT_BRACKET;
else{
- cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp);
+ pp->currentInput->ungetch(pp, pp->currentInput, ch, yylvalpp);
return '<';
}
}
}
case '>':
- ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
+ ch = pp->currentInput->getch(pp, pp->currentInput, yylvalpp);
if (ch == '>') {
- ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
- if(ch == '=')
+ ch = pp->currentInput->getch(pp, pp->currentInput, yylvalpp);
+ if (ch == '=')
return CPP_RIGHT_ASSIGN;
else{
- cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp);
+ pp->currentInput->ungetch(pp, pp->currentInput, ch, yylvalpp);
return CPP_RIGHT_OP;
}
} else {
if (ch == '=') {
return CPP_GE_OP;
} else {
- cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp);
+ pp->currentInput->ungetch(pp, pp->currentInput, ch, yylvalpp);
return '>';
}
}
case '.':
- ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
+ ch = pp->currentInput->getch(pp, pp->currentInput, yylvalpp);
if (ch >= '0' && ch <= '9') {
- cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp);
- return lFloatConst(yylvalpp->symbol_name, 0, '.', yylvalpp);
+ pp->currentInput->ungetch(pp, pp->currentInput, ch, yylvalpp);
+ return pp->lFloatConst(yylvalpp->name, 0, '.', yylvalpp);
} else {
- cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp);
+ pp->currentInput->ungetch(pp, pp->currentInput, ch, yylvalpp);
return '.';
}
case '/':
- ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
+ ch = pp->currentInput->getch(pp, pp->currentInput, yylvalpp);
if (ch == '/') {
do {
- ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
+ ch = pp->currentInput->getch(pp, pp->currentInput, yylvalpp);
if (ch == '\\') {
// allow an escaped newline, otherwise escapes in comments are meaningless
- ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
+ ch = pp->currentInput->getch(pp, pp->currentInput, yylvalpp);
if (ch == '\r' || ch == '\n') {
- int nextch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
+ int nextch = pp->currentInput->getch(pp, pp->currentInput, yylvalpp);
if (ch == '\r' && nextch == '\n')
- ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
+ ch = pp->currentInput->getch(pp, pp->currentInput, yylvalpp);
else
ch = nextch;
}
}
} while (ch != '\n' && ch != EOF);
if (ch == EOF)
- return -1;
+ return EOF;
return '\n';
} else if (ch == '*') {
int nlcount = 0;
- ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
+ ch = pp->currentInput->getch(pp, pp->currentInput, yylvalpp);
do {
while (ch != '*') {
- if (ch == '\n') nlcount++;
+ if (ch == '\n')
+ nlcount++;
if (ch == EOF) {
- ShPpErrorToInfoLog("EOF in comment");
- return -1;
+ pp->parseContext.error(yylvalpp->loc,"EOF in comment", "comment", "");
+
+ return EOF;
}
- ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
+ ch = pp->currentInput->getch(pp, pp->currentInput, yylvalpp);
}
- ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
+ ch = pp->currentInput->getch(pp, pp->currentInput, yylvalpp);
if (ch == EOF) {
- ShPpErrorToInfoLog("EOF in comment");
- return -1;
+ pp->parseContext.error(yylvalpp->loc,"EOF in comment", "comment", "");
+
+ return EOF;
}
} while (ch != '/');
- if (nlcount) {
+ if (nlcount)
return '\n';
- }
// Go try it again...
} else if (ch == '=') {
return CPP_DIV_ASSIGN;
} else {
- cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp);
+ pp->currentInput->ungetch(pp, pp->currentInput, ch, yylvalpp);
return '/';
}
break;
case '"':
- ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
+ ch = pp->currentInput->getch(pp, pp->currentInput, yylvalpp);
while (ch != '"' && ch != '\n' && ch != EOF) {
if (ch == '\\') {
- ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
+ ch = pp->currentInput->getch(pp, pp->currentInput, yylvalpp);
if (ch == '\n' || ch == EOF) {
break;
}
}
- if (len < MAX_TOKEN_LENGTH) {
+ if (len < TPpToken::maxTokenLength) {
tokenText[len] = ch;
len++;
- ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
+ ch = pp->currentInput->getch(pp, pp->currentInput, yylvalpp);
} else
break;
};
tokenText[len] = '\0';
if (ch == '"') {
- yylvalpp->sc_ident = LookUpAddString(atable, tokenText);
+ yylvalpp->atom = pp->LookUpAddString(&pp->atomTable, tokenText);
return CPP_STRCONSTANT;
} else {
- ShPpErrorToInfoLog("end of line in string");
+ pp->parseContext.error(yylvalpp->loc,"end of line in string", "string", "");
return CPP_ERROR_SY;
}
}
}
} // byte_scan
-const char* PpTokenize(yystypepp* yylvalpp)
+const char* TPpContext::tokenize(TPpToken* yylvalpp)
{
- int token = '\n';
+ int token = '\n';
for(;;) {
char* tokenString = 0;
- token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
+ token = currentInput->scan(this, currentInput, yylvalpp);
yylvalpp->ppToken = token;
if (check_EOF(token))
return 0;
if (token == '#') {
- if (cpp->previous_token == '\n'|| cpp->previous_token == 0) {
+ if (previous_token == '\n' || previous_token == 0) {
token = readCPPline(yylvalpp);
- if(check_EOF(token))
+ if (check_EOF(token))
return 0;
continue;
} else {
- ShPpErrorToInfoLog("preprocessor directive cannot be preceded by another token");
+ parseContext.error(yylvalpp->loc,"preprocessor directive cannot be preceded by another token", "#", "");
return 0;
}
}
- cpp->previous_token = token;
+ previous_token = token;
if (token == '\n')
continue;
- cpp->notAVersionToken = 1;
+ notAVersionToken = true;
// expand macros
- if (token == CPP_IDENTIFIER && MacroExpand(yylvalpp->sc_ident, yylvalpp, 0) == 1)
+ if (token == CPP_IDENTIFIER && MacroExpand(yylvalpp->atom, yylvalpp, 0) == 1)
continue;
if (token == CPP_IDENTIFIER)
- tokenString = GetStringOfAtom(atable, yylvalpp->sc_ident);
+ tokenString = GetStringOfAtom(&atomTable, yylvalpp->atom);
else if (token == CPP_INTCONSTANT || token == CPP_UINTCONSTANT ||
token == CPP_FLOATCONSTANT || token == CPP_DOUBLECONSTANT)
- tokenString = yylvalpp->symbol_name;
+ tokenString = yylvalpp->name;
else
- tokenString = GetStringOfAtom(atable, token);
+ tokenString = GetStringOfAtom(&atomTable, token);
if (tokenString) {
if (tokenString[0] != 0)
- cpp->tokensBeforeEOF = 1;
+ parseContext.tokensBeforeEOF = 1;
return tokenString;
}
} // PpTokenize
//Checks if the token just read is EOF or not.
-int check_EOF(int token)
+int TPpContext::check_EOF(int token)
{
- if(token==-1){
- if(cpp->ifdepth >0){
- ShPpErrorToInfoLog("missing #endif");
- cpp->CompileError=1;
- }
- return 1;
- }
- return 0;
+ if (token == EOF) {
+ if (ifdepth > 0)
+ parseContext.error(parseContext.currentLoc, "missing #endif", "#if", "");
+ return 1;
+ }
+ return 0;
}
///////////////////////////////////////////////////////////////////////////////////////////////
//
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
+//Copyright (C) 2013 LunarG, Inc.
//All rights reserved.
//
//Redistribution and use in source and binary forms, with or without
#include <stdio.h>
#include <string.h>
-#include "slglobals.h"
+#include "PpContext.h"
///////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////// Symbol Table Variables: ///////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////
-Scope *ScopeList = NULL;
-Scope *CurrentScope = NULL;
-Scope *GlobalScope = NULL;
-
-static void unlinkScope(void *_scope) {
- Scope *scope = (Scope*)_scope;
+static void unlinkScope(void *_scope, void* scopeList)
+{
+ TPpContext::Scope *scope = (TPpContext::Scope*)_scope;
if (scope->next)
scope->next->prev = scope->prev;
if (scope->prev)
scope->prev->next = scope->next;
else
- ScopeList = scope->next;
+ *(TPpContext::Scope**)scopeList = scope->next;
}
/*
- * NewScope()
- *
- */
-Scope *NewScopeInPool(MemoryPool *pool)
+* NewScope()
+*
+*/
+TPpContext::Scope* TPpContext::NewScopeInPool(MemoryPool *pool)
{
Scope *lScope;
lScope->parent = NULL;
lScope->funScope = NULL;
lScope->symbols = NULL;
-
+
lScope->level = 0;
lScope->programs = NULL;
ScopeList->prev = lScope;
lScope->prev = 0;
ScopeList = lScope;
- mem_AddCleanup(pool, unlinkScope, lScope);
+ mem_AddCleanup(pool, unlinkScope, lScope, &ScopeList);
+
return lScope;
} // NewScope
/*
- * PushScope()
- *
- */
+* PushScope()
+*
+*/
-void PushScope(Scope *fScope)
+void TPpContext::PushScope(Scope *fScope)
{
Scope *lScope;
if (fScope->level == 1) {
if (!GlobalScope) {
/* HACK - CTD -- if GlobalScope==NULL and level==1, we're
- * defining a function in the superglobal scope. Things
- * will break if we leave the level as 1, so we arbitrarily
- * set it to 2 */
+ * defining a function in the superglobal scope. Things
+ * will break if we leave the level as 1, so we arbitrarily
+ * set it to 2 */
fScope->level = 2;
}
}
} // PushScope
/*
- * PopScope()
- *
- */
+* PopScope()
+*
+*/
-Scope *PopScope(void)
+TPpContext::Scope* TPpContext::PopScope(void)
{
Scope *lScope;
} // PopScope
/*
- * NewSymbol() - Allocate a new symbol node;
- *
- */
+* NewSymbol() - Allocate a new symbol node;
+*
+*/
-Symbol *NewSymbol(SourceLoc *loc, Scope *fScope, int name, symbolkind kind)
+TPpContext::Symbol* TPpContext::NewSymbol(TSourceLoc *loc, Scope *fScope, int name, symbolkind kind)
{
Symbol *lSymb;
char *pch;
lSymb->name = name;
lSymb->loc = *loc;
lSymb->kind = kind;
-
+
// Clear union area:
pch = (char *) &lSymb->details;
} // NewSymbol
/*
- * lAddToTree() - Using a binary tree is not a good idea for basic atom values because they
- * are generated in order. We'll fix this later (by reversing the bit pattern).
- */
+* lAddToTree() - Using a binary tree is not a good idea for basic atom values because they
+* are generated in order. We'll fix this later (by reversing the bit pattern).
+*/
-static void lAddToTree(Symbol **fSymbols, Symbol *fSymb)
+void TPpContext::lAddToTree(Symbol **fSymbols, Symbol *fSymb, AtomTable *atable)
{
- Symbol *lSymb;
+ TPpContext::Symbol *lSymb;
int lrev, frev;
lSymb = *fSymbols;
while (lSymb) {
lrev = GetReversedAtom(atable, lSymb->name);
if (lrev == frev) {
- ShPpErrorToInfoLog("GetAtomString(atable, fSymb->name)");
+ printf("GetAtomString(atable, fSymb->name)");
break;
} else {
if (lrev > frev) {
/*
- * AddSymbol() - Add a variable, type, or function name to a scope.
- *
- */
+* AddSymbol() - Add a variable, type, or function name to a scope.
+*
+*/
-Symbol *AddSymbol(SourceLoc *loc, Scope *fScope, int atom, symbolkind kind)
+TPpContext::Symbol* TPpContext::AddSymbol(TSourceLoc *loc, Scope *fScope, int atom, symbolkind kind)
{
Symbol *lSymb;
if (!fScope)
fScope = CurrentScope;
lSymb = NewSymbol(loc, fScope, atom, kind);
- lAddToTree(&fScope->symbols, lSymb);
+ lAddToTree(&fScope->symbols, lSymb, &atomTable);
return lSymb;
} // AddSymbol
/*********************************************************************************************/
/*
- * LookUpLocalSymbol()
- *
- */
+* LookUpLocalSymbol()
+*
+*/
-Symbol *LookUpLocalSymbol(Scope *fScope, int atom)
+TPpContext::Symbol* TPpContext::LookUpLocalSymbol(Scope *fScope, int atom)
{
Symbol *lSymb;
int rname, ratom;
- ratom = GetReversedAtom(atable, atom);
+ ratom = GetReversedAtom(&atomTable, atom);
if (!fScope)
fScope = CurrentScope;
lSymb = fScope->symbols;
while (lSymb) {
- rname = GetReversedAtom(atable, lSymb->name);
+ rname = GetReversedAtom(&atomTable, lSymb->name);
if (rname == ratom) {
return lSymb;
} else {
} // LookUpLocalSymbol
/*
- * LookUpSymbol()
- *
- */
+* LookUpSymbol()
+*
+*/
-Symbol *LookUpSymbol(Scope *fScope, int atom)
+TPpContext::Symbol* TPpContext::LookUpSymbol(Scope *fScope, int atom)
{
Symbol *lSymb;
//
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
+//Copyright (C) 2013 LunarG, Inc.
//All rights reserved.
//
//Redistribution and use in source and binary forms, with or without
// tokens.c
//
#ifdef _WIN32
- #define _CRT_SECURE_NO_WARNINGS
- #define snprintf sprintf_s
+#define _CRT_SECURE_NO_WARNINGS
+#define snprintf sprintf_s
#endif
#include <assert.h>
#include <string.h>
#include <ctype.h>
-#include "slglobals.h"
+#include "PpContext.h"
+#include "PpTokens.h"
///////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////// Preprocessor and Token Recorder and Playback: ////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////
/*
- * idstr()
- * Copy a string to a malloc'ed block and convert it into something suitable
- * for an ID
- *
- */
+* idstr()
+* Copy a string to a malloc'ed block and convert it into something suitable
+* for an ID
+*
+*/
-static char *idstr(const char *fstr, MemoryPool *pool)
+char* TPpContext::idstr(const char *fstr, MemoryPool *pool)
{
size_t len;
char *str, *t;
str = (char *) malloc(len + 1);
else
str = (char *) mem_Alloc(pool, len + 1);
-
+
for (f=fstr, t=str; *f; f++) {
if (isalnum(*f)) *t++ = *f;
else if (*f == '.' || *f == '/') *t++ = '_';
/*
- * lNewBlock()
- *
- */
+* lNewBlock()
+*
+*/
-static TokenBlock *lNewBlock(TokenStream *fTok, MemoryPool *pool)
+TPpContext::TokenBlock* TPpContext::lNewBlock(TokenStream *fTok, MemoryPool *pool)
{
TokenBlock *lBlock;
fTok->head = lBlock;
}
fTok->current = lBlock;
+
return lBlock;
} // lNewBlock
/*
- * lAddByte()
- *
- */
+* lAddByte()
+*
+*/
-static void lAddByte(TokenStream *fTok, unsigned char fVal)
+void TPpContext::lAddByte(TokenStream *fTok, unsigned char fVal)
{
TokenBlock *lBlock;
lBlock = fTok->current;
} // lAddByte
-
/*
- * lReadByte() - Get the next byte from a stream.
- *
- */
+* lReadByte() - Get the next byte from a stream.
+*
+*/
-static int lReadByte(TokenStream *pTok)
+int TPpContext::lReadByte(TokenStream *pTok)
{
TokenBlock *lBlock;
int lval = -1;
/////////////////////////////////////// Global Functions://////////////////////////////////////
/*
- * NewTokenStream()
- *
- */
+* NewTokenStream()
+*
+*/
-TokenStream *NewTokenStream(const char *name, MemoryPool *pool)
+TPpContext::TokenStream* TPpContext::NewTokenStream(const char *name, MemoryPool *pool)
{
TokenStream *pTok;
} // NewTokenStream
/*
- * DeleteTokenStream()
- *
- */
+* DeleteTokenStream()
+*
+*/
-void DeleteTokenStream(TokenStream *pTok)
+void TPpContext::DeleteTokenStream(TokenStream *pTok)
{
TokenBlock *pBlock, *nBlock;
} // DeleteTokenStream
/*
- * RecordToken() - Add a token to the end of a list for later playback or printout.
- *
- */
+* RecordToken() - Add a token to the end of a list for later playback or printout.
+*
+*/
-void RecordToken(TokenStream *pTok, int token, yystypepp * yylvalpp)
+void TPpContext::RecordToken(TokenStream *pTok, int token, TPpToken * yylvalpp)
{
const char *s;
char *str = NULL;
case CPP_IDENTIFIER:
case CPP_TYPEIDENTIFIER:
case CPP_STRCONSTANT:
- s = GetAtomString(atable, yylvalpp->sc_ident);
+ s = GetAtomString(&atomTable, yylvalpp->atom);
while (*s)
lAddByte(pTok, (unsigned char) *s++);
lAddByte(pTok, 0);
case CPP_UINTCONSTANT:
case CPP_FLOATCONSTANT:
case CPP_DOUBLECONSTANT:
- str = yylvalpp->symbol_name;
- while (*str){
+ str = yylvalpp->name;
+ while (*str){
lAddByte(pTok, (unsigned char) *str);
str++;
- }
- lAddByte(pTok, 0);
- break;
+ }
+ lAddByte(pTok, 0);
+ break;
case '(':
- lAddByte(pTok, (unsigned char)(yylvalpp->sc_int ? 1 : 0));
+ lAddByte(pTok, (unsigned char)(yylvalpp->ival ? 1 : 0));
default:
break;
}
} // RecordToken
/*
- * RewindTokenStream() - Reset a token stream in preperation for reading.
- *
- */
+* RewindTokenStream() - Reset a token stream in preperation for reading.
+*
+*/
-void RewindTokenStream(TokenStream *pTok)
+void TPpContext::RewindTokenStream(TokenStream *pTok)
{
if (pTok->head) {
pTok->current = pTok->head;
} // RewindTokenStream
/*
- * ReadToken() - Read the next token from a stream.
- *
- */
+* ReadToken() - Read the next token from a stream.
+*
+*/
-int ReadToken(TokenStream *pTok, yystypepp * yylvalpp)
+int TPpContext::ReadToken(TokenStream *pTok, TPpToken * yylvalpp)
{
//TODO: PP: why is this different than byte_scan
- char tokenText[MAX_TOKEN_LENGTH + 1];
+ char tokenText[TPpToken::maxTokenLength + 1];
int ltoken, len;
char ch;
ltoken = lReadByte(pTok);
+ yylvalpp->loc = parseContext.currentLoc;
if (ltoken >= 0) {
if (ltoken > 127)
ltoken += 128;
len = 0;
ch = lReadByte(pTok);
while ((ch >= 'a' && ch <= 'z') ||
- (ch >= 'A' && ch <= 'Z') ||
- (ch >= '0' && ch <= '9') ||
- ch == '_')
+ (ch >= 'A' && ch <= 'Z') ||
+ (ch >= '0' && ch <= '9') ||
+ ch == '_')
{
- if (len < MAX_TOKEN_LENGTH) {
+ if (len < TPpToken::maxTokenLength) {
tokenText[len] = ch;
len++;
ch = lReadByte(pTok);
} else {
- ShPpErrorToInfoLog("token too long");
+ parseContext.error(yylvalpp->loc,"name too long", "", "");
break;
}
}
tokenText[len] = '\0';
assert(ch == '\0');
- yylvalpp->sc_ident = LookUpAddString(atable, tokenText);
+ yylvalpp->atom = LookUpAddString(&atomTable, tokenText);
return CPP_IDENTIFIER;
break;
case CPP_STRCONSTANT:
len = 0;
while ((ch = lReadByte(pTok)) != 0) {
- if (len < MAX_TOKEN_LENGTH)
+ if (len < TPpToken::maxTokenLength)
tokenText[len++] = ch;
else
break;
}
tokenText[len] = 0;
- yylvalpp->sc_ident = LookUpAddString(atable, tokenText);
+ yylvalpp->atom = LookUpAddString(&atomTable, tokenText);
break;
case CPP_FLOATCONSTANT:
case CPP_DOUBLECONSTANT:
ch = lReadByte(pTok);
while ((ch >= '0' && ch <= '9') || ch=='e' || ch=='E' || ch=='.' || ch=='+' || ch=='-' || ch=='l' || ch=='L' || ch=='f'|| ch=='F')
{
- if (len < MAX_TOKEN_LENGTH) {
+ if (len < TPpToken::maxTokenLength) {
tokenText[len] = ch;
len++;
ch = lReadByte(pTok);
} else {
- ShPpErrorToInfoLog("token too long");
+ parseContext.error(yylvalpp->loc,"float literal too long", "", "");
break;
}
}
tokenText[len] = '\0';
assert(ch == '\0');
- strcpy(yylvalpp->symbol_name, tokenText);
- yylvalpp->sc_dval = atof(yylvalpp->symbol_name);
+ strcpy(yylvalpp->name, tokenText);
+ yylvalpp->dval = atof(yylvalpp->name);
break;
case CPP_INTCONSTANT:
case CPP_UINTCONSTANT:
ch = lReadByte(pTok);
while ((ch >= '0' && ch <= '9') || ch == 'u' || ch == 'U')
{
- if (len < MAX_TOKEN_LENGTH) {
+ if (len < TPpToken::maxTokenLength) {
tokenText[len] = ch;
len++;
ch = lReadByte(pTok);
} else {
- ShPpErrorToInfoLog("token too long");
+ parseContext.error(yylvalpp->loc,"integer literal too long", "", "");
break;
}
}
tokenText[len] = '\0';
assert(ch == '\0');
- strcpy(yylvalpp->symbol_name,tokenText);
- yylvalpp->sc_int = atoi(yylvalpp->symbol_name);
+ strcpy(yylvalpp->name,tokenText);
+ yylvalpp->ival = atoi(yylvalpp->name);
break;
case '(':
- yylvalpp->sc_int = lReadByte(pTok);
+ yylvalpp->ival = lReadByte(pTok);
break;
}
return ltoken;
}
- return EOF_SY;
+ return EOF;
} // ReadToken
-typedef struct TokenInputSrc {
- InputSrc base;
- TokenStream *tokens;
- int (*final)(CPPStruct *);
-} TokenInputSrc;
-
-static int scan_token(TokenInputSrc *in, yystypepp * yylvalpp)
+int TPpContext::scan_token(TPpContext* pp, TokenInputSrc *in, TPpToken * yylvalpp)
{
- int token = ReadToken(in->tokens, yylvalpp);
- int (*final)(CPPStruct *);
- cpp->tokenLoc->file = cpp->currentInput->name;
- cpp->tokenLoc->line = cpp->currentInput->line;
+ int token = pp->ReadToken(in->tokens, yylvalpp);
+ int (*final)(TPpContext *);
+ yylvalpp->loc.string = pp->currentInput->name;
+ yylvalpp->loc.line = pp->currentInput->line;
if (token == '\n') {
in->base.line++;
return token;
}
- if (token > 0) return token;
- cpp->currentInput = in->base.prev;
+ if (token > 0)
+ return token;
+ pp->currentInput = in->base.prev;
final = in->final;
free(in);
- if (final && !final(cpp)) return -1;
- return cpp->currentInput->scan(cpp->currentInput, yylvalpp);
+ if (final && !final(pp))
+ return -1;
+
+ return pp->currentInput->scan(pp, pp->currentInput, yylvalpp);
}
-int ReadFromTokenStream(TokenStream *ts, int name, int (*final)(CPPStruct *))
+int TPpContext::ReadFromTokenStream(TokenStream *ts, int name, int (*final)(TPpContext *))
{
TokenInputSrc *in = (TokenInputSrc *) malloc(sizeof(TokenInputSrc));
memset(in, 0, sizeof(TokenInputSrc));
in->base.name = name;
- in->base.prev = cpp->currentInput;
- in->base.scan = (int (*)(InputSrc *, yystypepp *))scan_token;
+ in->base.prev = currentInput;
+ in->base.scan = (int (*)(TPpContext*, InputSrc*, TPpToken*))scan_token;
in->base.line = 1;
in->tokens = ts;
in->final = final;
RewindTokenStream(ts);
- cpp->currentInput = &in->base;
+ currentInput = &in->base;
+
return 1;
}
-typedef struct UngotToken {
- InputSrc base;
- int token;
- yystypepp lval;
-} UngotToken;
-
-static int reget_token(UngotToken *t, yystypepp * yylvalpp)
+int TPpContext::reget_token(TPpContext* pp, UngotToken *t, TPpToken * yylvalpp)
{
int token = t->token;
*yylvalpp = t->lval;
- cpp->currentInput = t->base.prev;
+ pp->currentInput = t->base.prev;
free(t);
return token;
}
-typedef int (*scanFnPtr_t)(struct InputSrc *, yystypepp *);
+typedef int (*scanFnPtr_t);
-void UngetToken(int token, yystypepp * yylvalpp) {
+void TPpContext::UngetToken(int token, TPpToken * yylvalpp)
+{
UngotToken *t = (UngotToken *) malloc(sizeof(UngotToken));
memset(t, 0, sizeof(UngotToken));
t->token = token;
t->lval = *yylvalpp;
- t->base.scan = (scanFnPtr_t)reget_token;
- t->base.prev = cpp->currentInput;
- t->base.name = cpp->currentInput->name;
- t->base.line = cpp->currentInput->line;
- cpp->currentInput = &t->base;
+ t->base.scan = (int(*)(TPpContext*, struct InputSrc *, TPpToken *))reget_token;
+ t->base.prev = currentInput;
+ t->base.name = currentInput->name;
+ t->base.line = currentInput->line;
+ currentInput = &t->base;
}
-void DumpTokenStream(FILE *fp, TokenStream *s, yystypepp * yylvalpp) {
+void TPpContext::DumpTokenStream(FILE *fp, TokenStream *s, TPpToken * yylvalpp)
+{
int token;
- const int maxSize = MAX_TOKEN_LENGTH + 5;
- char str[100];
if (fp == 0) fp = stdout;
RewindTokenStream(s);
switch (token) {
case CPP_IDENTIFIER:
case CPP_TYPEIDENTIFIER:
- snprintf(str, maxSize, "%s ", GetAtomString(atable, yylvalpp->sc_ident));
+ printf("%s ", GetAtomString(&atomTable, yylvalpp->atom));
break;
case CPP_STRCONSTANT:
- snprintf(str, maxSize, "\"%s\"", GetAtomString(atable, yylvalpp->sc_ident));
+ printf("\"%s\"", GetAtomString(&atomTable, yylvalpp->atom));
break;
case CPP_FLOATCONSTANT:
case CPP_DOUBLECONSTANT:
- printf("%g9.6 ", yylvalpp->sc_dval);
+ printf("%g9.6 ", yylvalpp->dval);
break;
case CPP_INTCONSTANT:
case CPP_UINTCONSTANT:
- printf("%d ", yylvalpp->sc_int);
+ printf("%d ", yylvalpp->ival);
break;
default:
if (token >= 127)
- snprintf(str, maxSize, "%s ", GetAtomString(atable, token));
+ printf("%s ", GetAtomString(&atomTable, token));
else
- snprintf(str, maxSize, "%c", token);
+ printf("%c", token);
break;
}
- ShPpDebugLogMsg(str);
}
}
\****************************************************************************/
#ifndef PARSER_H
-# define PARSER_H
+#define PARSER_H
-# define CPP_AND_OP 257
-# define CPP_SUB_ASSIGN 259
-# define CPP_MOD_ASSIGN 260
-# define CPP_ADD_ASSIGN 261
-# define CPP_DIV_ASSIGN 262
-# define CPP_MUL_ASSIGN 263
-# define CPP_EQ_OP 264
-# define CPP_XOR_OP 265
-# define CPP_ERROR_SY 266
-# define CPP_FLOATCONSTANT 267
-# define CPP_GE_OP 268
-# define CPP_RIGHT_OP 269
-# define CPP_IDENTIFIER 270
-# define CPP_INTCONSTANT 271
-# define CPP_LE_OP 272
-# define CPP_LEFT_OP 273
-# define CPP_DEC_OP 274
-# define CPP_NE_OP 275
-# define CPP_OR_OP 276
-# define CPP_INC_OP 277
-# define CPP_STRCONSTANT 278
-# define CPP_TYPEIDENTIFIER 279
-# define CPP_RIGHT_ASSIGN 280
-# define CPP_LEFT_ASSIGN 281
-# define CPP_AND_ASSIGN 282
-# define CPP_OR_ASSIGN 283
-# define CPP_XOR_ASSIGN 284
-# define CPP_LEFT_BRACKET 285
-# define CPP_RIGHT_BRACKET 286
-# define CPP_LEFT_BRACE 287
-# define CPP_RIGHT_BRACE 288
-# define CPP_UINTCONSTANT 289
-# define CPP_DOUBLECONSTANT 290
-# define CPP_FIRST_USER_TOKEN_SY 291
+#define CPP_AND_OP 257
+#define CPP_SUB_ASSIGN 259
+#define CPP_MOD_ASSIGN 260
+#define CPP_ADD_ASSIGN 261
+#define CPP_DIV_ASSIGN 262
+#define CPP_MUL_ASSIGN 263
+#define CPP_EQ_OP 264
+#define CPP_XOR_OP 265
+#define CPP_ERROR_SY 266
+#define CPP_FLOATCONSTANT 267
+#define CPP_GE_OP 268
+#define CPP_RIGHT_OP 269
+#define CPP_IDENTIFIER 270
+#define CPP_INTCONSTANT 271
+#define CPP_LE_OP 272
+#define CPP_LEFT_OP 273
+#define CPP_DEC_OP 274
+#define CPP_NE_OP 275
+#define CPP_OR_OP 276
+#define CPP_INC_OP 277
+#define CPP_STRCONSTANT 278
+#define CPP_TYPEIDENTIFIER 279
+#define CPP_RIGHT_ASSIGN 280
+#define CPP_LEFT_ASSIGN 281
+#define CPP_AND_ASSIGN 282
+#define CPP_OR_ASSIGN 283
+#define CPP_XOR_ASSIGN 284
+#define CPP_LEFT_BRACKET 285
+#define CPP_RIGHT_BRACKET 286
+#define CPP_LEFT_BRACE 287
+#define CPP_RIGHT_BRACE 288
+#define CPP_UINTCONSTANT 289
+#define CPP_DOUBLECONSTANT 290
+
+#define CPP_FIRST_USER_TOKEN_SY 291
#endif /* not PARSER_H */
+++ /dev/null
-//
-//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
-//All rights reserved.
-//
-//Redistribution and use in source and binary forms, with or without
-//modification, are permitted provided that the following conditions
-//are met:
-//
-// Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//
-// Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following
-// disclaimer in the documentation and/or other materials provided
-// with the distribution.
-//
-// Neither the name of 3Dlabs Inc. Ltd. 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 BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
-//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
-//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
-//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
-//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
-//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-//POSSIBILITY OF SUCH DAMAGE.
-//
-/****************************************************************************\
-Copyright (c) 2002, NVIDIA Corporation.
-
-NVIDIA Corporation("NVIDIA") supplies this software to you in
-consideration of your agreement to the following terms, and your use,
-installation, modification or redistribution of this NVIDIA software
-constitutes acceptance of these terms. If you do not agree with these
-terms, please do not use, install, modify or redistribute this NVIDIA
-software.
-
-In consideration of your agreement to abide by the following terms, and
-subject to these terms, NVIDIA grants you a personal, non-exclusive
-license, under NVIDIA's copyrights in this original NVIDIA software (the
-"NVIDIA Software"), to use, reproduce, modify and redistribute the
-NVIDIA Software, with or without modifications, in source and/or binary
-forms; provided that if you redistribute the NVIDIA Software, you must
-retain the copyright notice of NVIDIA, this notice and the following
-text and disclaimers in all such redistributions of the NVIDIA Software.
-Neither the name, trademarks, service marks nor logos of NVIDIA
-Corporation may be used to endorse or promote products derived from the
-NVIDIA Software without specific prior written permission from NVIDIA.
-Except as expressly stated in this notice, no other rights or licenses
-express or implied, are granted by NVIDIA herein, including but not
-limited to any patent rights that may be infringed by your derivative
-works or by other works in which the NVIDIA Software may be
-incorporated. No hardware is licensed hereunder.
-
-THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
-WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
-INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,
-NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
-ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER
-PRODUCTS.
-
-IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,
-INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
-TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
-USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY
-OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE
-NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
-TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
-NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-\****************************************************************************/
-//
-// atom.h
-//
-
-#if !defined(__ATOM_H)
-#define __ATOM_H 1
-
-typedef struct AtomTable_Rec AtomTable;
-
-extern AtomTable *atable;
-
-int InitAtomTable(AtomTable *atable, int htsize);
-void FreeAtomTable(AtomTable *atable);
-int AddAtom(AtomTable *atable, const char *s);
-void PrintAtomTable(AtomTable *atable);
-int LookUpAddString(AtomTable *atable, const char *s);
-const char *GetAtomString(AtomTable *atable, int atom);
-int GetReversedAtom(AtomTable *atable, int atom);
-char* GetStringOfAtom(AtomTable *atable, int atom);
-#endif // !defined(__ATOM_H)
+++ /dev/null
-//
-//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
-//All rights reserved.
-//
-//Redistribution and use in source and binary forms, with or without
-//modification, are permitted provided that the following conditions
-//are met:
-//
-// Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//
-// Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following
-// disclaimer in the documentation and/or other materials provided
-// with the distribution.
-//
-// Neither the name of 3Dlabs Inc. Ltd. 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 BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
-//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
-//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
-//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
-//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
-//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-//POSSIBILITY OF SUCH DAMAGE.
-//
-/****************************************************************************\
-Copyright (c) 2002, NVIDIA Corporation.
-
-NVIDIA Corporation("NVIDIA") supplies this software to you in
-consideration of your agreement to the following terms, and your use,
-installation, modification or redistribution of this NVIDIA software
-constitutes acceptance of these terms. If you do not agree with these
-terms, please do not use, install, modify or redistribute this NVIDIA
-software.
-
-In consideration of your agreement to abide by the following terms, and
-subject to these terms, NVIDIA grants you a personal, non-exclusive
-license, under NVIDIA's copyrights in this original NVIDIA software (the
-"NVIDIA Software"), to use, reproduce, modify and redistribute the
-NVIDIA Software, with or without modifications, in source and/or binary
-forms; provided that if you redistribute the NVIDIA Software, you must
-retain the copyright notice of NVIDIA, this notice and the following
-text and disclaimers in all such redistributions of the NVIDIA Software.
-Neither the name, trademarks, service marks nor logos of NVIDIA
-Corporation may be used to endorse or promote products derived from the
-NVIDIA Software without specific prior written permission from NVIDIA.
-Except as expressly stated in this notice, no other rights or licenses
-express or implied, are granted by NVIDIA herein, including but not
-limited to any patent rights that may be infringed by your derivative
-works or by other works in which the NVIDIA Software may be
-incorporated. No hardware is licensed hereunder.
-
-THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
-WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
-INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,
-NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
-ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER
-PRODUCTS.
-
-IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,
-INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
-TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
-USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY
-OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE
-NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
-TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
-NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-\****************************************************************************/
-//
-// cpp.c
-//
-
-#define _CRT_SECURE_NO_WARNINGS
-
-#include <stdarg.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <ctype.h>
-
-#include "slglobals.h"
-
-static int CPPif(yystypepp * yylvalpp);
-
-/* Don't use memory.c's replacements, as we clean up properly here */
-#undef malloc
-#undef free
-
-static int bindAtom = 0;
-static int constAtom = 0;
-static int defaultAtom = 0;
-static int defineAtom = 0;
-static int definedAtom = 0;
-static int elseAtom = 0;
-static int elifAtom = 0;
-static int endifAtom = 0;
-static int ifAtom = 0;
-static int ifdefAtom = 0;
-static int ifndefAtom = 0;
-static int includeAtom = 0;
-static int lineAtom = 0;
-static int pragmaAtom = 0;
-static int texunitAtom = 0;
-static int undefAtom = 0;
-static int errorAtom = 0;
-static int __LINE__Atom = 0;
-static int __FILE__Atom = 0;
-static int __VERSION__Atom = 0;
-static int versionAtom = 0;
-static int coreAtom = 0;
-static int compatibilityAtom = 0;
-static int esAtom = 0;
-static int extensionAtom = 0;
-
-static Scope *macros = 0;
-#define MAX_MACRO_ARGS 64
-#define MAX_IF_NESTING 64
-
-static SourceLoc ifloc; /* outermost #if */
-
-int ChkCorrectElseNesting(void);
-int PredefineMacro(char *);
-void FreeMacro(MacroSymbol *);
-
-int InitCPP(void)
-{
- char buffer[64], *t;
- const char *f;
- // Add various atoms needed by the CPP line scanner:
- bindAtom = LookUpAddString(atable, "bind");
- constAtom = LookUpAddString(atable, "const");
- defaultAtom = LookUpAddString(atable, "default");
- defineAtom = LookUpAddString(atable, "define");
- definedAtom = LookUpAddString(atable, "defined");
- elifAtom = LookUpAddString(atable, "elif");
- elseAtom = LookUpAddString(atable, "else");
- endifAtom = LookUpAddString(atable, "endif");
- ifAtom = LookUpAddString(atable, "if");
- ifdefAtom = LookUpAddString(atable, "ifdef");
- ifndefAtom = LookUpAddString(atable, "ifndef");
- includeAtom = LookUpAddString(atable, "include");
- lineAtom = LookUpAddString(atable, "line");
- pragmaAtom = LookUpAddString(atable, "pragma");
- texunitAtom = LookUpAddString(atable, "texunit");
- undefAtom = LookUpAddString(atable, "undef");
- errorAtom = LookUpAddString(atable, "error");
- __LINE__Atom = LookUpAddString(atable, "__LINE__");
- __FILE__Atom = LookUpAddString(atable, "__FILE__");
- __VERSION__Atom = LookUpAddString(atable, "__VERSION__");
- versionAtom = LookUpAddString(atable, "version");
- coreAtom = LookUpAddString(atable, "core");
- compatibilityAtom = LookUpAddString(atable, "compatibility");
- esAtom = LookUpAddString(atable, "es");
- extensionAtom = LookUpAddString(atable, "extension");
- macros = NewScopeInPool(mem_CreatePool(0, 0));
- strcpy(buffer, "PROFILE_");
- t = buffer + strlen(buffer);
- f = cpp->options.profileString;
- while ((isalnum(*f) || *f == '_') && t < buffer + sizeof(buffer) - 1)
- *t++ = toupper(*f++);
- *t = 0;
- return 1;
-} // InitCPP
-
-int FreeCPP(void)
-{
- if (macros)
- {
- mem_FreePool(macros->pool);
- macros = 0;
- }
-
- return 1;
-}
-
-int FinalCPP(void)
-{
- if (cpp->ifdepth)
- ShPpErrorToInfoLog("missing #endif");
- return 1;
-}
-
-static int CPPdefine(yystypepp * yylvalpp)
-{
- int token, name, args[MAX_MACRO_ARGS], argc;
- const char *message;
- MacroSymbol mac;
- Symbol *symb;
- SourceLoc dummyLoc;
- memset(&mac, 0, sizeof(mac));
- token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
- if (token != CPP_IDENTIFIER) {
- ShPpErrorToInfoLog("#define not followed by macro name");
- return token;
- }
- name = yylvalpp->sc_ident;
- token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
- if (token == '(' && !yylvalpp->sc_int) {
- // gather arguments
- argc = 0;
- do {
- token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
- if (argc == 0 && token == ')')
- break;
- if (token != CPP_IDENTIFIER) {
- ShPpErrorToInfoLog("#define: bad argument");
-
- return token;
- }
- if (argc < MAX_MACRO_ARGS)
- args[argc++] = yylvalpp->sc_ident;
- token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
- } while (token == ',');
- if (token != ')') {
- ShPpErrorToInfoLog("#define: missing parenthesis");
-
- return token;
- }
- mac.argc = argc;
- mac.args = (int*)mem_Alloc(macros->pool, argc * sizeof(int));
- memcpy(mac.args, args, argc * sizeof(int));
- token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
- }
- mac.body = NewTokenStream(GetAtomString(atable, name), macros->pool);
- while (token != '\n') {
- while (token == '\\') {
- token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
- if (token == '\n')
- token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
- else
- RecordToken(mac.body, '\\', yylvalpp);
- }
- RecordToken(mac.body, token, yylvalpp);
- token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
- };
-
- symb = LookUpSymbol(macros, name);
- if (symb) {
- if (!symb->details.mac.undef) {
- // already defined -- need to make sure they are identical
- if (symb->details.mac.argc != mac.argc)
- goto error;
- for (argc=0; argc < mac.argc; argc++)
- if (symb->details.mac.args[argc] != mac.args[argc])
- goto error;
- RewindTokenStream(symb->details.mac.body);
- RewindTokenStream(mac.body);
- do {
- int old_lval, old_token;
- old_token = ReadToken(symb->details.mac.body, yylvalpp);
- old_lval = yylvalpp->sc_int;
- token = ReadToken(mac.body, yylvalpp);
- if (token != old_token || yylvalpp->sc_int != old_lval) {
- error:
- StoreStr("Macro Redefined");
- StoreStr(GetStringOfAtom(atable, name));
- message = GetStrfromTStr();
- DecLineNumber();
- ShPpErrorToInfoLog(message);
- IncLineNumber();
- ResetTString();
- break;
- }
- } while (token > 0);
- }
- //FreeMacro(&symb->details.mac);
- } else {
- dummyLoc.file = 0;
- dummyLoc.line = 0;
- symb = AddSymbol(&dummyLoc, macros, name, MACRO_S);
- }
- symb->details.mac = mac;
-
- return '\n';
-} // CPPdefine
-
-static int CPPundef(yystypepp * yylvalpp)
-{
- int token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
- Symbol *symb;
- if (token == '\n') {
- ShPpErrorToInfoLog("#undef must be followed by macro name");
-
- return token;
- }
- if (token != CPP_IDENTIFIER) {
- ShPpErrorToInfoLog("#undef must be followed by macro name");
-
- return token;
- }
-
- symb = LookUpSymbol(macros, yylvalpp->sc_ident);
- if (symb) {
- symb->details.mac.undef = 1;
- }
- token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
- if (token != '\n') {
- ShPpErrorToInfoLog("#undef can only be followed by a single macro name");
- }
-
- return token;
-} // CPPundef
-
-/* CPPelse -- skip forward to appropriate spot. This is actually used
-** to skip to a #endif after seeing an #else, AND to skip to a #else,
-** #elif, or #endif after a #if/#ifdef/#ifndef/#elif test was false
-*/
-
-static int CPPelse(int matchelse, yystypepp * yylvalpp)
-{
- int atom;
- int depth = 0;
- int token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
-
- while (token > 0) {
- if (token != '#') {
- while (token != '\n')
- token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
-
- token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
- continue;
- }
-
- if ((token = cpp->currentInput->scan(cpp->currentInput, yylvalpp)) != CPP_IDENTIFIER)
- continue;
-
- atom = yylvalpp->sc_ident;
- if (atom == ifAtom || atom == ifdefAtom || atom == ifndefAtom) {
- depth++;
- cpp->ifdepth++;
- cpp->elsetracker++;
- } else if (atom == endifAtom) {
- cpp->elsedepth[cpp->elsetracker] = 0;
- --cpp->elsetracker;
- if (depth == 0) {
- // found the #endif we are looking for
- if (cpp->ifdepth)
- --cpp->ifdepth;
- break;
- }
- --depth;
- --cpp->ifdepth;
- } else if (matchelse && depth == 0) {
- if (atom == elseAtom ) {
- // found the #else we are looking for
- token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
- if (token != '\n') {
- ShPpWarningToInfoLog("unexpected tokens following #else directive - expected a newline");
- while (token != '\n')
- token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
- }
- break;
- } else if (atom == elifAtom) {
- /* we decrement cpp->ifdepth here, because CPPif will increment
- * it and we really want to leave it alone */
- if (cpp->ifdepth) {
- --cpp->ifdepth;
- cpp->elsedepth[cpp->elsetracker] = 0;
- --cpp->elsetracker;
- }
-
- return CPPif(yylvalpp);
- }
- } else if((atom == elseAtom) && (!ChkCorrectElseNesting())) {
- ShPpErrorToInfoLog("#else after #else");
- cpp->CompileError = 1;
- }
- }; // end while
-
- return token;
-}
-
-enum eval_prec {
- MIN_PREC,
- COND, LOGOR, LOGAND, OR, XOR, AND, EQUAL, RELATION, SHIFT, ADD, MUL, UNARY,
- MAX_PREC
-};
-
-static int op_logor(int a, int b) { return a || b; }
-static int op_logand(int a, int b) { return a && b; }
-static int op_or(int a, int b) { return a | b; }
-static int op_xor(int a, int b) { return a ^ b; }
-static int op_and(int a, int b) { return a & b; }
-static int op_eq(int a, int b) { return a == b; }
-static int op_ne(int a, int b) { return a != b; }
-static int op_ge(int a, int b) { return a >= b; }
-static int op_le(int a, int b) { return a <= b; }
-static int op_gt(int a, int b) { return a > b; }
-static int op_lt(int a, int b) { return a < b; }
-static int op_shl(int a, int b) { return a << b; }
-static int op_shr(int a, int b) { return a >> b; }
-static int op_add(int a, int b) { return a + b; }
-static int op_sub(int a, int b) { return a - b; }
-static int op_mul(int a, int b) { return a * b; }
-static int op_div(int a, int b) { return a / b; }
-static int op_mod(int a, int b) { return a % b; }
-static int op_pos(int a) { return a; }
-static int op_neg(int a) { return -a; }
-static int op_cmpl(int a) { return ~a; }
-static int op_not(int a) { return !a; }
-
-struct Tbinops {
- int token, prec, (*op)(int, int);
-} binop[] = {
- { CPP_OR_OP, LOGOR, op_logor },
- { CPP_AND_OP, LOGAND, op_logand },
- { '|', OR, op_or },
- { '^', XOR, op_xor },
- { '&', AND, op_and },
- { CPP_EQ_OP, EQUAL, op_eq },
- { CPP_NE_OP, EQUAL, op_ne },
- { '>', RELATION, op_gt },
- { CPP_GE_OP, RELATION, op_ge },
- { '<', RELATION, op_lt },
- { CPP_LE_OP, RELATION, op_le },
- { CPP_LEFT_OP, SHIFT, op_shl },
- { CPP_RIGHT_OP, SHIFT, op_shr },
- { '+', ADD, op_add },
- { '-', ADD, op_sub },
- { '*', MUL, op_mul },
- { '/', MUL, op_div },
- { '%', MUL, op_mod },
-};
-
-struct tunops {
- int token, (*op)(int);
-} unop[] = {
- { '+', op_pos },
- { '-', op_neg },
- { '~', op_cmpl },
- { '!', op_not },
-};
-
-#define ALEN(A) (sizeof(A)/sizeof(A[0]))
-
-static int eval(int token, int prec, int *res, int *err, yystypepp * yylvalpp)
-{
- int i, val;
- Symbol *s;
-
- if (token == CPP_IDENTIFIER) {
- if (yylvalpp->sc_ident == definedAtom) {
- int needclose = 0;
- token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
- if (token == '(') {
- needclose = 1;
- token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
- }
- if (token != CPP_IDENTIFIER) {
- ShPpErrorToInfoLog("incorrect preprocessor directive");
- *err = 1;
- *res = 0;
-
- return token;
- }
- *res = (s = LookUpSymbol(macros, yylvalpp->sc_ident))
- ? !s->details.mac.undef : 0;
- token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
- if (needclose) {
- if (token != ')') {
- ShPpErrorToInfoLog("missing ')'");
- *err = 1;
- *res = 0;
-
- return token;
- }
- token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
- }
- } else {
- int macroReturn = MacroExpand(yylvalpp->sc_ident, yylvalpp, 1);
- if (macroReturn == 0) {
- ShPpErrorToInfoLog("can't evaluate expression");
- *err = 1;
- *res = 0;
-
- return token;
- } else {
- if (macroReturn == -1) {
- if (ShPpMacrosMustBeDefinedError())
- *err = 1;
- }
- token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
-
- return eval(token, prec, res, err, yylvalpp);
- }
- }
- } else if (token == CPP_INTCONSTANT) {
- *res = yylvalpp->sc_int;
- token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
- } else if (token == '(') {
- token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
- token = eval(token, MIN_PREC, res, err, yylvalpp);
- if (!*err) {
- if (token != ')') {
- ShPpErrorToInfoLog("expected ')'");
- *err = 1;
- *res = 0;
-
- return token;
- }
- token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
- }
- } else {
- for (i = ALEN(unop) - 1; i >= 0; i--) {
- if (unop[i].token == token)
- break;
- }
- if (i >= 0) {
- token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
- token = eval(token, UNARY, res, err, yylvalpp);
- *res = unop[i].op(*res);
- } else {
- ShPpErrorToInfoLog("bad expression");
- *err = 1;
- *res = 0;
-
- return token;
- }
- }
- while (!*err) {
- if (token == ')' || token == '\n')
- break;
- for (i = ALEN(binop) - 1; i >= 0; i--) {
- if (binop[i].token == token)
- break;
- }
- if (i < 0 || binop[i].prec <= prec)
- break;
- val = *res;
- token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
- token = eval(token, binop[i].prec, res, err, yylvalpp);
- *res = binop[i].op(val, *res);
- }
-
- return token;
-} // eval
-
-static int CPPif(yystypepp * yylvalpp)
-{
- int token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
- int res = 0, err = 0;
- cpp->elsetracker++;
- if (!cpp->ifdepth++)
- ifloc = *cpp->tokenLoc;
- if (cpp->ifdepth > MAX_IF_NESTING){
- ShPpErrorToInfoLog("max #if nesting depth exceeded");
- return 0;
- }
- token = eval(token, MIN_PREC, &res, &err, yylvalpp);
- if (token != '\n') {
- ShPpWarningToInfoLog("unexpected tokens following directive - expected a newline");
- while (token != '\n')
- token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
- }
- if (!res && !err) {
- token = CPPelse(1, yylvalpp);
- }
-
- return token;
-} // CPPif
-
-static int CPPifdef(int defined, yystypepp * yylvalpp)
-{
- int token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
- int name = yylvalpp->sc_ident;
- if(++cpp->ifdepth > MAX_IF_NESTING){
- ShPpErrorToInfoLog("max #if nesting depth exceeded");
- return 0;
- }
- cpp->elsetracker++;
- if (token != CPP_IDENTIFIER) {
- defined ? ShPpErrorToInfoLog("#ifdef not followed by macro name") : ShPpErrorToInfoLog("#ifndef not followed by macro name");
- } else {
- Symbol *s = LookUpSymbol(macros, name);
- token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
- if (token != '\n') {
- ShPpWarningToInfoLog("unexpected tokens following #ifdef - expected a newline");
- while (token != '\n')
- token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
- }
- if (((s && !s->details.mac.undef) ? 1 : 0) != defined)
- token = CPPelse(1, yylvalpp);
- }
- return token;
-} // CPPifdef
-
-static int CPPline(yystypepp * yylvalpp)
-{
- int token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
- if (token=='\n') {
- DecLineNumber();
- ShPpErrorToInfoLog("#line must by followed by an integral literal");
- IncLineNumber();
- return token;
- }
- else if (token == CPP_INTCONSTANT) {
- yylvalpp->sc_int=atoi(yylvalpp->symbol_name);
- SetLineNumber(yylvalpp->sc_int);
- token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
-
- if (token == CPP_INTCONSTANT) {
- yylvalpp->sc_int=atoi(yylvalpp->symbol_name);
- SetStringNumber(yylvalpp->sc_int);
- token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
- if(token!='\n')
- ShPpErrorToInfoLog("#line cannot be followed by more than two integral literals");
- }
- else if (token == '\n')
-
- return token;
- else
- ShPpErrorToInfoLog("#line second argument can only be an integral literal");
- } else
- ShPpErrorToInfoLog("#line first argument can only be an integral literal");
-
- return token;
-}
-
-static int CPPerror(yystypepp * yylvalpp)
-{
- int token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
- const char *message;
-
- while (token != '\n') {
- if (token == CPP_INTCONSTANT || token == CPP_UINTCONSTANT ||
- token == CPP_FLOATCONSTANT || token == CPP_DOUBLECONSTANT) {
- StoreStr(yylvalpp->symbol_name);
- }else if(token == CPP_IDENTIFIER || token == CPP_STRCONSTANT){
- StoreStr(GetStringOfAtom(atable, yylvalpp->sc_ident));
- }else {
- StoreStr(GetStringOfAtom(atable, token));
- }
- token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
- }
- DecLineNumber();
- //store this msg into the shader's information log..set the Compile Error flag!!!!
- message=GetStrfromTStr();
- ShPpErrorToInfoLog(message);
- ResetTString();
- cpp->CompileError=1;
- IncLineNumber();
- return '\n';
-}//CPPerror
-
-static int CPPpragma(yystypepp * yylvalpp)
-{
- char SrcStrName[2];
- char** allTokens;
- int tokenCount = 0;
- int maxTokenCount = 10;
- const char* SrcStr;
- int i;
-
- int token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
-
- if (token=='\n') {
- DecLineNumber();
- ShPpErrorToInfoLog("#pragma must be followed by pragma arguments");
- IncLineNumber();
- return token;
- }
-
- allTokens = (char**)malloc(sizeof(char*) * maxTokenCount);
-
- while (token != '\n') {
- if (tokenCount >= maxTokenCount) {
- maxTokenCount *= 2;
- allTokens = (char**)realloc((char**)allTokens, sizeof(char*) * maxTokenCount);
- }
- switch (token) {
- case CPP_IDENTIFIER:
- SrcStr = GetAtomString(atable, yylvalpp->sc_ident);
- allTokens[tokenCount] = (char*)malloc(strlen(SrcStr) + 1);
- strcpy(allTokens[tokenCount++], SrcStr);
- break;
- case CPP_INTCONSTANT:
- case CPP_UINTCONSTANT:
- case CPP_FLOATCONSTANT:
- case CPP_DOUBLECONSTANT:
- SrcStr = yylvalpp->symbol_name;
- allTokens[tokenCount] = (char*)malloc(strlen(SrcStr) + 1);
- strcpy(allTokens[tokenCount++], SrcStr);
- break;
- case -1:
- // EOF
- ShPpErrorToInfoLog("#pragma directive must end with a newline");
- return token;
- default:
- SrcStrName[0] = token;
- SrcStrName[1] = '\0';
- allTokens[tokenCount] = (char*)malloc(2);
- strcpy(allTokens[tokenCount++], SrcStrName);
- }
- token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
- }
-
- cpp->currentInput->ungetch(cpp->currentInput, token, yylvalpp);
- HandlePragma((const char**)allTokens, tokenCount);
- token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
-
- for (i = 0; i < tokenCount; ++i) {
- free (allTokens[i]);
- }
- free (allTokens);
-
- return token;
-} // CPPpragma
-
-// This is just for error checking: the version and profile are decided before preprocessing starts
-static int CPPversion(yystypepp * yylvalpp)
-{
- int token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
-
- if (cpp->notAVersionToken == 1)
- ShPpErrorToInfoLog("#version must occur before any other statement in the program");
-
- if (token == '\n'){
- DecLineNumber();
- ShPpErrorToInfoLog("#version");
- IncLineNumber();
-
- return token;
- }
-
- if (token != CPP_INTCONSTANT)
- ShPpErrorToInfoLog("#version");
-
- yylvalpp->sc_int = atoi(yylvalpp->symbol_name);
-
- token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
-
- if (token == '\n')
- return token;
- else {
- if (yylvalpp->sc_ident != coreAtom &&
- yylvalpp->sc_ident != compatibilityAtom &&
- yylvalpp->sc_ident != esAtom)
- ShPpErrorToInfoLog("#version profile name");
-
- token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
-
- if (token == '\n')
- return token;
- else
- ShPpErrorToInfoLog("#version");
- }
-
- return token;
-} // CPPversion
-
-static int CPPextension(yystypepp * yylvalpp)
-{
-
- int token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
- char extensionName[80];
-
- if(token=='\n'){
- DecLineNumber();
- ShPpErrorToInfoLog("extension name not specified");
- IncLineNumber();
- return token;
- }
-
- if (token != CPP_IDENTIFIER)
- ShPpErrorToInfoLog("#extension");
-
- strcpy(extensionName, GetAtomString(atable, yylvalpp->sc_ident));
-
- token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
- if (token != ':') {
- ShPpErrorToInfoLog("':' missing after extension name");
- return token;
- }
-
- token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
- if (token != CPP_IDENTIFIER) {
- ShPpErrorToInfoLog("behavior for extension not specified");
- return token;
- }
-
- updateExtensionBehavior(extensionName, GetAtomString(atable, yylvalpp->sc_ident));
-
- token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
- if (token == '\n'){
- return token;
- }
- else{
- ShPpErrorToInfoLog("#extension");
- }
- return token;
-} // CPPextension
-
-int readCPPline(yystypepp * yylvalpp)
-{
- int token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
- const char *message;
- int isVersion = 0;
-
- if (token == CPP_IDENTIFIER) {
- if (yylvalpp->sc_ident == defineAtom) {
- token = CPPdefine(yylvalpp);
- } else if (yylvalpp->sc_ident == elseAtom) {
- if (ChkCorrectElseNesting()) {
- if (! cpp->ifdepth) {
- ShPpErrorToInfoLog("#else mismatch");
- cpp->CompileError = 1;
- }
- token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
- if (token != '\n') {
- ShPpWarningToInfoLog("unexpected tokens following #else - expected a newline");
- while (token != '\n')
- token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
- }
- token = CPPelse(0, yylvalpp);
- } else {
- ShPpErrorToInfoLog("#else after a #else");
- cpp->ifdepth = 0;
- cpp->notAVersionToken = 1;
- return 0;
- }
- } else if (yylvalpp->sc_ident == elifAtom) {
- if (!cpp->ifdepth){
- ShPpErrorToInfoLog("#elif mismatch");
- cpp->CompileError=1;
- }
- // this token is really a dont care, but we still need to eat the tokens
- token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
- while (token != '\n')
- token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
- token = CPPelse(0, yylvalpp);
- } else if (yylvalpp->sc_ident == endifAtom) {
- cpp->elsedepth[cpp->elsetracker] = 0;
- --cpp->elsetracker;
- if (!cpp->ifdepth){
- ShPpErrorToInfoLog("#endif mismatch");
- cpp->CompileError=1;
- }
- else
- --cpp->ifdepth;
- } else if (yylvalpp->sc_ident == ifAtom) {
- token = CPPif(yylvalpp);
- } else if (yylvalpp->sc_ident == ifdefAtom) {
- token = CPPifdef(1, yylvalpp);
- } else if (yylvalpp->sc_ident == ifndefAtom) {
- token = CPPifdef(0, yylvalpp);
- } else if (yylvalpp->sc_ident == lineAtom) {
- token = CPPline(yylvalpp);
- } else if (yylvalpp->sc_ident == pragmaAtom) {
- token = CPPpragma(yylvalpp);
- } else if (yylvalpp->sc_ident == undefAtom) {
- token = CPPundef(yylvalpp);
- } else if (yylvalpp->sc_ident == errorAtom) {
- token = CPPerror(yylvalpp);
- } else if (yylvalpp->sc_ident == versionAtom) {
- token = CPPversion(yylvalpp);
- isVersion = 1;
- } else if (yylvalpp->sc_ident == extensionAtom) {
- token = CPPextension(yylvalpp);
- } else {
- StoreStr("Invalid Directive");
- StoreStr(GetStringOfAtom(atable, yylvalpp->sc_ident));
- message=GetStrfromTStr();
- ShPpErrorToInfoLog(message);
- ResetTString();
- }
- }
- while (token != '\n' && token != 0 && token != EOF) {
- token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
- }
-
- cpp->notAVersionToken = !isVersion;
-
- return token;
-} // readCPPline
-
-void FreeMacro(MacroSymbol *s) {
- DeleteTokenStream(s->body);
-}
-
-static int eof_scan(InputSrc *in, yystypepp * yylvalpp) { return -1; }
-static void noop(InputSrc *in, int ch, yystypepp * yylvalpp) { }
-
-static void PushEofSrc() {
- InputSrc *in = (InputSrc*)malloc(sizeof(InputSrc));
- memset(in, 0, sizeof(InputSrc));
- in->scan = eof_scan;
- in->getch = eof_scan;
- in->ungetch = noop;
- in->prev = cpp->currentInput;
- cpp->currentInput = in;
-}
-
-static void PopEofSrc() {
- if (cpp->currentInput->scan == eof_scan) {
- InputSrc *in = cpp->currentInput;
- cpp->currentInput = in->prev;
- free(in);
- }
-}
-
-static TokenStream *PrescanMacroArg(TokenStream *a, yystypepp * yylvalpp) {
- int token;
- TokenStream *n;
- RewindTokenStream(a);
- do {
- token = ReadToken(a, yylvalpp);
- if (token == CPP_IDENTIFIER && LookUpSymbol(macros, yylvalpp->sc_ident))
- break;
- } while (token > 0);
- if (token <= 0) return a;
- n = NewTokenStream("macro arg", 0);
- PushEofSrc();
- ReadFromTokenStream(a, 0, 0);
- while ((token = cpp->currentInput->scan(cpp->currentInput, yylvalpp)) > 0) {
- if (token == CPP_IDENTIFIER && MacroExpand(yylvalpp->sc_ident, yylvalpp, 0) == 1)
- continue;
- RecordToken(n, token, yylvalpp);
- }
- PopEofSrc();
- DeleteTokenStream(a);
- return n;
-} // PrescanMacroArg
-
-typedef struct MacroInputSrc {
- InputSrc base;
- MacroSymbol *mac;
- TokenStream **args;
-} MacroInputSrc;
-
-/* macro_scan ---
-** return the next token for a macro expansion, handling macro args
-*/
-static int macro_scan(InputSrc *inInput, yystypepp * yylvalpp)
-{
- MacroInputSrc* in = (MacroInputSrc*)inInput;
-
- int i;
- int token = ReadToken(in->mac->body, yylvalpp);
- if (token == CPP_IDENTIFIER) {
- for (i = in->mac->argc-1; i>=0; i--)
- if (in->mac->args[i] == yylvalpp->sc_ident)
- break;
- if (i >= 0) {
- ReadFromTokenStream(in->args[i], yylvalpp->sc_ident, 0);
-
- return cpp->currentInput->scan(cpp->currentInput, yylvalpp);
- }
- }
-
- if (token > 0)
- return token;
-
- in->mac->busy = 0;
- cpp->currentInput = in->base.prev;
- if (in->args) {
- for (i=in->mac->argc-1; i>=0; i--)
- DeleteTokenStream(in->args[i]);
- free(in->args);
- }
- free(in);
-
- return cpp->currentInput->scan(cpp->currentInput, yylvalpp);
-} // macro_scan
-
-// return a zero, for scanning a macro that was never defined
-static int zero_scan(InputSrc *inInput, yystypepp * yylvalpp)
-{
- MacroInputSrc* in = (MacroInputSrc*)inInput;
-
- strcpy(yylvalpp->symbol_name, "0");
- yylvalpp->sc_int = 0;
-
- // pop input
- cpp->currentInput = in->base.prev;
- free(in);
-
- return CPP_INTCONSTANT;
-}
-
-/* MacroExpand
-** Check an identifier (atom) to see if it is a macro that should be expanded.
-** If it is, push an InputSrc that will produce the appropriate expansion
-** and return 1.
-** If it is, but undefined, it should expand to 0, push an InputSrc that will
-** expand to 0 and return -1.
-** Otherwise, return 0.
-*/
-int MacroExpand(int atom, yystypepp* yylvalpp, int expandUndef)
-{
- Symbol *sym = LookUpSymbol(macros, atom);
- MacroInputSrc *in;
- int i, j, token;
- int depth = 0;
- const char *message;
-
- if (atom == __LINE__Atom) {
- yylvalpp->sc_int = GetLineNumber();
- sprintf(yylvalpp->symbol_name, "%d", yylvalpp->sc_int);
- UngetToken(CPP_INTCONSTANT, yylvalpp);
-
- return 1;
- }
-
- if (atom == __FILE__Atom) {
- yylvalpp->sc_int = GetStringNumber();
- sprintf(yylvalpp->symbol_name, "%d", yylvalpp->sc_int);
- UngetToken(CPP_INTCONSTANT, yylvalpp);
-
- return 1;
- }
-
- if (atom == __VERSION__Atom) {
- yylvalpp->sc_int = GetShaderVersion(cpp->pC);
- sprintf(yylvalpp->symbol_name, "%d", yylvalpp->sc_int);
- UngetToken(CPP_INTCONSTANT, yylvalpp);
-
- return 1;
- }
-
- // no recursive expansions
- if (sym && sym->details.mac.busy)
- return 0;
-
- // not expanding of undefined symbols
- if ((! sym || sym->details.mac.undef) && ! expandUndef)
- return 0;
-
- in = (MacroInputSrc*)malloc(sizeof(*in));
- memset(in, 0, sizeof(*in));
- in->base.line = cpp->currentInput->line;
- in->base.name = cpp->currentInput->name;
-
- if ((! sym || sym->details.mac.undef) && expandUndef) {
- // push input
- in->base.scan = zero_scan;
- in->base.prev = cpp->currentInput;
- cpp->currentInput = &in->base;
-
- return -1;
- }
-
- in->base.scan = macro_scan;
- in->mac = &sym->details.mac;
- if (sym->details.mac.args) {
- token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
- if (token != '(') {
- UngetToken(token, yylvalpp);
- yylvalpp->sc_ident = atom;
-
- return 0;
- }
- in->args = (TokenStream**)malloc(in->mac->argc * sizeof(TokenStream *));
- for (i=0; i<in->mac->argc; i++)
- in->args[i] = NewTokenStream("macro arg", 0);
- i=0;j=0;
- do {
- depth = 0;
- while (1) {
- token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
- if (token <= 0) {
- StoreStr("EOF in Macro ");
- StoreStr(GetStringOfAtom(atable, atom));
- message=GetStrfromTStr();
- ShPpErrorToInfoLog(message);
- ResetTString();
-
- return 1;
- }
- if((in->mac->argc==0) && (token!=')')) break;
- if (depth == 0 && (token == ',' || token == ')')) break;
- if (token == '(') depth++;
- if (token == ')') depth--;
- RecordToken(in->args[i], token, yylvalpp);
- j=1;
- }
- if (token == ')') {
- if((in->mac->argc==1) &&j==0)
- break;
- i++;
- break;
- }
- i++;
- } while (i < in->mac->argc);
-
- if (i < in->mac->argc) {
- StoreStr("Too few args in Macro ");
- StoreStr(GetStringOfAtom(atable, atom));
- message=GetStrfromTStr();
- ShPpErrorToInfoLog(message);
- ResetTString();
- } else if (token != ')') {
- depth=0;
- while (token >= 0 && (depth > 0 || token != ')')) {
- if (token == ')') depth--;
- token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
- if (token == '(') depth++;
- }
-
- if (token <= 0) {
- StoreStr("EOF in Macro ");
- StoreStr(GetStringOfAtom(atable, atom));
- message=GetStrfromTStr();
- ShPpErrorToInfoLog(message);
- ResetTString();
-
- return 1;
- }
- StoreStr("Too many args in Macro ");
- StoreStr(GetStringOfAtom(atable, atom));
- message=GetStrfromTStr();
- ShPpErrorToInfoLog(message);
- ResetTString();
- }
- for (i=0; i<in->mac->argc; i++) {
- in->args[i] = PrescanMacroArg(in->args[i], yylvalpp);
- }
- }
-#if 0
- printf(" <%s:%d>found macro %s\n", GetAtomString(atable, loc.file),
- loc.line, GetAtomString(atable, atom));
- for (i=0; i<in->mac->argc; i++) {
- printf("\targ %s = '", GetAtomString(atable, in->mac->args[i]));
- DumpTokenStream(stdout, in->args[i]);
- printf("'\n");
- }
-#endif
- /*retain the input source*/
- in->base.prev = cpp->currentInput;
- sym->details.mac.busy = 1;
- RewindTokenStream(sym->details.mac.body);
- cpp->currentInput = &in->base;
-
- return 1;
-} // MacroExpand
-
-int ChkCorrectElseNesting(void)
-{
- if (cpp->elsedepth[cpp->elsetracker] == 0) {
- cpp->elsedepth[cpp->elsetracker] = 1;
-
- return 1;
- }
-
- return 0;
-}
+++ /dev/null
-//
-//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
-//All rights reserved.
-//
-//Redistribution and use in source and binary forms, with or without
-//modification, are permitted provided that the following conditions
-//are met:
-//
-// Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//
-// Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following
-// disclaimer in the documentation and/or other materials provided
-// with the distribution.
-//
-// Neither the name of 3Dlabs Inc. Ltd. 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 BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
-//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
-//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
-//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
-//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
-//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-//POSSIBILITY OF SUCH DAMAGE.
-//
-/****************************************************************************\
-Copyright (c) 2002, NVIDIA Corporation.
-
-NVIDIA Corporation("NVIDIA") supplies this software to you in
-consideration of your agreement to the following terms, and your use,
-installation, modification or redistribution of this NVIDIA software
-constitutes acceptance of these terms. If you do not agree with these
-terms, please do not use, install, modify or redistribute this NVIDIA
-software.
-
-In consideration of your agreement to abide by the following terms, and
-subject to these terms, NVIDIA grants you a personal, non-exclusive
-license, under NVIDIA's copyrights in this original NVIDIA software (the
-"NVIDIA Software"), to use, reproduce, modify and redistribute the
-NVIDIA Software, with or without modifications, in source and/or binary
-forms; provided that if you redistribute the NVIDIA Software, you must
-retain the copyright notice of NVIDIA, this notice and the following
-text and disclaimers in all such redistributions of the NVIDIA Software.
-Neither the name, trademarks, service marks nor logos of NVIDIA
-Corporation may be used to endorse or promote products derived from the
-NVIDIA Software without specific prior written permission from NVIDIA.
-Except as expressly stated in this notice, no other rights or licenses
-express or implied, are granted by NVIDIA herein, including but not
-limited to any patent rights that may be infringed by your derivative
-works or by other works in which the NVIDIA Software may be
-incorporated. No hardware is licensed hereunder.
-
-THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
-WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
-INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,
-NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
-ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER
-PRODUCTS.
-
-IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,
-INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
-TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
-USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY
-OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE
-NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
-TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
-NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-\****************************************************************************/
-//
-// cpp.h
-//
-
-#if !defined(__CPP_H)
-#define __CPP_H 1
-
-#include "parser.h"
-#include "tokens.h"
-#include "Versions.h"
-
-typedef struct MacroSymbol {
- int argc;
- int *args;
- TokenStream *body;
- unsigned busy:1;
- unsigned undef:1;
-} MacroSymbol;
-
-int InitCPP(void);
-int FinalCPP(void);
-int readCPPline(yystypepp * yylvalpp);
-int MacroExpand(int atom, yystypepp * yylvalpp, int expandUndef);
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-void ShPpDebugLogMsg(const char *msg); // Prints information into debug log
-void ShPpErrorToInfoLog(const char*); // Store cpp Err Msg into Sh.Info.Log
-void ShPpWarningToInfoLog(const char *msg); // Prints warning messages into info log
-int ShPpMacrosMustBeDefinedError();
-
-void HandlePragma(const char**, int numTokens); // #pragma directive container.
-void ResetTString(void); // #error Message as TString.
-void StoreStr(const char*); // Store the TString in Parse Context.
-void SetLineNumber(int); // Set line number.
-void SetStringNumber(int); // Set string number.
-int GetLineNumber(void); // Get the current String Number.
-int GetStringNumber(void); // Get the current String Number.
-const char* GetStrfromTStr(void); // Convert TString to String.
-void SetVersion(int);
-int GetShaderVersion(void*);
-void updateExtensionBehavior(const char* extName, const char* behavior);
-int FreeCPP(void);
-
-#ifdef __cplusplus
-}
-#endif
-
-
-#endif // !(defined(__CPP_H)
+++ /dev/null
-//
-//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
-//All rights reserved.
-//
-//Redistribution and use in source and binary forms, with or without
-//modification, are permitted provided that the following conditions
-//are met:
-//
-// Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//
-// Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following
-// disclaimer in the documentation and/or other materials provided
-// with the distribution.
-//
-// Neither the name of 3Dlabs Inc. Ltd. 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 BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
-//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
-//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
-//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
-//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
-//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-//POSSIBILITY OF SUCH DAMAGE.
-//
-/****************************************************************************\
-Copyright (c) 2002, NVIDIA Corporation.
-
-NVIDIA Corporation("NVIDIA") supplies this software to you in
-consideration of your agreement to the following terms, and your use,
-installation, modification or redistribution of this NVIDIA software
-constitutes acceptance of these terms. If you do not agree with these
-terms, please do not use, install, modify or redistribute this NVIDIA
-software.
-
-In consideration of your agreement to abide by the following terms, and
-subject to these terms, NVIDIA grants you a personal, non-exclusive
-license, under NVIDIA's copyrights in this original NVIDIA software (the
-"NVIDIA Software"), to use, reproduce, modify and redistribute the
-NVIDIA Software, with or without modifications, in source and/or binary
-forms; provided that if you redistribute the NVIDIA Software, you must
-retain the copyright notice of NVIDIA, this notice and the following
-text and disclaimers in all such redistributions of the NVIDIA Software.
-Neither the name, trademarks, service marks nor logos of NVIDIA
-Corporation may be used to endorse or promote products derived from the
-NVIDIA Software without specific prior written permission from NVIDIA.
-Except as expressly stated in this notice, no other rights or licenses
-express or implied, are granted by NVIDIA herein, including but not
-limited to any patent rights that may be infringed by your derivative
-works or by other works in which the NVIDIA Software may be
-incorporated. No hardware is licensed hereunder.
-
-THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
-WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
-INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,
-NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
-ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER
-PRODUCTS.
-
-IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,
-INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
-TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
-USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY
-OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE
-NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
-TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
-NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-\****************************************************************************/
-//
-// cppstruct.c
-//
-
-#include <stdio.h>
-#include <stdlib.h>
-
-#include "slglobals.h"
-
-CPPStruct *cpp = NULL;
-static int refCount = 0;
-
-int ResetPreprocessor(void);
-int FreeCPPStruct(void);
-
-/*
- * InitCPPStruct() - Initilaize the CPP structure.
- *
- */
-
-int InitCPPStruct(void)
-{
- int len;
- char *p;
-
- cpp = (CPPStruct *) malloc(sizeof(CPPStruct));
- if (cpp == NULL)
- return 0;
-
- refCount++;
-
- // Initialize public members:
- cpp->pLastSourceLoc = &cpp->lastSourceLoc;
-
- p = (char *) &cpp->options;
- len = sizeof(cpp->options);
- while (--len >= 0)
- p[len] = 0;
-
- ResetPreprocessor();
- return 1;
-} // InitCPPStruct
-
-int ResetPreprocessor(void)
-{
- // Initialize private members:
-
- cpp->lastSourceLoc.file = 0;
- cpp->lastSourceLoc.line = 0;
- cpp->pC=0;
- cpp->CompileError=0;
- cpp->ifdepth=0;
- for(cpp->elsetracker=0; cpp->elsetracker<64; cpp->elsetracker++)
- cpp->elsedepth[cpp->elsetracker]=0;
- cpp->elsetracker=0;
- cpp->tokensBeforeEOF = 0;
- return 1;
-}
-
-//Intializing the Preprocessor.
-
-int InitPreprocessor(void)
-{
- # define CPP_STUFF true
- # ifdef CPP_STUFF
- FreeCPPStruct();
- InitCPPStruct();
- cpp->options.Quiet = 1;
- cpp->options.profileString = "generic";
- if (!InitAtomTable(atable, 0))
- return 1;
- if (!InitScanner(cpp))
- return 1;
- # endif
- return 0;
-}
-
-//FreeCPPStruct() - Free the CPP structure.
-
-int FreeCPPStruct(void)
-{
- if (refCount)
- {
- free(cpp);
- refCount--;
- }
-
- return 1;
-}
-
-//Finalizing the Preprocessor.
-
-int FinalizePreprocessor(void)
-{
- # define CPP_STUFF true
- # ifdef CPP_STUFF
- FreeAtomTable(atable);
- FreeCPPStruct();
- FreeScanner();
- # endif
- return 0;
-}
-
-
-///////////////////////////////////////////////////////////////////////////////////////////////
-////////////////////////////////////// End of cppstruct.c //////////////////////////////////////
-///////////////////////////////////////////////////////////////////////////////////////////////
+++ /dev/null
-//
-//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
-//All rights reserved.
-//
-//Redistribution and use in source and binary forms, with or without
-//modification, are permitted provided that the following conditions
-//are met:
-//
-// Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//
-// Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following
-// disclaimer in the documentation and/or other materials provided
-// with the distribution.
-//
-// Neither the name of 3Dlabs Inc. Ltd. 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 BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
-//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
-//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
-//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
-//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
-//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-//POSSIBILITY OF SUCH DAMAGE.
-//
-/****************************************************************************\
-Copyright (c) 2002, NVIDIA Corporation.
-
-NVIDIA Corporation("NVIDIA") supplies this software to you in
-consideration of your agreement to the following terms, and your use,
-installation, modification or redistribution of this NVIDIA software
-constitutes acceptance of these terms. If you do not agree with these
-terms, please do not use, install, modify or redistribute this NVIDIA
-software.
-
-In consideration of your agreement to abide by the following terms, and
-subject to these terms, NVIDIA grants you a personal, non-exclusive
-license, under NVIDIA's copyrights in this original NVIDIA software (the
-"NVIDIA Software"), to use, reproduce, modify and redistribute the
-NVIDIA Software, with or without modifications, in source and/or binary
-forms; provided that if you redistribute the NVIDIA Software, you must
-retain the copyright notice of NVIDIA, this notice and the following
-text and disclaimers in all such redistributions of the NVIDIA Software.
-Neither the name, trademarks, service marks nor logos of NVIDIA
-Corporation may be used to endorse or promote products derived from the
-NVIDIA Software without specific prior written permission from NVIDIA.
-Except as expressly stated in this notice, no other rights or licenses
-express or implied, are granted by NVIDIA herein, including but not
-limited to any patent rights that may be infringed by your derivative
-works or by other works in which the NVIDIA Software may be
-incorporated. No hardware is licensed hereunder.
-
-THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
-WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
-INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,
-NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
-ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER
-PRODUCTS.
-
-IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,
-INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
-TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
-USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY
-OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE
-NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
-TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
-NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-\****************************************************************************/
-//
-#ifndef __MEMORY_H
-#define __MEMORY_H
-
-typedef struct MemoryPool_rec MemoryPool;
-
-extern MemoryPool *mem_CreatePool(size_t chunksize, unsigned align);
-extern void mem_FreePool(MemoryPool *);
-extern void *mem_Alloc(MemoryPool *p, size_t size);
-extern void *mem_Realloc(MemoryPool *p, void *old, size_t oldsize, size_t newsize);
-extern int mem_AddCleanup(MemoryPool *p, void (*fn)(void *), void *arg);
-
-#endif /* __MEMORY_H */
+++ /dev/null
-//
-//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
-//All rights reserved.
-//
-//Redistribution and use in source and binary forms, with or without
-//modification, are permitted provided that the following conditions
-//are met:
-//
-// Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//
-// Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following
-// disclaimer in the documentation and/or other materials provided
-// with the distribution.
-//
-// Neither the name of 3Dlabs Inc. Ltd. 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 BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
-//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
-//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
-//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
-//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
-//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-//POSSIBILITY OF SUCH DAMAGE.
-//
-/****************************************************************************\
-Copyright (c) 2002, NVIDIA Corporation.
-
-NVIDIA Corporation("NVIDIA") supplies this software to you in
-consideration of your agreement to the following terms, and your use,
-installation, modification or redistribution of this NVIDIA software
-constitutes acceptance of these terms. If you do not agree with these
-terms, please do not use, install, modify or redistribute this NVIDIA
-software.
-
-In consideration of your agreement to abide by the following terms, and
-subject to these terms, NVIDIA grants you a personal, non-exclusive
-license, under NVIDIA's copyrights in this original NVIDIA software (the
-"NVIDIA Software"), to use, reproduce, modify and redistribute the
-NVIDIA Software, with or without modifications, in source and/or binary
-forms; provided that if you redistribute the NVIDIA Software, you must
-retain the copyright notice of NVIDIA, this notice and the following
-text and disclaimers in all such redistributions of the NVIDIA Software.
-Neither the name, trademarks, service marks nor logos of NVIDIA
-Corporation may be used to endorse or promote products derived from the
-NVIDIA Software without specific prior written permission from NVIDIA.
-Except as expressly stated in this notice, no other rights or licenses
-express or implied, are granted by NVIDIA herein, including but not
-limited to any patent rights that may be infringed by your derivative
-works or by other works in which the NVIDIA Software may be
-incorporated. No hardware is licensed hereunder.
-
-THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
-WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
-INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,
-NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
-ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER
-PRODUCTS.
-
-IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,
-INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
-TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
-USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY
-OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE
-NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
-TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
-NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-\****************************************************************************/
-
-#ifndef PREPROCESS_H
-#define PREPROCESS_H
-
-typedef struct SourceLoc_Rec {
- int file;
- int line;
-} SourceLoc;
-
-typedef struct Options_Rec {
- const char *profileString;
- int ErrorMode;
- int Quiet;
-
- // Debug The Compiler options:
- int DumpAtomTable;
-} Options;
-
-#define MAX_TOKEN_LENGTH 1024
-
-typedef struct {
- int ppToken;
- int sc_int;
- double sc_dval;
- int sc_ident;
- char symbol_name[MAX_TOKEN_LENGTH+1];
-} yystypepp;
-
-typedef struct InputSrc {
- struct InputSrc *prev;
- int (*scan)(struct InputSrc *, yystypepp *);
- int (*getch)(struct InputSrc *, yystypepp *);
- void (*ungetch)(struct InputSrc *, int, yystypepp *);
- int name; /* atom */
- int line;
-} InputSrc;
-
-typedef struct CPPStruct {
- // Public members
- SourceLoc *pLastSourceLoc; // Set at the start of each statement by the tree walkers
- Options options; // Compile options and parameters
-
- // Private members
- SourceLoc lastSourceLoc;
-
- // Scanner data:
-
- SourceLoc *tokenLoc; // Source location of most recent token seen by the scanner
- int mostRecentToken; // Most recent token seen by the scanner
- InputSrc *currentInput;
- int previous_token;
- int notAVersionToken; // used to make sure that #version is the first token seen in the file, if present
-
- void *pC; // storing the parseContext of the compile object in cpp.
-
- // Private members:
- SourceLoc ltokenLoc;
- int ifdepth; //current #if-#else-#endif nesting in the cpp.c file (pre-processor)
- int elsedepth[64]; //Keep a track of #if depth..Max allowed is 64.
- int elsetracker; //#if-#else and #endif constructs...Counter.
- const char *ErrMsg;
- int CompileError; //Indicate compile error when #error, #else,#elif mismatch.
-
- //
- // Globals used to communicate between parseStrings() and yy_input()and
- // also across the files.(gen_glslang.cpp and scanner.c)
- //
- int PaWhichStr; // which string we're parsing
- int* PaStrLen; // array of lengths of the PaArgv strings
- int PaArgc; // count of strings in the array
- char** PaArgv; // our array of strings to parse
- unsigned int tokensBeforeEOF : 1;
-} CPPStruct;
-
-extern CPPStruct *cpp;
-
-int InitPreprocessor(void);
-int FinalizePreprocessor(void);
-int ScanFromString(char *s);
-const char* PpTokenize(yystypepp*);
-
-#endif
+++ /dev/null
-//
-//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
-//All rights reserved.
-//
-//Redistribution and use in source and binary forms, with or without
-//modification, are permitted provided that the following conditions
-//are met:
-//
-// Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//
-// Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following
-// disclaimer in the documentation and/or other materials provided
-// with the distribution.
-//
-// Neither the name of 3Dlabs Inc. Ltd. 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 BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
-//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
-//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
-//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
-//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
-//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-//POSSIBILITY OF SUCH DAMAGE.
-//
-/****************************************************************************\
-Copyright (c) 2002, NVIDIA Corporation.
-
-NVIDIA Corporation("NVIDIA") supplies this software to you in
-consideration of your agreement to the following terms, and your use,
-installation, modification or redistribution of this NVIDIA software
-constitutes acceptance of these terms. If you do not agree with these
-terms, please do not use, install, modify or redistribute this NVIDIA
-software.
-
-In consideration of your agreement to abide by the following terms, and
-subject to these terms, NVIDIA grants you a personal, non-exclusive
-license, under NVIDIA's copyrights in this original NVIDIA software (the
-"NVIDIA Software"), to use, reproduce, modify and redistribute the
-NVIDIA Software, with or without modifications, in source and/or binary
-forms; provided that if you redistribute the NVIDIA Software, you must
-retain the copyright notice of NVIDIA, this notice and the following
-text and disclaimers in all such redistributions of the NVIDIA Software.
-Neither the name, trademarks, service marks nor logos of NVIDIA
-Corporation may be used to endorse or promote products derived from the
-NVIDIA Software without specific prior written permission from NVIDIA.
-Except as expressly stated in this notice, no other rights or licenses
-express or implied, are granted by NVIDIA herein, including but not
-limited to any patent rights that may be infringed by your derivative
-works or by other works in which the NVIDIA Software may be
-incorporated. No hardware is licensed hereunder.
-
-THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
-WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
-INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,
-NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
-ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER
-PRODUCTS.
-
-IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,
-INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
-TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
-USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY
-OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE
-NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
-TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
-NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-\****************************************************************************/
-//
-// slglobals.h
-//
-
-#if !defined(__SLGLOBALS_H)
-#define __SLGLOBALS_H 1
-
-#include "preprocess.h"
-
-// TODO: threading: Multi-threading note: The existence of this global makes
-// this preprocessing single-threaded only.
-extern CPPStruct *cpp;
-
-#undef CPPC_DEBUG_THE_COMPILER
-#if defined(_DEBUG)
-#define CPPC_DEBUG_THE_COMPILER 1
-#endif
-
-#undef CPPC_ENABLE_TOOLS
-#define CPPC_ENABLE_TOOLS 1
-
-#include "memory.h"
-#include "atom.h"
-#include "scanner.h"
-#include "cpp.h"
-#include "tokens.h"
-#include "symbols.h"
-#if !defined(NO_PARSER)
-#include "parser.h"
-#endif
-
-#if !defined(NULL)
-#define NULL 0
-#endif
-
-#endif // !(defined(__SLGLOBALS_H)
-
-
-
-
+++ /dev/null
-//
-//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
-//All rights reserved.
-//
-//Redistribution and use in source and binary forms, with or without
-//modification, are permitted provided that the following conditions
-//are met:
-//
-// Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//
-// Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following
-// disclaimer in the documentation and/or other materials provided
-// with the distribution.
-//
-// Neither the name of 3Dlabs Inc. Ltd. 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 BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
-//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
-//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
-//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
-//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
-//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-//POSSIBILITY OF SUCH DAMAGE.
-//
-/****************************************************************************\
-Copyright (c) 2002, NVIDIA Corporation.
-
-NVIDIA Corporation("NVIDIA") supplies this software to you in
-consideration of your agreement to the following terms, and your use,
-installation, modification or redistribution of this NVIDIA software
-constitutes acceptance of these terms. If you do not agree with these
-terms, please do not use, install, modify or redistribute this NVIDIA
-software.
-
-In consideration of your agreement to abide by the following terms, and
-subject to these terms, NVIDIA grants you a personal, non-exclusive
-license, under NVIDIA's copyrights in this original NVIDIA software (the
-"NVIDIA Software"), to use, reproduce, modify and redistribute the
-NVIDIA Software, with or without modifications, in source and/or binary
-forms; provided that if you redistribute the NVIDIA Software, you must
-retain the copyright notice of NVIDIA, this notice and the following
-text and disclaimers in all such redistributions of the NVIDIA Software.
-Neither the name, trademarks, service marks nor logos of NVIDIA
-Corporation may be used to endorse or promote products derived from the
-NVIDIA Software without specific prior written permission from NVIDIA.
-Except as expressly stated in this notice, no other rights or licenses
-express or implied, are granted by NVIDIA herein, including but not
-limited to any patent rights that may be infringed by your derivative
-works or by other works in which the NVIDIA Software may be
-incorporated. No hardware is licensed hereunder.
-
-THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
-WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
-INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,
-NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
-ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER
-PRODUCTS.
-
-IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,
-INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
-TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
-USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY
-OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE
-NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
-TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
-NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-\****************************************************************************/
-//
-// symbols.h
-//
-
-#if !defined(__SYMBOLS_H)
-#define __SYMBOLS_H 1
-
-#include "memory.h"
-
-typedef enum symbolkind {
- MACRO_S
-} symbolkind;
-
-// Typedefs for things defined here in "symbols.h":
-
-typedef struct Scope_Rec Scope;
-typedef struct Symbol_Rec Symbol;
-
-typedef struct SymbolList_Rec {
- struct SymbolList_Rec *next;
- Symbol *symb;
-} SymbolList;
-
-struct Scope_Rec {
- Scope *next, *prev; // doubly-linked list of all scopes
- Scope *parent;
- Scope *funScope; // Points to base scope of enclosing function
- MemoryPool *pool; // pool used for allocation in this scope
- Symbol *symbols;
-
- int level; // 0 = super globals, 1 = globals, etc.
-
- // Only used at global scope (level 1):
- SymbolList *programs; // List of programs for this compilation.
-};
-
-
-// Symbol table is a simple binary tree.
-
-#include "cpp.h" // to get MacroSymbol def
-
-struct Symbol_Rec {
- Symbol *left, *right;
- Symbol *next;
- int name; // Name atom
- SourceLoc loc;
- symbolkind kind;
- union {
- MacroSymbol mac;
- } details;
-};
-
-extern Scope *CurrentScope;
-extern Scope *GlobalScope;
-extern Scope *ScopeList;
-
-Scope *NewScopeInPool(MemoryPool *);
-#define NewScope() NewScopeInPool(CurrentScope->pool)
-void PushScope(Scope *fScope);
-Scope *PopScope(void);
-Symbol *NewSymbol(SourceLoc *loc, Scope *fScope, int name, symbolkind kind);
-Symbol *AddSymbol(SourceLoc *loc, Scope *fScope, int atom, symbolkind kind);
-Symbol *LookUpLocalSymbol(Scope *fScope, int atom);
-Symbol *LookUpSymbol(Scope *fScope, int atom);
-
-#endif // !defined(__SYMBOLS_H)
-
+++ /dev/null
-//
-//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
-//All rights reserved.
-//
-//Redistribution and use in source and binary forms, with or without
-//modification, are permitted provided that the following conditions
-//are met:
-//
-// Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//
-// Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following
-// disclaimer in the documentation and/or other materials provided
-// with the distribution.
-//
-// Neither the name of 3Dlabs Inc. Ltd. 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 BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
-//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
-//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
-//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
-//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
-//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-//POSSIBILITY OF SUCH DAMAGE.
-//
-/****************************************************************************\
-Copyright (c) 2002, NVIDIA Corporation.
-
-NVIDIA Corporation("NVIDIA") supplies this software to you in
-consideration of your agreement to the following terms, and your use,
-installation, modification or redistribution of this NVIDIA software
-constitutes acceptance of these terms. If you do not agree with these
-terms, please do not use, install, modify or redistribute this NVIDIA
-software.
-
-In consideration of your agreement to abide by the following terms, and
-subject to these terms, NVIDIA grants you a personal, non-exclusive
-license, under NVIDIA's copyrights in this original NVIDIA software (the
-"NVIDIA Software"), to use, reproduce, modify and redistribute the
-NVIDIA Software, with or without modifications, in source and/or binary
-forms; provided that if you redistribute the NVIDIA Software, you must
-retain the copyright notice of NVIDIA, this notice and the following
-text and disclaimers in all such redistributions of the NVIDIA Software.
-Neither the name, trademarks, service marks nor logos of NVIDIA
-Corporation may be used to endorse or promote products derived from the
-NVIDIA Software without specific prior written permission from NVIDIA.
-Except as expressly stated in this notice, no other rights or licenses
-express or implied, are granted by NVIDIA herein, including but not
-limited to any patent rights that may be infringed by your derivative
-works or by other works in which the NVIDIA Software may be
-incorporated. No hardware is licensed hereunder.
-
-THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
-WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
-INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,
-NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
-ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER
-PRODUCTS.
-
-IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,
-INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
-TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
-USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY
-OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE
-NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
-TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
-NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-\****************************************************************************/
-//
-// tokens.h
-//
-
-#if !defined(__TOKENS_H)
-#define __TOKENS_H 1
-
-#include "parser.h"
-
-#define EOF_SY (-1)
-
-typedef struct TokenBlock_Rec TokenBlock;
-
-typedef struct TokenStream_Rec {
- struct TokenStream_Rec *next;
- char *name;
- TokenBlock *head;
- TokenBlock *current;
-} TokenStream;
-
-struct TokenBlock_Rec {
- TokenBlock *next;
- int current;
- int count;
- int max;
- unsigned char *data;
-};
-
-extern TokenStream stdlib_cpp_stream;
-
-
-TokenStream *NewTokenStream(const char *name, MemoryPool *pool);
-void DeleteTokenStream(TokenStream *pTok);
-void RecordToken(TokenStream *pTok, int token, yystypepp * yylvalpp);
-void RewindTokenStream(TokenStream *pTok);
-int ReadToken(TokenStream *pTok, yystypepp * yylvalpp);
-int ReadFromTokenStream(TokenStream *pTok, int name, int (*final)(CPPStruct *));
-void UngetToken(int, yystypepp * yylvalpp);
-
-#if defined(CPPC_ENABLE_TOOLS)
-
-void DumpTokenStream(FILE *, TokenStream *, yystypepp * yylvalpp);
-
-#endif // defined(CPPC_ENABLE_TOOLS)
-
-#endif // !defined(__TOKENS_H)
+++ /dev/null
-\r
-extern int timeclock;\r
-\r
-\r
-int yyerror; /* Yyerror and yycost are set by guards. */\r
-int yycost; /* If yyerror is set to a nonzero value by a */\r
- /* guard, the reduction with which the guard */\r
- /* is associated is not performed, and the */\r
- /* error recovery mechanism is invoked. */\r
- /* Yycost indicates the cost of performing */\r
- /* the reduction given the attributes of the */\r
- /* symbols. */\r
-\r
-\r
-/* YYMAXDEPTH indicates the size of the parser's state and value */\r
-/* stacks. */\r
-\r
-#ifndef YYMAXDEPTH\r
-#define YYMAXDEPTH 500\r
-#endif\r
-\r
-/* YYMAXRULES must be at least as large as the number of rules that */\r
-/* could be placed in the rule queue. That number could be determined */\r
-/* from the grammar and the size of the stack, but, as yet, it is not. */\r
-\r
-#ifndef YYMAXRULES\r
-#define YYMAXRULES 100\r
-#endif\r
-\r
-#ifndef YYMAXBACKUP\r
-#define YYMAXBACKUP 100\r
-#endif\r
-\r
-\r
-short yyss[YYMAXDEPTH]; /* the state stack */\r
-YYSTYPE yyvs[YYMAXDEPTH]; /* the semantic value stack */\r
-YYLTYPE yyls[YYMAXDEPTH]; /* the location stack */\r
-short yyrq[YYMAXRULES]; /* the rule queue */\r
-int yychar; /* the lookahead symbol */\r
-\r
-YYSTYPE yylval; /* the semantic value of the */\r
- /* lookahead symbol */\r
-\r
-YYSTYPE yytval; /* the semantic value for the state */\r
- /* at the top of the state stack. */\r
-\r
-YYSTYPE yyval; /* the variable used to return */\r
- /* semantic values from the action */\r
- /* routines */\r
-\r
-YYLTYPE yylloc; /* location data for the lookahead */\r
- /* symbol */\r
-\r
-YYLTYPE yytloc; /* location data for the state at the */\r
- /* top of the state stack */\r
-\r
-\r
-int yynunlexed;\r
-short yyunchar[YYMAXBACKUP];\r
-YYSTYPE yyunval[YYMAXBACKUP];\r
-YYLTYPE yyunloc[YYMAXBACKUP];\r
-\r
-short *yygssp; /* a pointer to the top of the state */\r
- /* stack; only set during error */\r
- /* recovery. */\r
-\r
-YYSTYPE *yygvsp; /* a pointer to the top of the value */\r
- /* stack; only set during error */\r
- /* recovery. */\r
-\r
-YYLTYPE *yyglsp; /* a pointer to the top of the */\r
- /* location stack; only set during */\r
- /* error recovery. */\r
-\r
-\r
-/* Yyget is an interface between the parser and the lexical analyzer. */\r
-/* It is costly to provide such an interface, but it avoids requiring */\r
-/* the lexical analyzer to be able to back up the scan. */\r
-\r
-yyget()\r
-{\r
- if (yynunlexed > 0)\r
- {\r
- yynunlexed--;\r
- yychar = yyunchar[yynunlexed];\r
- yylval = yyunval[yynunlexed];\r
- yylloc = yyunloc[yynunlexed];\r
- }\r
- else if (yychar <= 0)\r
- yychar = 0;\r
- else\r
- {\r
- yychar = yylex();\r
- if (yychar < 0)\r
- yychar = 0;\r
- else yychar = YYTRANSLATE(yychar);\r
- }\r
-}\r
-\r
-\r
-\r
-yyunlex(chr, val, loc)\r
-int chr;\r
-YYSTYPE val;\r
-YYLTYPE loc;\r
-{\r
- yyunchar[yynunlexed] = chr;\r
- yyunval[yynunlexed] = val;\r
- yyunloc[yynunlexed] = loc;\r
- yynunlexed++;\r
-}\r
-\r
-\r
-\r
-yyrestore(first, last)\r
-register short *first;\r
-register short *last;\r
-{\r
- register short *ssp;\r
- register short *rp;\r
- register int symbol;\r
- register int state;\r
- register int tvalsaved;\r
-\r
- ssp = yygssp;\r
- yyunlex(yychar, yylval, yylloc);\r
-\r
- tvalsaved = 0;\r
- while (first != last)\r
- {\r
- symbol = yystos[*ssp];\r
- if (symbol < YYNTBASE)\r
- {\r
- yyunlex(symbol, yytval, yytloc);\r
- tvalsaved = 1;\r
- ssp--;\r
- }\r
-\r
- ssp--;\r
-\r
- if (first == yyrq)\r
- first = yyrq + YYMAXRULES;\r
-\r
- first--;\r
-\r
- for (rp = yyrhs + yyprhs[*first]; symbol = *rp; rp++)\r
- {\r
- if (symbol < YYNTBASE)\r
- state = yytable[yypact[*ssp] + symbol];\r
- else\r
- {\r
- state = yypgoto[symbol - YYNTBASE] + *ssp;\r
-\r
- if (state >= 0 && state <= YYLAST && yycheck[state] == *ssp)\r
- state = yytable[state];\r
- else\r
- state = yydefgoto[symbol - YYNTBASE];\r
- }\r
-\r
- *++ssp = state;\r
- }\r
- }\r
-\r
- if ( ! tvalsaved && ssp > yyss)\r
- {\r
- yyunlex(yystos[*ssp], yytval, yytloc);\r
- ssp--;\r
- }\r
-\r
- yygssp = ssp;\r
-}\r
-\r
-\r
-\r
-int\r
-yyparse()\r
-{\r
- register int yystate;\r
- register int yyn;\r
- register short *yyssp;\r
- register short *yyrq0;\r
- register short *yyptr;\r
- register YYSTYPE *yyvsp;\r
-\r
- int yylen;\r
- YYLTYPE *yylsp;\r
- short *yyrq1;\r
- short *yyrq2;\r
-\r
- yystate = 0;\r
- yyssp = yyss - 1;\r
- yyvsp = yyvs - 1;\r
- yylsp = yyls - 1;\r
- yyrq0 = yyrq;\r
- yyrq1 = yyrq0;\r
- yyrq2 = yyrq0;\r
-\r
- yychar = yylex();\r
- if (yychar < 0)\r
- yychar = 0;\r
- else yychar = YYTRANSLATE(yychar);\r
-\r
-yynewstate:\r
-\r
- if (yyssp >= yyss + YYMAXDEPTH - 1)\r
- {\r
- yyabort("Parser Stack Overflow");\r
- YYABORT;\r
- }\r
-\r
- *++yyssp = yystate;\r
-\r
-yyresume:\r
-\r
- yyn = yypact[yystate];\r
- if (yyn == YYFLAG)\r
- goto yydefault;\r
-\r
- yyn += yychar;\r
- if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar)\r
- goto yydefault;\r
-\r
- yyn = yytable[yyn];\r
- if (yyn < 0)\r
- {\r
- yyn = -yyn;\r
- goto yyreduce;\r
- }\r
- else if (yyn == 0)\r
- goto yyerrlab;\r
-\r
- yystate = yyn;\r
-\r
- yyptr = yyrq2;\r
- while (yyptr != yyrq1)\r
- {\r
- yyn = *yyptr++;\r
- yylen = yyr2[yyn];\r
- yyvsp -= yylen;\r
- yylsp -= yylen;\r
-\r
- yyguard(yyn, yyvsp, yylsp);\r
- if (yyerror)\r
- goto yysemerr;\r
-\r
- yyaction(yyn, yyvsp, yylsp);\r
- *++yyvsp = yyval;\r
-\r
- yylsp++;\r
- if (yylen == 0)\r
- {\r
- yylsp->timestamp = timeclock;\r
- yylsp->first_line = yytloc.first_line;\r
- yylsp->first_column = yytloc.first_column;\r
- yylsp->last_line = (yylsp-1)->last_line;\r
- yylsp->last_column = (yylsp-1)->last_column;\r
- yylsp->text = 0;\r
- }\r
- else\r
- {\r
- yylsp->last_line = (yylsp+yylen-1)->last_line;\r
- yylsp->last_column = (yylsp+yylen-1)->last_column;\r
- }\r
- \r
- if (yyptr == yyrq + YYMAXRULES)\r
- yyptr = yyrq;\r
- }\r
-\r
- if (yystate == YYFINAL)\r
- YYACCEPT;\r
-\r
- yyrq2 = yyptr;\r
- yyrq1 = yyrq0;\r
-\r
- *++yyvsp = yytval;\r
- *++yylsp = yytloc;\r
- yytval = yylval;\r
- yytloc = yylloc;\r
- yyget();\r
-\r
- goto yynewstate;\r
-\r
-yydefault:\r
-\r
- yyn = yydefact[yystate];\r
- if (yyn == 0)\r
- goto yyerrlab;\r
-\r
-yyreduce:\r
-\r
- *yyrq0++ = yyn;\r
-\r
- if (yyrq0 == yyrq + YYMAXRULES)\r
- yyrq0 = yyrq;\r
-\r
- if (yyrq0 == yyrq2)\r
- {\r
- yyabort("Parser Rule Queue Overflow");\r
- YYABORT;\r
- }\r
-\r
- yyssp -= yyr2[yyn];\r
- yyn = yyr1[yyn];\r
-\r
- yystate = yypgoto[yyn - YYNTBASE] + *yyssp;\r
- if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)\r
- yystate = yytable[yystate];\r
- else\r
- yystate = yydefgoto[yyn - YYNTBASE];\r
-\r
- goto yynewstate;\r
-\r
-yysemerr:\r
- *--yyptr = yyn;\r
- yyrq2 = yyptr;\r
- yyvsp += yyr2[yyn];\r
-\r
-yyerrlab:\r
-\r
- yygssp = yyssp;\r
- yygvsp = yyvsp;\r
- yyglsp = yylsp;\r
- yyrestore(yyrq0, yyrq2);\r
- yyrecover();\r
- yystate = *yygssp;\r
- yyssp = yygssp;\r
- yyvsp = yygvsp;\r
- yyrq0 = yyrq;\r
- yyrq1 = yyrq0;\r
- yyrq2 = yyrq0;\r
- goto yyresume;\r
-}\r
-\r
-$\r
+++ /dev/null
-/* -*-C-*- Note some compilers choke on comments on `#line' lines. */\r
-\r
-/* Skeleton output parser for bison,\r
- Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc.\r
-\r
- This program is free software; you can redistribute it and/or modify\r
- it under the terms of the GNU General Public License as published by\r
- the Free Software Foundation; either version 2, or (at your option)\r
- any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with this program; if not, write to the Free Software\r
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */\r
-\r
-/* As a special exception, when this file is copied by Bison into a\r
- Bison output file, you may use that output file without restriction.\r
- This special exception was added by the Free Software Foundation\r
- in version 1.24 of Bison. */\r
-\r
-#ifdef __GNUC__\r
-#define alloca __builtin_alloca\r
-#else /* not __GNUC__ */\r
-#if HAVE_ALLOCA_H\r
-#include <alloca.h>\r
-#else /* not HAVE_ALLOCA_H */\r
-#ifdef _AIX\r
- #pragma alloca\r
-#else /* not _AIX */\r
-char *alloca ();\r
-#endif /* not _AIX */\r
-#endif /* not HAVE_ALLOCA_H */\r
-#endif /* not __GNUC__ */\r
-\r
-extern void yyerror(char* s);\r
-\r
-#ifndef alloca\r
-#ifdef __GNUC__\r
-#define alloca __builtin_alloca\r
-#else /* not GNU C. */\r
-#if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi)\r
-#include <alloca.h>\r
-#else /* not sparc */\r
-#if (defined (MSDOS) && !defined (__TURBOC__)) || defined (WIN32)\r
-#include <malloc.h>\r
-#else /* not MSDOS, or __TURBOC__ */\r
-#if defined(_AIX)\r
-#include <malloc.h>\r
- #pragma alloca\r
-#else /* not MSDOS, __TURBOC__, or _AIX */\r
-#ifdef __hpux\r
-#ifdef __cplusplus\r
-extern "C" {\r
-void *alloca (unsigned int);\r
-};\r
-#else /* not __cplusplus */\r
-void *alloca ();\r
-#endif /* not __cplusplus */\r
-#endif /* __hpux */\r
-#endif /* not _AIX */\r
-#endif /* not MSDOS, or __TURBOC__ */\r
-#endif /* not sparc. */\r
-#endif /* not GNU C. */\r
-#endif /* alloca not defined. */\r
-\r
-/* This is the parser code that is written into each bison parser\r
- when the %semantic_parser declaration is not specified in the grammar.\r
- It was written by Richard Stallman by simplifying the hairy parser\r
- used when %semantic_parser is specified. */\r
-\r
-/* Note: there must be only one dollar sign in this file.\r
- It is replaced by the list of actions, each action\r
- as one case of the switch. */\r
-\r
-#define yyerrok (yyerrstatus = 0)\r
-#define yyclearin (yychar = YYEMPTY)\r
-#define YYEMPTY -2\r
-#define YYEOF 0\r
-#define YYACCEPT return(0)\r
-#define YYABORT return(1)\r
-#define YYERROR goto yyerrlab1\r
-/* Like YYERROR except do call yyerror.\r
- This remains here temporarily to ease the\r
- transition to the new meaning of YYERROR, for GCC.\r
- Once GCC version 2 has supplanted version 1, this can go. */\r
-#define YYFAIL goto yyerrlab\r
-#define YYRECOVERING() (!!yyerrstatus)\r
-#define YYBACKUP(token, value) \\r
-do \\r
- if (yychar == YYEMPTY && yylen == 1) \\r
- { yychar = (token), yylval = (value); \\r
- yychar1 = YYTRANSLATE (yychar); \\r
- YYPOPSTACK; \\r
- goto yybackup; \\r
- } \\r
- else \\r
- { yyerror ("syntax error: cannot back up"); YYERROR; } \\r
-while (0)\r
-\r
-#define YYTERROR 1\r
-#define YYERRCODE 256\r
-\r
-#ifndef YYPURE\r
-#define YYLEX yylex()\r
-#endif\r
-\r
-#ifdef YYPURE\r
-#ifdef YYLSP_NEEDED\r
-#ifdef YYLEX_PARAM\r
-#define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM)\r
-#else\r
-#define YYLEX yylex(&yylval, &yylloc)\r
-#endif\r
-#else /* not YYLSP_NEEDED */\r
-#ifdef YYLEX_PARAM\r
-#define YYLEX yylex(&yylval, YYLEX_PARAM)\r
-#else\r
-#define YYLEX yylex(&yylval)\r
-#endif\r
-#endif /* not YYLSP_NEEDED */\r
-#endif\r
-\r
-/* If nonreentrant, generate the variables here */\r
-\r
-#ifndef YYPURE\r
-\r
-int yychar; /* the lookahead symbol */\r
-YYSTYPE yylval; /* the semantic value of the */\r
- /* lookahead symbol */\r
-\r
-#ifdef YYLSP_NEEDED\r
-YYLTYPE yylloc; /* location data for the lookahead */\r
- /* symbol */\r
-#endif\r
-\r
-int yynerrs; /* number of parse errors so far */\r
-#endif /* not YYPURE */\r
-\r
-#if YYDEBUG != 0\r
-int yydebug; /* nonzero means print parse trace */\r
-/* Since this is uninitialized, it does not stop multiple parsers\r
- from coexisting. */\r
-#endif\r
-\r
-/* YYINITDEPTH indicates the initial size of the parser's stacks */\r
-\r
-#ifndef YYINITDEPTH\r
-#define YYINITDEPTH 200\r
-#endif\r
-\r
-/* YYMAXDEPTH is the maximum size the stacks can grow to\r
- (effective only if the built-in stack extension method is used). */\r
-\r
-#if YYMAXDEPTH == 0\r
-#undef YYMAXDEPTH\r
-#endif\r
-\r
-#ifndef YYMAXDEPTH\r
-#define YYMAXDEPTH 10000\r
-#endif\r
-\r
-/* Prevent warning if -Wstrict-prototypes. */\r
-#ifdef __GNUC__\r
-int yyparse (void);\r
-#endif\r
-\f\r
-#if __GNUC__ > 1 /* GNU C and GNU C++ define this. */\r
-#define __yy_memcpy(FROM,TO,COUNT) __builtin_memcpy(TO,FROM,COUNT)\r
-#else /* not GNU C or C++ */\r
-#ifndef __cplusplus\r
-\r
-/* This is the most reliable way to avoid incompatibilities\r
- in available built-in functions on various systems. */\r
-static void\r
-__yy_memcpy (from, to, count)\r
- char *from;\r
- char *to;\r
- size_t count;\r
-{\r
- register char *f = from;\r
- register char *t = to;\r
- register size_t i = count;\r
-\r
- while (i-- > 0)\r
- *t++ = *f++;\r
-}\r
-\r
-#else /* __cplusplus */\r
-\r
-/* This is the most reliable way to avoid incompatibilities\r
- in available built-in functions on various systems. */\r
-static void\r
-__yy_memcpy (char *from, char *to, size_t count)\r
-{\r
- register char *f = from;\r
- register char *t = to;\r
- register size_t i = count;\r
-\r
- while (i-- > 0)\r
- *t++ = *f++;\r
-}\r
-\r
-#endif\r
-#endif\r
-\r
-/* The user can define YYPARSE_PARAM as the name of an argument to be passed\r
- into yyparse. The argument should have type void *.\r
- It should actually point to an object.\r
- Grammar actions can access the variable by casting it\r
- to the proper pointer type. */\r
-\r
-#ifdef YYPARSE_PARAM\r
-#ifndef YYPARSE_PARAM_DECL\r
-#define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;\r
-#endif \r
-#else\r
-#define YYPARSE_PARAM\r
-#define YYPARSE_PARAM_DECL\r
-#endif\r
-\r
-extern YY_DECL;\r
-\r
-int\r
-yyparse(YYPARSE_PARAM_DECL YYPARSE_PARAM) {\r
- register int yystate;\r
- register int yyn;\r
- register short *yyssp;\r
- register YYSTYPE *yyvsp;\r
- int yyerrstatus; /* number of tokens to shift before error messages enabled */\r
- int yychar1 = 0; /* lookahead token as an internal (translated) token number */\r
-\r
- short yyssa[YYINITDEPTH]; /* the state stack */\r
- YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */\r
-\r
- short *yyss = yyssa; /* refer to the stacks thru separate pointers */\r
- YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */\r
-\r
-#ifdef YYLSP_NEEDED\r
- YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */\r
- YYLTYPE *yyls = yylsa;\r
- YYLTYPE *yylsp;\r
-\r
-#define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)\r
-#else\r
-#define YYPOPSTACK (yyvsp--, yyssp--)\r
-#endif\r
-\r
- size_t yystacksize = YYINITDEPTH;\r
-\r
-#ifdef YYPURE\r
- int yychar;\r
- YYSTYPE yylval;\r
- int yynerrs;\r
-#ifdef YYLSP_NEEDED\r
- YYLTYPE yylloc;\r
-#endif\r
-#endif\r
-\r
- YYSTYPE yyval; /* the variable used to return */\r
- /* semantic values from the action */\r
- /* routines */\r
-\r
- int yylen;\r
-\r
-#if YYDEBUG != 0\r
- if (yydebug)\r
- fprintf(stderr, "Starting parse\n");\r
-#endif\r
-\r
- yystate = 0;\r
- yyerrstatus = 0;\r
- yynerrs = 0;\r
- yychar = YYEMPTY; /* Cause a token to be read. */\r
-\r
- /* Initialize stack pointers.\r
- Waste one element of value and location stack\r
- so that they stay on the same level as the state stack.\r
- The wasted elements are never initialized. */\r
-\r
- yyssp = yyss - 1;\r
- yyvsp = yyvs;\r
-#ifdef YYLSP_NEEDED\r
- yylsp = yyls;\r
-#endif\r
-\r
-/* Push a new state, which is found in yystate . */\r
-/* In all cases, when you get here, the value and location stacks\r
- have just been pushed. so pushing a state here evens the stacks. */\r
-yynewstate:\r
-\r
- *++yyssp = yystate;\r
-\r
- if (yyssp >= yyss + yystacksize - 1)\r
- {\r
- /* Give user a chance to reallocate the stack */\r
- /* Use copies of these so that the &'s don't force the real ones into memory. */\r
- YYSTYPE *yyvs1 = yyvs;\r
- short *yyss1 = yyss;\r
-#ifdef YYLSP_NEEDED\r
- YYLTYPE *yyls1 = yyls;\r
-#endif\r
-\r
- /* Get the current used size of the three stacks, in elements. */\r
- size_t size = yyssp - yyss + 1;\r
-\r
-#ifdef yyoverflow\r
- /* Each stack pointer address is followed by the size of\r
- the data in use in that stack, in bytes. */\r
-#ifdef YYLSP_NEEDED\r
- /* This used to be a conditional around just the two extra args,\r
- but that might be undefined if yyoverflow is a macro. */\r
- yyoverflow("parser stack overflow",\r
- &yyss1, size * sizeof (*yyssp),\r
- &yyvs1, size * sizeof (*yyvsp),\r
- &yyls1, size * sizeof (*yylsp),\r
- &yystacksize);\r
-#else\r
- yyoverflow("parser stack overflow",\r
- &yyss1, size * sizeof (*yyssp),\r
- &yyvs1, size * sizeof (*yyvsp),\r
- &yystacksize);\r
-#endif\r
-\r
- yyss = yyss1; yyvs = yyvs1;\r
-#ifdef YYLSP_NEEDED\r
- yyls = yyls1;\r
-#endif\r
-#else /* no yyoverflow */\r
- /* Extend the stack our own way. */\r
- if (yystacksize >= YYMAXDEPTH)\r
- {\r
- yyerror("parser stack overflow");\r
- return 2;\r
- }\r
- yystacksize *= 2;\r
- if (yystacksize > YYMAXDEPTH)\r
- yystacksize = YYMAXDEPTH;\r
- yyss = (short *) alloca (yystacksize * sizeof (*yyssp));\r
- __yy_memcpy ((char *)yyss1, (char *)yyss, size * sizeof (*yyssp));\r
- yyvs = (YYSTYPE *) alloca (yystacksize * sizeof (*yyvsp));\r
- __yy_memcpy ((char *)yyvs1, (char *)yyvs, size * sizeof (*yyvsp));\r
-#ifdef YYLSP_NEEDED\r
- yyls = (YYLTYPE *) alloca (yystacksize * sizeof (*yylsp));\r
- __yy_memcpy ((char *)yyls1, (char *)yyls, size * sizeof (*yylsp));\r
-#endif\r
-#endif /* no yyoverflow */\r
-\r
- yyssp = yyss + size - 1;\r
- yyvsp = yyvs + size - 1;\r
-#ifdef YYLSP_NEEDED\r
- yylsp = yyls + size - 1;\r
-#endif\r
-\r
-#if YYDEBUG != 0\r
- if (yydebug)\r
- fprintf(stderr, "Stack size increased to %d\n", yystacksize);\r
-#endif\r
-\r
- if (yyssp >= yyss + yystacksize - 1)\r
- YYABORT;\r
- }\r
-\r
-#if YYDEBUG != 0\r
- if (yydebug)\r
- fprintf(stderr, "Entering state %d\n", yystate);\r
-#endif\r
-\r
- goto yybackup;\r
- yybackup:\r
-\r
-/* Do appropriate processing given the current state. */\r
-/* Read a lookahead token if we need one and don't already have one. */\r
-/* yyresume: */\r
-\r
- /* First try to decide what to do without reference to lookahead token. */\r
-\r
- yyn = yypact[yystate];\r
- if (yyn == YYFLAG)\r
- goto yydefault;\r
-\r
- /* Not known => get a lookahead token if don't already have one. */\r
-\r
- /* yychar is either YYEMPTY or YYEOF\r
- or a valid token in external form. */\r
-\r
- if (yychar == YYEMPTY)\r
- {\r
-#if YYDEBUG != 0\r
- if (yydebug)\r
- fprintf(stderr, "Reading a token: ");\r
-#endif\r
- yychar = YYLEX;\r
- }\r
-\r
- /* Convert token to internal form (in yychar1) for indexing tables with */\r
-\r
- if (yychar <= 0) /* This means end of input. */\r
- {\r
- yychar1 = 0;\r
- yychar = YYEOF; /* Don't call YYLEX any more */\r
-\r
-#if YYDEBUG != 0\r
- if (yydebug)\r
- fprintf(stderr, "Now at end of input.\n");\r
-#endif\r
- }\r
- else\r
- {\r
- yychar1 = YYTRANSLATE(yychar);\r
-\r
-#if YYDEBUG != 0\r
- if (yydebug)\r
- {\r
- fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);\r
- /* Give the individual parser a way to print the precise meaning\r
- of a token, for further debugging info. */\r
-#ifdef YYPRINT\r
- YYPRINT (stderr, yychar, yylval);\r
-#endif\r
- fprintf (stderr, ")\n");\r
- }\r
-#endif\r
- }\r
-\r
- yyn += yychar1;\r
- if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)\r
- goto yydefault;\r
-\r
- yyn = yytable[yyn];\r
-\r
- /* yyn is what to do for this token type in this state.\r
- Negative => reduce, -yyn is rule number.\r
- Positive => shift, yyn is new state.\r
- New state is final state => don't bother to shift,\r
- just return success.\r
- 0, or most negative number => error. */\r
-\r
- if (yyn < 0)\r
- {\r
- if (yyn == YYFLAG)\r
- goto yyerrlab;\r
- yyn = -yyn;\r
- goto yyreduce;\r
- }\r
- else if (yyn == 0)\r
- goto yyerrlab;\r
-\r
- if (yyn == YYFINAL)\r
- YYACCEPT;\r
-\r
- /* Shift the lookahead token. */\r
-\r
-#if YYDEBUG != 0\r
- if (yydebug)\r
- fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);\r
-#endif\r
-\r
- /* Discard the token being shifted unless it is eof. */\r
- if (yychar != YYEOF)\r
- yychar = YYEMPTY;\r
-\r
- *++yyvsp = yylval;\r
-#ifdef YYLSP_NEEDED\r
- *++yylsp = yylloc;\r
-#endif\r
-\r
- /* count tokens shifted since error; after three, turn off error status. */\r
- if (yyerrstatus) yyerrstatus--;\r
-\r
- yystate = yyn;\r
- goto yynewstate;\r
-\r
-/* Do the default action for the current state. */\r
-yydefault:\r
-\r
- yyn = yydefact[yystate];\r
- if (yyn == 0)\r
- goto yyerrlab;\r
-\r
-/* Do a reduction. yyn is the number of a rule to reduce with. */\r
-yyreduce:\r
- yylen = yyr2[yyn];\r
- if (yylen > 0)\r
- yyval = yyvsp[1-yylen]; /* implement default value of the action */\r
-\r
-#if YYDEBUG != 0\r
- if (yydebug)\r
- {\r
- int i;\r
-\r
- fprintf (stderr, "Reducing via rule %d (line %d), ",\r
- yyn, yyrline[yyn]);\r
-\r
- /* Print the symbols being reduced, and their result. */\r
- for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)\r
- fprintf (stderr, "%s ", yytname[yyrhs[i]]);\r
- fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);\r
- }\r
-#endif\r
-\r
-$ /* the action file gets copied in in place of this dollarsign */\r
- yyvsp -= yylen;\r
- yyssp -= yylen;\r
-#ifdef YYLSP_NEEDED\r
- yylsp -= yylen;\r
-#endif\r
-\r
-#if YYDEBUG != 0\r
- if (yydebug)\r
- {\r
- short *ssp1 = yyss - 1;\r
- fprintf (stderr, "state stack now");\r
- while (ssp1 != yyssp)\r
- fprintf (stderr, " %d", *++ssp1);\r
- fprintf (stderr, "\n");\r
- }\r
-#endif\r
-\r
- *++yyvsp = yyval;\r
-\r
-#ifdef YYLSP_NEEDED\r
- yylsp++;\r
- if (yylen == 0)\r
- {\r
- yylsp->first_line = yylloc.first_line;\r
- yylsp->first_column = yylloc.first_column;\r
- yylsp->last_line = (yylsp-1)->last_line;\r
- yylsp->last_column = (yylsp-1)->last_column;\r
- yylsp->text = 0;\r
- }\r
- else\r
- {\r
- yylsp->last_line = (yylsp+yylen-1)->last_line;\r
- yylsp->last_column = (yylsp+yylen-1)->last_column;\r
- }\r
-#endif\r
-\r
- /* Now "shift" the result of the reduction.\r
- Determine what state that goes to,\r
- based on the state we popped back to\r
- and the rule number reduced by. */\r
-\r
- yyn = yyr1[yyn];\r
-\r
- yystate = yypgoto[yyn - YYNTBASE] + *yyssp;\r
- if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)\r
- yystate = yytable[yystate];\r
- else\r
- yystate = yydefgoto[yyn - YYNTBASE];\r
-\r
- goto yynewstate;\r
-\r
-yyerrlab: /* here on detecting error */\r
-\r
- if (! yyerrstatus)\r
- /* If not already recovering from an error, report this error. */\r
- {\r
- ++yynerrs;\r
-\r
-#ifdef YYERROR_VERBOSE\r
- yyn = yypact[yystate];\r
-\r
- if (yyn > YYFLAG && yyn < YYLAST)\r
- {\r
- int size = 0;\r
- char *msg;\r
- int x, count;\r
-\r
- count = 0;\r
- /* Start X at -yyn if nec to avoid negative indexes in yycheck. */\r
- for (x = (yyn < 0 ? -yyn : 0);\r
- x < (sizeof(yytname) / sizeof(char *)); x++)\r
- if (yycheck[x + yyn] == x)\r
- size += strlen(yytname[x]) + 15, count++;\r
- msg = (char *) malloc(size + 15);\r
- if (msg != 0)\r
- {\r
- strcpy(msg, "parse error");\r
-\r
- if (count < 5)\r
- {\r
- count = 0;\r
- for (x = (yyn < 0 ? -yyn : 0);\r
- x < (sizeof(yytname) / sizeof(char *)); x++)\r
- if (yycheck[x + yyn] == x)\r
- {\r
- strcat(msg, count == 0 ? ", expecting `" : " or `");\r
- strcat(msg, yytname[x]);\r
- strcat(msg, "'");\r
- count++;\r
- }\r
- }\r
- yyerror(msg);\r
- free(msg);\r
- }\r
- else\r
- yyerror ("parse error; also virtual memory exceeded");\r
- }\r
- else\r
-#endif /* YYERROR_VERBOSE */\r
- yyerror("parse error");\r
- }\r
-\r
- goto yyerrlab1;\r
-yyerrlab1: /* here on error raised explicitly by an action */\r
-\r
- if (yyerrstatus == 3)\r
- {\r
- /* if just tried and failed to reuse lookahead token after an error, discard it. */\r
-\r
- /* return failure if at end of input */\r
- if (yychar == YYEOF)\r
- YYABORT;\r
-\r
-#if YYDEBUG != 0\r
- if (yydebug)\r
- fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);\r
-#endif\r
-\r
- yychar = YYEMPTY;\r
- }\r
-\r
- /* Else will try to reuse lookahead token\r
- after shifting the error token. */\r
-\r
- yyerrstatus = 3; /* Each real token shifted decrements this */\r
-\r
- goto yyerrhandle;\r
-\r
-yyerrdefault: /* current state does not do anything special for the error token. */\r
-\r
-#if 0\r
- /* This is wrong; only states that explicitly want error tokens\r
- should shift them. */\r
- yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/\r
- if (yyn) goto yydefault;\r
-#endif\r
-\r
-yyerrpop: /* pop the current state because it cannot handle the error token */\r
-\r
- if (yyssp == yyss) YYABORT;\r
- yyvsp--;\r
- yystate = *--yyssp;\r
-#ifdef YYLSP_NEEDED\r
- yylsp--;\r
-#endif\r
-\r
-#if YYDEBUG != 0\r
- if (yydebug)\r
- {\r
- short *ssp1 = yyss - 1;\r
- fprintf (stderr, "Error: state stack now");\r
- while (ssp1 != yyssp)\r
- fprintf (stderr, " %d", *++ssp1);\r
- fprintf (stderr, "\n");\r
- }\r
-#endif\r
-\r
-yyerrhandle:\r
-\r
- yyn = yypact[yystate];\r
- if (yyn == YYFLAG)\r
- goto yyerrdefault;\r
-\r
- yyn += YYTERROR;\r
- if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)\r
- goto yyerrdefault;\r
-\r
- yyn = yytable[yyn];\r
- if (yyn < 0)\r
- {\r
- if (yyn == YYFLAG)\r
- goto yyerrpop;\r
- yyn = -yyn;\r
- goto yyreduce;\r
- }\r
- else if (yyn == 0)\r
- goto yyerrpop;\r
-\r
- if (yyn == YYFINAL)\r
- YYACCEPT;\r
-\r
-#if YYDEBUG != 0\r
- if (yydebug)\r
- fprintf(stderr, "Shifting error token, ");\r
-#endif\r
-\r
- *++yyvsp = yylval;\r
-#ifdef YYLSP_NEEDED\r
- *++yylsp = yylloc;\r
-#endif\r
-\r
- yystate = yyn;\r
- goto yynewstate;\r
-}\r
--- /dev/null
+## Copyright (C) 2002, 2005-2012 Free Software Foundation, Inc.\r
+\r
+# This program is free software: you can redistribute it and/or modify\r
+# it under the terms of the GNU General Public License as published by\r
+# the Free Software Foundation, either version 3 of the License, or\r
+# (at your option) any later version.\r
+#\r
+# This program is distributed in the hope that it will be useful,\r
+# but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
+# GNU General Public License for more details.\r
+#\r
+# You should have received a copy of the GNU General Public License\r
+# along with this program. If not, see <http://www.gnu.org/licenses/>.\r
+\r
+dist_pkgdata_DATA = README bison.m4 \\r
+ c-like.m4 \\r
+ c-skel.m4 c.m4 yacc.c glr.c \\r
+ c++-skel.m4 c++.m4 location.cc lalr1.cc glr.cc stack.hh \\r
+ java-skel.m4 java.m4 lalr1.java\r
+\r
+m4sugardir = $(pkgdatadir)/m4sugar\r
+dist_m4sugar_DATA = m4sugar/m4sugar.m4 m4sugar/foreach.m4\r
+\r
+xsltdir = $(pkgdatadir)/xslt\r
+dist_xslt_DATA = \\r
+ xslt/bison.xsl \\r
+ xslt/xml2dot.xsl \\r
+ xslt/xml2text.xsl \\r
+ xslt/xml2xhtml.xsl\r
--- /dev/null
+# Makefile.in generated by automake 1.12.5 from Makefile.am.\r
+# @configure_input@\r
+\r
+# Copyright (C) 1994-2012 Free Software Foundation, Inc.\r
+\r
+# This Makefile.in is free software; the Free Software Foundation\r
+# gives unlimited permission to copy and/or distribute it,\r
+# with or without modifications, as long as this notice is preserved.\r
+\r
+# This program is distributed in the hope that it will be useful,\r
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without\r
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A\r
+# PARTICULAR PURPOSE.\r
+\r
+@SET_MAKE@\r
+\r
+# This program is free software: you can redistribute it and/or modify\r
+# it under the terms of the GNU General Public License as published by\r
+# the Free Software Foundation, either version 3 of the License, or\r
+# (at your option) any later version.\r
+#\r
+# This program is distributed in the hope that it will be useful,\r
+# but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
+# GNU General Public License for more details.\r
+#\r
+# You should have received a copy of the GNU General Public License\r
+# along with this program. If not, see <http://www.gnu.org/licenses/>.\r
+\r
+VPATH = @srcdir@\r
+am__make_dryrun = \\r
+ { \\r
+ am__dry=no; \\r
+ case $$MAKEFLAGS in \\r
+ *\\[\ \ ]*) \\r
+ echo 'am--echo: ; @echo "AM" OK' | $(MAKE) -f - 2>/dev/null \\r
+ | grep '^AM OK$$' >/dev/null || am__dry=yes;; \\r
+ *) \\r
+ for am__flg in $$MAKEFLAGS; do \\r
+ case $$am__flg in \\r
+ *=*|--*) ;; \\r
+ *n*) am__dry=yes; break;; \\r
+ esac; \\r
+ done;; \\r
+ esac; \\r
+ test $$am__dry = yes; \\r
+ }\r
+pkgdatadir = $(datadir)/@PACKAGE@\r
+pkgincludedir = $(includedir)/@PACKAGE@\r
+pkglibdir = $(libdir)/@PACKAGE@\r
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd\r
+install_sh_DATA = $(install_sh) -c -m 644\r
+install_sh_PROGRAM = $(install_sh) -c\r
+install_sh_SCRIPT = $(install_sh) -c\r
+INSTALL_HEADER = $(INSTALL_DATA)\r
+transform = $(program_transform_name)\r
+NORMAL_INSTALL = :\r
+PRE_INSTALL = :\r
+POST_INSTALL = :\r
+NORMAL_UNINSTALL = :\r
+PRE_UNINSTALL = :\r
+POST_UNINSTALL = :\r
+build_triplet = @build@\r
+host_triplet = @host@\r
+subdir = data\r
+DIST_COMMON = README $(dist_m4sugar_DATA) $(dist_pkgdata_DATA) \\r
+ $(dist_xslt_DATA) $(srcdir)/Makefile.am $(srcdir)/Makefile.in\r
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4\r
+am__aclocal_m4_deps = $(top_srcdir)/m4/00gnulib.m4 \\r
+ $(top_srcdir)/m4/alloca.m4 $(top_srcdir)/m4/asm-underscore.m4 \\r
+ $(top_srcdir)/m4/assert.m4 $(top_srcdir)/m4/bison-i18n.m4 \\r
+ $(top_srcdir)/m4/c-working.m4 $(top_srcdir)/m4/calloc.m4 \\r
+ $(top_srcdir)/m4/close-stream.m4 $(top_srcdir)/m4/close.m4 \\r
+ $(top_srcdir)/m4/closeout.m4 $(top_srcdir)/m4/codeset.m4 \\r
+ $(top_srcdir)/m4/config-h.m4 $(top_srcdir)/m4/configmake.m4 \\r
+ $(top_srcdir)/m4/cxx.m4 $(top_srcdir)/m4/dirname.m4 \\r
+ $(top_srcdir)/m4/dmalloc.m4 \\r
+ $(top_srcdir)/m4/double-slash-root.m4 $(top_srcdir)/m4/dup2.m4 \\r
+ $(top_srcdir)/m4/environ.m4 $(top_srcdir)/m4/errno_h.m4 \\r
+ $(top_srcdir)/m4/error.m4 $(top_srcdir)/m4/exponentd.m4 \\r
+ $(top_srcdir)/m4/exponentf.m4 $(top_srcdir)/m4/exponentl.m4 \\r
+ $(top_srcdir)/m4/extensions.m4 \\r
+ $(top_srcdir)/m4/extern-inline.m4 \\r
+ $(top_srcdir)/m4/fatal-signal.m4 $(top_srcdir)/m4/fcntl-o.m4 \\r
+ $(top_srcdir)/m4/fcntl.m4 $(top_srcdir)/m4/fcntl_h.m4 \\r
+ $(top_srcdir)/m4/flex.m4 $(top_srcdir)/m4/float_h.m4 \\r
+ $(top_srcdir)/m4/fopen.m4 $(top_srcdir)/m4/fpending.m4 \\r
+ $(top_srcdir)/m4/fpieee.m4 $(top_srcdir)/m4/fprintf-posix.m4 \\r
+ $(top_srcdir)/m4/frexp.m4 $(top_srcdir)/m4/frexpl.m4 \\r
+ $(top_srcdir)/m4/fseterr.m4 $(top_srcdir)/m4/fstat.m4 \\r
+ $(top_srcdir)/m4/getdelim.m4 $(top_srcdir)/m4/getdtablesize.m4 \\r
+ $(top_srcdir)/m4/getline.m4 $(top_srcdir)/m4/getopt.m4 \\r
+ $(top_srcdir)/m4/gettext.m4 $(top_srcdir)/m4/glibc21.m4 \\r
+ $(top_srcdir)/m4/gnulib-common.m4 \\r
+ $(top_srcdir)/m4/gnulib-comp.m4 $(top_srcdir)/m4/iconv.m4 \\r
+ $(top_srcdir)/m4/include_next.m4 \\r
+ $(top_srcdir)/m4/intlmacosx.m4 $(top_srcdir)/m4/intmax_t.m4 \\r
+ $(top_srcdir)/m4/inttypes-pri.m4 $(top_srcdir)/m4/inttypes.m4 \\r
+ $(top_srcdir)/m4/inttypes_h.m4 $(top_srcdir)/m4/isnan.m4 \\r
+ $(top_srcdir)/m4/isnand.m4 $(top_srcdir)/m4/isnanf.m4 \\r
+ $(top_srcdir)/m4/isnanl.m4 $(top_srcdir)/m4/iswblank.m4 \\r
+ $(top_srcdir)/m4/javacomp.m4 $(top_srcdir)/m4/javaexec.m4 \\r
+ $(top_srcdir)/m4/largefile.m4 $(top_srcdir)/m4/ldexp.m4 \\r
+ $(top_srcdir)/m4/ldexpl.m4 $(top_srcdir)/m4/lib-ld.m4 \\r
+ $(top_srcdir)/m4/lib-link.m4 $(top_srcdir)/m4/lib-prefix.m4 \\r
+ $(top_srcdir)/m4/libunistring-base.m4 \\r
+ $(top_srcdir)/m4/localcharset.m4 $(top_srcdir)/m4/locale-fr.m4 \\r
+ $(top_srcdir)/m4/locale-ja.m4 $(top_srcdir)/m4/locale-zh.m4 \\r
+ $(top_srcdir)/m4/lock.m4 $(top_srcdir)/m4/longlong.m4 \\r
+ $(top_srcdir)/m4/m4.m4 $(top_srcdir)/m4/malloc.m4 \\r
+ $(top_srcdir)/m4/math_h.m4 $(top_srcdir)/m4/mbchar.m4 \\r
+ $(top_srcdir)/m4/mbiter.m4 $(top_srcdir)/m4/mbrtowc.m4 \\r
+ $(top_srcdir)/m4/mbsinit.m4 $(top_srcdir)/m4/mbstate_t.m4 \\r
+ $(top_srcdir)/m4/mbswidth.m4 $(top_srcdir)/m4/memchr.m4 \\r
+ $(top_srcdir)/m4/mmap-anon.m4 $(top_srcdir)/m4/mode_t.m4 \\r
+ $(top_srcdir)/m4/msvc-inval.m4 \\r
+ $(top_srcdir)/m4/msvc-nothrow.m4 $(top_srcdir)/m4/multiarch.m4 \\r
+ $(top_srcdir)/m4/nls.m4 $(top_srcdir)/m4/nocrash.m4 \\r
+ $(top_srcdir)/m4/obstack-printf.m4 $(top_srcdir)/m4/off_t.m4 \\r
+ $(top_srcdir)/m4/open.m4 $(top_srcdir)/m4/pathmax.m4 \\r
+ $(top_srcdir)/m4/perror.m4 $(top_srcdir)/m4/pipe2.m4 \\r
+ $(top_srcdir)/m4/po.m4 $(top_srcdir)/m4/posix_spawn.m4 \\r
+ $(top_srcdir)/m4/printf-frexp.m4 \\r
+ $(top_srcdir)/m4/printf-frexpl.m4 \\r
+ $(top_srcdir)/m4/printf-posix-rpl.m4 \\r
+ $(top_srcdir)/m4/printf.m4 $(top_srcdir)/m4/progtest.m4 \\r
+ $(top_srcdir)/m4/quote.m4 $(top_srcdir)/m4/quotearg.m4 \\r
+ $(top_srcdir)/m4/raise.m4 $(top_srcdir)/m4/rawmemchr.m4 \\r
+ $(top_srcdir)/m4/realloc.m4 $(top_srcdir)/m4/sched_h.m4 \\r
+ $(top_srcdir)/m4/setenv.m4 $(top_srcdir)/m4/sig_atomic_t.m4 \\r
+ $(top_srcdir)/m4/sigaction.m4 $(top_srcdir)/m4/signal_h.m4 \\r
+ $(top_srcdir)/m4/signalblocking.m4 $(top_srcdir)/m4/signbit.m4 \\r
+ $(top_srcdir)/m4/size_max.m4 \\r
+ $(top_srcdir)/m4/snprintf-posix.m4 \\r
+ $(top_srcdir)/m4/snprintf.m4 $(top_srcdir)/m4/spawn-pipe.m4 \\r
+ $(top_srcdir)/m4/spawn_h.m4 $(top_srcdir)/m4/sprintf-posix.m4 \\r
+ $(top_srcdir)/m4/ssize_t.m4 $(top_srcdir)/m4/stat.m4 \\r
+ $(top_srcdir)/m4/stdbool.m4 $(top_srcdir)/m4/stddef_h.m4 \\r
+ $(top_srcdir)/m4/stdint.m4 $(top_srcdir)/m4/stdint_h.m4 \\r
+ $(top_srcdir)/m4/stdio_h.m4 $(top_srcdir)/m4/stdlib_h.m4 \\r
+ $(top_srcdir)/m4/stpcpy.m4 $(top_srcdir)/m4/strchrnul.m4 \\r
+ $(top_srcdir)/m4/strdup.m4 $(top_srcdir)/m4/strerror.m4 \\r
+ $(top_srcdir)/m4/strerror_r.m4 $(top_srcdir)/m4/string_h.m4 \\r
+ $(top_srcdir)/m4/strndup.m4 $(top_srcdir)/m4/strnlen.m4 \\r
+ $(top_srcdir)/m4/strtoul.m4 $(top_srcdir)/m4/strverscmp.m4 \\r
+ $(top_srcdir)/m4/sys_socket_h.m4 \\r
+ $(top_srcdir)/m4/sys_stat_h.m4 $(top_srcdir)/m4/sys_types_h.m4 \\r
+ $(top_srcdir)/m4/sys_wait_h.m4 $(top_srcdir)/m4/threadlib.m4 \\r
+ $(top_srcdir)/m4/time_h.m4 $(top_srcdir)/m4/timevar.m4 \\r
+ $(top_srcdir)/m4/unistd-safer.m4 $(top_srcdir)/m4/unistd_h.m4 \\r
+ $(top_srcdir)/m4/unlocked-io.m4 $(top_srcdir)/m4/vasnprintf.m4 \\r
+ $(top_srcdir)/m4/vfprintf-posix.m4 \\r
+ $(top_srcdir)/m4/vsnprintf-posix.m4 \\r
+ $(top_srcdir)/m4/vsnprintf.m4 \\r
+ $(top_srcdir)/m4/vsprintf-posix.m4 \\r
+ $(top_srcdir)/m4/wait-process.m4 $(top_srcdir)/m4/waitpid.m4 \\r
+ $(top_srcdir)/m4/warn-on-use.m4 $(top_srcdir)/m4/warnings.m4 \\r
+ $(top_srcdir)/m4/wchar_h.m4 $(top_srcdir)/m4/wchar_t.m4 \\r
+ $(top_srcdir)/m4/wctype_h.m4 $(top_srcdir)/m4/wcwidth.m4 \\r
+ $(top_srcdir)/m4/wint_t.m4 $(top_srcdir)/m4/xalloc.m4 \\r
+ $(top_srcdir)/m4/xsize.m4 $(top_srcdir)/m4/xstrndup.m4 \\r
+ $(top_srcdir)/configure.ac\r
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \\r
+ $(ACLOCAL_M4)\r
+mkinstalldirs = $(install_sh) -d\r
+CONFIG_HEADER = $(top_builddir)/lib/config.h\r
+CONFIG_CLEAN_FILES =\r
+CONFIG_CLEAN_VPATH_FILES =\r
+AM_V_P = $(am__v_P_@AM_V@)\r
+am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)\r
+am__v_P_0 = false\r
+am__v_P_1 = :\r
+AM_V_GEN = $(am__v_GEN_@AM_V@)\r
+am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)\r
+am__v_GEN_0 = @echo " GEN " $@;\r
+am__v_GEN_1 = \r
+AM_V_at = $(am__v_at_@AM_V@)\r
+am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)\r
+am__v_at_0 = @\r
+am__v_at_1 = \r
+SOURCES =\r
+DIST_SOURCES =\r
+am__can_run_installinfo = \\r
+ case $$AM_UPDATE_INFO_DIR in \\r
+ n|no|NO) false;; \\r
+ *) (install-info --version) >/dev/null 2>&1;; \\r
+ esac\r
+am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;\r
+am__vpath_adj = case $$p in \\r
+ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \\r
+ *) f=$$p;; \\r
+ esac;\r
+am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;\r
+am__install_max = 40\r
+am__nobase_strip_setup = \\r
+ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`\r
+am__nobase_strip = \\r
+ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"\r
+am__nobase_list = $(am__nobase_strip_setup); \\r
+ for p in $$list; do echo "$$p $$p"; done | \\r
+ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \\r
+ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \\r
+ if (++n[$$2] == $(am__install_max)) \\r
+ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \\r
+ END { for (dir in files) print dir, files[dir] }'\r
+am__base_list = \\r
+ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \\r
+ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'\r
+am__uninstall_files_from_dir = { \\r
+ test -z "$$files" \\r
+ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \\r
+ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \\r
+ $(am__cd) "$$dir" && rm -f $$files; }; \\r
+ }\r
+am__installdirs = "$(DESTDIR)$(m4sugardir)" "$(DESTDIR)$(pkgdatadir)" \\r
+ "$(DESTDIR)$(xsltdir)"\r
+DATA = $(dist_m4sugar_DATA) $(dist_pkgdata_DATA) $(dist_xslt_DATA)\r
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)\r
+pkglibexecdir = @pkglibexecdir@\r
+ACLOCAL = @ACLOCAL@\r
+ALLOCA = @ALLOCA@\r
+ALLOCA_H = @ALLOCA_H@\r
+AMTAR = @AMTAR@\r
+AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@\r
+APPLE_UNIVERSAL_BUILD = @APPLE_UNIVERSAL_BUILD@\r
+AR = @AR@\r
+ARFLAGS = @ARFLAGS@\r
+ASM_SYMBOL_PREFIX = @ASM_SYMBOL_PREFIX@\r
+AUTOCONF = @AUTOCONF@\r
+AUTOHEADER = @AUTOHEADER@\r
+AUTOM4TE = @AUTOM4TE@\r
+AUTOMAKE = @AUTOMAKE@\r
+AWK = @AWK@\r
+BISON_CXX_WORKS = @BISON_CXX_WORKS@\r
+BISON_C_WORKS = @BISON_C_WORKS@\r
+BISON_LOCALEDIR = @BISON_LOCALEDIR@\r
+BITSIZEOF_PTRDIFF_T = @BITSIZEOF_PTRDIFF_T@\r
+BITSIZEOF_SIG_ATOMIC_T = @BITSIZEOF_SIG_ATOMIC_T@\r
+BITSIZEOF_SIZE_T = @BITSIZEOF_SIZE_T@\r
+BITSIZEOF_WCHAR_T = @BITSIZEOF_WCHAR_T@\r
+BITSIZEOF_WINT_T = @BITSIZEOF_WINT_T@\r
+CC = @CC@\r
+CCDEPMODE = @CCDEPMODE@\r
+CFLAGS = @CFLAGS@\r
+CLASSPATH = @CLASSPATH@\r
+CLASSPATH_SEPARATOR = @CLASSPATH_SEPARATOR@\r
+CONFIG_INCLUDE = @CONFIG_INCLUDE@\r
+CONF_JAVA = @CONF_JAVA@\r
+CONF_JAVAC = @CONF_JAVAC@\r
+CPP = @CPP@\r
+CPPFLAGS = @CPPFLAGS@\r
+CXX = @CXX@\r
+CXXDEPMODE = @CXXDEPMODE@\r
+CXXFLAGS = @CXXFLAGS@\r
+CXX_COMPILER_POSIXLY_CORRECT = @CXX_COMPILER_POSIXLY_CORRECT@\r
+CYGPATH_W = @CYGPATH_W@\r
+C_COMPILER_POSIXLY_CORRECT = @C_COMPILER_POSIXLY_CORRECT@\r
+DEFS = @DEFS@\r
+DEPDIR = @DEPDIR@\r
+DOT = @DOT@\r
+ECHO_C = @ECHO_C@\r
+ECHO_N = @ECHO_N@\r
+ECHO_T = @ECHO_T@\r
+EGREP = @EGREP@\r
+EMULTIHOP_HIDDEN = @EMULTIHOP_HIDDEN@\r
+EMULTIHOP_VALUE = @EMULTIHOP_VALUE@\r
+ENOLINK_HIDDEN = @ENOLINK_HIDDEN@\r
+ENOLINK_VALUE = @ENOLINK_VALUE@\r
+EOVERFLOW_HIDDEN = @EOVERFLOW_HIDDEN@\r
+EOVERFLOW_VALUE = @EOVERFLOW_VALUE@\r
+ERRNO_H = @ERRNO_H@\r
+EXEEXT = @EXEEXT@\r
+FLOAT_H = @FLOAT_H@\r
+GCC = @GCC@\r
+GETOPT_H = @GETOPT_H@\r
+GETTEXT_MACRO_VERSION = @GETTEXT_MACRO_VERSION@\r
+GLIBC21 = @GLIBC21@\r
+GMSGFMT = @GMSGFMT@\r
+GMSGFMT_015 = @GMSGFMT_015@\r
+GNULIB_ACOSF = @GNULIB_ACOSF@\r
+GNULIB_ACOSL = @GNULIB_ACOSL@\r
+GNULIB_ASINF = @GNULIB_ASINF@\r
+GNULIB_ASINL = @GNULIB_ASINL@\r
+GNULIB_ATAN2F = @GNULIB_ATAN2F@\r
+GNULIB_ATANF = @GNULIB_ATANF@\r
+GNULIB_ATANL = @GNULIB_ATANL@\r
+GNULIB_ATOLL = @GNULIB_ATOLL@\r
+GNULIB_BTOWC = @GNULIB_BTOWC@\r
+GNULIB_CALLOC_POSIX = @GNULIB_CALLOC_POSIX@\r
+GNULIB_CANONICALIZE_FILE_NAME = @GNULIB_CANONICALIZE_FILE_NAME@\r
+GNULIB_CBRT = @GNULIB_CBRT@\r
+GNULIB_CBRTF = @GNULIB_CBRTF@\r
+GNULIB_CBRTL = @GNULIB_CBRTL@\r
+GNULIB_CEIL = @GNULIB_CEIL@\r
+GNULIB_CEILF = @GNULIB_CEILF@\r
+GNULIB_CEILL = @GNULIB_CEILL@\r
+GNULIB_CHDIR = @GNULIB_CHDIR@\r
+GNULIB_CHOWN = @GNULIB_CHOWN@\r
+GNULIB_CLOSE = @GNULIB_CLOSE@\r
+GNULIB_COPYSIGN = @GNULIB_COPYSIGN@\r
+GNULIB_COPYSIGNF = @GNULIB_COPYSIGNF@\r
+GNULIB_COPYSIGNL = @GNULIB_COPYSIGNL@\r
+GNULIB_COSF = @GNULIB_COSF@\r
+GNULIB_COSHF = @GNULIB_COSHF@\r
+GNULIB_COSL = @GNULIB_COSL@\r
+GNULIB_DPRINTF = @GNULIB_DPRINTF@\r
+GNULIB_DUP = @GNULIB_DUP@\r
+GNULIB_DUP2 = @GNULIB_DUP2@\r
+GNULIB_DUP3 = @GNULIB_DUP3@\r
+GNULIB_ENVIRON = @GNULIB_ENVIRON@\r
+GNULIB_EUIDACCESS = @GNULIB_EUIDACCESS@\r
+GNULIB_EXP2 = @GNULIB_EXP2@\r
+GNULIB_EXP2F = @GNULIB_EXP2F@\r
+GNULIB_EXP2L = @GNULIB_EXP2L@\r
+GNULIB_EXPF = @GNULIB_EXPF@\r
+GNULIB_EXPL = @GNULIB_EXPL@\r
+GNULIB_EXPM1 = @GNULIB_EXPM1@\r
+GNULIB_EXPM1F = @GNULIB_EXPM1F@\r
+GNULIB_EXPM1L = @GNULIB_EXPM1L@\r
+GNULIB_FABSF = @GNULIB_FABSF@\r
+GNULIB_FABSL = @GNULIB_FABSL@\r
+GNULIB_FACCESSAT = @GNULIB_FACCESSAT@\r
+GNULIB_FCHDIR = @GNULIB_FCHDIR@\r
+GNULIB_FCHMODAT = @GNULIB_FCHMODAT@\r
+GNULIB_FCHOWNAT = @GNULIB_FCHOWNAT@\r
+GNULIB_FCLOSE = @GNULIB_FCLOSE@\r
+GNULIB_FCNTL = @GNULIB_FCNTL@\r
+GNULIB_FDATASYNC = @GNULIB_FDATASYNC@\r
+GNULIB_FDOPEN = @GNULIB_FDOPEN@\r
+GNULIB_FFLUSH = @GNULIB_FFLUSH@\r
+GNULIB_FFSL = @GNULIB_FFSL@\r
+GNULIB_FFSLL = @GNULIB_FFSLL@\r
+GNULIB_FGETC = @GNULIB_FGETC@\r
+GNULIB_FGETS = @GNULIB_FGETS@\r
+GNULIB_FLOOR = @GNULIB_FLOOR@\r
+GNULIB_FLOORF = @GNULIB_FLOORF@\r
+GNULIB_FLOORL = @GNULIB_FLOORL@\r
+GNULIB_FMA = @GNULIB_FMA@\r
+GNULIB_FMAF = @GNULIB_FMAF@\r
+GNULIB_FMAL = @GNULIB_FMAL@\r
+GNULIB_FMOD = @GNULIB_FMOD@\r
+GNULIB_FMODF = @GNULIB_FMODF@\r
+GNULIB_FMODL = @GNULIB_FMODL@\r
+GNULIB_FOPEN = @GNULIB_FOPEN@\r
+GNULIB_FPRINTF = @GNULIB_FPRINTF@\r
+GNULIB_FPRINTF_POSIX = @GNULIB_FPRINTF_POSIX@\r
+GNULIB_FPURGE = @GNULIB_FPURGE@\r
+GNULIB_FPUTC = @GNULIB_FPUTC@\r
+GNULIB_FPUTS = @GNULIB_FPUTS@\r
+GNULIB_FREAD = @GNULIB_FREAD@\r
+GNULIB_FREOPEN = @GNULIB_FREOPEN@\r
+GNULIB_FREXP = @GNULIB_FREXP@\r
+GNULIB_FREXPF = @GNULIB_FREXPF@\r
+GNULIB_FREXPL = @GNULIB_FREXPL@\r
+GNULIB_FSCANF = @GNULIB_FSCANF@\r
+GNULIB_FSEEK = @GNULIB_FSEEK@\r
+GNULIB_FSEEKO = @GNULIB_FSEEKO@\r
+GNULIB_FSTAT = @GNULIB_FSTAT@\r
+GNULIB_FSTATAT = @GNULIB_FSTATAT@\r
+GNULIB_FSYNC = @GNULIB_FSYNC@\r
+GNULIB_FTELL = @GNULIB_FTELL@\r
+GNULIB_FTELLO = @GNULIB_FTELLO@\r
+GNULIB_FTRUNCATE = @GNULIB_FTRUNCATE@\r
+GNULIB_FUTIMENS = @GNULIB_FUTIMENS@\r
+GNULIB_FWRITE = @GNULIB_FWRITE@\r
+GNULIB_GETC = @GNULIB_GETC@\r
+GNULIB_GETCHAR = @GNULIB_GETCHAR@\r
+GNULIB_GETCWD = @GNULIB_GETCWD@\r
+GNULIB_GETDELIM = @GNULIB_GETDELIM@\r
+GNULIB_GETDOMAINNAME = @GNULIB_GETDOMAINNAME@\r
+GNULIB_GETDTABLESIZE = @GNULIB_GETDTABLESIZE@\r
+GNULIB_GETGROUPS = @GNULIB_GETGROUPS@\r
+GNULIB_GETHOSTNAME = @GNULIB_GETHOSTNAME@\r
+GNULIB_GETLINE = @GNULIB_GETLINE@\r
+GNULIB_GETLOADAVG = @GNULIB_GETLOADAVG@\r
+GNULIB_GETLOGIN = @GNULIB_GETLOGIN@\r
+GNULIB_GETLOGIN_R = @GNULIB_GETLOGIN_R@\r
+GNULIB_GETPAGESIZE = @GNULIB_GETPAGESIZE@\r
+GNULIB_GETSUBOPT = @GNULIB_GETSUBOPT@\r
+GNULIB_GETUSERSHELL = @GNULIB_GETUSERSHELL@\r
+GNULIB_GL_UNISTD_H_GETOPT = @GNULIB_GL_UNISTD_H_GETOPT@\r
+GNULIB_GRANTPT = @GNULIB_GRANTPT@\r
+GNULIB_GROUP_MEMBER = @GNULIB_GROUP_MEMBER@\r
+GNULIB_HYPOT = @GNULIB_HYPOT@\r
+GNULIB_HYPOTF = @GNULIB_HYPOTF@\r
+GNULIB_HYPOTL = @GNULIB_HYPOTL@\r
+GNULIB_ILOGB = @GNULIB_ILOGB@\r
+GNULIB_ILOGBF = @GNULIB_ILOGBF@\r
+GNULIB_ILOGBL = @GNULIB_ILOGBL@\r
+GNULIB_IMAXABS = @GNULIB_IMAXABS@\r
+GNULIB_IMAXDIV = @GNULIB_IMAXDIV@\r
+GNULIB_ISATTY = @GNULIB_ISATTY@\r
+GNULIB_ISFINITE = @GNULIB_ISFINITE@\r
+GNULIB_ISINF = @GNULIB_ISINF@\r
+GNULIB_ISNAN = @GNULIB_ISNAN@\r
+GNULIB_ISNAND = @GNULIB_ISNAND@\r
+GNULIB_ISNANF = @GNULIB_ISNANF@\r
+GNULIB_ISNANL = @GNULIB_ISNANL@\r
+GNULIB_ISWBLANK = @GNULIB_ISWBLANK@\r
+GNULIB_ISWCTYPE = @GNULIB_ISWCTYPE@\r
+GNULIB_LCHMOD = @GNULIB_LCHMOD@\r
+GNULIB_LCHOWN = @GNULIB_LCHOWN@\r
+GNULIB_LDEXPF = @GNULIB_LDEXPF@\r
+GNULIB_LDEXPL = @GNULIB_LDEXPL@\r
+GNULIB_LINK = @GNULIB_LINK@\r
+GNULIB_LINKAT = @GNULIB_LINKAT@\r
+GNULIB_LOG = @GNULIB_LOG@\r
+GNULIB_LOG10 = @GNULIB_LOG10@\r
+GNULIB_LOG10F = @GNULIB_LOG10F@\r
+GNULIB_LOG10L = @GNULIB_LOG10L@\r
+GNULIB_LOG1P = @GNULIB_LOG1P@\r
+GNULIB_LOG1PF = @GNULIB_LOG1PF@\r
+GNULIB_LOG1PL = @GNULIB_LOG1PL@\r
+GNULIB_LOG2 = @GNULIB_LOG2@\r
+GNULIB_LOG2F = @GNULIB_LOG2F@\r
+GNULIB_LOG2L = @GNULIB_LOG2L@\r
+GNULIB_LOGB = @GNULIB_LOGB@\r
+GNULIB_LOGBF = @GNULIB_LOGBF@\r
+GNULIB_LOGBL = @GNULIB_LOGBL@\r
+GNULIB_LOGF = @GNULIB_LOGF@\r
+GNULIB_LOGL = @GNULIB_LOGL@\r
+GNULIB_LSEEK = @GNULIB_LSEEK@\r
+GNULIB_LSTAT = @GNULIB_LSTAT@\r
+GNULIB_MALLOC_POSIX = @GNULIB_MALLOC_POSIX@\r
+GNULIB_MBRLEN = @GNULIB_MBRLEN@\r
+GNULIB_MBRTOWC = @GNULIB_MBRTOWC@\r
+GNULIB_MBSCASECMP = @GNULIB_MBSCASECMP@\r
+GNULIB_MBSCASESTR = @GNULIB_MBSCASESTR@\r
+GNULIB_MBSCHR = @GNULIB_MBSCHR@\r
+GNULIB_MBSCSPN = @GNULIB_MBSCSPN@\r
+GNULIB_MBSINIT = @GNULIB_MBSINIT@\r
+GNULIB_MBSLEN = @GNULIB_MBSLEN@\r
+GNULIB_MBSNCASECMP = @GNULIB_MBSNCASECMP@\r
+GNULIB_MBSNLEN = @GNULIB_MBSNLEN@\r
+GNULIB_MBSNRTOWCS = @GNULIB_MBSNRTOWCS@\r
+GNULIB_MBSPBRK = @GNULIB_MBSPBRK@\r
+GNULIB_MBSPCASECMP = @GNULIB_MBSPCASECMP@\r
+GNULIB_MBSRCHR = @GNULIB_MBSRCHR@\r
+GNULIB_MBSRTOWCS = @GNULIB_MBSRTOWCS@\r
+GNULIB_MBSSEP = @GNULIB_MBSSEP@\r
+GNULIB_MBSSPN = @GNULIB_MBSSPN@\r
+GNULIB_MBSSTR = @GNULIB_MBSSTR@\r
+GNULIB_MBSTOK_R = @GNULIB_MBSTOK_R@\r
+GNULIB_MBTOWC = @GNULIB_MBTOWC@\r
+GNULIB_MEMCHR = @GNULIB_MEMCHR@\r
+GNULIB_MEMMEM = @GNULIB_MEMMEM@\r
+GNULIB_MEMPCPY = @GNULIB_MEMPCPY@\r
+GNULIB_MEMRCHR = @GNULIB_MEMRCHR@\r
+GNULIB_MKDIRAT = @GNULIB_MKDIRAT@\r
+GNULIB_MKDTEMP = @GNULIB_MKDTEMP@\r
+GNULIB_MKFIFO = @GNULIB_MKFIFO@\r
+GNULIB_MKFIFOAT = @GNULIB_MKFIFOAT@\r
+GNULIB_MKNOD = @GNULIB_MKNOD@\r
+GNULIB_MKNODAT = @GNULIB_MKNODAT@\r
+GNULIB_MKOSTEMP = @GNULIB_MKOSTEMP@\r
+GNULIB_MKOSTEMPS = @GNULIB_MKOSTEMPS@\r
+GNULIB_MKSTEMP = @GNULIB_MKSTEMP@\r
+GNULIB_MKSTEMPS = @GNULIB_MKSTEMPS@\r
+GNULIB_MKTIME = @GNULIB_MKTIME@\r
+GNULIB_MODF = @GNULIB_MODF@\r
+GNULIB_MODFF = @GNULIB_MODFF@\r
+GNULIB_MODFL = @GNULIB_MODFL@\r
+GNULIB_NANOSLEEP = @GNULIB_NANOSLEEP@\r
+GNULIB_NONBLOCKING = @GNULIB_NONBLOCKING@\r
+GNULIB_OBSTACK_PRINTF = @GNULIB_OBSTACK_PRINTF@\r
+GNULIB_OBSTACK_PRINTF_POSIX = @GNULIB_OBSTACK_PRINTF_POSIX@\r
+GNULIB_OPEN = @GNULIB_OPEN@\r
+GNULIB_OPENAT = @GNULIB_OPENAT@\r
+GNULIB_PCLOSE = @GNULIB_PCLOSE@\r
+GNULIB_PERROR = @GNULIB_PERROR@\r
+GNULIB_PIPE = @GNULIB_PIPE@\r
+GNULIB_PIPE2 = @GNULIB_PIPE2@\r
+GNULIB_POPEN = @GNULIB_POPEN@\r
+GNULIB_POSIX_OPENPT = @GNULIB_POSIX_OPENPT@\r
+GNULIB_POSIX_SPAWN = @GNULIB_POSIX_SPAWN@\r
+GNULIB_POSIX_SPAWNATTR_DESTROY = @GNULIB_POSIX_SPAWNATTR_DESTROY@\r
+GNULIB_POSIX_SPAWNATTR_GETFLAGS = @GNULIB_POSIX_SPAWNATTR_GETFLAGS@\r
+GNULIB_POSIX_SPAWNATTR_GETPGROUP = @GNULIB_POSIX_SPAWNATTR_GETPGROUP@\r
+GNULIB_POSIX_SPAWNATTR_GETSCHEDPARAM = @GNULIB_POSIX_SPAWNATTR_GETSCHEDPARAM@\r
+GNULIB_POSIX_SPAWNATTR_GETSCHEDPOLICY = @GNULIB_POSIX_SPAWNATTR_GETSCHEDPOLICY@\r
+GNULIB_POSIX_SPAWNATTR_GETSIGDEFAULT = @GNULIB_POSIX_SPAWNATTR_GETSIGDEFAULT@\r
+GNULIB_POSIX_SPAWNATTR_GETSIGMASK = @GNULIB_POSIX_SPAWNATTR_GETSIGMASK@\r
+GNULIB_POSIX_SPAWNATTR_INIT = @GNULIB_POSIX_SPAWNATTR_INIT@\r
+GNULIB_POSIX_SPAWNATTR_SETFLAGS = @GNULIB_POSIX_SPAWNATTR_SETFLAGS@\r
+GNULIB_POSIX_SPAWNATTR_SETPGROUP = @GNULIB_POSIX_SPAWNATTR_SETPGROUP@\r
+GNULIB_POSIX_SPAWNATTR_SETSCHEDPARAM = @GNULIB_POSIX_SPAWNATTR_SETSCHEDPARAM@\r
+GNULIB_POSIX_SPAWNATTR_SETSCHEDPOLICY = @GNULIB_POSIX_SPAWNATTR_SETSCHEDPOLICY@\r
+GNULIB_POSIX_SPAWNATTR_SETSIGDEFAULT = @GNULIB_POSIX_SPAWNATTR_SETSIGDEFAULT@\r
+GNULIB_POSIX_SPAWNATTR_SETSIGMASK = @GNULIB_POSIX_SPAWNATTR_SETSIGMASK@\r
+GNULIB_POSIX_SPAWNP = @GNULIB_POSIX_SPAWNP@\r
+GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDCLOSE = @GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDCLOSE@\r
+GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDDUP2 = @GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDDUP2@\r
+GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDOPEN = @GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDOPEN@\r
+GNULIB_POSIX_SPAWN_FILE_ACTIONS_DESTROY = @GNULIB_POSIX_SPAWN_FILE_ACTIONS_DESTROY@\r
+GNULIB_POSIX_SPAWN_FILE_ACTIONS_INIT = @GNULIB_POSIX_SPAWN_FILE_ACTIONS_INIT@\r
+GNULIB_POWF = @GNULIB_POWF@\r
+GNULIB_PREAD = @GNULIB_PREAD@\r
+GNULIB_PRINTF = @GNULIB_PRINTF@\r
+GNULIB_PRINTF_POSIX = @GNULIB_PRINTF_POSIX@\r
+GNULIB_PTHREAD_SIGMASK = @GNULIB_PTHREAD_SIGMASK@\r
+GNULIB_PTSNAME = @GNULIB_PTSNAME@\r
+GNULIB_PTSNAME_R = @GNULIB_PTSNAME_R@\r
+GNULIB_PUTC = @GNULIB_PUTC@\r
+GNULIB_PUTCHAR = @GNULIB_PUTCHAR@\r
+GNULIB_PUTENV = @GNULIB_PUTENV@\r
+GNULIB_PUTS = @GNULIB_PUTS@\r
+GNULIB_PWRITE = @GNULIB_PWRITE@\r
+GNULIB_RAISE = @GNULIB_RAISE@\r
+GNULIB_RANDOM = @GNULIB_RANDOM@\r
+GNULIB_RANDOM_R = @GNULIB_RANDOM_R@\r
+GNULIB_RAWMEMCHR = @GNULIB_RAWMEMCHR@\r
+GNULIB_READ = @GNULIB_READ@\r
+GNULIB_READLINK = @GNULIB_READLINK@\r
+GNULIB_READLINKAT = @GNULIB_READLINKAT@\r
+GNULIB_REALLOC_POSIX = @GNULIB_REALLOC_POSIX@\r
+GNULIB_REALPATH = @GNULIB_REALPATH@\r
+GNULIB_REMAINDER = @GNULIB_REMAINDER@\r
+GNULIB_REMAINDERF = @GNULIB_REMAINDERF@\r
+GNULIB_REMAINDERL = @GNULIB_REMAINDERL@\r
+GNULIB_REMOVE = @GNULIB_REMOVE@\r
+GNULIB_RENAME = @GNULIB_RENAME@\r
+GNULIB_RENAMEAT = @GNULIB_RENAMEAT@\r
+GNULIB_RINT = @GNULIB_RINT@\r
+GNULIB_RINTF = @GNULIB_RINTF@\r
+GNULIB_RINTL = @GNULIB_RINTL@\r
+GNULIB_RMDIR = @GNULIB_RMDIR@\r
+GNULIB_ROUND = @GNULIB_ROUND@\r
+GNULIB_ROUNDF = @GNULIB_ROUNDF@\r
+GNULIB_ROUNDL = @GNULIB_ROUNDL@\r
+GNULIB_RPMATCH = @GNULIB_RPMATCH@\r
+GNULIB_SCANF = @GNULIB_SCANF@\r
+GNULIB_SETENV = @GNULIB_SETENV@\r
+GNULIB_SETHOSTNAME = @GNULIB_SETHOSTNAME@\r
+GNULIB_SIGACTION = @GNULIB_SIGACTION@\r
+GNULIB_SIGNAL_H_SIGPIPE = @GNULIB_SIGNAL_H_SIGPIPE@\r
+GNULIB_SIGNBIT = @GNULIB_SIGNBIT@\r
+GNULIB_SIGPROCMASK = @GNULIB_SIGPROCMASK@\r
+GNULIB_SINF = @GNULIB_SINF@\r
+GNULIB_SINHF = @GNULIB_SINHF@\r
+GNULIB_SINL = @GNULIB_SINL@\r
+GNULIB_SLEEP = @GNULIB_SLEEP@\r
+GNULIB_SNPRINTF = @GNULIB_SNPRINTF@\r
+GNULIB_SPRINTF_POSIX = @GNULIB_SPRINTF_POSIX@\r
+GNULIB_SQRTF = @GNULIB_SQRTF@\r
+GNULIB_SQRTL = @GNULIB_SQRTL@\r
+GNULIB_STAT = @GNULIB_STAT@\r
+GNULIB_STDIO_H_NONBLOCKING = @GNULIB_STDIO_H_NONBLOCKING@\r
+GNULIB_STDIO_H_SIGPIPE = @GNULIB_STDIO_H_SIGPIPE@\r
+GNULIB_STPCPY = @GNULIB_STPCPY@\r
+GNULIB_STPNCPY = @GNULIB_STPNCPY@\r
+GNULIB_STRCASESTR = @GNULIB_STRCASESTR@\r
+GNULIB_STRCHRNUL = @GNULIB_STRCHRNUL@\r
+GNULIB_STRDUP = @GNULIB_STRDUP@\r
+GNULIB_STRERROR = @GNULIB_STRERROR@\r
+GNULIB_STRERROR_R = @GNULIB_STRERROR_R@\r
+GNULIB_STRNCAT = @GNULIB_STRNCAT@\r
+GNULIB_STRNDUP = @GNULIB_STRNDUP@\r
+GNULIB_STRNLEN = @GNULIB_STRNLEN@\r
+GNULIB_STRPBRK = @GNULIB_STRPBRK@\r
+GNULIB_STRPTIME = @GNULIB_STRPTIME@\r
+GNULIB_STRSEP = @GNULIB_STRSEP@\r
+GNULIB_STRSIGNAL = @GNULIB_STRSIGNAL@\r
+GNULIB_STRSTR = @GNULIB_STRSTR@\r
+GNULIB_STRTOD = @GNULIB_STRTOD@\r
+GNULIB_STRTOIMAX = @GNULIB_STRTOIMAX@\r
+GNULIB_STRTOK_R = @GNULIB_STRTOK_R@\r
+GNULIB_STRTOLL = @GNULIB_STRTOLL@\r
+GNULIB_STRTOULL = @GNULIB_STRTOULL@\r
+GNULIB_STRTOUMAX = @GNULIB_STRTOUMAX@\r
+GNULIB_STRVERSCMP = @GNULIB_STRVERSCMP@\r
+GNULIB_SYMLINK = @GNULIB_SYMLINK@\r
+GNULIB_SYMLINKAT = @GNULIB_SYMLINKAT@\r
+GNULIB_SYSTEM_POSIX = @GNULIB_SYSTEM_POSIX@\r
+GNULIB_TANF = @GNULIB_TANF@\r
+GNULIB_TANHF = @GNULIB_TANHF@\r
+GNULIB_TANL = @GNULIB_TANL@\r
+GNULIB_TIMEGM = @GNULIB_TIMEGM@\r
+GNULIB_TIME_R = @GNULIB_TIME_R@\r
+GNULIB_TMPFILE = @GNULIB_TMPFILE@\r
+GNULIB_TOWCTRANS = @GNULIB_TOWCTRANS@\r
+GNULIB_TRUNC = @GNULIB_TRUNC@\r
+GNULIB_TRUNCF = @GNULIB_TRUNCF@\r
+GNULIB_TRUNCL = @GNULIB_TRUNCL@\r
+GNULIB_TTYNAME_R = @GNULIB_TTYNAME_R@\r
+GNULIB_UNISTD_H_NONBLOCKING = @GNULIB_UNISTD_H_NONBLOCKING@\r
+GNULIB_UNISTD_H_SIGPIPE = @GNULIB_UNISTD_H_SIGPIPE@\r
+GNULIB_UNLINK = @GNULIB_UNLINK@\r
+GNULIB_UNLINKAT = @GNULIB_UNLINKAT@\r
+GNULIB_UNLOCKPT = @GNULIB_UNLOCKPT@\r
+GNULIB_UNSETENV = @GNULIB_UNSETENV@\r
+GNULIB_USLEEP = @GNULIB_USLEEP@\r
+GNULIB_UTIMENSAT = @GNULIB_UTIMENSAT@\r
+GNULIB_VASPRINTF = @GNULIB_VASPRINTF@\r
+GNULIB_VDPRINTF = @GNULIB_VDPRINTF@\r
+GNULIB_VFPRINTF = @GNULIB_VFPRINTF@\r
+GNULIB_VFPRINTF_POSIX = @GNULIB_VFPRINTF_POSIX@\r
+GNULIB_VFSCANF = @GNULIB_VFSCANF@\r
+GNULIB_VPRINTF = @GNULIB_VPRINTF@\r
+GNULIB_VPRINTF_POSIX = @GNULIB_VPRINTF_POSIX@\r
+GNULIB_VSCANF = @GNULIB_VSCANF@\r
+GNULIB_VSNPRINTF = @GNULIB_VSNPRINTF@\r
+GNULIB_VSPRINTF_POSIX = @GNULIB_VSPRINTF_POSIX@\r
+GNULIB_WAITPID = @GNULIB_WAITPID@\r
+GNULIB_WCPCPY = @GNULIB_WCPCPY@\r
+GNULIB_WCPNCPY = @GNULIB_WCPNCPY@\r
+GNULIB_WCRTOMB = @GNULIB_WCRTOMB@\r
+GNULIB_WCSCASECMP = @GNULIB_WCSCASECMP@\r
+GNULIB_WCSCAT = @GNULIB_WCSCAT@\r
+GNULIB_WCSCHR = @GNULIB_WCSCHR@\r
+GNULIB_WCSCMP = @GNULIB_WCSCMP@\r
+GNULIB_WCSCOLL = @GNULIB_WCSCOLL@\r
+GNULIB_WCSCPY = @GNULIB_WCSCPY@\r
+GNULIB_WCSCSPN = @GNULIB_WCSCSPN@\r
+GNULIB_WCSDUP = @GNULIB_WCSDUP@\r
+GNULIB_WCSLEN = @GNULIB_WCSLEN@\r
+GNULIB_WCSNCASECMP = @GNULIB_WCSNCASECMP@\r
+GNULIB_WCSNCAT = @GNULIB_WCSNCAT@\r
+GNULIB_WCSNCMP = @GNULIB_WCSNCMP@\r
+GNULIB_WCSNCPY = @GNULIB_WCSNCPY@\r
+GNULIB_WCSNLEN = @GNULIB_WCSNLEN@\r
+GNULIB_WCSNRTOMBS = @GNULIB_WCSNRTOMBS@\r
+GNULIB_WCSPBRK = @GNULIB_WCSPBRK@\r
+GNULIB_WCSRCHR = @GNULIB_WCSRCHR@\r
+GNULIB_WCSRTOMBS = @GNULIB_WCSRTOMBS@\r
+GNULIB_WCSSPN = @GNULIB_WCSSPN@\r
+GNULIB_WCSSTR = @GNULIB_WCSSTR@\r
+GNULIB_WCSTOK = @GNULIB_WCSTOK@\r
+GNULIB_WCSWIDTH = @GNULIB_WCSWIDTH@\r
+GNULIB_WCSXFRM = @GNULIB_WCSXFRM@\r
+GNULIB_WCTOB = @GNULIB_WCTOB@\r
+GNULIB_WCTOMB = @GNULIB_WCTOMB@\r
+GNULIB_WCTRANS = @GNULIB_WCTRANS@\r
+GNULIB_WCTYPE = @GNULIB_WCTYPE@\r
+GNULIB_WCWIDTH = @GNULIB_WCWIDTH@\r
+GNULIB_WMEMCHR = @GNULIB_WMEMCHR@\r
+GNULIB_WMEMCMP = @GNULIB_WMEMCMP@\r
+GNULIB_WMEMCPY = @GNULIB_WMEMCPY@\r
+GNULIB_WMEMMOVE = @GNULIB_WMEMMOVE@\r
+GNULIB_WMEMSET = @GNULIB_WMEMSET@\r
+GNULIB_WRITE = @GNULIB_WRITE@\r
+GNULIB__EXIT = @GNULIB__EXIT@\r
+GREP = @GREP@\r
+HAVE_ACOSF = @HAVE_ACOSF@\r
+HAVE_ACOSL = @HAVE_ACOSL@\r
+HAVE_ASINF = @HAVE_ASINF@\r
+HAVE_ASINL = @HAVE_ASINL@\r
+HAVE_ATAN2F = @HAVE_ATAN2F@\r
+HAVE_ATANF = @HAVE_ATANF@\r
+HAVE_ATANL = @HAVE_ATANL@\r
+HAVE_ATOLL = @HAVE_ATOLL@\r
+HAVE_BTOWC = @HAVE_BTOWC@\r
+HAVE_CANONICALIZE_FILE_NAME = @HAVE_CANONICALIZE_FILE_NAME@\r
+HAVE_CBRT = @HAVE_CBRT@\r
+HAVE_CBRTF = @HAVE_CBRTF@\r
+HAVE_CBRTL = @HAVE_CBRTL@\r
+HAVE_CHOWN = @HAVE_CHOWN@\r
+HAVE_COPYSIGN = @HAVE_COPYSIGN@\r
+HAVE_COPYSIGNL = @HAVE_COPYSIGNL@\r
+HAVE_COSF = @HAVE_COSF@\r
+HAVE_COSHF = @HAVE_COSHF@\r
+HAVE_COSL = @HAVE_COSL@\r
+HAVE_DECL_ACOSL = @HAVE_DECL_ACOSL@\r
+HAVE_DECL_ASINL = @HAVE_DECL_ASINL@\r
+HAVE_DECL_ATANL = @HAVE_DECL_ATANL@\r
+HAVE_DECL_CBRTF = @HAVE_DECL_CBRTF@\r
+HAVE_DECL_CBRTL = @HAVE_DECL_CBRTL@\r
+HAVE_DECL_CEILF = @HAVE_DECL_CEILF@\r
+HAVE_DECL_CEILL = @HAVE_DECL_CEILL@\r
+HAVE_DECL_COPYSIGNF = @HAVE_DECL_COPYSIGNF@\r
+HAVE_DECL_COSL = @HAVE_DECL_COSL@\r
+HAVE_DECL_ENVIRON = @HAVE_DECL_ENVIRON@\r
+HAVE_DECL_EXP2 = @HAVE_DECL_EXP2@\r
+HAVE_DECL_EXP2F = @HAVE_DECL_EXP2F@\r
+HAVE_DECL_EXP2L = @HAVE_DECL_EXP2L@\r
+HAVE_DECL_EXPL = @HAVE_DECL_EXPL@\r
+HAVE_DECL_EXPM1L = @HAVE_DECL_EXPM1L@\r
+HAVE_DECL_FCHDIR = @HAVE_DECL_FCHDIR@\r
+HAVE_DECL_FDATASYNC = @HAVE_DECL_FDATASYNC@\r
+HAVE_DECL_FLOORF = @HAVE_DECL_FLOORF@\r
+HAVE_DECL_FLOORL = @HAVE_DECL_FLOORL@\r
+HAVE_DECL_FPURGE = @HAVE_DECL_FPURGE@\r
+HAVE_DECL_FREXPL = @HAVE_DECL_FREXPL@\r
+HAVE_DECL_FSEEKO = @HAVE_DECL_FSEEKO@\r
+HAVE_DECL_FTELLO = @HAVE_DECL_FTELLO@\r
+HAVE_DECL_GETDELIM = @HAVE_DECL_GETDELIM@\r
+HAVE_DECL_GETDOMAINNAME = @HAVE_DECL_GETDOMAINNAME@\r
+HAVE_DECL_GETLINE = @HAVE_DECL_GETLINE@\r
+HAVE_DECL_GETLOADAVG = @HAVE_DECL_GETLOADAVG@\r
+HAVE_DECL_GETLOGIN_R = @HAVE_DECL_GETLOGIN_R@\r
+HAVE_DECL_GETPAGESIZE = @HAVE_DECL_GETPAGESIZE@\r
+HAVE_DECL_GETUSERSHELL = @HAVE_DECL_GETUSERSHELL@\r
+HAVE_DECL_IMAXABS = @HAVE_DECL_IMAXABS@\r
+HAVE_DECL_IMAXDIV = @HAVE_DECL_IMAXDIV@\r
+HAVE_DECL_LDEXPL = @HAVE_DECL_LDEXPL@\r
+HAVE_DECL_LOCALTIME_R = @HAVE_DECL_LOCALTIME_R@\r
+HAVE_DECL_LOG10L = @HAVE_DECL_LOG10L@\r
+HAVE_DECL_LOG2 = @HAVE_DECL_LOG2@\r
+HAVE_DECL_LOG2F = @HAVE_DECL_LOG2F@\r
+HAVE_DECL_LOG2L = @HAVE_DECL_LOG2L@\r
+HAVE_DECL_LOGB = @HAVE_DECL_LOGB@\r
+HAVE_DECL_LOGL = @HAVE_DECL_LOGL@\r
+HAVE_DECL_MEMMEM = @HAVE_DECL_MEMMEM@\r
+HAVE_DECL_MEMRCHR = @HAVE_DECL_MEMRCHR@\r
+HAVE_DECL_OBSTACK_PRINTF = @HAVE_DECL_OBSTACK_PRINTF@\r
+HAVE_DECL_REMAINDER = @HAVE_DECL_REMAINDER@\r
+HAVE_DECL_REMAINDERL = @HAVE_DECL_REMAINDERL@\r
+HAVE_DECL_RINTF = @HAVE_DECL_RINTF@\r
+HAVE_DECL_ROUND = @HAVE_DECL_ROUND@\r
+HAVE_DECL_ROUNDF = @HAVE_DECL_ROUNDF@\r
+HAVE_DECL_ROUNDL = @HAVE_DECL_ROUNDL@\r
+HAVE_DECL_SETENV = @HAVE_DECL_SETENV@\r
+HAVE_DECL_SETHOSTNAME = @HAVE_DECL_SETHOSTNAME@\r
+HAVE_DECL_SINL = @HAVE_DECL_SINL@\r
+HAVE_DECL_SNPRINTF = @HAVE_DECL_SNPRINTF@\r
+HAVE_DECL_SQRTL = @HAVE_DECL_SQRTL@\r
+HAVE_DECL_STRDUP = @HAVE_DECL_STRDUP@\r
+HAVE_DECL_STRERROR_R = @HAVE_DECL_STRERROR_R@\r
+HAVE_DECL_STRNDUP = @HAVE_DECL_STRNDUP@\r
+HAVE_DECL_STRNLEN = @HAVE_DECL_STRNLEN@\r
+HAVE_DECL_STRSIGNAL = @HAVE_DECL_STRSIGNAL@\r
+HAVE_DECL_STRTOIMAX = @HAVE_DECL_STRTOIMAX@\r
+HAVE_DECL_STRTOK_R = @HAVE_DECL_STRTOK_R@\r
+HAVE_DECL_STRTOUMAX = @HAVE_DECL_STRTOUMAX@\r
+HAVE_DECL_TANL = @HAVE_DECL_TANL@\r
+HAVE_DECL_TRUNC = @HAVE_DECL_TRUNC@\r
+HAVE_DECL_TRUNCF = @HAVE_DECL_TRUNCF@\r
+HAVE_DECL_TRUNCL = @HAVE_DECL_TRUNCL@\r
+HAVE_DECL_TTYNAME_R = @HAVE_DECL_TTYNAME_R@\r
+HAVE_DECL_UNSETENV = @HAVE_DECL_UNSETENV@\r
+HAVE_DECL_VSNPRINTF = @HAVE_DECL_VSNPRINTF@\r
+HAVE_DECL_WCTOB = @HAVE_DECL_WCTOB@\r
+HAVE_DECL_WCWIDTH = @HAVE_DECL_WCWIDTH@\r
+HAVE_DPRINTF = @HAVE_DPRINTF@\r
+HAVE_DUP2 = @HAVE_DUP2@\r
+HAVE_DUP3 = @HAVE_DUP3@\r
+HAVE_EUIDACCESS = @HAVE_EUIDACCESS@\r
+HAVE_EXPF = @HAVE_EXPF@\r
+HAVE_EXPL = @HAVE_EXPL@\r
+HAVE_EXPM1 = @HAVE_EXPM1@\r
+HAVE_EXPM1F = @HAVE_EXPM1F@\r
+HAVE_FABSF = @HAVE_FABSF@\r
+HAVE_FABSL = @HAVE_FABSL@\r
+HAVE_FACCESSAT = @HAVE_FACCESSAT@\r
+HAVE_FCHDIR = @HAVE_FCHDIR@\r
+HAVE_FCHMODAT = @HAVE_FCHMODAT@\r
+HAVE_FCHOWNAT = @HAVE_FCHOWNAT@\r
+HAVE_FCNTL = @HAVE_FCNTL@\r
+HAVE_FDATASYNC = @HAVE_FDATASYNC@\r
+HAVE_FEATURES_H = @HAVE_FEATURES_H@\r
+HAVE_FFSL = @HAVE_FFSL@\r
+HAVE_FFSLL = @HAVE_FFSLL@\r
+HAVE_FMA = @HAVE_FMA@\r
+HAVE_FMAF = @HAVE_FMAF@\r
+HAVE_FMAL = @HAVE_FMAL@\r
+HAVE_FMODF = @HAVE_FMODF@\r
+HAVE_FMODL = @HAVE_FMODL@\r
+HAVE_FREXPF = @HAVE_FREXPF@\r
+HAVE_FSEEKO = @HAVE_FSEEKO@\r
+HAVE_FSTATAT = @HAVE_FSTATAT@\r
+HAVE_FSYNC = @HAVE_FSYNC@\r
+HAVE_FTELLO = @HAVE_FTELLO@\r
+HAVE_FTRUNCATE = @HAVE_FTRUNCATE@\r
+HAVE_FUTIMENS = @HAVE_FUTIMENS@\r
+HAVE_GCJ_C = @HAVE_GCJ_C@\r
+HAVE_GCJ_IN_PATH = @HAVE_GCJ_IN_PATH@\r
+HAVE_GETDTABLESIZE = @HAVE_GETDTABLESIZE@\r
+HAVE_GETGROUPS = @HAVE_GETGROUPS@\r
+HAVE_GETHOSTNAME = @HAVE_GETHOSTNAME@\r
+HAVE_GETLOGIN = @HAVE_GETLOGIN@\r
+HAVE_GETOPT_H = @HAVE_GETOPT_H@\r
+HAVE_GETPAGESIZE = @HAVE_GETPAGESIZE@\r
+HAVE_GETSUBOPT = @HAVE_GETSUBOPT@\r
+HAVE_GIJ = @HAVE_GIJ@\r
+HAVE_GIJ_IN_PATH = @HAVE_GIJ_IN_PATH@\r
+HAVE_GRANTPT = @HAVE_GRANTPT@\r
+HAVE_GROUP_MEMBER = @HAVE_GROUP_MEMBER@\r
+HAVE_HYPOTF = @HAVE_HYPOTF@\r
+HAVE_HYPOTL = @HAVE_HYPOTL@\r
+HAVE_ILOGB = @HAVE_ILOGB@\r
+HAVE_ILOGBF = @HAVE_ILOGBF@\r
+HAVE_ILOGBL = @HAVE_ILOGBL@\r
+HAVE_INTTYPES_H = @HAVE_INTTYPES_H@\r
+HAVE_ISNAND = @HAVE_ISNAND@\r
+HAVE_ISNANF = @HAVE_ISNANF@\r
+HAVE_ISNANL = @HAVE_ISNANL@\r
+HAVE_ISWBLANK = @HAVE_ISWBLANK@\r
+HAVE_ISWCNTRL = @HAVE_ISWCNTRL@\r
+HAVE_JAVA = @HAVE_JAVA@\r
+HAVE_JAVAC = @HAVE_JAVAC@\r
+HAVE_JAVAC_ENVVAR = @HAVE_JAVAC_ENVVAR@\r
+HAVE_JAVAC_IN_PATH = @HAVE_JAVAC_IN_PATH@\r
+HAVE_JAVA_ENVVAR = @HAVE_JAVA_ENVVAR@\r
+HAVE_JAVA_IN_PATH = @HAVE_JAVA_IN_PATH@\r
+HAVE_JIKES = @HAVE_JIKES@\r
+HAVE_JIKES_IN_PATH = @HAVE_JIKES_IN_PATH@\r
+HAVE_JRE = @HAVE_JRE@\r
+HAVE_JRE_IN_PATH = @HAVE_JRE_IN_PATH@\r
+HAVE_JVIEW = @HAVE_JVIEW@\r
+HAVE_JVIEW_IN_PATH = @HAVE_JVIEW_IN_PATH@\r
+HAVE_LCHMOD = @HAVE_LCHMOD@\r
+HAVE_LCHOWN = @HAVE_LCHOWN@\r
+HAVE_LDEXPF = @HAVE_LDEXPF@\r
+HAVE_LINK = @HAVE_LINK@\r
+HAVE_LINKAT = @HAVE_LINKAT@\r
+HAVE_LOG10F = @HAVE_LOG10F@\r
+HAVE_LOG10L = @HAVE_LOG10L@\r
+HAVE_LOG1P = @HAVE_LOG1P@\r
+HAVE_LOG1PF = @HAVE_LOG1PF@\r
+HAVE_LOG1PL = @HAVE_LOG1PL@\r
+HAVE_LOGBF = @HAVE_LOGBF@\r
+HAVE_LOGBL = @HAVE_LOGBL@\r
+HAVE_LOGF = @HAVE_LOGF@\r
+HAVE_LOGL = @HAVE_LOGL@\r
+HAVE_LONG_LONG_INT = @HAVE_LONG_LONG_INT@\r
+HAVE_LSTAT = @HAVE_LSTAT@\r
+HAVE_MBRLEN = @HAVE_MBRLEN@\r
+HAVE_MBRTOWC = @HAVE_MBRTOWC@\r
+HAVE_MBSINIT = @HAVE_MBSINIT@\r
+HAVE_MBSLEN = @HAVE_MBSLEN@\r
+HAVE_MBSNRTOWCS = @HAVE_MBSNRTOWCS@\r
+HAVE_MBSRTOWCS = @HAVE_MBSRTOWCS@\r
+HAVE_MEMCHR = @HAVE_MEMCHR@\r
+HAVE_MEMPCPY = @HAVE_MEMPCPY@\r
+HAVE_MKDIRAT = @HAVE_MKDIRAT@\r
+HAVE_MKDTEMP = @HAVE_MKDTEMP@\r
+HAVE_MKFIFO = @HAVE_MKFIFO@\r
+HAVE_MKFIFOAT = @HAVE_MKFIFOAT@\r
+HAVE_MKNOD = @HAVE_MKNOD@\r
+HAVE_MKNODAT = @HAVE_MKNODAT@\r
+HAVE_MKOSTEMP = @HAVE_MKOSTEMP@\r
+HAVE_MKOSTEMPS = @HAVE_MKOSTEMPS@\r
+HAVE_MKSTEMP = @HAVE_MKSTEMP@\r
+HAVE_MKSTEMPS = @HAVE_MKSTEMPS@\r
+HAVE_MODFF = @HAVE_MODFF@\r
+HAVE_MODFL = @HAVE_MODFL@\r
+HAVE_MSVC_INVALID_PARAMETER_HANDLER = @HAVE_MSVC_INVALID_PARAMETER_HANDLER@\r
+HAVE_NANOSLEEP = @HAVE_NANOSLEEP@\r
+HAVE_OPENAT = @HAVE_OPENAT@\r
+HAVE_OS_H = @HAVE_OS_H@\r
+HAVE_PCLOSE = @HAVE_PCLOSE@\r
+HAVE_PIPE = @HAVE_PIPE@\r
+HAVE_PIPE2 = @HAVE_PIPE2@\r
+HAVE_POPEN = @HAVE_POPEN@\r
+HAVE_POSIX_OPENPT = @HAVE_POSIX_OPENPT@\r
+HAVE_POSIX_SIGNALBLOCKING = @HAVE_POSIX_SIGNALBLOCKING@\r
+HAVE_POSIX_SPAWN = @HAVE_POSIX_SPAWN@\r
+HAVE_POSIX_SPAWNATTR_T = @HAVE_POSIX_SPAWNATTR_T@\r
+HAVE_POSIX_SPAWN_FILE_ACTIONS_T = @HAVE_POSIX_SPAWN_FILE_ACTIONS_T@\r
+HAVE_POWF = @HAVE_POWF@\r
+HAVE_PREAD = @HAVE_PREAD@\r
+HAVE_PTHREAD_SIGMASK = @HAVE_PTHREAD_SIGMASK@\r
+HAVE_PTSNAME = @HAVE_PTSNAME@\r
+HAVE_PTSNAME_R = @HAVE_PTSNAME_R@\r
+HAVE_PWRITE = @HAVE_PWRITE@\r
+HAVE_RAISE = @HAVE_RAISE@\r
+HAVE_RANDOM = @HAVE_RANDOM@\r
+HAVE_RANDOM_H = @HAVE_RANDOM_H@\r
+HAVE_RANDOM_R = @HAVE_RANDOM_R@\r
+HAVE_RAWMEMCHR = @HAVE_RAWMEMCHR@\r
+HAVE_READLINK = @HAVE_READLINK@\r
+HAVE_READLINKAT = @HAVE_READLINKAT@\r
+HAVE_REALPATH = @HAVE_REALPATH@\r
+HAVE_REMAINDER = @HAVE_REMAINDER@\r
+HAVE_REMAINDERF = @HAVE_REMAINDERF@\r
+HAVE_RENAMEAT = @HAVE_RENAMEAT@\r
+HAVE_RINT = @HAVE_RINT@\r
+HAVE_RINTL = @HAVE_RINTL@\r
+HAVE_RPMATCH = @HAVE_RPMATCH@\r
+HAVE_SAME_LONG_DOUBLE_AS_DOUBLE = @HAVE_SAME_LONG_DOUBLE_AS_DOUBLE@\r
+HAVE_SCHED_H = @HAVE_SCHED_H@\r
+HAVE_SETENV = @HAVE_SETENV@\r
+HAVE_SETHOSTNAME = @HAVE_SETHOSTNAME@\r
+HAVE_SIGACTION = @HAVE_SIGACTION@\r
+HAVE_SIGHANDLER_T = @HAVE_SIGHANDLER_T@\r
+HAVE_SIGINFO_T = @HAVE_SIGINFO_T@\r
+HAVE_SIGNED_SIG_ATOMIC_T = @HAVE_SIGNED_SIG_ATOMIC_T@\r
+HAVE_SIGNED_WCHAR_T = @HAVE_SIGNED_WCHAR_T@\r
+HAVE_SIGNED_WINT_T = @HAVE_SIGNED_WINT_T@\r
+HAVE_SIGSET_T = @HAVE_SIGSET_T@\r
+HAVE_SINF = @HAVE_SINF@\r
+HAVE_SINHF = @HAVE_SINHF@\r
+HAVE_SINL = @HAVE_SINL@\r
+HAVE_SLEEP = @HAVE_SLEEP@\r
+HAVE_SPAWN_H = @HAVE_SPAWN_H@\r
+HAVE_SQRTF = @HAVE_SQRTF@\r
+HAVE_SQRTL = @HAVE_SQRTL@\r
+HAVE_STDINT_H = @HAVE_STDINT_H@\r
+HAVE_STPCPY = @HAVE_STPCPY@\r
+HAVE_STPNCPY = @HAVE_STPNCPY@\r
+HAVE_STRCASESTR = @HAVE_STRCASESTR@\r
+HAVE_STRCHRNUL = @HAVE_STRCHRNUL@\r
+HAVE_STRPBRK = @HAVE_STRPBRK@\r
+HAVE_STRPTIME = @HAVE_STRPTIME@\r
+HAVE_STRSEP = @HAVE_STRSEP@\r
+HAVE_STRTOD = @HAVE_STRTOD@\r
+HAVE_STRTOLL = @HAVE_STRTOLL@\r
+HAVE_STRTOULL = @HAVE_STRTOULL@\r
+HAVE_STRUCT_RANDOM_DATA = @HAVE_STRUCT_RANDOM_DATA@\r
+HAVE_STRUCT_SCHED_PARAM = @HAVE_STRUCT_SCHED_PARAM@\r
+HAVE_STRUCT_SIGACTION_SA_SIGACTION = @HAVE_STRUCT_SIGACTION_SA_SIGACTION@\r
+HAVE_STRVERSCMP = @HAVE_STRVERSCMP@\r
+HAVE_SYMLINK = @HAVE_SYMLINK@\r
+HAVE_SYMLINKAT = @HAVE_SYMLINKAT@\r
+HAVE_SYS_BITYPES_H = @HAVE_SYS_BITYPES_H@\r
+HAVE_SYS_INTTYPES_H = @HAVE_SYS_INTTYPES_H@\r
+HAVE_SYS_LOADAVG_H = @HAVE_SYS_LOADAVG_H@\r
+HAVE_SYS_PARAM_H = @HAVE_SYS_PARAM_H@\r
+HAVE_SYS_TYPES_H = @HAVE_SYS_TYPES_H@\r
+HAVE_TANF = @HAVE_TANF@\r
+HAVE_TANHF = @HAVE_TANHF@\r
+HAVE_TANL = @HAVE_TANL@\r
+HAVE_TIMEGM = @HAVE_TIMEGM@\r
+HAVE_TYPE_VOLATILE_SIG_ATOMIC_T = @HAVE_TYPE_VOLATILE_SIG_ATOMIC_T@\r
+HAVE_UNISTD_H = @HAVE_UNISTD_H@\r
+HAVE_UNLINKAT = @HAVE_UNLINKAT@\r
+HAVE_UNLOCKPT = @HAVE_UNLOCKPT@\r
+HAVE_UNSIGNED_LONG_LONG_INT = @HAVE_UNSIGNED_LONG_LONG_INT@\r
+HAVE_USLEEP = @HAVE_USLEEP@\r
+HAVE_UTIMENSAT = @HAVE_UTIMENSAT@\r
+HAVE_VASPRINTF = @HAVE_VASPRINTF@\r
+HAVE_VDPRINTF = @HAVE_VDPRINTF@\r
+HAVE_WCHAR_H = @HAVE_WCHAR_H@\r
+HAVE_WCHAR_T = @HAVE_WCHAR_T@\r
+HAVE_WCPCPY = @HAVE_WCPCPY@\r
+HAVE_WCPNCPY = @HAVE_WCPNCPY@\r
+HAVE_WCRTOMB = @HAVE_WCRTOMB@\r
+HAVE_WCSCASECMP = @HAVE_WCSCASECMP@\r
+HAVE_WCSCAT = @HAVE_WCSCAT@\r
+HAVE_WCSCHR = @HAVE_WCSCHR@\r
+HAVE_WCSCMP = @HAVE_WCSCMP@\r
+HAVE_WCSCOLL = @HAVE_WCSCOLL@\r
+HAVE_WCSCPY = @HAVE_WCSCPY@\r
+HAVE_WCSCSPN = @HAVE_WCSCSPN@\r
+HAVE_WCSDUP = @HAVE_WCSDUP@\r
+HAVE_WCSLEN = @HAVE_WCSLEN@\r
+HAVE_WCSNCASECMP = @HAVE_WCSNCASECMP@\r
+HAVE_WCSNCAT = @HAVE_WCSNCAT@\r
+HAVE_WCSNCMP = @HAVE_WCSNCMP@\r
+HAVE_WCSNCPY = @HAVE_WCSNCPY@\r
+HAVE_WCSNLEN = @HAVE_WCSNLEN@\r
+HAVE_WCSNRTOMBS = @HAVE_WCSNRTOMBS@\r
+HAVE_WCSPBRK = @HAVE_WCSPBRK@\r
+HAVE_WCSRCHR = @HAVE_WCSRCHR@\r
+HAVE_WCSRTOMBS = @HAVE_WCSRTOMBS@\r
+HAVE_WCSSPN = @HAVE_WCSSPN@\r
+HAVE_WCSSTR = @HAVE_WCSSTR@\r
+HAVE_WCSTOK = @HAVE_WCSTOK@\r
+HAVE_WCSWIDTH = @HAVE_WCSWIDTH@\r
+HAVE_WCSXFRM = @HAVE_WCSXFRM@\r
+HAVE_WCTRANS_T = @HAVE_WCTRANS_T@\r
+HAVE_WCTYPE_H = @HAVE_WCTYPE_H@\r
+HAVE_WCTYPE_T = @HAVE_WCTYPE_T@\r
+HAVE_WINSOCK2_H = @HAVE_WINSOCK2_H@\r
+HAVE_WINT_T = @HAVE_WINT_T@\r
+HAVE_WMEMCHR = @HAVE_WMEMCHR@\r
+HAVE_WMEMCMP = @HAVE_WMEMCMP@\r
+HAVE_WMEMCPY = @HAVE_WMEMCPY@\r
+HAVE_WMEMMOVE = @HAVE_WMEMMOVE@\r
+HAVE_WMEMSET = @HAVE_WMEMSET@\r
+HAVE__BOOL = @HAVE__BOOL@\r
+HAVE__EXIT = @HAVE__EXIT@\r
+HELP2MAN = @HELP2MAN@\r
+INCLUDE_NEXT = @INCLUDE_NEXT@\r
+INCLUDE_NEXT_AS_FIRST_DIRECTIVE = @INCLUDE_NEXT_AS_FIRST_DIRECTIVE@\r
+INSTALL = @INSTALL@\r
+INSTALL_DATA = @INSTALL_DATA@\r
+INSTALL_PROGRAM = @INSTALL_PROGRAM@\r
+INSTALL_SCRIPT = @INSTALL_SCRIPT@\r
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@\r
+INT32_MAX_LT_INTMAX_MAX = @INT32_MAX_LT_INTMAX_MAX@\r
+INT64_MAX_EQ_LONG_MAX = @INT64_MAX_EQ_LONG_MAX@\r
+INTLLIBS = @INTLLIBS@\r
+INTL_MACOSX_LIBS = @INTL_MACOSX_LIBS@\r
+ISNAND_LIBM = @ISNAND_LIBM@\r
+ISNANF_LIBM = @ISNANF_LIBM@\r
+ISNANL_LIBM = @ISNANL_LIBM@\r
+ISNAN_LIBM = @ISNAN_LIBM@\r
+LDEXPL_LIBM = @LDEXPL_LIBM@\r
+LDEXP_LIBM = @LDEXP_LIBM@\r
+LDFLAGS = @LDFLAGS@\r
+LEX = @LEX@\r
+LEXLIB = @LEXLIB@\r
+LEX_IS_FLEX = @LEX_IS_FLEX@\r
+LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@\r
+LIBBISON_LIBDEPS = @LIBBISON_LIBDEPS@\r
+LIBBISON_LTLIBDEPS = @LIBBISON_LTLIBDEPS@\r
+LIBICONV = @LIBICONV@\r
+LIBINTL = @LIBINTL@\r
+LIBMULTITHREAD = @LIBMULTITHREAD@\r
+LIBOBJS = @LIBOBJS@\r
+LIBPTH = @LIBPTH@\r
+LIBPTH_PREFIX = @LIBPTH_PREFIX@\r
+LIBS = @LIBS@\r
+LIBTHREAD = @LIBTHREAD@\r
+LIBUNISTRING_UNITYPES_H = @LIBUNISTRING_UNITYPES_H@\r
+LIBUNISTRING_UNIWIDTH_H = @LIBUNISTRING_UNIWIDTH_H@\r
+LOCALCHARSET_TESTS_ENVIRONMENT = @LOCALCHARSET_TESTS_ENVIRONMENT@\r
+LOCALE_FR_UTF8 = @LOCALE_FR_UTF8@\r
+LOCALE_JA = @LOCALE_JA@\r
+LOCALE_ZH_CN = @LOCALE_ZH_CN@\r
+LTLIBICONV = @LTLIBICONV@\r
+LTLIBINTL = @LTLIBINTL@\r
+LTLIBMULTITHREAD = @LTLIBMULTITHREAD@\r
+LTLIBOBJS = @LTLIBOBJS@\r
+LTLIBPTH = @LTLIBPTH@\r
+LTLIBTHREAD = @LTLIBTHREAD@\r
+M4 = @M4@\r
+M4_DEBUGFILE = @M4_DEBUGFILE@\r
+M4_GNU = @M4_GNU@\r
+MAKEINFO = @MAKEINFO@\r
+MKDIR_P = @MKDIR_P@\r
+MSGFMT = @MSGFMT@\r
+MSGFMT_015 = @MSGFMT_015@\r
+MSGMERGE = @MSGMERGE@\r
+NEXT_AS_FIRST_DIRECTIVE_ERRNO_H = @NEXT_AS_FIRST_DIRECTIVE_ERRNO_H@\r
+NEXT_AS_FIRST_DIRECTIVE_FCNTL_H = @NEXT_AS_FIRST_DIRECTIVE_FCNTL_H@\r
+NEXT_AS_FIRST_DIRECTIVE_FLOAT_H = @NEXT_AS_FIRST_DIRECTIVE_FLOAT_H@\r
+NEXT_AS_FIRST_DIRECTIVE_GETOPT_H = @NEXT_AS_FIRST_DIRECTIVE_GETOPT_H@\r
+NEXT_AS_FIRST_DIRECTIVE_INTTYPES_H = @NEXT_AS_FIRST_DIRECTIVE_INTTYPES_H@\r
+NEXT_AS_FIRST_DIRECTIVE_MATH_H = @NEXT_AS_FIRST_DIRECTIVE_MATH_H@\r
+NEXT_AS_FIRST_DIRECTIVE_SCHED_H = @NEXT_AS_FIRST_DIRECTIVE_SCHED_H@\r
+NEXT_AS_FIRST_DIRECTIVE_SIGNAL_H = @NEXT_AS_FIRST_DIRECTIVE_SIGNAL_H@\r
+NEXT_AS_FIRST_DIRECTIVE_SPAWN_H = @NEXT_AS_FIRST_DIRECTIVE_SPAWN_H@\r
+NEXT_AS_FIRST_DIRECTIVE_STDDEF_H = @NEXT_AS_FIRST_DIRECTIVE_STDDEF_H@\r
+NEXT_AS_FIRST_DIRECTIVE_STDINT_H = @NEXT_AS_FIRST_DIRECTIVE_STDINT_H@\r
+NEXT_AS_FIRST_DIRECTIVE_STDIO_H = @NEXT_AS_FIRST_DIRECTIVE_STDIO_H@\r
+NEXT_AS_FIRST_DIRECTIVE_STDLIB_H = @NEXT_AS_FIRST_DIRECTIVE_STDLIB_H@\r
+NEXT_AS_FIRST_DIRECTIVE_STRING_H = @NEXT_AS_FIRST_DIRECTIVE_STRING_H@\r
+NEXT_AS_FIRST_DIRECTIVE_SYS_STAT_H = @NEXT_AS_FIRST_DIRECTIVE_SYS_STAT_H@\r
+NEXT_AS_FIRST_DIRECTIVE_SYS_TYPES_H = @NEXT_AS_FIRST_DIRECTIVE_SYS_TYPES_H@\r
+NEXT_AS_FIRST_DIRECTIVE_SYS_WAIT_H = @NEXT_AS_FIRST_DIRECTIVE_SYS_WAIT_H@\r
+NEXT_AS_FIRST_DIRECTIVE_TIME_H = @NEXT_AS_FIRST_DIRECTIVE_TIME_H@\r
+NEXT_AS_FIRST_DIRECTIVE_UNISTD_H = @NEXT_AS_FIRST_DIRECTIVE_UNISTD_H@\r
+NEXT_AS_FIRST_DIRECTIVE_WCHAR_H = @NEXT_AS_FIRST_DIRECTIVE_WCHAR_H@\r
+NEXT_AS_FIRST_DIRECTIVE_WCTYPE_H = @NEXT_AS_FIRST_DIRECTIVE_WCTYPE_H@\r
+NEXT_ERRNO_H = @NEXT_ERRNO_H@\r
+NEXT_FCNTL_H = @NEXT_FCNTL_H@\r
+NEXT_FLOAT_H = @NEXT_FLOAT_H@\r
+NEXT_GETOPT_H = @NEXT_GETOPT_H@\r
+NEXT_INTTYPES_H = @NEXT_INTTYPES_H@\r
+NEXT_MATH_H = @NEXT_MATH_H@\r
+NEXT_SCHED_H = @NEXT_SCHED_H@\r
+NEXT_SIGNAL_H = @NEXT_SIGNAL_H@\r
+NEXT_SPAWN_H = @NEXT_SPAWN_H@\r
+NEXT_STDDEF_H = @NEXT_STDDEF_H@\r
+NEXT_STDINT_H = @NEXT_STDINT_H@\r
+NEXT_STDIO_H = @NEXT_STDIO_H@\r
+NEXT_STDLIB_H = @NEXT_STDLIB_H@\r
+NEXT_STRING_H = @NEXT_STRING_H@\r
+NEXT_SYS_STAT_H = @NEXT_SYS_STAT_H@\r
+NEXT_SYS_TYPES_H = @NEXT_SYS_TYPES_H@\r
+NEXT_SYS_WAIT_H = @NEXT_SYS_WAIT_H@\r
+NEXT_TIME_H = @NEXT_TIME_H@\r
+NEXT_UNISTD_H = @NEXT_UNISTD_H@\r
+NEXT_WCHAR_H = @NEXT_WCHAR_H@\r
+NEXT_WCTYPE_H = @NEXT_WCTYPE_H@\r
+OBJEXT = @OBJEXT@\r
+PACKAGE = @PACKAGE@\r
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@\r
+PACKAGE_COPYRIGHT_YEAR = @PACKAGE_COPYRIGHT_YEAR@\r
+PACKAGE_NAME = @PACKAGE_NAME@\r
+PACKAGE_STRING = @PACKAGE_STRING@\r
+PACKAGE_TARNAME = @PACKAGE_TARNAME@\r
+PACKAGE_URL = @PACKAGE_URL@\r
+PACKAGE_VERSION = @PACKAGE_VERSION@\r
+PATH_SEPARATOR = @PATH_SEPARATOR@\r
+PERL = @PERL@\r
+POSUB = @POSUB@\r
+PRAGMA_COLUMNS = @PRAGMA_COLUMNS@\r
+PRAGMA_SYSTEM_HEADER = @PRAGMA_SYSTEM_HEADER@\r
+PRIPTR_PREFIX = @PRIPTR_PREFIX@\r
+PRI_MACROS_BROKEN = @PRI_MACROS_BROKEN@\r
+PTHREAD_H_DEFINES_STRUCT_TIMESPEC = @PTHREAD_H_DEFINES_STRUCT_TIMESPEC@\r
+PTRDIFF_T_SUFFIX = @PTRDIFF_T_SUFFIX@\r
+RANLIB = @RANLIB@\r
+REPLACE_BTOWC = @REPLACE_BTOWC@\r
+REPLACE_CALLOC = @REPLACE_CALLOC@\r
+REPLACE_CANONICALIZE_FILE_NAME = @REPLACE_CANONICALIZE_FILE_NAME@\r
+REPLACE_CBRTF = @REPLACE_CBRTF@\r
+REPLACE_CBRTL = @REPLACE_CBRTL@\r
+REPLACE_CEIL = @REPLACE_CEIL@\r
+REPLACE_CEILF = @REPLACE_CEILF@\r
+REPLACE_CEILL = @REPLACE_CEILL@\r
+REPLACE_CHOWN = @REPLACE_CHOWN@\r
+REPLACE_CLOSE = @REPLACE_CLOSE@\r
+REPLACE_DPRINTF = @REPLACE_DPRINTF@\r
+REPLACE_DUP = @REPLACE_DUP@\r
+REPLACE_DUP2 = @REPLACE_DUP2@\r
+REPLACE_EXP2 = @REPLACE_EXP2@\r
+REPLACE_EXP2L = @REPLACE_EXP2L@\r
+REPLACE_EXPM1 = @REPLACE_EXPM1@\r
+REPLACE_EXPM1F = @REPLACE_EXPM1F@\r
+REPLACE_FABSL = @REPLACE_FABSL@\r
+REPLACE_FCHOWNAT = @REPLACE_FCHOWNAT@\r
+REPLACE_FCLOSE = @REPLACE_FCLOSE@\r
+REPLACE_FCNTL = @REPLACE_FCNTL@\r
+REPLACE_FDOPEN = @REPLACE_FDOPEN@\r
+REPLACE_FFLUSH = @REPLACE_FFLUSH@\r
+REPLACE_FLOOR = @REPLACE_FLOOR@\r
+REPLACE_FLOORF = @REPLACE_FLOORF@\r
+REPLACE_FLOORL = @REPLACE_FLOORL@\r
+REPLACE_FMA = @REPLACE_FMA@\r
+REPLACE_FMAF = @REPLACE_FMAF@\r
+REPLACE_FMAL = @REPLACE_FMAL@\r
+REPLACE_FMOD = @REPLACE_FMOD@\r
+REPLACE_FMODF = @REPLACE_FMODF@\r
+REPLACE_FMODL = @REPLACE_FMODL@\r
+REPLACE_FOPEN = @REPLACE_FOPEN@\r
+REPLACE_FPRINTF = @REPLACE_FPRINTF@\r
+REPLACE_FPURGE = @REPLACE_FPURGE@\r
+REPLACE_FREOPEN = @REPLACE_FREOPEN@\r
+REPLACE_FREXP = @REPLACE_FREXP@\r
+REPLACE_FREXPF = @REPLACE_FREXPF@\r
+REPLACE_FREXPL = @REPLACE_FREXPL@\r
+REPLACE_FSEEK = @REPLACE_FSEEK@\r
+REPLACE_FSEEKO = @REPLACE_FSEEKO@\r
+REPLACE_FSTAT = @REPLACE_FSTAT@\r
+REPLACE_FSTATAT = @REPLACE_FSTATAT@\r
+REPLACE_FTELL = @REPLACE_FTELL@\r
+REPLACE_FTELLO = @REPLACE_FTELLO@\r
+REPLACE_FTRUNCATE = @REPLACE_FTRUNCATE@\r
+REPLACE_FUTIMENS = @REPLACE_FUTIMENS@\r
+REPLACE_GETCWD = @REPLACE_GETCWD@\r
+REPLACE_GETDELIM = @REPLACE_GETDELIM@\r
+REPLACE_GETDOMAINNAME = @REPLACE_GETDOMAINNAME@\r
+REPLACE_GETGROUPS = @REPLACE_GETGROUPS@\r
+REPLACE_GETLINE = @REPLACE_GETLINE@\r
+REPLACE_GETLOGIN_R = @REPLACE_GETLOGIN_R@\r
+REPLACE_GETPAGESIZE = @REPLACE_GETPAGESIZE@\r
+REPLACE_HUGE_VAL = @REPLACE_HUGE_VAL@\r
+REPLACE_HYPOT = @REPLACE_HYPOT@\r
+REPLACE_HYPOTF = @REPLACE_HYPOTF@\r
+REPLACE_HYPOTL = @REPLACE_HYPOTL@\r
+REPLACE_ILOGB = @REPLACE_ILOGB@\r
+REPLACE_ILOGBF = @REPLACE_ILOGBF@\r
+REPLACE_ISATTY = @REPLACE_ISATTY@\r
+REPLACE_ISFINITE = @REPLACE_ISFINITE@\r
+REPLACE_ISINF = @REPLACE_ISINF@\r
+REPLACE_ISNAN = @REPLACE_ISNAN@\r
+REPLACE_ISWBLANK = @REPLACE_ISWBLANK@\r
+REPLACE_ISWCNTRL = @REPLACE_ISWCNTRL@\r
+REPLACE_ITOLD = @REPLACE_ITOLD@\r
+REPLACE_LCHOWN = @REPLACE_LCHOWN@\r
+REPLACE_LDEXPL = @REPLACE_LDEXPL@\r
+REPLACE_LINK = @REPLACE_LINK@\r
+REPLACE_LINKAT = @REPLACE_LINKAT@\r
+REPLACE_LOCALTIME_R = @REPLACE_LOCALTIME_R@\r
+REPLACE_LOG = @REPLACE_LOG@\r
+REPLACE_LOG10 = @REPLACE_LOG10@\r
+REPLACE_LOG10F = @REPLACE_LOG10F@\r
+REPLACE_LOG10L = @REPLACE_LOG10L@\r
+REPLACE_LOG1P = @REPLACE_LOG1P@\r
+REPLACE_LOG1PF = @REPLACE_LOG1PF@\r
+REPLACE_LOG1PL = @REPLACE_LOG1PL@\r
+REPLACE_LOG2 = @REPLACE_LOG2@\r
+REPLACE_LOG2F = @REPLACE_LOG2F@\r
+REPLACE_LOG2L = @REPLACE_LOG2L@\r
+REPLACE_LOGB = @REPLACE_LOGB@\r
+REPLACE_LOGBF = @REPLACE_LOGBF@\r
+REPLACE_LOGBL = @REPLACE_LOGBL@\r
+REPLACE_LOGF = @REPLACE_LOGF@\r
+REPLACE_LOGL = @REPLACE_LOGL@\r
+REPLACE_LSEEK = @REPLACE_LSEEK@\r
+REPLACE_LSTAT = @REPLACE_LSTAT@\r
+REPLACE_MALLOC = @REPLACE_MALLOC@\r
+REPLACE_MBRLEN = @REPLACE_MBRLEN@\r
+REPLACE_MBRTOWC = @REPLACE_MBRTOWC@\r
+REPLACE_MBSINIT = @REPLACE_MBSINIT@\r
+REPLACE_MBSNRTOWCS = @REPLACE_MBSNRTOWCS@\r
+REPLACE_MBSRTOWCS = @REPLACE_MBSRTOWCS@\r
+REPLACE_MBSTATE_T = @REPLACE_MBSTATE_T@\r
+REPLACE_MBTOWC = @REPLACE_MBTOWC@\r
+REPLACE_MEMCHR = @REPLACE_MEMCHR@\r
+REPLACE_MEMMEM = @REPLACE_MEMMEM@\r
+REPLACE_MKDIR = @REPLACE_MKDIR@\r
+REPLACE_MKFIFO = @REPLACE_MKFIFO@\r
+REPLACE_MKNOD = @REPLACE_MKNOD@\r
+REPLACE_MKSTEMP = @REPLACE_MKSTEMP@\r
+REPLACE_MKTIME = @REPLACE_MKTIME@\r
+REPLACE_MODF = @REPLACE_MODF@\r
+REPLACE_MODFF = @REPLACE_MODFF@\r
+REPLACE_MODFL = @REPLACE_MODFL@\r
+REPLACE_NAN = @REPLACE_NAN@\r
+REPLACE_NANOSLEEP = @REPLACE_NANOSLEEP@\r
+REPLACE_NULL = @REPLACE_NULL@\r
+REPLACE_OBSTACK_PRINTF = @REPLACE_OBSTACK_PRINTF@\r
+REPLACE_OPEN = @REPLACE_OPEN@\r
+REPLACE_OPENAT = @REPLACE_OPENAT@\r
+REPLACE_PERROR = @REPLACE_PERROR@\r
+REPLACE_POPEN = @REPLACE_POPEN@\r
+REPLACE_POSIX_SPAWN = @REPLACE_POSIX_SPAWN@\r
+REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDCLOSE = @REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDCLOSE@\r
+REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDDUP2 = @REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDDUP2@\r
+REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDOPEN = @REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDOPEN@\r
+REPLACE_PREAD = @REPLACE_PREAD@\r
+REPLACE_PRINTF = @REPLACE_PRINTF@\r
+REPLACE_PTHREAD_SIGMASK = @REPLACE_PTHREAD_SIGMASK@\r
+REPLACE_PTSNAME = @REPLACE_PTSNAME@\r
+REPLACE_PTSNAME_R = @REPLACE_PTSNAME_R@\r
+REPLACE_PUTENV = @REPLACE_PUTENV@\r
+REPLACE_PWRITE = @REPLACE_PWRITE@\r
+REPLACE_RAISE = @REPLACE_RAISE@\r
+REPLACE_RANDOM_R = @REPLACE_RANDOM_R@\r
+REPLACE_READ = @REPLACE_READ@\r
+REPLACE_READLINK = @REPLACE_READLINK@\r
+REPLACE_REALLOC = @REPLACE_REALLOC@\r
+REPLACE_REALPATH = @REPLACE_REALPATH@\r
+REPLACE_REMAINDER = @REPLACE_REMAINDER@\r
+REPLACE_REMAINDERF = @REPLACE_REMAINDERF@\r
+REPLACE_REMAINDERL = @REPLACE_REMAINDERL@\r
+REPLACE_REMOVE = @REPLACE_REMOVE@\r
+REPLACE_RENAME = @REPLACE_RENAME@\r
+REPLACE_RENAMEAT = @REPLACE_RENAMEAT@\r
+REPLACE_RMDIR = @REPLACE_RMDIR@\r
+REPLACE_ROUND = @REPLACE_ROUND@\r
+REPLACE_ROUNDF = @REPLACE_ROUNDF@\r
+REPLACE_ROUNDL = @REPLACE_ROUNDL@\r
+REPLACE_SETENV = @REPLACE_SETENV@\r
+REPLACE_SIGNBIT = @REPLACE_SIGNBIT@\r
+REPLACE_SIGNBIT_USING_GCC = @REPLACE_SIGNBIT_USING_GCC@\r
+REPLACE_SLEEP = @REPLACE_SLEEP@\r
+REPLACE_SNPRINTF = @REPLACE_SNPRINTF@\r
+REPLACE_SPRINTF = @REPLACE_SPRINTF@\r
+REPLACE_SQRTL = @REPLACE_SQRTL@\r
+REPLACE_STAT = @REPLACE_STAT@\r
+REPLACE_STDIO_READ_FUNCS = @REPLACE_STDIO_READ_FUNCS@\r
+REPLACE_STDIO_WRITE_FUNCS = @REPLACE_STDIO_WRITE_FUNCS@\r
+REPLACE_STPNCPY = @REPLACE_STPNCPY@\r
+REPLACE_STRCASESTR = @REPLACE_STRCASESTR@\r
+REPLACE_STRCHRNUL = @REPLACE_STRCHRNUL@\r
+REPLACE_STRDUP = @REPLACE_STRDUP@\r
+REPLACE_STRERROR = @REPLACE_STRERROR@\r
+REPLACE_STRERROR_R = @REPLACE_STRERROR_R@\r
+REPLACE_STRNCAT = @REPLACE_STRNCAT@\r
+REPLACE_STRNDUP = @REPLACE_STRNDUP@\r
+REPLACE_STRNLEN = @REPLACE_STRNLEN@\r
+REPLACE_STRSIGNAL = @REPLACE_STRSIGNAL@\r
+REPLACE_STRSTR = @REPLACE_STRSTR@\r
+REPLACE_STRTOD = @REPLACE_STRTOD@\r
+REPLACE_STRTOIMAX = @REPLACE_STRTOIMAX@\r
+REPLACE_STRTOK_R = @REPLACE_STRTOK_R@\r
+REPLACE_SYMLINK = @REPLACE_SYMLINK@\r
+REPLACE_TIMEGM = @REPLACE_TIMEGM@\r
+REPLACE_TMPFILE = @REPLACE_TMPFILE@\r
+REPLACE_TOWLOWER = @REPLACE_TOWLOWER@\r
+REPLACE_TRUNC = @REPLACE_TRUNC@\r
+REPLACE_TRUNCF = @REPLACE_TRUNCF@\r
+REPLACE_TRUNCL = @REPLACE_TRUNCL@\r
+REPLACE_TTYNAME_R = @REPLACE_TTYNAME_R@\r
+REPLACE_UNLINK = @REPLACE_UNLINK@\r
+REPLACE_UNLINKAT = @REPLACE_UNLINKAT@\r
+REPLACE_UNSETENV = @REPLACE_UNSETENV@\r
+REPLACE_USLEEP = @REPLACE_USLEEP@\r
+REPLACE_UTIMENSAT = @REPLACE_UTIMENSAT@\r
+REPLACE_VASPRINTF = @REPLACE_VASPRINTF@\r
+REPLACE_VDPRINTF = @REPLACE_VDPRINTF@\r
+REPLACE_VFPRINTF = @REPLACE_VFPRINTF@\r
+REPLACE_VPRINTF = @REPLACE_VPRINTF@\r
+REPLACE_VSNPRINTF = @REPLACE_VSNPRINTF@\r
+REPLACE_VSPRINTF = @REPLACE_VSPRINTF@\r
+REPLACE_WCRTOMB = @REPLACE_WCRTOMB@\r
+REPLACE_WCSNRTOMBS = @REPLACE_WCSNRTOMBS@\r
+REPLACE_WCSRTOMBS = @REPLACE_WCSRTOMBS@\r
+REPLACE_WCSWIDTH = @REPLACE_WCSWIDTH@\r
+REPLACE_WCTOB = @REPLACE_WCTOB@\r
+REPLACE_WCTOMB = @REPLACE_WCTOMB@\r
+REPLACE_WCWIDTH = @REPLACE_WCWIDTH@\r
+REPLACE_WRITE = @REPLACE_WRITE@\r
+SCHED_H = @SCHED_H@\r
+SET_MAKE = @SET_MAKE@\r
+SHELL = @SHELL@\r
+SIG_ATOMIC_T_SUFFIX = @SIG_ATOMIC_T_SUFFIX@\r
+SIZE_T_SUFFIX = @SIZE_T_SUFFIX@\r
+STDBOOL_H = @STDBOOL_H@\r
+STDDEF_H = @STDDEF_H@\r
+STDINT_H = @STDINT_H@\r
+STRIP = @STRIP@\r
+SYS_TIME_H_DEFINES_STRUCT_TIMESPEC = @SYS_TIME_H_DEFINES_STRUCT_TIMESPEC@\r
+TIME_H_DEFINES_STRUCT_TIMESPEC = @TIME_H_DEFINES_STRUCT_TIMESPEC@\r
+UINT32_MAX_LT_UINTMAX_MAX = @UINT32_MAX_LT_UINTMAX_MAX@\r
+UINT64_MAX_EQ_ULONG_MAX = @UINT64_MAX_EQ_ULONG_MAX@\r
+UNDEFINE_STRTOK_R = @UNDEFINE_STRTOK_R@\r
+UNISTD_H_HAVE_WINSOCK2_H = @UNISTD_H_HAVE_WINSOCK2_H@\r
+UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS = @UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS@\r
+USE_NLS = @USE_NLS@\r
+VALGRIND = @VALGRIND@\r
+VALGRIND_PREBISON = @VALGRIND_PREBISON@\r
+VERSION = @VERSION@\r
+WARN_CFLAGS = @WARN_CFLAGS@\r
+WARN_CFLAGS_TEST = @WARN_CFLAGS_TEST@\r
+WARN_CXXFLAGS = @WARN_CXXFLAGS@\r
+WARN_CXXFLAGS_TEST = @WARN_CXXFLAGS_TEST@\r
+WCHAR_T_SUFFIX = @WCHAR_T_SUFFIX@\r
+WERROR_CFLAGS = @WERROR_CFLAGS@\r
+WERROR_CXXFLAGS = @WERROR_CXXFLAGS@\r
+WINDOWS_64_BIT_OFF_T = @WINDOWS_64_BIT_OFF_T@\r
+WINDOWS_64_BIT_ST_SIZE = @WINDOWS_64_BIT_ST_SIZE@\r
+WINT_T_SUFFIX = @WINT_T_SUFFIX@\r
+XGETTEXT = @XGETTEXT@\r
+XGETTEXT_015 = @XGETTEXT_015@\r
+XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@\r
+XSLTPROC = @XSLTPROC@\r
+YACC = @YACC@\r
+YACC_LIBRARY = @YACC_LIBRARY@\r
+YACC_SCRIPT = @YACC_SCRIPT@\r
+YFLAGS = @YFLAGS@\r
+abs_builddir = @abs_builddir@\r
+abs_srcdir = @abs_srcdir@\r
+abs_top_builddir = @abs_top_builddir@\r
+abs_top_srcdir = @abs_top_srcdir@\r
+ac_ct_CC = @ac_ct_CC@\r
+ac_ct_CXX = @ac_ct_CXX@\r
+aclocaldir = @aclocaldir@\r
+am__include = @am__include@\r
+am__leading_dot = @am__leading_dot@\r
+am__quote = @am__quote@\r
+am__tar = @am__tar@\r
+am__untar = @am__untar@\r
+bindir = @bindir@\r
+build = @build@\r
+build_alias = @build_alias@\r
+build_cpu = @build_cpu@\r
+build_os = @build_os@\r
+build_vendor = @build_vendor@\r
+builddir = @builddir@\r
+datadir = @datadir@\r
+datarootdir = @datarootdir@\r
+docdir = @docdir@\r
+dvidir = @dvidir@\r
+exec_prefix = @exec_prefix@\r
+gl_LIBOBJS = @gl_LIBOBJS@\r
+gl_LTLIBOBJS = @gl_LTLIBOBJS@\r
+gltests_LIBOBJS = @gltests_LIBOBJS@\r
+gltests_LTLIBOBJS = @gltests_LTLIBOBJS@\r
+gltests_WITNESS = @gltests_WITNESS@\r
+host = @host@\r
+host_alias = @host_alias@\r
+host_cpu = @host_cpu@\r
+host_os = @host_os@\r
+host_vendor = @host_vendor@\r
+htmldir = @htmldir@\r
+includedir = @includedir@\r
+infodir = @infodir@\r
+install_sh = @install_sh@\r
+libdir = @libdir@\r
+libexecdir = @libexecdir@\r
+lispdir = @lispdir@\r
+localedir = @localedir@\r
+localstatedir = @localstatedir@\r
+mandir = @mandir@\r
+mkdir_p = @mkdir_p@\r
+oldincludedir = @oldincludedir@\r
+pdfdir = @pdfdir@\r
+prefix = @prefix@\r
+program_transform_name = @program_transform_name@\r
+psdir = @psdir@\r
+sbindir = @sbindir@\r
+sharedstatedir = @sharedstatedir@\r
+srcdir = @srcdir@\r
+sysconfdir = @sysconfdir@\r
+target_alias = @target_alias@\r
+top_build_prefix = @top_build_prefix@\r
+top_builddir = @top_builddir@\r
+top_srcdir = @top_srcdir@\r
+dist_pkgdata_DATA = README bison.m4 \\r
+ c-like.m4 \\r
+ c-skel.m4 c.m4 yacc.c glr.c \\r
+ c++-skel.m4 c++.m4 location.cc lalr1.cc glr.cc stack.hh \\r
+ java-skel.m4 java.m4 lalr1.java\r
+\r
+m4sugardir = $(pkgdatadir)/m4sugar\r
+dist_m4sugar_DATA = m4sugar/m4sugar.m4 m4sugar/foreach.m4\r
+xsltdir = $(pkgdatadir)/xslt\r
+dist_xslt_DATA = \\r
+ xslt/bison.xsl \\r
+ xslt/xml2dot.xsl \\r
+ xslt/xml2text.xsl \\r
+ xslt/xml2xhtml.xsl\r
+\r
+all: all-am\r
+\r
+.SUFFIXES:\r
+$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)\r
+ @for dep in $?; do \\r
+ case '$(am__configure_deps)' in \\r
+ *$$dep*) \\r
+ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \\r
+ && { if test -f $@; then exit 0; else break; fi; }; \\r
+ exit 1;; \\r
+ esac; \\r
+ done; \\r
+ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnits data/Makefile'; \\r
+ $(am__cd) $(top_srcdir) && \\r
+ $(AUTOMAKE) --gnits data/Makefile\r
+.PRECIOUS: Makefile\r
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status\r
+ @case '$?' in \\r
+ *config.status*) \\r
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \\r
+ *) \\r
+ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \\r
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \\r
+ esac;\r
+\r
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)\r
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh\r
+\r
+$(top_srcdir)/configure: $(am__configure_deps)\r
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh\r
+$(ACLOCAL_M4): $(am__aclocal_m4_deps)\r
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh\r
+$(am__aclocal_m4_deps):\r
+install-dist_m4sugarDATA: $(dist_m4sugar_DATA)\r
+ @$(NORMAL_INSTALL)\r
+ @list='$(dist_m4sugar_DATA)'; test -n "$(m4sugardir)" || list=; \\r
+ if test -n "$$list"; then \\r
+ echo " $(MKDIR_P) '$(DESTDIR)$(m4sugardir)'"; \\r
+ $(MKDIR_P) "$(DESTDIR)$(m4sugardir)" || exit 1; \\r
+ fi; \\r
+ for p in $$list; do \\r
+ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \\r
+ echo "$$d$$p"; \\r
+ done | $(am__base_list) | \\r
+ while read files; do \\r
+ echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(m4sugardir)'"; \\r
+ $(INSTALL_DATA) $$files "$(DESTDIR)$(m4sugardir)" || exit $$?; \\r
+ done\r
+\r
+uninstall-dist_m4sugarDATA:\r
+ @$(NORMAL_UNINSTALL)\r
+ @list='$(dist_m4sugar_DATA)'; test -n "$(m4sugardir)" || list=; \\r
+ files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \\r
+ dir='$(DESTDIR)$(m4sugardir)'; $(am__uninstall_files_from_dir)\r
+install-dist_pkgdataDATA: $(dist_pkgdata_DATA)\r
+ @$(NORMAL_INSTALL)\r
+ @list='$(dist_pkgdata_DATA)'; test -n "$(pkgdatadir)" || list=; \\r
+ if test -n "$$list"; then \\r
+ echo " $(MKDIR_P) '$(DESTDIR)$(pkgdatadir)'"; \\r
+ $(MKDIR_P) "$(DESTDIR)$(pkgdatadir)" || exit 1; \\r
+ fi; \\r
+ for p in $$list; do \\r
+ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \\r
+ echo "$$d$$p"; \\r
+ done | $(am__base_list) | \\r
+ while read files; do \\r
+ echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(pkgdatadir)'"; \\r
+ $(INSTALL_DATA) $$files "$(DESTDIR)$(pkgdatadir)" || exit $$?; \\r
+ done\r
+\r
+uninstall-dist_pkgdataDATA:\r
+ @$(NORMAL_UNINSTALL)\r
+ @list='$(dist_pkgdata_DATA)'; test -n "$(pkgdatadir)" || list=; \\r
+ files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \\r
+ dir='$(DESTDIR)$(pkgdatadir)'; $(am__uninstall_files_from_dir)\r
+install-dist_xsltDATA: $(dist_xslt_DATA)\r
+ @$(NORMAL_INSTALL)\r
+ @list='$(dist_xslt_DATA)'; test -n "$(xsltdir)" || list=; \\r
+ if test -n "$$list"; then \\r
+ echo " $(MKDIR_P) '$(DESTDIR)$(xsltdir)'"; \\r
+ $(MKDIR_P) "$(DESTDIR)$(xsltdir)" || exit 1; \\r
+ fi; \\r
+ for p in $$list; do \\r
+ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \\r
+ echo "$$d$$p"; \\r
+ done | $(am__base_list) | \\r
+ while read files; do \\r
+ echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(xsltdir)'"; \\r
+ $(INSTALL_DATA) $$files "$(DESTDIR)$(xsltdir)" || exit $$?; \\r
+ done\r
+\r
+uninstall-dist_xsltDATA:\r
+ @$(NORMAL_UNINSTALL)\r
+ @list='$(dist_xslt_DATA)'; test -n "$(xsltdir)" || list=; \\r
+ files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \\r
+ dir='$(DESTDIR)$(xsltdir)'; $(am__uninstall_files_from_dir)\r
+tags: TAGS\r
+TAGS:\r
+\r
+ctags: CTAGS\r
+CTAGS:\r
+\r
+cscope cscopelist:\r
+\r
+\r
+distdir: $(DISTFILES)\r
+ @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \\r
+ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \\r
+ list='$(DISTFILES)'; \\r
+ dist_files=`for file in $$list; do echo $$file; done | \\r
+ sed -e "s|^$$srcdirstrip/||;t" \\r
+ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \\r
+ case $$dist_files in \\r
+ */*) $(MKDIR_P) `echo "$$dist_files" | \\r
+ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \\r
+ sort -u` ;; \\r
+ esac; \\r
+ for file in $$dist_files; do \\r
+ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \\r
+ if test -d $$d/$$file; then \\r
+ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \\r
+ if test -d "$(distdir)/$$file"; then \\r
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \\r
+ fi; \\r
+ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \\r
+ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \\r
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \\r
+ fi; \\r
+ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \\r
+ else \\r
+ test -f "$(distdir)/$$file" \\r
+ || cp -p $$d/$$file "$(distdir)/$$file" \\r
+ || exit 1; \\r
+ fi; \\r
+ done\r
+check-am: all-am\r
+check: check-am\r
+all-am: Makefile $(DATA)\r
+installdirs:\r
+ for dir in "$(DESTDIR)$(m4sugardir)" "$(DESTDIR)$(pkgdatadir)" "$(DESTDIR)$(xsltdir)"; do \\r
+ test -z "$$dir" || $(MKDIR_P) "$$dir"; \\r
+ done\r
+install: install-am\r
+install-exec: install-exec-am\r
+install-data: install-data-am\r
+uninstall: uninstall-am\r
+\r
+install-am: all-am\r
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am\r
+\r
+installcheck: installcheck-am\r
+install-strip:\r
+ if test -z '$(STRIP)'; then \\r
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \\r
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \\r
+ install; \\r
+ else \\r
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \\r
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \\r
+ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \\r
+ fi\r
+mostlyclean-generic:\r
+\r
+clean-generic:\r
+\r
+distclean-generic:\r
+ -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)\r
+ -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)\r
+\r
+maintainer-clean-generic:\r
+ @echo "This command is intended for maintainers to use"\r
+ @echo "it deletes files that may require special tools to rebuild."\r
+clean: clean-am\r
+\r
+clean-am: clean-generic mostlyclean-am\r
+\r
+distclean: distclean-am\r
+ -rm -f Makefile\r
+distclean-am: clean-am distclean-generic\r
+\r
+dvi: dvi-am\r
+\r
+dvi-am:\r
+\r
+html: html-am\r
+\r
+html-am:\r
+\r
+info: info-am\r
+\r
+info-am:\r
+\r
+install-data-am: install-dist_m4sugarDATA install-dist_pkgdataDATA \\r
+ install-dist_xsltDATA\r
+\r
+install-dvi: install-dvi-am\r
+\r
+install-dvi-am:\r
+\r
+install-exec-am:\r
+\r
+install-html: install-html-am\r
+\r
+install-html-am:\r
+\r
+install-info: install-info-am\r
+\r
+install-info-am:\r
+\r
+install-man:\r
+\r
+install-pdf: install-pdf-am\r
+\r
+install-pdf-am:\r
+\r
+install-ps: install-ps-am\r
+\r
+install-ps-am:\r
+\r
+installcheck-am:\r
+\r
+maintainer-clean: maintainer-clean-am\r
+ -rm -f Makefile\r
+maintainer-clean-am: distclean-am maintainer-clean-generic\r
+\r
+mostlyclean: mostlyclean-am\r
+\r
+mostlyclean-am: mostlyclean-generic\r
+\r
+pdf: pdf-am\r
+\r
+pdf-am:\r
+\r
+ps: ps-am\r
+\r
+ps-am:\r
+\r
+uninstall-am: uninstall-dist_m4sugarDATA uninstall-dist_pkgdataDATA \\r
+ uninstall-dist_xsltDATA\r
+\r
+.MAKE: install-am install-strip\r
+\r
+.PHONY: all all-am check check-am clean clean-generic distclean \\r
+ distclean-generic distdir dvi dvi-am html html-am info info-am \\r
+ install install-am install-data install-data-am \\r
+ install-dist_m4sugarDATA install-dist_pkgdataDATA \\r
+ install-dist_xsltDATA install-dvi install-dvi-am install-exec \\r
+ install-exec-am install-html install-html-am install-info \\r
+ install-info-am install-man install-pdf install-pdf-am \\r
+ install-ps install-ps-am install-strip installcheck \\r
+ installcheck-am installdirs maintainer-clean \\r
+ maintainer-clean-generic mostlyclean mostlyclean-generic pdf \\r
+ pdf-am ps ps-am uninstall uninstall-am \\r
+ uninstall-dist_m4sugarDATA uninstall-dist_pkgdataDATA \\r
+ uninstall-dist_xsltDATA\r
+\r
+\r
+# Tell versions [3.59,3.63) of GNU make to not export all variables.\r
+# Otherwise a system limit (for SysV at least) may be exceeded.\r
+.NOEXPORT:\r
--- /dev/null
+-*- outline -*-\r
+\r
+This directory contains data needed by Bison.\r
+\r
+* Skeletons\r
+Bison skeletons: the general shapes of the different parser kinds,\r
+that are specialized for specific grammars by the bison program.\r
+\r
+Currently, the supported skeletons are:\r
+\r
+- yacc.c\r
+ It used to be named bison.simple: it corresponds to C Yacc\r
+ compatible LALR(1) parsers.\r
+\r
+- lalr1.cc\r
+ Produces a C++ parser class.\r
+\r
+- lalr1.java\r
+ Produces a Java parser class.\r
+\r
+- glr.c\r
+ A Generalized LR C parser based on Bison's LALR(1) tables.\r
+\r
+- glr.cc\r
+ A Generalized LR C++ parser. Actually a C++ wrapper around glr.c.\r
+\r
+These skeletons are the only ones supported by the Bison team.\r
+Because the interface between skeletons and the bison program is not\r
+finished, *we are not bound to it*. In particular, Bison is not\r
+mature enough for us to consider that ``foreign skeletons'' are\r
+supported.\r
+\r
+* m4sugar\r
+This directory contains M4sugar, sort of an extended library for M4,\r
+which is used by Bison to instantiate the skeletons.\r
+\r
+* xslt\r
+This directory contains XSLT programs that transform Bison's XML output\r
+into various formats.\r
+\r
+- bison.xsl\r
+ A library of routines used by the other XSLT programs.\r
+\r
+- xml2dot.xsl\r
+ Conversion into GraphViz's dot format.\r
+\r
+- xml2text.xsl\r
+ Conversion into text.\r
+\r
+- xml2xhtml.xsl\r
+ Conversion into XHTML.\r
+\r
+-----\r
+\r
+Copyright (C) 2002, 2008-2012 Free Software Foundation, Inc.\r
+\r
+This file is part of GNU Bison.\r
+\r
+This program is free software: you can redistribute it and/or modify\r
+it under the terms of the GNU General Public License as published by\r
+the Free Software Foundation, either version 3 of the License, or\r
+(at your option) any later version.\r
+\r
+This program is distributed in the hope that it will be useful,\r
+but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
+GNU General Public License for more details.\r
+\r
+You should have received a copy of the GNU General Public License\r
+along with this program. If not, see <http://www.gnu.org/licenses/>.\r
--- /dev/null
+ -*- Autoconf -*-\r
+\r
+# Language-independent M4 Macros for Bison.\r
+\r
+# Copyright (C) 2002, 2004-2012 Free Software Foundation, Inc.\r
+\r
+# This program is free software: you can redistribute it and/or modify\r
+# it under the terms of the GNU General Public License as published by\r
+# the Free Software Foundation, either version 3 of the License, or\r
+# (at your option) any later version.\r
+#\r
+# This program is distributed in the hope that it will be useful,\r
+# but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
+# GNU General Public License for more details.\r
+#\r
+# You should have received a copy of the GNU General Public License\r
+# along with this program. If not, see <http://www.gnu.org/licenses/>.\r
+\r
+\r
+## ---------------- ##\r
+## Identification. ##\r
+## ---------------- ##\r
+\r
+# b4_copyright(TITLE, YEARS)\r
+# --------------------------\r
+m4_define([b4_copyright],\r
+[b4_comment([A Bison parser, made by GNU Bison b4_version.])\r
+\r
+b4_comment([$1\r
+\r
+m4_text_wrap([Copyright (C) $2 Free Software Foundation, Inc.], [ ])\r
+\r
+This program is free software: you can redistribute it and/or modify\r
+it under the terms of the GNU General Public License as published by\r
+the Free Software Foundation, either version 3 of the License, or\r
+(at your option) any later version.\r
+\r
+This program is distributed in the hope that it will be useful,\r
+but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
+GNU General Public License for more details.\r
+\r
+You should have received a copy of the GNU General Public License\r
+along with this program. If not, see <http://www.gnu.org/licenses/>.])\r
+\r
+b4_comment([As a special exception, you may create a larger work that contains\r
+part or all of the Bison parser skeleton and distribute that work\r
+under terms of your choice, so long as that work isn't itself a\r
+parser generator using the skeleton or a modified version thereof\r
+as a parser skeleton. Alternatively, if you modify or redistribute\r
+the parser skeleton itself, you may (at your option) remove this\r
+special exception, which will cause the skeleton and the resulting\r
+Bison output files to be licensed under the GNU General Public\r
+License without this special exception.\r
+\r
+This special exception was added by the Free Software Foundation in\r
+version 2.2 of Bison.])])\r
+\r
+\r
+## -------- ##\r
+## Output. ##\r
+## -------- ##\r
+\r
+# b4_output_begin(FILE)\r
+# ---------------------\r
+# Enable output, i.e., send to diversion 0, expand after "#", and\r
+# generate the tag to output into FILE. Must be followed by EOL.\r
+m4_define([b4_output_begin],\r
+[m4_changecom()\r
+m4_divert_push(0)dnl\r
+@output(m4_unquote([$1])@)@dnl\r
+])\r
+\r
+\r
+# b4_output_end()\r
+# ---------------\r
+# Output nothing, restore # as comment character (no expansions after #).\r
+m4_define([b4_output_end],\r
+[m4_divert_pop(0)\r
+m4_changecom([#])\r
+])\r
+\r
+\r
+## ---------------- ##\r
+## Error handling. ##\r
+## ---------------- ##\r
+\r
+# The following error handling macros print error directives that should not\r
+# become arguments of other macro invocations since they would likely then be\r
+# mangled. Thus, they print to stdout directly.\r
+\r
+# b4_cat(TEXT)\r
+# ------------\r
+# Write TEXT to stdout. Precede the final newline with an @ so that it's\r
+# escaped. For example:\r
+#\r
+# b4_cat([[@complain(invalid input@)]])\r
+m4_define([b4_cat],\r
+[m4_syscmd([cat <<'_m4eof'\r
+]m4_bpatsubst(m4_dquote($1), [_m4eof], [_m4@`eof])[@\r
+_m4eof\r
+])dnl\r
+m4_if(m4_sysval, [0], [], [m4_fatal([$0: cannot write to stdout])])])\r
+\r
+# b4_error(KIND, FORMAT, [ARG1], [ARG2], ...)\r
+# -------------------------------------------\r
+# Write @KIND(FORMAT@,ARG1@,ARG2@,...@) to stdout.\r
+#\r
+# For example:\r
+#\r
+# b4_error([[warn]], [[invalid value for '%s': %s]], [[foo]], [[3]])\r
+m4_define([b4_error],\r
+[b4_cat([[@]$1[(]$2[]]dnl\r
+[m4_if([$#], [2], [],\r
+ [m4_foreach([b4_arg],\r
+ m4_dquote(m4_shift(m4_shift($@))),\r
+ [[@,]b4_arg])])[@)]])])\r
+\r
+# b4_error_at(KIND, START, END, FORMAT, [ARG1], [ARG2], ...)\r
+# ----------------------------------------------------------\r
+# Write @KIND_at(START@,END@,FORMAT@,ARG1@,ARG2@,...@) to stdout.\r
+#\r
+# For example:\r
+#\r
+# b4_error_at([[complain]], [[input.y:2.3]], [[input.y:5.4]],\r
+# [[invalid %s]], [[foo]])\r
+m4_define([b4_error_at],\r
+[b4_cat([[@]$1[_at(]$2[@,]$3[@,]$4[]]dnl\r
+[m4_if([$#], [4], [],\r
+ [m4_foreach([b4_arg],\r
+ m4_dquote(m4_shift(m4_shift(m4_shift(m4_shift($@))))),\r
+ [[@,]b4_arg])])[@)]])])\r
+\r
+# b4_warn(FORMAT, [ARG1], [ARG2], ...)\r
+# ------------------------------------\r
+# Write @warn(FORMAT@,ARG1@,ARG2@,...@) to stdout.\r
+#\r
+# For example:\r
+#\r
+# b4_warn([[invalid value for '%s': %s]], [[foo]], [[3]])\r
+#\r
+# As a simple test suite, this:\r
+#\r
+# m4_divert(-1)\r
+# m4_define([asdf], [ASDF])\r
+# m4_define([fsa], [FSA])\r
+# m4_define([fdsa], [FDSA])\r
+# b4_warn([[[asdf), asdf]]], [[[fsa), fsa]]], [[[fdsa), fdsa]]])\r
+# b4_warn([[asdf), asdf]], [[fsa), fsa]], [[fdsa), fdsa]])\r
+# b4_warn()\r
+# b4_warn(1)\r
+# b4_warn(1, 2)\r
+#\r
+# Should produce this without newlines:\r
+#\r
+# @warn([asdf), asdf]@,[fsa), fsa]@,[fdsa), fdsa]@)\r
+# @warn(asdf), asdf@,fsa), fsa@,fdsa), fdsa@)\r
+# @warn(@)\r
+# @warn(1@)\r
+# @warn(1@,2@)\r
+m4_define([b4_warn],\r
+[b4_error([[warn]], $@)])\r
+\r
+# b4_warn_at(START, END, FORMAT, [ARG1], [ARG2], ...)\r
+# ---------------------------------------------------\r
+# Write @warn(START@,END@,FORMAT@,ARG1@,ARG2@,...@) to stdout.\r
+#\r
+# For example:\r
+#\r
+# b4_warn_at([[input.y:2.3]], [[input.y:5.4]], [[invalid %s]], [[foo]])\r
+m4_define([b4_warn_at],\r
+[b4_error_at([[warn]], $@)])\r
+\r
+# b4_complain(FORMAT, [ARG1], [ARG2], ...)\r
+# ----------------------------------------\r
+# Write @complain(FORMAT@,ARG1@,ARG2@,...@) to stdout.\r
+#\r
+# See b4_warn example.\r
+m4_define([b4_complain],\r
+[b4_error([[complain]], $@)])\r
+\r
+# b4_complain_at(START, END, FORMAT, [ARG1], [ARG2], ...)\r
+# -------------------------------------------------------\r
+# Write @complain(START@,END@,FORMAT@,ARG1@,ARG2@,...@) to stdout.\r
+#\r
+# See b4_warn_at example.\r
+m4_define([b4_complain_at],\r
+[b4_error_at([[complain]], $@)])\r
+\r
+# b4_fatal(FORMAT, [ARG1], [ARG2], ...)\r
+# -------------------------------------\r
+# Write @fatal(FORMAT@,ARG1@,ARG2@,...@) to stdout and exit.\r
+#\r
+# See b4_warn example.\r
+m4_define([b4_fatal],\r
+[b4_error([[fatal]], $@)dnl\r
+m4_exit(1)])\r
+\r
+# b4_fatal_at(START, END, FORMAT, [ARG1], [ARG2], ...)\r
+# ----------------------------------------------------\r
+# Write @fatal(START@,END@,FORMAT@,ARG1@,ARG2@,...@) to stdout and exit.\r
+#\r
+# See b4_warn_at example.\r
+m4_define([b4_fatal_at],\r
+[b4_error_at([[fatal]], $@)dnl\r
+m4_exit(1)])\r
+\r
+\r
+## ------------ ##\r
+## Data Types. ##\r
+## ------------ ##\r
+\r
+# b4_ints_in(INT1, INT2, LOW, HIGH)\r
+# ---------------------------------\r
+# Return 1 iff both INT1 and INT2 are in [LOW, HIGH], 0 otherwise.\r
+m4_define([b4_ints_in],\r
+[m4_eval([$3 <= $1 && $1 <= $4 && $3 <= $2 && $2 <= $4])])\r
+\r
+\r
+\r
+## ------------------ ##\r
+## Decoding options. ##\r
+## ------------------ ##\r
+\r
+# b4_flag_if(FLAG, IF-TRUE, IF-FALSE)\r
+# -----------------------------------\r
+# Run IF-TRUE if b4_FLAG_flag is 1, IF-FALSE if FLAG is 0, otherwise fail.\r
+m4_define([b4_flag_if],\r
+[m4_case(b4_$1_flag,\r
+ [0], [$3],\r
+ [1], [$2],\r
+ [m4_fatal([invalid $1 value: ]$1)])])\r
+\r
+\r
+# b4_define_flag_if(FLAG)\r
+# -----------------------\r
+# Define "b4_FLAG_if(IF-TRUE, IF-FALSE)" that depends on the\r
+# value of the Boolean FLAG.\r
+m4_define([b4_define_flag_if],\r
+[_b4_define_flag_if($[1], $[2], [$1])])\r
+\r
+# _b4_define_flag_if($1, $2, FLAG)\r
+# --------------------------------\r
+# Work around the impossibility to define macros inside macros,\r
+# because issuing `[$1]' is not possible in M4. GNU M4 should provide\r
+# $$1 a la M5/TeX.\r
+m4_define([_b4_define_flag_if],\r
+[m4_if([$1$2], $[1]$[2], [],\r
+ [m4_fatal([$0: Invalid arguments: $@])])dnl\r
+m4_define([b4_$3_if],\r
+ [b4_flag_if([$3], [$1], [$2])])])\r
+\r
+\r
+# b4_FLAG_if(IF-TRUE, IF-FALSE)\r
+# -----------------------------\r
+# Expand IF-TRUE, if FLAG is true, IF-FALSE otherwise.\r
+b4_define_flag_if([defines]) # Whether headers are requested.\r
+b4_define_flag_if([error_verbose]) # Whether error are verbose.\r
+b4_define_flag_if([glr]) # Whether a GLR parser is requested.\r
+b4_define_flag_if([locations]) # Whether locations are tracked.\r
+b4_define_flag_if([nondeterministic]) # Whether conflicts should be handled.\r
+b4_define_flag_if([token_table]) # Whether yytoken_table is demanded.\r
+b4_define_flag_if([yacc]) # Whether POSIX Yacc is emulated.\r
+\r
+# yytoken_table is needed to support verbose errors.\r
+b4_error_verbose_if([m4_define([b4_token_table_flag], [1])])\r
+\r
+\r
+\r
+## ----------- ##\r
+## Synclines. ##\r
+## ----------- ##\r
+\r
+# b4_basename(NAME)\r
+# -----------------\r
+# Similar to POSIX basename; the differences don't matter here.\r
+# Beware that NAME is not evaluated.\r
+m4_define([b4_basename],\r
+[m4_bpatsubst([$1], [^.*/\([^/]+\)/*$], [\1])])\r
+\r
+\r
+# b4_syncline(LINE, FILE)\r
+# -----------------------\r
+m4_define([b4_syncline],\r
+[b4_flag_if([synclines],\r
+[b4_sync_end([__line__], [b4_basename(m4_quote(__file__))])\r
+b4_sync_start([$1], [$2])])])\r
+\r
+m4_define([b4_sync_end], [b4_comment([Line $1 of $2])])\r
+m4_define([b4_sync_start], [b4_comment([Line $1 of $2])])\r
+\r
+# b4_user_code(USER-CODE)\r
+# -----------------------\r
+# Emit code from the user, ending it with synclines.\r
+m4_define([b4_user_code],\r
+[$1\r
+b4_syncline([@oline@], [@ofile@])])\r
+\r
+\r
+# b4_define_user_code(MACRO)\r
+# --------------------------\r
+# From b4_MACRO, build b4_user_MACRO that includes the synclines.\r
+m4_define([b4_define_user_code],\r
+[m4_define([b4_user_$1],\r
+[b4_user_code([b4_$1])])])\r
+\r
+\r
+# b4_user_actions\r
+# b4_user_initial_action\r
+# b4_user_post_prologue\r
+# b4_user_pre_prologue\r
+# b4_user_stype\r
+# ----------------------\r
+# Macros that issue user code, ending with synclines.\r
+b4_define_user_code([actions])\r
+b4_define_user_code([initial_action])\r
+b4_define_user_code([post_prologue])\r
+b4_define_user_code([pre_prologue])\r
+b4_define_user_code([stype])\r
+\r
+\r
+# b4_check_user_names(WHAT, USER-LIST, BISON-NAMESPACE)\r
+# -----------------------------------------------------\r
+# Complain if any name of type WHAT is used by the user (as recorded in\r
+# USER-LIST) but is not used by Bison (as recorded by macros in the\r
+# namespace BISON-NAMESPACE).\r
+#\r
+# USER-LIST must expand to a list specifying all user occurrences of all names\r
+# of type WHAT. Each item in the list must be a triplet specifying one\r
+# occurrence: name, start boundary, and end boundary. Empty string names are\r
+# fine. An empty list is fine.\r
+#\r
+# For example, to define b4_foo_user_names to be used for USER-LIST with three\r
+# name occurrences and with correct quoting:\r
+#\r
+# m4_define([b4_foo_user_names],\r
+# [[[[[[bar]], [[parser.y:1.7]], [[parser.y:1.16]]]],\r
+# [[[[bar]], [[parser.y:5.7]], [[parser.y:5.16]]]],\r
+# [[[[baz]], [[parser.y:8.7]], [[parser.y:8.16]]]]]])\r
+#\r
+# The macro BISON-NAMESPACE(bar) must be defined iff the name bar of type WHAT\r
+# is used by Bison (in the front-end or in the skeleton). Empty string names\r
+# are fine, but it would be ugly for Bison to actually use one.\r
+#\r
+# For example, to use b4_foo_bison_names for BISON-NAMESPACE and define that\r
+# the names bar and baz are used by Bison:\r
+#\r
+# m4_define([b4_foo_bison_names(bar)])\r
+# m4_define([b4_foo_bison_names(baz)])\r
+#\r
+# To invoke b4_check_user_names with TYPE foo, with USER-LIST\r
+# b4_foo_user_names, with BISON-NAMESPACE b4_foo_bison_names, and with correct\r
+# quoting:\r
+#\r
+# b4_check_user_names([[foo]], [b4_foo_user_names],\r
+# [[b4_foo_bison_names]])\r
+m4_define([b4_check_user_names],\r
+[m4_foreach([b4_occurrence], $2,\r
+[m4_pushdef([b4_occurrence], b4_occurrence)dnl\r
+m4_pushdef([b4_user_name], m4_car(b4_occurrence))dnl\r
+m4_pushdef([b4_start], m4_car(m4_shift(b4_occurrence)))dnl\r
+m4_pushdef([b4_end], m4_shift(m4_shift(b4_occurrence)))dnl\r
+m4_ifndef($3[(]m4_quote(b4_user_name)[)],\r
+ [b4_complain_at([b4_start], [b4_end],\r
+ [[%s '%s' is not used]],\r
+ [$1], [b4_user_name])])[]dnl\r
+m4_popdef([b4_occurrence])dnl\r
+m4_popdef([b4_user_name])dnl\r
+m4_popdef([b4_start])dnl\r
+m4_popdef([b4_end])dnl\r
+])])\r
+\r
+\r
+\r
+\r
+## --------------------- ##\r
+## b4_percent_define_*. ##\r
+## --------------------- ##\r
+\r
+\r
+# b4_percent_define_use(VARIABLE)\r
+# -------------------------------\r
+# Declare that VARIABLE was used.\r
+m4_define([b4_percent_define_use],\r
+[m4_define([b4_percent_define_bison_variables(]$1[)])dnl\r
+])\r
+\r
+# b4_percent_define_get(VARIABLE, [DEFAULT])\r
+# ------------------------------------------\r
+# Mimic muscle_percent_define_get in ../src/muscle-tab.h. That is, if\r
+# the %define variable VARIABLE is defined, emit its value. Contrary\r
+# to its C counterpart, return DEFAULT otherwise. Also, record\r
+# Bison's usage of VARIABLE by defining\r
+# b4_percent_define_bison_variables(VARIABLE).\r
+#\r
+# For example:\r
+#\r
+# b4_percent_define_get([[foo]])\r
+m4_define([b4_percent_define_get],\r
+[b4_percent_define_use([$1])dnl\r
+m4_ifdef([b4_percent_define(]$1[)],\r
+ [m4_indir([b4_percent_define(]$1[)])],\r
+ [$2])])\r
+\r
+\r
+# b4_percent_define_get_loc(VARIABLE)\r
+# -----------------------------------\r
+# Mimic muscle_percent_define_get_loc in ../src/muscle-tab.h exactly. That is,\r
+# if the %define variable VARIABLE is undefined, complain fatally since that's\r
+# a Bison or skeleton error. Otherwise, return its definition location in a\r
+# form approriate for the first two arguments of b4_warn_at, b4_complain_at, or\r
+# b4_fatal_at. Don't record this as a Bison usage of VARIABLE as there's no\r
+# reason to suspect that the user-supplied value has yet influenced the output.\r
+#\r
+# For example:\r
+#\r
+# b4_complain_at(b4_percent_define_get_loc([[foo]]), [[invalid foo]])\r
+m4_define([b4_percent_define_get_loc],\r
+[m4_ifdef([b4_percent_define_loc(]$1[)],\r
+ [m4_pushdef([b4_loc], m4_indir([b4_percent_define_loc(]$1[)]))dnl\r
+b4_loc[]dnl\r
+m4_popdef([b4_loc])],\r
+ [b4_fatal([[b4_percent_define_get_loc: undefined %%define variable '%s']], [$1])])])\r
+\r
+# b4_percent_define_get_syncline(VARIABLE)\r
+# ----------------------------------------\r
+# Mimic muscle_percent_define_get_syncline in ../src/muscle-tab.h exactly.\r
+# That is, if the %define variable VARIABLE is undefined, complain fatally\r
+# since that's a Bison or skeleton error. Otherwise, return its definition\r
+# location as a b4_syncline invocation. Don't record this as a Bison usage of\r
+# VARIABLE as there's no reason to suspect that the user-supplied value has yet\r
+# influenced the output.\r
+#\r
+# For example:\r
+#\r
+# b4_percent_define_get_syncline([[foo]])\r
+m4_define([b4_percent_define_get_syncline],\r
+[m4_ifdef([b4_percent_define_syncline(]$1[)],\r
+ [m4_indir([b4_percent_define_syncline(]$1[)])],\r
+ [b4_fatal([[b4_percent_define_get_syncline: undefined %%define variable '%s']], [$1])])])\r
+\r
+# b4_percent_define_ifdef(VARIABLE, IF-TRUE, [IF-FALSE])\r
+# ------------------------------------------------------\r
+# Mimic muscle_percent_define_ifdef in ../src/muscle-tab.h exactly. That is,\r
+# if the %define variable VARIABLE is defined, expand IF-TRUE, else expand\r
+# IF-FALSE. Also, record Bison's usage of VARIABLE by defining\r
+# b4_percent_define_bison_variables(VARIABLE).\r
+#\r
+# For example:\r
+#\r
+# b4_percent_define_ifdef([[foo]], [[it's defined]], [[it's undefined]])\r
+m4_define([b4_percent_define_ifdef],\r
+[m4_ifdef([b4_percent_define(]$1[)],\r
+ [m4_define([b4_percent_define_bison_variables(]$1[)])$2],\r
+ [$3])])\r
+\r
+# b4_percent_define_flag_if(VARIABLE, IF-TRUE, [IF-FALSE])\r
+# --------------------------------------------------------\r
+# Mimic muscle_percent_define_flag_if in ../src/muscle-tab.h exactly. That is,\r
+# if the %define variable VARIABLE is defined to "" or "true", expand IF-TRUE.\r
+# If it is defined to "false", expand IF-FALSE. Complain if it is undefined\r
+# (a Bison or skeleton error since the default value should have been set\r
+# already) or defined to any other value (possibly a user error). Also, record\r
+# Bison's usage of VARIABLE by defining\r
+# b4_percent_define_bison_variables(VARIABLE).\r
+#\r
+# For example:\r
+#\r
+# b4_percent_define_flag_if([[foo]], [[it's true]], [[it's false]])\r
+m4_define([b4_percent_define_flag_if],\r
+[b4_percent_define_ifdef([$1],\r
+ [m4_case(b4_percent_define_get([$1]),\r
+ [], [$2], [true], [$2], [false], [$3],\r
+ [m4_expand_once([b4_complain_at(b4_percent_define_get_loc([$1]),\r
+ [[invalid value for %%define Boolean variable '%s']],\r
+ [$1])],\r
+ [[b4_percent_define_flag_if($1)]])])],\r
+ [b4_fatal([[b4_percent_define_flag_if: undefined %%define variable '%s']], [$1])])])\r
+\r
+# b4_percent_define_default(VARIABLE, DEFAULT)\r
+# --------------------------------------------\r
+# Mimic muscle_percent_define_default in ../src/muscle-tab.h exactly. That is,\r
+# if the %define variable VARIABLE is undefined, set its value to DEFAULT.\r
+# Don't record this as a Bison usage of VARIABLE as there's no reason to\r
+# suspect that the value has yet influenced the output.\r
+#\r
+# For example:\r
+#\r
+# b4_percent_define_default([[foo]], [[default value]])\r
+m4_define([b4_percent_define_default],\r
+[m4_ifndef([b4_percent_define(]$1[)],\r
+ [m4_define([b4_percent_define(]$1[)], [$2])dnl\r
+ m4_define([b4_percent_define_loc(]$1[)],\r
+ [[[[<skeleton default value>:-1.-1]],\r
+ [[<skeleton default value>:-1.-1]]]])dnl\r
+ m4_define([b4_percent_define_syncline(]$1[)], [[]])])])\r
+\r
+# b4_percent_define_check_values(VALUES)\r
+# --------------------------------------\r
+# Mimic muscle_percent_define_check_values in ../src/muscle-tab.h exactly\r
+# except that the VALUES structure is more appropriate for M4. That is, VALUES\r
+# is a list of sublists of strings. For each sublist, the first string is the\r
+# name of a %define variable, and all remaining strings in that sublist are the\r
+# valid values for that variable. Complain if such a variable is undefined (a\r
+# Bison error since the default value should have been set already) or defined\r
+# to any other value (possibly a user error). Don't record this as a Bison\r
+# usage of the variable as there's no reason to suspect that the value has yet\r
+# influenced the output.\r
+#\r
+# For example:\r
+#\r
+# b4_percent_define_check_values([[[[foo]], [[foo-value1]], [[foo-value2]]]],\r
+# [[[[bar]], [[bar-value1]]]])\r
+m4_define([b4_percent_define_check_values],\r
+[m4_foreach([b4_sublist], m4_quote($@),\r
+ [_b4_percent_define_check_values(b4_sublist)])])\r
+\r
+m4_define([_b4_percent_define_check_values],\r
+[m4_ifdef([b4_percent_define(]$1[)],\r
+ [m4_pushdef([b4_good_value], [0])dnl\r
+ m4_if($#, 1, [],\r
+ [m4_foreach([b4_value], m4_dquote(m4_shift($@)),\r
+ [m4_if(m4_indir([b4_percent_define(]$1[)]), b4_value,\r
+ [m4_define([b4_good_value], [1])])])])dnl\r
+ m4_if(b4_good_value, [0],\r
+ [b4_complain_at(b4_percent_define_get_loc([$1]),\r
+ [[invalid value for %%define variable '%s': '%s']],\r
+ [$1],\r
+ m4_dquote(m4_indir([b4_percent_define(]$1[)])))\r
+ m4_foreach([b4_value], m4_dquote(m4_shift($@)),\r
+ [b4_complain_at(b4_percent_define_get_loc([$1]),\r
+ [[accepted value: '%s']],\r
+ m4_dquote(b4_value))])])dnl\r
+ m4_popdef([b4_good_value])],\r
+ [b4_fatal([[b4_percent_define_check_values: undefined %%define variable '%s']], [$1])])])\r
+\r
+# b4_percent_code_get([QUALIFIER])\r
+# --------------------------------\r
+# If any %code blocks for QUALIFIER are defined, emit them beginning with a\r
+# comment and ending with synclines and a newline. If QUALIFIER is not\r
+# specified or empty, do this for the unqualified %code blocks. Also, record\r
+# Bison's usage of QUALIFIER (if specified) by defining\r
+# b4_percent_code_bison_qualifiers(QUALIFIER).\r
+#\r
+# For example, to emit any unqualified %code blocks followed by any %code\r
+# blocks for the qualifier foo:\r
+#\r
+# b4_percent_code_get\r
+# b4_percent_code_get([[foo]])\r
+m4_define([b4_percent_code_get],\r
+[m4_pushdef([b4_macro_name], [[b4_percent_code(]$1[)]])dnl\r
+m4_ifval([$1], [m4_define([b4_percent_code_bison_qualifiers(]$1[)])])dnl\r
+m4_ifdef(b4_macro_name,\r
+[b4_comment([m4_if([$#], [0], [[Unqualified %code]],\r
+ [["%code ]$1["]])[ blocks.]])\r
+b4_user_code([m4_indir(b4_macro_name)])\r
+])dnl\r
+m4_popdef([b4_macro_name])])\r
+\r
+# b4_percent_code_ifdef(QUALIFIER, IF-TRUE, [IF-FALSE])\r
+# -----------------------------------------------------\r
+# If any %code blocks for QUALIFIER (or unqualified %code blocks if\r
+# QUALIFIER is empty) are defined, expand IF-TRUE, else expand IF-FALSE.\r
+# Also, record Bison's usage of QUALIFIER (if specified) by defining\r
+# b4_percent_code_bison_qualifiers(QUALIFIER).\r
+m4_define([b4_percent_code_ifdef],\r
+[m4_ifdef([b4_percent_code(]$1[)],\r
+ [m4_ifval([$1], [m4_define([b4_percent_code_bison_qualifiers(]$1[)])])$2],\r
+ [$3])])\r
+\r
+\r
+## ----------------------------------------------------------- ##\r
+## After processing the skeletons, check that all the user's ##\r
+## %define variables and %code qualifiers were used by Bison. ##\r
+## ----------------------------------------------------------- ##\r
+\r
+m4_define([b4_check_user_names_wrap],\r
+[m4_ifdef([b4_percent_]$1[_user_]$2[s],\r
+ [b4_check_user_names([[%]$1 $2],\r
+ [b4_percent_]$1[_user_]$2[s],\r
+ [[b4_percent_]$1[_bison_]$2[s]])])])\r
+\r
+m4_wrap_lifo([\r
+b4_check_user_names_wrap([[define]], [[variable]])\r
+b4_check_user_names_wrap([[code]], [[qualifier]])\r
+])\r
+\r
+\r
+## ---------------- ##\r
+## Default values. ##\r
+## ---------------- ##\r
+\r
+# m4_define_default([b4_lex_param], []) dnl breaks other skeletons\r
+m4_define_default([b4_pre_prologue], [])\r
+m4_define_default([b4_post_prologue], [])\r
+m4_define_default([b4_epilogue], [])\r
+m4_define_default([b4_parse_param], [])\r
+\r
+# The initial column and line.\r
+m4_define_default([b4_location_initial_column], [1])\r
+m4_define_default([b4_location_initial_line], [1])\r
+\r
+# Sanity checks.\r
+b4_percent_define_ifdef([api.prefix],\r
+[m4_ifdef([b4_prefix],\r
+[b4_complain_at(b4_percent_define_get_loc([api.prefix]),\r
+ [['%s' and '%s' cannot be used together]],\r
+ [%name-prefix],\r
+ [%define api.prefix])])])\r
--- /dev/null
+ -*- Autoconf -*-\r
+\r
+# C++ skeleton dispatching for Bison.\r
+\r
+# Copyright (C) 2006-2007, 2009-2012 Free Software Foundation, Inc.\r
+\r
+# This program is free software: you can redistribute it and/or modify\r
+# it under the terms of the GNU General Public License as published by\r
+# the Free Software Foundation, either version 3 of the License, or\r
+# (at your option) any later version.\r
+#\r
+# This program is distributed in the hope that it will be useful,\r
+# but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
+# GNU General Public License for more details.\r
+#\r
+# You should have received a copy of the GNU General Public License\r
+# along with this program. If not, see <http://www.gnu.org/licenses/>.\r
+\r
+b4_glr_if( [m4_define([b4_used_skeleton], [b4_pkgdatadir/[glr.cc]])])\r
+b4_nondeterministic_if([m4_define([b4_used_skeleton], [b4_pkgdatadir/[glr.cc]])])\r
+\r
+m4_define_default([b4_used_skeleton], [b4_pkgdatadir/[lalr1.cc]])\r
+m4_define_default([b4_skeleton], ["b4_basename(b4_used_skeleton)"])\r
+\r
+m4_include(b4_used_skeleton)\r
--- /dev/null
+ -*- Autoconf -*-\r
+\r
+# C++ skeleton for Bison\r
+\r
+# Copyright (C) 2002-2012 Free Software Foundation, Inc.\r
+\r
+# This program is free software: you can redistribute it and/or modify\r
+# it under the terms of the GNU General Public License as published by\r
+# the Free Software Foundation, either version 3 of the License, or\r
+# (at your option) any later version.\r
+#\r
+# This program is distributed in the hope that it will be useful,\r
+# but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
+# GNU General Public License for more details.\r
+#\r
+# You should have received a copy of the GNU General Public License\r
+# along with this program. If not, see <http://www.gnu.org/licenses/>.\r
+\r
+m4_include(b4_pkgdatadir/[c.m4])\r
+\r
+## ---------------- ##\r
+## Default values. ##\r
+## ---------------- ##\r
+\r
+# Default parser class name.\r
+b4_percent_define_default([[parser_class_name]], [[parser]])\r
+\r
+# Don't do that so that we remember whether we're using a user\r
+# request, or the default value.\r
+#\r
+# b4_percent_define_default([[api.location.type]], [[location]])\r
+\r
+b4_percent_define_default([[filename_type]], [[std::string]])\r
+b4_percent_define_default([[namespace]], m4_defn([b4_prefix]))\r
+b4_percent_define_default([[global_tokens_and_yystype]], [[false]])\r
+b4_percent_define_default([[define_location_comparison]],\r
+ [m4_if(b4_percent_define_get([[filename_type]]),\r
+ [std::string], [[true]], [[false]])])\r
+\r
+\r
+## ----------- ##\r
+## Namespace. ##\r
+## ----------- ##\r
+\r
+m4_define([b4_namespace_ref], [b4_percent_define_get([[namespace]])])\r
+\r
+# Don't permit an empty b4_namespace_ref. Any `::parser::foo' appended to it\r
+# would compile as an absolute reference with `parser' in the global namespace.\r
+# b4_namespace_open would open an anonymous namespace and thus establish\r
+# internal linkage. This would compile. However, it's cryptic, and internal\r
+# linkage for the parser would be specified in all translation units that\r
+# include the header, which is always generated. If we ever need to permit\r
+# internal linkage somehow, surely we can find a cleaner approach.\r
+m4_if(m4_bregexp(b4_namespace_ref, [^[ ]*$]), [-1], [],\r
+[b4_complain_at(b4_percent_define_get_loc([[namespace]]),\r
+ [[namespace reference is empty]])])\r
+\r
+# Instead of assuming the C++ compiler will do it, Bison should reject any\r
+# invalid b4_namepsace_ref that would be converted to a valid\r
+# b4_namespace_open. The problem is that Bison doesn't always output\r
+# b4_namespace_ref to uncommented code but should reserve the ability to do so\r
+# in future releases without risking breaking any existing user grammars.\r
+# Specifically, don't allow empty names as b4_namespace_open would just convert\r
+# those into anonymous namespaces, and that might tempt some users.\r
+m4_if(m4_bregexp(b4_namespace_ref, [::[ ]*::]), [-1], [],\r
+[b4_complain_at(b4_percent_define_get_loc([[namespace]]),\r
+ [[namespace reference has consecutive "::"]])])\r
+m4_if(m4_bregexp(b4_namespace_ref, [::[ ]*$]), [-1], [],\r
+[b4_complain_at(b4_percent_define_get_loc([[namespace]]),\r
+ [[namespace reference has a trailing "::"]])])\r
+\r
+m4_define([b4_namespace_open],\r
+[b4_user_code([b4_percent_define_get_syncline([[namespace]])\r
+[namespace ]m4_bpatsubst(m4_dquote(m4_bpatsubst(m4_dquote(b4_namespace_ref),\r
+ [^\(.\)[ ]*::], [\1])),\r
+ [::], [ { namespace ])[ {]])])\r
+\r
+m4_define([b4_namespace_close],\r
+[b4_user_code([b4_percent_define_get_syncline([[namespace]])\r
+m4_bpatsubst(m4_dquote(m4_bpatsubst(m4_dquote(b4_namespace_ref[ ]),\r
+ [^\(.\)[ ]*\(::\)?\([^][:]\|:[^:]\)*],\r
+ [\1])),\r
+ [::\([^][:]\|:[^:]\)*], [} ])[} // ]b4_namespace_ref])])\r
+\r
+\r
+# b4_token_enums(LIST-OF-PAIRS-TOKEN-NAME-TOKEN-NUMBER)\r
+# -----------------------------------------------------\r
+# Output the definition of the tokens as enums.\r
+m4_define([b4_token_enums],\r
+[/* Tokens. */\r
+ enum yytokentype {\r
+m4_map_sep([ b4_token_enum], [,\r
+],\r
+ [$@])\r
+ };\r
+])\r
+\r
+\r
+\r
+\r
+## ----------------- ##\r
+## Semantic Values. ##\r
+## ----------------- ##\r
+\r
+\r
+# b4_lhs_value([TYPE])\r
+# --------------------\r
+# Expansion of $<TYPE>$.\r
+m4_define([b4_lhs_value],\r
+[(yyval[]m4_ifval([$1], [.$1]))])\r
+\r
+\r
+# b4_rhs_value(RULE-LENGTH, NUM, [TYPE])\r
+# --------------------------------------\r
+# Expansion of $<TYPE>NUM, where the current rule has RULE-LENGTH\r
+# symbols on RHS.\r
+m4_define([b4_rhs_value],\r
+[(yysemantic_stack_@{($1) - ($2)@}m4_ifval([$3], [.$3]))])\r
+\r
+# b4_lhs_location()\r
+# -----------------\r
+# Expansion of @$.\r
+m4_define([b4_lhs_location],\r
+[(yyloc)])\r
+\r
+\r
+# b4_rhs_location(RULE-LENGTH, NUM)\r
+# ---------------------------------\r
+# Expansion of @NUM, where the current rule has RULE-LENGTH symbols\r
+# on RHS.\r
+m4_define([b4_rhs_location],\r
+[(yylocation_stack_@{($1) - ($2)@})])\r
+\r
+\r
+# b4_parse_param_decl\r
+# -------------------\r
+# Extra formal arguments of the constructor.\r
+# Change the parameter names from "foo" into "foo_yyarg", so that\r
+# there is no collision bw the user chosen attribute name, and the\r
+# argument name in the constructor.\r
+m4_define([b4_parse_param_decl],\r
+[m4_ifset([b4_parse_param],\r
+ [m4_map_sep([b4_parse_param_decl_1], [, ], [b4_parse_param])])])\r
+\r
+m4_define([b4_parse_param_decl_1],\r
+[$1_yyarg])\r
+\r
+\r
+\r
+# b4_parse_param_cons\r
+# -------------------\r
+# Extra initialisations of the constructor.\r
+m4_define([b4_parse_param_cons],\r
+ [m4_ifset([b4_parse_param],\r
+ [\r
+ b4_cc_constructor_calls(b4_parse_param)])])\r
+m4_define([b4_cc_constructor_calls],\r
+ [m4_map_sep([b4_cc_constructor_call], [,\r
+ ], [$@])])\r
+m4_define([b4_cc_constructor_call],\r
+ [$2 ($2_yyarg)])\r
+\r
+# b4_parse_param_vars\r
+# -------------------\r
+# Extra instance variables.\r
+m4_define([b4_parse_param_vars],\r
+ [m4_ifset([b4_parse_param],\r
+ [\r
+ /* User arguments. */\r
+b4_cc_var_decls(b4_parse_param)])])\r
+m4_define([b4_cc_var_decls],\r
+ [m4_map_sep([b4_cc_var_decl], [\r
+], [$@])])\r
+m4_define([b4_cc_var_decl],\r
+ [ $1;])\r
+\r
+\r
+## ---------##\r
+## Values. ##\r
+## ---------##\r
+\r
+# b4_yylloc_default_define\r
+# ------------------------\r
+# Define YYLLOC_DEFAULT.\r
+m4_define([b4_yylloc_default_define],\r
+[[/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].\r
+ If N is 0, then set CURRENT to the empty location which ends\r
+ the previous symbol: RHS[0] (always defined). */\r
+\r
+# ifndef YYLLOC_DEFAULT\r
+# define YYLLOC_DEFAULT(Current, Rhs, N) \\r
+ do \\r
+ if (N) \\r
+ { \\r
+ (Current).begin = YYRHSLOC (Rhs, 1).begin; \\r
+ (Current).end = YYRHSLOC (Rhs, N).end; \\r
+ } \\r
+ else \\r
+ { \\r
+ (Current).begin = (Current).end = YYRHSLOC (Rhs, 0).end; \\r
+ } \\r
+ while (/*CONSTCOND*/ false)\r
+# endif\r
+]])\r
--- /dev/null
+ -*- Autoconf -*-\r
+\r
+# Common code for C-like languages (C, C++, Java, etc.)\r
+\r
+# Copyright (C) 2012 Free Software Foundation, Inc.\r
+\r
+# This program is free software: you can redistribute it and/or modify\r
+# it under the terms of the GNU General Public License as published by\r
+# the Free Software Foundation, either version 3 of the License, or\r
+# (at your option) any later version.\r
+#\r
+# This program is distributed in the hope that it will be useful,\r
+# but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
+# GNU General Public License for more details.\r
+#\r
+# You should have received a copy of the GNU General Public License\r
+# along with this program. If not, see <http://www.gnu.org/licenses/>.\r
+\r
+# b4_dollar_dollar_(VALUE, FIELD, DEFAULT-FIELD)\r
+# ----------------------------------------------\r
+# If FIELD (or DEFAULT-FIELD) is non-null, return "VALUE.FIELD",\r
+# otherwise just VALUE. Be sure to pass "(VALUE)" is VALUE is a\r
+# pointer.\r
+m4_define([b4_dollar_dollar_],\r
+[m4_if([$2], [[]],\r
+ [m4_ifval([$3], [($1.$3)],\r
+ [$1])],\r
+ [($1.$2)])])\r
+\r
+# b4_dollar_pushdef(VALUE-POINTER, DEFAULT-FIELD, LOCATION)\r
+# b4_dollar_popdef\r
+# ---------------------------------------------------------\r
+# Define b4_dollar_dollar for VALUE and DEFAULT-FIELD,\r
+# and b4_at_dollar for LOCATION.\r
+m4_define([b4_dollar_pushdef],\r
+[m4_pushdef([b4_dollar_dollar],\r
+ [b4_dollar_dollar_([$1], m4_dquote($][1), [$2])])dnl\r
+m4_pushdef([b4_at_dollar], [$3])dnl\r
+])\r
+m4_define([b4_dollar_popdef],\r
+[m4_popdef([b4_at_dollar])dnl\r
+m4_popdef([b4_dollar_dollar])dnl\r
+])\r
--- /dev/null
+ -*- Autoconf -*-\r
+\r
+# C skeleton dispatching for Bison.\r
+\r
+# Copyright (C) 2006-2007, 2009-2012 Free Software Foundation, Inc.\r
+\r
+# This program is free software: you can redistribute it and/or modify\r
+# it under the terms of the GNU General Public License as published by\r
+# the Free Software Foundation, either version 3 of the License, or\r
+# (at your option) any later version.\r
+#\r
+# This program is distributed in the hope that it will be useful,\r
+# but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
+# GNU General Public License for more details.\r
+#\r
+# You should have received a copy of the GNU General Public License\r
+# along with this program. If not, see <http://www.gnu.org/licenses/>.\r
+\r
+b4_glr_if( [m4_define([b4_used_skeleton], [b4_pkgdatadir/[glr.c]])])\r
+b4_nondeterministic_if([m4_define([b4_used_skeleton], [b4_pkgdatadir/[glr.c]])])\r
+\r
+m4_define_default([b4_used_skeleton], [b4_pkgdatadir/[yacc.c]])\r
+m4_define_default([b4_skeleton], ["b4_basename(b4_used_skeleton)"])\r
+\r
+m4_include(b4_used_skeleton)\r
--- /dev/null
+ -*- Autoconf -*-\r
+\r
+# C M4 Macros for Bison.\r
+\r
+# Copyright (C) 2002, 2004-2012 Free Software Foundation, Inc.\r
+\r
+# This program is free software: you can redistribute it and/or modify\r
+# it under the terms of the GNU General Public License as published by\r
+# the Free Software Foundation, either version 3 of the License, or\r
+# (at your option) any later version.\r
+#\r
+# This program is distributed in the hope that it will be useful,\r
+# but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
+# GNU General Public License for more details.\r
+#\r
+# You should have received a copy of the GNU General Public License\r
+# along with this program. If not, see <http://www.gnu.org/licenses/>.\r
+\r
+m4_include(b4_pkgdatadir/[c-like.m4])\r
+\r
+# b4_tocpp(STRING)\r
+# ----------------\r
+# Convert STRING into a valid C macro name.\r
+m4_define([b4_tocpp],\r
+[m4_toupper(m4_bpatsubst(m4_quote($1), [[^a-zA-Z0-9]+], [_]))])\r
+\r
+\r
+# b4_cpp_guard(FILE)\r
+# ------------------\r
+# A valid C macro name to use as a CPP header guard for FILE.\r
+m4_define([b4_cpp_guard],\r
+[[YY_]b4_tocpp(m4_defn([b4_prefix])/[$1])[_INCLUDED]])\r
+\r
+\r
+# b4_cpp_guard_open(FILE)\r
+# b4_cpp_guard_close(FILE)\r
+# ------------------------\r
+# If FILE does not expand to nothing, open/close CPP inclusion guards for FILE.\r
+m4_define([b4_cpp_guard_open],\r
+[m4_ifval(m4_quote($1),\r
+[#ifndef b4_cpp_guard([$1])\r
+# define b4_cpp_guard([$1])])])\r
+\r
+m4_define([b4_cpp_guard_close],\r
+[m4_ifval(m4_quote($1),\r
+[#endif b4_comment([!b4_cpp_guard([$1])])])])\r
+\r
+\r
+## ---------------- ##\r
+## Identification. ##\r
+## ---------------- ##\r
+\r
+# b4_comment(TEXT)\r
+# ----------------\r
+m4_define([b4_comment], [/* m4_bpatsubst([$1], [\r
+], [\r
+ ]) */])\r
+\r
+# b4_identification\r
+# -----------------\r
+# Depends on individual skeletons to define b4_pure_flag, b4_push_flag, or\r
+# b4_pull_flag if they use the values of the %define variables api.pure or\r
+# api.push-pull.\r
+m4_define([b4_identification],\r
+[[/* Identify Bison output. */\r
+#define YYBISON 1\r
+\r
+/* Bison version. */\r
+#define YYBISON_VERSION "]b4_version["\r
+\r
+/* Skeleton name. */\r
+#define YYSKELETON_NAME ]b4_skeleton[]m4_ifdef([b4_pure_flag], [[\r
+\r
+/* Pure parsers. */\r
+#define YYPURE ]b4_pure_flag])[]m4_ifdef([b4_push_flag], [[\r
+\r
+/* Push parsers. */\r
+#define YYPUSH ]b4_push_flag])[]m4_ifdef([b4_pull_flag], [[\r
+\r
+/* Pull parsers. */\r
+#define YYPULL ]b4_pull_flag])[\r
+]])\r
+\r
+\r
+## ---------------- ##\r
+## Default values. ##\r
+## ---------------- ##\r
+\r
+# b4_api_prefix, b4_api_PREFIX\r
+# ----------------------------\r
+# Corresponds to %define api.prefix\r
+b4_percent_define_default([[api.prefix]], [[yy]])\r
+m4_define([b4_api_prefix],\r
+[b4_percent_define_get([[api.prefix]])])\r
+m4_define([b4_api_PREFIX],\r
+[m4_toupper(b4_api_prefix)])\r
+\r
+\r
+# b4_prefix\r
+# ---------\r
+# If the %name-prefix is not given, it is api.prefix.\r
+m4_define_default([b4_prefix], [b4_api_prefix])\r
+\r
+# If the %union is not named, its name is YYSTYPE.\r
+m4_define_default([b4_union_name], [b4_api_PREFIX[]STYPE])\r
+\r
+\r
+## ------------------------ ##\r
+## Pure/impure interfaces. ##\r
+## ------------------------ ##\r
+\r
+# b4_user_args\r
+# ------------\r
+m4_define([b4_user_args],\r
+[m4_ifset([b4_parse_param], [, b4_c_args(b4_parse_param)])])\r
+\r
+\r
+# b4_parse_param\r
+# --------------\r
+# If defined, b4_parse_param arrives double quoted, but below we prefer\r
+# it to be single quoted.\r
+m4_define([b4_parse_param],\r
+b4_parse_param)\r
+\r
+\r
+# b4_parse_param_for(DECL, FORMAL, BODY)\r
+# ---------------------------------------\r
+# Iterate over the user parameters, binding the declaration to DECL,\r
+# the formal name to FORMAL, and evaluating the BODY.\r
+m4_define([b4_parse_param_for],\r
+[m4_foreach([$1_$2], m4_defn([b4_parse_param]),\r
+[m4_pushdef([$1], m4_unquote(m4_car($1_$2)))dnl\r
+m4_pushdef([$2], m4_shift($1_$2))dnl\r
+$3[]dnl\r
+m4_popdef([$2])dnl\r
+m4_popdef([$1])dnl\r
+])])\r
+\r
+# b4_parse_param_use\r
+# ------------------\r
+# `YYUSE' all the parse-params.\r
+m4_define([b4_parse_param_use],\r
+[b4_parse_param_for([Decl], [Formal], [ YYUSE (Formal);\r
+])dnl\r
+])\r
+\r
+\r
+## ------------ ##\r
+## Data Types. ##\r
+## ------------ ##\r
+\r
+# b4_int_type(MIN, MAX)\r
+# ---------------------\r
+# Return the smallest int type able to handle numbers ranging from\r
+# MIN to MAX (included).\r
+m4_define([b4_int_type],\r
+[m4_if(b4_ints_in($@, [0], [255]), [1], [unsigned char],\r
+ b4_ints_in($@, [-128], [127]), [1], [signed char],\r
+\r
+ b4_ints_in($@, [0], [65535]), [1], [unsigned short int],\r
+ b4_ints_in($@, [-32768], [32767]), [1], [short int],\r
+\r
+ m4_eval([0 <= $1]), [1], [unsigned int],\r
+\r
+ [int])])\r
+\r
+\r
+# b4_int_type_for(NAME)\r
+# ---------------------\r
+# Return the smallest int type able to handle numbers ranging from\r
+# `NAME_min' to `NAME_max' (included).\r
+m4_define([b4_int_type_for],\r
+[b4_int_type($1_min, $1_max)])\r
+\r
+\r
+# b4_table_value_equals(TABLE, VALUE, LITERAL)\r
+# --------------------------------------------\r
+# Without inducing a comparison warning from the compiler, check if the\r
+# literal value LITERAL equals VALUE from table TABLE, which must have\r
+# TABLE_min and TABLE_max defined. YYID must be defined as an identity\r
+# function that suppresses warnings about constant conditions.\r
+m4_define([b4_table_value_equals],\r
+[m4_if(m4_eval($3 < m4_indir([b4_]$1[_min])\r
+ || m4_indir([b4_]$1[_max]) < $3), [1],\r
+ [[YYID (0)]],\r
+ [(!!(($2) == ($3)))])])\r
+\r
+\r
+## ---------##\r
+## Values. ##\r
+## ---------##\r
+\r
+\r
+# b4_null_define\r
+# --------------\r
+# Portability issues: define a YY_NULL appropriate for the current\r
+# language (C, C++98, or C++11).\r
+m4_define([b4_null_define],\r
+[# ifndef YY_NULL\r
+# if defined __cplusplus && 201103L <= __cplusplus\r
+# define YY_NULL nullptr\r
+# else\r
+# define YY_NULL 0\r
+# endif\r
+# endif[]dnl\r
+])\r
+\r
+\r
+# b4_null\r
+# -------\r
+# Return a null pointer constant.\r
+m4_define([b4_null], [YY_NULL])\r
+\r
+\r
+\r
+## ------------------------- ##\r
+## Assigning token numbers. ##\r
+## ------------------------- ##\r
+\r
+# b4_token_define(TOKEN-NAME, TOKEN-NUMBER)\r
+# -----------------------------------------\r
+# Output the definition of this token as #define.\r
+m4_define([b4_token_define],\r
+[#define $1 $2\r
+])\r
+\r
+\r
+# b4_token_defines(LIST-OF-PAIRS-TOKEN-NAME-TOKEN-NUMBER)\r
+# -------------------------------------------------------\r
+# Output the definition of the tokens (if there are) as #defines.\r
+m4_define([b4_token_defines],\r
+[m4_if([$#$1], [1], [],\r
+[/* Tokens. */\r
+m4_map([b4_token_define], [$@])])\r
+])\r
+\r
+\r
+# b4_token_enum(TOKEN-NAME, TOKEN-NUMBER)\r
+# ---------------------------------------\r
+# Output the definition of this token as an enum.\r
+m4_define([b4_token_enum],\r
+[$1 = $2])\r
+\r
+\r
+# b4_token_enums(LIST-OF-PAIRS-TOKEN-NAME-TOKEN-NUMBER)\r
+# -----------------------------------------------------\r
+# Output the definition of the tokens (if there are) as enums.\r
+m4_define([b4_token_enums],\r
+[m4_if([$#$1], [1], [],\r
+[[/* Tokens. */\r
+#ifndef ]b4_api_PREFIX[TOKENTYPE\r
+# define ]b4_api_PREFIX[TOKENTYPE\r
+ /* Put the tokens into the symbol table, so that GDB and other debuggers\r
+ know about them. */\r
+ enum ]b4_api_prefix[tokentype {\r
+]m4_map_sep([ b4_token_enum], [,\r
+],\r
+ [$@])[\r
+ };\r
+#endif\r
+]])])\r
+\r
+\r
+# b4_token_enums_defines(LIST-OF-PAIRS-TOKEN-NAME-TOKEN-NUMBER)\r
+# -------------------------------------------------------------\r
+# Output the definition of the tokens (if there are any) as enums and, if POSIX\r
+# Yacc is enabled, as #defines.\r
+m4_define([b4_token_enums_defines],\r
+[b4_token_enums($@)b4_yacc_if([b4_token_defines($@)], [])\r
+])\r
+\r
+\r
+\r
+## --------------------------------------------- ##\r
+## Defining C functions in both K&R and ANSI-C. ##\r
+## --------------------------------------------- ##\r
+\r
+\r
+# b4_modern_c\r
+# -----------\r
+# A predicate useful in #if to determine whether C is ancient or modern.\r
+#\r
+# If __STDC__ is defined, the compiler is modern. IBM xlc 7.0 when run\r
+# as 'cc' doesn't define __STDC__ (or __STDC_VERSION__) for pedantic\r
+# reasons, but it defines __C99__FUNC__ so check that as well.\r
+# Microsoft C normally doesn't define these macros, but it defines _MSC_VER.\r
+# Consider a C++ compiler to be modern if it defines __cplusplus.\r
+#\r
+m4_define([b4_c_modern],\r
+ [[(defined __STDC__ || defined __C99__FUNC__ \\r
+ || defined __cplusplus || defined _MSC_VER)]])\r
+\r
+# b4_c_function_def(NAME, RETURN-VALUE, [DECL1, NAME1], ...)\r
+# ----------------------------------------------------------\r
+# Declare the function NAME.\r
+m4_define([b4_c_function_def],\r
+[#if b4_c_modern\r
+b4_c_ansi_function_def($@)\r
+#else\r
+$2\r
+$1 (b4_c_knr_formal_names(m4_shift2($@)))\r
+b4_c_knr_formal_decls(m4_shift2($@))\r
+#endif[]dnl\r
+])\r
+\r
+\r
+# b4_c_ansi_function_def(NAME, RETURN-VALUE, [DECL1, NAME1], ...)\r
+# ---------------------------------------------------------------\r
+# Declare the function NAME in ANSI.\r
+m4_define([b4_c_ansi_function_def],\r
+[$2\r
+$1 (b4_c_ansi_formals(m4_shift2($@)))[]dnl\r
+])\r
+\r
+\r
+# b4_c_ansi_formals([DECL1, NAME1], ...)\r
+# --------------------------------------\r
+# Output the arguments ANSI-C definition.\r
+m4_define([b4_c_ansi_formals],\r
+[m4_if([$#], [0], [void],\r
+ [$#$1], [1], [void],\r
+ [m4_map_sep([b4_c_ansi_formal], [, ], [$@])])])\r
+\r
+m4_define([b4_c_ansi_formal],\r
+[$1])\r
+\r
+\r
+# b4_c_knr_formal_names([DECL1, NAME1], ...)\r
+# ------------------------------------------\r
+# Output the argument names.\r
+m4_define([b4_c_knr_formal_names],\r
+[m4_map_sep([b4_c_knr_formal_name], [, ], [$@])])\r
+\r
+m4_define([b4_c_knr_formal_name],\r
+[$2])\r
+\r
+\r
+# b4_c_knr_formal_decls([DECL1, NAME1], ...)\r
+# ------------------------------------------\r
+# Output the K&R argument declarations.\r
+m4_define([b4_c_knr_formal_decls],\r
+[m4_map_sep([b4_c_knr_formal_decl],\r
+ [\r
+],\r
+ [$@])])\r
+\r
+m4_define([b4_c_knr_formal_decl],\r
+[ $1;])\r
+\r
+\r
+\r
+## ------------------------------------------------------------ ##\r
+## Declaring (prototyping) C functions in both K&R and ANSI-C. ##\r
+## ------------------------------------------------------------ ##\r
+\r
+\r
+# b4_c_ansi_function_decl(NAME, RETURN-VALUE, [DECL1, NAME1], ...)\r
+# ----------------------------------------------------------------\r
+# Declare the function NAME ANSI C style.\r
+m4_define([b4_c_ansi_function_decl],\r
+[$2 $1 (b4_c_ansi_formals(m4_shift2($@)));[]dnl\r
+])\r
+\r
+\r
+\r
+# b4_c_function_decl(NAME, RETURN-VALUE, [DECL1, NAME1], ...)\r
+# -----------------------------------------------------------\r
+# Declare the function NAME in both K&R and ANSI C.\r
+m4_define([b4_c_function_decl],\r
+[#if defined __STDC__ || defined __cplusplus\r
+b4_c_ansi_function_decl($@)\r
+#else\r
+$2 $1 ();\r
+#endif[]dnl\r
+])\r
+\r
+\r
+\r
+## --------------------- ##\r
+## Calling C functions. ##\r
+## --------------------- ##\r
+\r
+\r
+# b4_c_function_call(NAME, RETURN-VALUE, [DECL1, NAME1], ...)\r
+# -----------------------------------------------------------\r
+# Call the function NAME with arguments NAME1, NAME2 etc.\r
+m4_define([b4_c_function_call],\r
+[$1 (b4_c_args(m4_shift2($@)))[]dnl\r
+])\r
+\r
+\r
+# b4_c_args([DECL1, NAME1], ...)\r
+# ------------------------------\r
+# Output the arguments NAME1, NAME2...\r
+m4_define([b4_c_args],\r
+[m4_map_sep([b4_c_arg], [, ], [$@])])\r
+\r
+m4_define([b4_c_arg],\r
+[$2])\r
+\r
+\r
+## ----------- ##\r
+## Synclines. ##\r
+## ----------- ##\r
+\r
+# b4_sync_start(LINE, FILE)\r
+# -----------------------\r
+m4_define([b4_sync_start], [[#]line $1 $2])\r
+\r
+\r
+## -------------- ##\r
+## User actions. ##\r
+## -------------- ##\r
+\r
+# b4_case(LABEL, STATEMENTS)\r
+# --------------------------\r
+m4_define([b4_case],\r
+[ case $1:\r
+$2\r
+ break;])\r
+\r
+# b4_symbol_actions(FILENAME, LINENO,\r
+# SYMBOL-TAG, SYMBOL-NUM,\r
+# SYMBOL-ACTION, SYMBOL-TYPENAME)\r
+# -------------------------------------------------\r
+# Issue the code for a symbol action (e.g., %printer).\r
+#\r
+# Define b4_dollar_dollar([TYPE-NAME]), and b4_at_dollar, which are\r
+# invoked where $<TYPE-NAME>$ and @$ were specified by the user.\r
+m4_define([b4_symbol_actions],\r
+[b4_dollar_pushdef([(*yyvaluep)], [$6], [(*yylocationp)])dnl\r
+ case $4: /* $3 */\r
+b4_syncline([$2], [$1])\r
+ $5;\r
+b4_syncline([@oline@], [@ofile@])\r
+ break;\r
+b4_dollar_popdef[]dnl\r
+])\r
+\r
+\r
+# b4_yydestruct_generate(FUNCTION-DECLARATOR)\r
+# -------------------------------------------\r
+# Generate the "yydestruct" function, which declaration is issued using\r
+# FUNCTION-DECLARATOR, which may be "b4_c_ansi_function_def" for ISO C\r
+# or "b4_c_function_def" for K&R.\r
+m4_define_default([b4_yydestruct_generate],\r
+[[/*-----------------------------------------------.\r
+| Release the memory associated to this symbol. |\r
+`-----------------------------------------------*/\r
+\r
+/*ARGSUSED*/\r
+]$1([yydestruct],\r
+ [static void],\r
+ [[const char *yymsg], [yymsg]],\r
+ [[int yytype], [yytype]],\r
+ [[YYSTYPE *yyvaluep], [yyvaluep]][]dnl\r
+b4_locations_if( [, [[YYLTYPE *yylocationp], [yylocationp]]])[]dnl\r
+m4_ifset([b4_parse_param], [, b4_parse_param]))[\r
+{\r
+ YYUSE (yyvaluep);\r
+]b4_locations_if([ YYUSE (yylocationp);\r
+])dnl\r
+b4_parse_param_use[]dnl\r
+[\r
+ if (!yymsg)\r
+ yymsg = "Deleting";\r
+ YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);\r
+\r
+ switch (yytype)\r
+ {\r
+]m4_map([b4_symbol_actions], m4_defn([b4_symbol_destructors]))[\r
+ default:\r
+ break;\r
+ }\r
+}]dnl\r
+])\r
+\r
+\r
+# b4_yy_symbol_print_generate(FUNCTION-DECLARATOR)\r
+# ------------------------------------------------\r
+# Generate the "yy_symbol_print" function, which declaration is issued using\r
+# FUNCTION-DECLARATOR, which may be "b4_c_ansi_function_def" for ISO C\r
+# or "b4_c_function_def" for K&R.\r
+m4_define_default([b4_yy_symbol_print_generate],\r
+[[\r
+/*--------------------------------.\r
+| Print this symbol on YYOUTPUT. |\r
+`--------------------------------*/\r
+\r
+/*ARGSUSED*/\r
+]$1([yy_symbol_value_print],\r
+ [static void],\r
+ [[FILE *yyoutput], [yyoutput]],\r
+ [[int yytype], [yytype]],\r
+ [[YYSTYPE const * const yyvaluep], [yyvaluep]][]dnl\r
+b4_locations_if([, [[YYLTYPE const * const yylocationp], [yylocationp]]])[]dnl\r
+m4_ifset([b4_parse_param], [, b4_parse_param]))[\r
+{\r
+ FILE *yyo = yyoutput;\r
+ YYUSE (yyo);\r
+ if (!yyvaluep)\r
+ return;\r
+]b4_locations_if([ YYUSE (yylocationp);\r
+])dnl\r
+b4_parse_param_use[]dnl\r
+[# ifdef YYPRINT\r
+ if (yytype < YYNTOKENS)\r
+ YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);\r
+# else\r
+ YYUSE (yyoutput);\r
+# endif\r
+ switch (yytype)\r
+ {\r
+]m4_map([b4_symbol_actions], m4_defn([b4_symbol_printers]))dnl\r
+[ default:\r
+ break;\r
+ }\r
+}\r
+\r
+\r
+/*--------------------------------.\r
+| Print this symbol on YYOUTPUT. |\r
+`--------------------------------*/\r
+\r
+]$1([yy_symbol_print],\r
+ [static void],\r
+ [[FILE *yyoutput], [yyoutput]],\r
+ [[int yytype], [yytype]],\r
+ [[YYSTYPE const * const yyvaluep], [yyvaluep]][]dnl\r
+b4_locations_if([, [[YYLTYPE const * const yylocationp], [yylocationp]]])[]dnl\r
+m4_ifset([b4_parse_param], [, b4_parse_param]))[\r
+{\r
+ if (yytype < YYNTOKENS)\r
+ YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);\r
+ else\r
+ YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);\r
+\r
+]b4_locations_if([ YY_LOCATION_PRINT (yyoutput, *yylocationp);\r
+ YYFPRINTF (yyoutput, ": ");\r
+])dnl\r
+[ yy_symbol_value_print (yyoutput, yytype, yyvaluep]dnl\r
+b4_locations_if([, yylocationp])[]b4_user_args[);\r
+ YYFPRINTF (yyoutput, ")");\r
+}]dnl\r
+])\r
+\r
+## -------------- ##\r
+## Declarations. ##\r
+## -------------- ##\r
+\r
+# b4_declare_yylstype\r
+# -------------------\r
+# Declarations that might either go into the header (if --defines) or\r
+# in the parser body. Declare YYSTYPE/YYLTYPE, and yylval/yylloc.\r
+m4_define([b4_declare_yylstype],\r
+[[#if ! defined ]b4_api_PREFIX[STYPE && ! defined ]b4_api_PREFIX[STYPE_IS_DECLARED\r
+]m4_ifdef([b4_stype],\r
+[[typedef union ]b4_union_name[\r
+{\r
+]b4_user_stype[\r
+} ]b4_api_PREFIX[STYPE;\r
+# define ]b4_api_PREFIX[STYPE_IS_TRIVIAL 1]],\r
+[m4_if(b4_tag_seen_flag, 0,\r
+[[typedef int ]b4_api_PREFIX[STYPE;\r
+# define ]b4_api_PREFIX[STYPE_IS_TRIVIAL 1]])])[\r
+# define ]b4_api_prefix[stype ]b4_api_PREFIX[STYPE /* obsolescent; will be withdrawn */\r
+# define ]b4_api_PREFIX[STYPE_IS_DECLARED 1\r
+#endif]b4_locations_if([[\r
+\r
+#if ! defined ]b4_api_PREFIX[LTYPE && ! defined ]b4_api_PREFIX[LTYPE_IS_DECLARED\r
+typedef struct ]b4_api_PREFIX[LTYPE\r
+{\r
+ int first_line;\r
+ int first_column;\r
+ int last_line;\r
+ int last_column;\r
+} ]b4_api_PREFIX[LTYPE;\r
+# define ]b4_api_prefix[ltype ]b4_api_PREFIX[LTYPE /* obsolescent; will be withdrawn */\r
+# define ]b4_api_PREFIX[LTYPE_IS_DECLARED 1\r
+# define ]b4_api_PREFIX[LTYPE_IS_TRIVIAL 1\r
+#endif]])\r
+\r
+b4_pure_if([], [[extern ]b4_api_PREFIX[STYPE ]b4_prefix[lval;\r
+]b4_locations_if([[extern ]b4_api_PREFIX[LTYPE ]b4_prefix[lloc;]])])[]dnl\r
+])\r
+\r
+# b4_YYDEBUG_define\r
+# ------------------\r
+m4_define([b4_YYDEBUG_define],\r
+[[/* Enabling traces. */\r
+]m4_if(b4_api_prefix, [yy],\r
+[[#ifndef YYDEBUG\r
+# define YYDEBUG ]b4_debug_flag[\r
+#endif]],\r
+[[#ifndef ]b4_api_PREFIX[DEBUG\r
+# if defined YYDEBUG\r
+# if YYDEBUG\r
+# define ]b4_api_PREFIX[DEBUG 1\r
+# else\r
+# define ]b4_api_PREFIX[DEBUG 0\r
+# endif\r
+# else /* ! defined YYDEBUG */\r
+# define ]b4_api_PREFIX[DEBUG ]b4_debug_flag[\r
+# endif /* ! defined YYDEBUG */\r
+#endif /* ! defined ]b4_api_PREFIX[DEBUG */]])[]dnl\r
+])\r
+\r
+# b4_declare_yydebug\r
+# ------------------\r
+m4_define([b4_declare_yydebug],\r
+[b4_YYDEBUG_define[\r
+#if ]b4_api_PREFIX[DEBUG\r
+extern int ]b4_prefix[debug;\r
+#endif][]dnl\r
+])\r
+\r
+# b4_yylloc_default_define\r
+# ------------------------\r
+# Define YYLLOC_DEFAULT.\r
+m4_define([b4_yylloc_default_define],\r
+[[/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].\r
+ If N is 0, then set CURRENT to the empty location which ends\r
+ the previous symbol: RHS[0] (always defined). */\r
+\r
+#ifndef YYLLOC_DEFAULT\r
+# define YYLLOC_DEFAULT(Current, Rhs, N) \\r
+ do \\r
+ if (YYID (N)) \\r
+ { \\r
+ (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \\r
+ (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \\r
+ (Current).last_line = YYRHSLOC (Rhs, N).last_line; \\r
+ (Current).last_column = YYRHSLOC (Rhs, N).last_column; \\r
+ } \\r
+ else \\r
+ { \\r
+ (Current).first_line = (Current).last_line = \\r
+ YYRHSLOC (Rhs, 0).last_line; \\r
+ (Current).first_column = (Current).last_column = \\r
+ YYRHSLOC (Rhs, 0).last_column; \\r
+ } \\r
+ while (YYID (0))\r
+#endif\r
+]])\r
+\r
+# b4_yy_location_print_define\r
+# ---------------------------\r
+# Define YY_LOCATION_PRINT.\r
+m4_define([b4_yy_location_print_define],\r
+[b4_locations_if([[\r
+/* YY_LOCATION_PRINT -- Print the location on the stream.\r
+ This macro was not mandated originally: define only if we know\r
+ we won't break user code: when these are the locations we know. */\r
+\r
+#ifndef __attribute__\r
+/* This feature is available in gcc versions 2.5 and later. */\r
+# if (! defined __GNUC__ || __GNUC__ < 2 \\r
+ || (__GNUC__ == 2 && __GNUC_MINOR__ < 5))\r
+# define __attribute__(Spec) /* empty */\r
+# endif\r
+#endif\r
+\r
+#ifndef YY_LOCATION_PRINT\r
+# if defined ]b4_api_PREFIX[LTYPE_IS_TRIVIAL && ]b4_api_PREFIX[LTYPE_IS_TRIVIAL\r
+\r
+/* Print *YYLOCP on YYO. Private, do not rely on its existence. */\r
+\r
+__attribute__((__unused__))\r
+]b4_c_function_def([yy_location_print_],\r
+ [static unsigned],\r
+ [[FILE *yyo], [yyo]],\r
+ [[YYLTYPE const * const yylocp], [yylocp]])[\r
+{\r
+ unsigned res = 0;\r
+ int end_col = 0 != yylocp->last_column ? yylocp->last_column - 1 : 0;\r
+ if (0 <= yylocp->first_line)\r
+ {\r
+ res += fprintf (yyo, "%d", yylocp->first_line);\r
+ if (0 <= yylocp->first_column)\r
+ res += fprintf (yyo, ".%d", yylocp->first_column);\r
+ }\r
+ if (0 <= yylocp->last_line)\r
+ {\r
+ if (yylocp->first_line < yylocp->last_line)\r
+ {\r
+ res += fprintf (yyo, "-%d", yylocp->last_line);\r
+ if (0 <= end_col)\r
+ res += fprintf (yyo, ".%d", end_col);\r
+ }\r
+ else if (0 <= end_col && yylocp->first_column < end_col)\r
+ res += fprintf (yyo, "-%d", end_col);\r
+ }\r
+ return res;\r
+ }\r
+\r
+# define YY_LOCATION_PRINT(File, Loc) \\r
+ yy_location_print_ (File, &(Loc))\r
+\r
+# else\r
+# define YY_LOCATION_PRINT(File, Loc) ((void) 0)\r
+# endif\r
+#endif]],\r
+[[/* This macro is provided for backward compatibility. */\r
+#ifndef YY_LOCATION_PRINT\r
+# define YY_LOCATION_PRINT(File, Loc) ((void) 0)\r
+#endif]])\r
+])\r
+\r
+# b4_yyloc_default\r
+# ----------------\r
+# Expand to a possible default value for yylloc.\r
+m4_define([b4_yyloc_default],\r
+[[\r
+# if defined ]b4_api_PREFIX[LTYPE_IS_TRIVIAL && ]b4_api_PREFIX[LTYPE_IS_TRIVIAL\r
+ = { ]m4_join([, ],\r
+ m4_defn([b4_location_initial_line]),\r
+ m4_defn([b4_location_initial_column]),\r
+ m4_defn([b4_location_initial_line]),\r
+ m4_defn([b4_location_initial_column]))[ }\r
+# endif\r
+]])\r
--- /dev/null
+ -*- C -*-
+
+# GLR skeleton for Bison
+
+# Copyright (C) 2002-2012 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 3 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, see <http://www.gnu.org/licenses/>.
+
+
+# If we are loaded by glr.cc, do not override c++.m4 definitions by
+# those of c.m4.
+m4_if(b4_skeleton, ["glr.c"],
+ [m4_include(b4_pkgdatadir/[c.m4])])
+
+## ---------------- ##
+## Default values. ##
+## ---------------- ##
+
+# Stack parameters.
+m4_define_default([b4_stack_depth_max], [10000])
+m4_define_default([b4_stack_depth_init], [200])
+
+
+
+## ------------------------ ##
+## Pure/impure interfaces. ##
+## ------------------------ ##
+
+b4_define_flag_if([pure])
+# If glr.cc is including this file and thus has already set b4_pure_flag,
+# do not change the value of b4_pure_flag, and do not record a use of api.pure.
+m4_ifndef([b4_pure_flag],
+[b4_percent_define_default([[api.pure]], [[false]])
+ m4_define([b4_pure_flag],
+ [b4_percent_define_flag_if([[api.pure]], [[1]], [[0]])])])
+
+# b4_user_formals
+# ---------------
+# The possible parse-params formal arguments preceded by a comma.
+#
+# This is not shared with yacc.c in c.m4 because GLR relies on ISO C
+# formal argument declarations.
+m4_define([b4_user_formals],
+[m4_ifset([b4_parse_param], [, b4_c_ansi_formals(b4_parse_param)])])
+
+
+# b4_lex_param
+# ------------
+# Accumule in b4_lex_param all the yylex arguments.
+# Yes, this is quite ugly...
+m4_define([b4_lex_param],
+m4_dquote(b4_pure_if([[[[YYSTYPE *]], [[&yylval]]][]dnl
+b4_locations_if([, [[YYLTYPE *], [&yylloc]]])])dnl
+m4_ifdef([b4_lex_param], [, ]b4_lex_param)))
+
+
+# b4_yyerror_args
+# ---------------
+# Optional effective arguments passed to yyerror: user args plus yylloc, and
+# a trailing comma.
+m4_define([b4_yyerror_args],
+[b4_pure_if([b4_locations_if([yylocp, ])])dnl
+m4_ifset([b4_parse_param], [b4_c_args(b4_parse_param), ])])
+
+
+# b4_lyyerror_args
+# ----------------
+# Same as above, but on the lookahead, hence &yylloc instead of yylocp.
+m4_define([b4_lyyerror_args],
+[b4_pure_if([b4_locations_if([&yylloc, ])])dnl
+m4_ifset([b4_parse_param], [b4_c_args(b4_parse_param), ])])
+
+
+# b4_pure_args
+# ------------
+# Same as b4_yyerror_args, but with a leading comma.
+m4_define([b4_pure_args],
+[b4_pure_if([b4_locations_if([, yylocp])])[]b4_user_args])
+
+
+# b4_lpure_args
+# -------------
+# Same as above, but on the lookahead, hence &yylloc instead of yylocp.
+m4_define([b4_lpure_args],
+[b4_pure_if([b4_locations_if([, &yylloc])])[]b4_user_args])
+
+
+
+# b4_pure_formals
+# ---------------
+# Arguments passed to yyerror: user formals plus yylocp with leading comma.
+m4_define([b4_pure_formals],
+[b4_pure_if([b4_locations_if([, YYLTYPE *yylocp])])[]b4_user_formals])
+
+
+# b4_locuser_formals(LOC = yylocp)
+# --------------------------------
+m4_define([b4_locuser_formals],
+[b4_locations_if([, YYLTYPE *m4_default([$1], [yylocp])])[]b4_user_formals])
+
+
+# b4_locuser_args(LOC = yylocp)
+# -----------------------------
+m4_define([b4_locuser_args],
+[b4_locations_if([, m4_default([$1], [yylocp])])[]b4_user_args])
+
+
+
+## ----------------- ##
+## Semantic Values. ##
+## ----------------- ##
+
+
+# b4_lhs_value([TYPE])
+# --------------------
+# Expansion of $<TYPE>$.
+m4_define([b4_lhs_value],
+[((*yyvalp)[]m4_ifval([$1], [.$1]))])
+
+
+# b4_rhs_value(RULE-LENGTH, NUM, [TYPE])
+# --------------------------------------
+# Expansion of $<TYPE>NUM, where the current rule has RULE-LENGTH
+# symbols on RHS.
+m4_define([b4_rhs_value],
+[(((yyGLRStackItem const *)yyvsp)@{YYFILL (($2) - ($1))@}.yystate.yysemantics.yysval[]m4_ifval([$3], [.$3]))])
+
+
+
+## ----------- ##
+## Locations. ##
+## ----------- ##
+
+# b4_lhs_location()
+# -----------------
+# Expansion of @$.
+m4_define([b4_lhs_location],
+[(*yylocp)])
+
+
+# b4_rhs_location(RULE-LENGTH, NUM)
+# ---------------------------------
+# Expansion of @NUM, where the current rule has RULE-LENGTH symbols
+# on RHS.
+m4_define([b4_rhs_location],
+[(((yyGLRStackItem const *)yyvsp)@{YYFILL (($2) - ($1))@}.yystate.yyloc)])
+
+
+## -------------- ##
+## Declarations. ##
+## -------------- ##
+
+# b4_shared_declarations
+# ----------------------
+# Declaration that might either go into the header (if --defines)
+# or open coded in the parser body.
+m4_define([b4_shared_declarations],
+[b4_declare_yydebug[
+]b4_percent_code_get([[requires]])[
+]b4_token_enums(b4_tokens)[
+]b4_declare_yylstype[
+]b4_c_ansi_function_decl(b4_prefix[parse], [int], b4_parse_param)[
+]b4_percent_code_get([[provides]])[]dnl
+])
+
+
+## -------------- ##
+## Output files. ##
+## -------------- ##
+
+b4_output_begin([b4_parser_file_name])
+b4_copyright([Skeleton implementation for Bison GLR parsers in C],
+ [2002-2012])[
+
+/* C GLR parser skeleton written by Paul Hilfinger. */
+
+]b4_identification
+
+b4_percent_code_get([[top]])[
+]m4_if(b4_api_prefix, [yy], [],
+[[/* Substitute the type names. */
+#define YYSTYPE ]b4_api_PREFIX[STYPE]b4_locations_if([[
+#define YYLTYPE ]b4_api_PREFIX[LTYPE]])])[
+]m4_if(b4_prefix, [yy], [],
+[[/* Substitute the variable and function names. */
+#define yyparse ]b4_prefix[parse
+#define yylex ]b4_prefix[lex
+#define yyerror ]b4_prefix[error
+#define yylval ]b4_prefix[lval
+#define yychar ]b4_prefix[char
+#define yydebug ]b4_prefix[debug
+#define yynerrs ]b4_prefix[nerrs]b4_locations_if([[
+#define yylloc ]b4_prefix[lloc]])])[
+
+/* Copy the first part of user declarations. */
+]b4_user_pre_prologue[
+
+]b4_null_define[
+
+]b4_defines_if([[#include "@basename(]b4_spec_defines_file[@)"]],
+ [b4_shared_declarations])[
+
+/* Enabling verbose error messages. */
+#ifdef YYERROR_VERBOSE
+# undef YYERROR_VERBOSE
+# define YYERROR_VERBOSE 1
+#else
+# define YYERROR_VERBOSE ]b4_error_verbose_flag[
+#endif
+
+/* Default (constant) value used for initialization for null
+ right-hand sides. Unlike the standard yacc.c template, here we set
+ the default value of $$ to a zeroed-out value. Since the default
+ value is undefined, this behavior is technically correct. */
+static YYSTYPE yyval_default;]b4_locations_if([[
+static YYLTYPE yyloc_default][]b4_yyloc_default;])[
+
+/* Copy the second part of user declarations. */
+]b4_user_post_prologue
+b4_percent_code_get[]dnl
+
+[#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#ifndef YY_
+# if defined YYENABLE_NLS && YYENABLE_NLS
+# if ENABLE_NLS
+# include <libintl.h> /* INFRINGES ON USER NAME SPACE */
+# define YY_(Msgid) dgettext ("bison-runtime", Msgid)
+# endif
+# endif
+# ifndef YY_
+# define YY_(Msgid) Msgid
+# endif
+#endif
+
+/* Suppress unused-variable warnings by "using" E. */
+#if ! defined lint || defined __GNUC__
+# define YYUSE(E) ((void) (E))
+#else
+# define YYUSE(E) /* empty */
+#endif
+
+/* Identity function, used to suppress warnings about constant conditions. */
+#ifndef lint
+# define YYID(N) (N)
+#else
+]b4_c_function_def([YYID], [static int], [[int i], [i]])[
+{
+ return i;
+}
+#endif
+
+#ifndef YYFREE
+# define YYFREE free
+#endif
+#ifndef YYMALLOC
+# define YYMALLOC malloc
+#endif
+#ifndef YYREALLOC
+# define YYREALLOC realloc
+#endif
+
+#define YYSIZEMAX ((size_t) -1)
+
+#ifdef __cplusplus
+ typedef bool yybool;
+#else
+ typedef unsigned char yybool;
+#endif
+#define yytrue 1
+#define yyfalse 0
+
+#ifndef YYSETJMP
+# include <setjmp.h>
+# define YYJMP_BUF jmp_buf
+# define YYSETJMP(Env) setjmp (Env)
+/* Pacify clang. */
+# define YYLONGJMP(Env, Val) (longjmp (Env, Val), YYASSERT (0))
+#endif
+
+/*-----------------.
+| GCC extensions. |
+`-----------------*/
+
+#ifndef __attribute__
+/* This feature is available in gcc versions 2.5 and later. */
+# if (! defined __GNUC__ || __GNUC__ < 2 \
+ || (__GNUC__ == 2 && __GNUC_MINOR__ < 5))
+# define __attribute__(Spec) /* empty */
+# endif
+#endif
+
+#ifndef YYASSERT
+# define YYASSERT(Condition) ((void) ((Condition) || (abort (), 0)))
+#endif
+
+/* YYFINAL -- State number of the termination state. */
+#define YYFINAL ]b4_final_state_number[
+/* YYLAST -- Last index in YYTABLE. */
+#define YYLAST ]b4_last[
+
+/* YYNTOKENS -- Number of terminals. */
+#define YYNTOKENS ]b4_tokens_number[
+/* YYNNTS -- Number of nonterminals. */
+#define YYNNTS ]b4_nterms_number[
+/* YYNRULES -- Number of rules. */
+#define YYNRULES ]b4_rules_number[
+/* YYNRULES -- Number of states. */
+#define YYNSTATES ]b4_states_number[
+/* YYMAXRHS -- Maximum number of symbols on right-hand side of rule. */
+#define YYMAXRHS ]b4_r2_max[
+/* YYMAXLEFT -- Maximum number of symbols to the left of a handle
+ accessed by $0, $-1, etc., in any rule. */
+#define YYMAXLEFT ]b4_max_left_semantic_context[
+
+/* YYTRANSLATE(X) -- Bison symbol number corresponding to X. */
+#define YYUNDEFTOK ]b4_undef_token_number[
+#define YYMAXUTOK ]b4_user_token_number_max[
+
+#define YYTRANSLATE(YYX) \
+ ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
+
+/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
+static const ]b4_int_type_for([b4_translate])[ yytranslate[] =
+{
+ ]b4_translate[
+};
+
+#if ]b4_api_PREFIX[DEBUG
+/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
+ YYRHS. */
+static const ]b4_int_type_for([b4_prhs])[ yyprhs[] =
+{
+ ]b4_prhs[
+};
+
+/* YYRHS -- A `-1'-separated list of the rules' RHS. */
+static const ]b4_int_type_for([b4_rhs])[ yyrhs[] =
+{
+ ]b4_rhs[
+};
+
+/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
+static const ]b4_int_type_for([b4_rline])[ yyrline[] =
+{
+ ]b4_rline[
+};
+#endif
+
+#if ]b4_api_PREFIX[DEBUG || YYERROR_VERBOSE || ]b4_token_table_flag[
+/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
+ First, the terminals, then, starting at YYNTOKENS, nonterminals. */
+static const char *const yytname[] =
+{
+ ]b4_tname[
+};
+#endif
+
+/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
+static const ]b4_int_type_for([b4_r1])[ yyr1[] =
+{
+ ]b4_r1[
+};
+
+/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
+static const ]b4_int_type_for([b4_r2])[ yyr2[] =
+{
+ ]b4_r2[
+};
+
+/* YYDPREC[RULE-NUM] -- Dynamic precedence of rule #RULE-NUM (0 if none). */
+static const ]b4_int_type_for([b4_dprec])[ yydprec[] =
+{
+ ]b4_dprec[
+};
+
+/* YYMERGER[RULE-NUM] -- Index of merging function for rule #RULE-NUM. */
+static const ]b4_int_type_for([b4_merger])[ yymerger[] =
+{
+ ]b4_merger[
+};
+
+/* YYDEFACT[S] -- default reduction number in state S. Performed when
+ YYTABLE doesn't specify something else to do. Zero means the default
+ is an error. */
+static const ]b4_int_type_for([b4_defact])[ yydefact[] =
+{
+ ]b4_defact[
+};
+
+/* YYPDEFGOTO[NTERM-NUM]. */
+static const ]b4_int_type_for([b4_defgoto])[ yydefgoto[] =
+{
+ ]b4_defgoto[
+};
+
+/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
+ STATE-NUM. */
+#define YYPACT_NINF ]b4_pact_ninf[
+static const ]b4_int_type_for([b4_pact])[ yypact[] =
+{
+ ]b4_pact[
+};
+
+/* YYPGOTO[NTERM-NUM]. */
+static const ]b4_int_type_for([b4_pgoto])[ yypgoto[] =
+{
+ ]b4_pgoto[
+};
+
+/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
+ positive, shift that token. If negative, reduce the rule which
+ number is the opposite. If YYTABLE_NINF, syntax error. */
+#define YYTABLE_NINF ]b4_table_ninf[
+static const ]b4_int_type_for([b4_table])[ yytable[] =
+{
+ ]b4_table[
+};
+
+/* YYCONFLP[YYPACT[STATE-NUM]] -- Pointer into YYCONFL of start of
+ list of conflicting reductions corresponding to action entry for
+ state STATE-NUM in yytable. 0 means no conflicts. The list in
+ yyconfl is terminated by a rule number of 0. */
+static const ]b4_int_type_for([b4_conflict_list_heads])[ yyconflp[] =
+{
+ ]b4_conflict_list_heads[
+};
+
+/* YYCONFL[I] -- lists of conflicting rule numbers, each terminated by
+ 0, pointed into by YYCONFLP. */
+]dnl Do not use b4_int_type_for here, since there are places where
+dnl pointers onto yyconfl are taken, which type is "short int *".
+dnl We probably ought to introduce a type for confl.
+[static const short int yyconfl[] =
+{
+ ]b4_conflicting_rules[
+};
+
+static const ]b4_int_type_for([b4_check])[ yycheck[] =
+{
+ ]b4_check[
+};
+
+/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
+ symbol of state STATE-NUM. */
+static const ]b4_int_type_for([b4_stos])[ yystos[] =
+{
+ ]b4_stos[
+};
+
+/* Error token number */
+#define YYTERROR 1
+
+]b4_locations_if([[
+]b4_yylloc_default_define[
+# define YYRHSLOC(Rhs, K) ((Rhs)[K].yystate.yyloc)
+]])[
+]b4_yy_location_print_define[
+
+/* YYLEX -- calling `yylex' with the right arguments. */
+#define YYLEX ]b4_c_function_call([yylex], [int], b4_lex_param)[
+
+]b4_pure_if(
+[
+#undef yynerrs
+#define yynerrs (yystackp->yyerrcnt)
+#undef yychar
+#define yychar (yystackp->yyrawchar)
+#undef yylval
+#define yylval (yystackp->yyval)
+#undef yylloc
+#define yylloc (yystackp->yyloc)
+m4_if(b4_prefix[], [yy], [],
+[#define b4_prefix[]nerrs yynerrs
+#define b4_prefix[]char yychar
+#define b4_prefix[]lval yylval
+#define b4_prefix[]lloc yylloc])],
+[YYSTYPE yylval;]b4_locations_if([[
+YYLTYPE yylloc;]])[
+
+int yynerrs;
+int yychar;])[
+
+static const int YYEOF = 0;
+static const int YYEMPTY = -2;
+
+typedef enum { yyok, yyaccept, yyabort, yyerr } YYRESULTTAG;
+
+#define YYCHK(YYE) \
+ do { YYRESULTTAG yyflag = YYE; if (yyflag != yyok) return yyflag; } \
+ while (YYID (0))
+
+#if ]b4_api_PREFIX[DEBUG
+
+# ifndef YYFPRINTF
+# define YYFPRINTF fprintf
+# endif
+
+# define YYDPRINTF(Args) \
+do { \
+ if (yydebug) \
+ YYFPRINTF Args; \
+} while (YYID (0))
+
+]b4_yy_symbol_print_generate([b4_c_ansi_function_def])[
+
+# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
+do { \
+ if (yydebug) \
+ { \
+ YYFPRINTF (stderr, "%s ", Title); \
+ yy_symbol_print (stderr, Type, Value]b4_locuser_args([Location])[); \
+ YYFPRINTF (stderr, "\n"); \
+ } \
+} while (YYID (0))
+
+/* Nonzero means print parse trace. It is left uninitialized so that
+ multiple parsers can coexist. */
+int yydebug;
+
+#else /* !]b4_api_PREFIX[DEBUG */
+
+# define YYDPRINTF(Args)
+# define YY_SYMBOL_PRINT(Title, Type, Value, Location)
+
+#endif /* !]b4_api_PREFIX[DEBUG */
+
+/* YYINITDEPTH -- initial size of the parser's stacks. */
+#ifndef YYINITDEPTH
+# define YYINITDEPTH ]b4_stack_depth_init[
+#endif
+
+/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
+ if the built-in stack extension method is used).
+
+ Do not make this value too large; the results are undefined if
+ SIZE_MAX < YYMAXDEPTH * sizeof (GLRStackItem)
+ evaluated with infinite-precision integer arithmetic. */
+
+#ifndef YYMAXDEPTH
+# define YYMAXDEPTH ]b4_stack_depth_max[
+#endif
+
+/* Minimum number of free items on the stack allowed after an
+ allocation. This is to allow allocation and initialization
+ to be completed by functions that call yyexpandGLRStack before the
+ stack is expanded, thus insuring that all necessary pointers get
+ properly redirected to new data. */
+#define YYHEADROOM 2
+
+#ifndef YYSTACKEXPANDABLE
+# if (! defined __cplusplus \
+ || (]b4_locations_if([[defined ]b4_api_PREFIX[LTYPE_IS_TRIVIAL && ]b4_api_PREFIX[LTYPE_IS_TRIVIAL \
+ && ]])[defined ]b4_api_PREFIX[STYPE_IS_TRIVIAL && ]b4_api_PREFIX[STYPE_IS_TRIVIAL))
+# define YYSTACKEXPANDABLE 1
+# else
+# define YYSTACKEXPANDABLE 0
+# endif
+#endif
+
+#if YYSTACKEXPANDABLE
+# define YY_RESERVE_GLRSTACK(Yystack) \
+ do { \
+ if (Yystack->yyspaceLeft < YYHEADROOM) \
+ yyexpandGLRStack (Yystack); \
+ } while (YYID (0))
+#else
+# define YY_RESERVE_GLRSTACK(Yystack) \
+ do { \
+ if (Yystack->yyspaceLeft < YYHEADROOM) \
+ yyMemoryExhausted (Yystack); \
+ } while (YYID (0))
+#endif
+
+
+#if YYERROR_VERBOSE
+
+# ifndef yystpcpy
+# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
+# define yystpcpy stpcpy
+# else
+/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
+ YYDEST. */
+static char *
+yystpcpy (char *yydest, const char *yysrc)
+{
+ char *yyd = yydest;
+ const char *yys = yysrc;
+
+ while ((*yyd++ = *yys++) != '\0')
+ continue;
+
+ return yyd - 1;
+}
+# endif
+# endif
+
+# ifndef yytnamerr
+/* Copy to YYRES the contents of YYSTR after stripping away unnecessary
+ quotes and backslashes, so that it's suitable for yyerror. The
+ heuristic is that double-quoting is unnecessary unless the string
+ contains an apostrophe, a comma, or backslash (other than
+ backslash-backslash). YYSTR is taken from yytname. If YYRES is
+ null, do not copy; instead, return the length of what the result
+ would have been. */
+static size_t
+yytnamerr (char *yyres, const char *yystr)
+{
+ if (*yystr == '"')
+ {
+ size_t yyn = 0;
+ char const *yyp = yystr;
+
+ for (;;)
+ switch (*++yyp)
+ {
+ case '\'':
+ case ',':
+ goto do_not_strip_quotes;
+
+ case '\\':
+ if (*++yyp != '\\')
+ goto do_not_strip_quotes;
+ /* Fall through. */
+ default:
+ if (yyres)
+ yyres[yyn] = *yyp;
+ yyn++;
+ break;
+
+ case '"':
+ if (yyres)
+ yyres[yyn] = '\0';
+ return yyn;
+ }
+ do_not_strip_quotes: ;
+ }
+
+ if (! yyres)
+ return strlen (yystr);
+
+ return yystpcpy (yyres, yystr) - yyres;
+}
+# endif
+
+#endif /* !YYERROR_VERBOSE */
+
+/** State numbers, as in LALR(1) machine */
+typedef int yyStateNum;
+
+/** Rule numbers, as in LALR(1) machine */
+typedef int yyRuleNum;
+
+/** Grammar symbol */
+typedef short int yySymbol;
+
+/** Item references, as in LALR(1) machine */
+typedef short int yyItemNum;
+
+typedef struct yyGLRState yyGLRState;
+typedef struct yyGLRStateSet yyGLRStateSet;
+typedef struct yySemanticOption yySemanticOption;
+typedef union yyGLRStackItem yyGLRStackItem;
+typedef struct yyGLRStack yyGLRStack;
+
+struct yyGLRState {
+ /** Type tag: always true. */
+ yybool yyisState;
+ /** Type tag for yysemantics. If true, yysval applies, otherwise
+ * yyfirstVal applies. */
+ yybool yyresolved;
+ /** Number of corresponding LALR(1) machine state. */
+ yyStateNum yylrState;
+ /** Preceding state in this stack */
+ yyGLRState* yypred;
+ /** Source position of the first token produced by my symbol */
+ size_t yyposn;
+ union {
+ /** First in a chain of alternative reductions producing the
+ * non-terminal corresponding to this state, threaded through
+ * yynext. */
+ yySemanticOption* yyfirstVal;
+ /** Semantic value for this state. */
+ YYSTYPE yysval;
+ } yysemantics;]b4_locations_if([[
+ /** Source location for this state. */
+ YYLTYPE yyloc;]])[
+};
+
+struct yyGLRStateSet {
+ yyGLRState** yystates;
+ /** During nondeterministic operation, yylookaheadNeeds tracks which
+ * stacks have actually needed the current lookahead. During deterministic
+ * operation, yylookaheadNeeds[0] is not maintained since it would merely
+ * duplicate yychar != YYEMPTY. */
+ yybool* yylookaheadNeeds;
+ size_t yysize, yycapacity;
+};
+
+struct yySemanticOption {
+ /** Type tag: always false. */
+ yybool yyisState;
+ /** Rule number for this reduction */
+ yyRuleNum yyrule;
+ /** The last RHS state in the list of states to be reduced. */
+ yyGLRState* yystate;
+ /** The lookahead for this reduction. */
+ int yyrawchar;
+ YYSTYPE yyval;]b4_locations_if([[
+ YYLTYPE yyloc;]])[
+ /** Next sibling in chain of options. To facilitate merging,
+ * options are chained in decreasing order by address. */
+ yySemanticOption* yynext;
+};
+
+/** Type of the items in the GLR stack. The yyisState field
+ * indicates which item of the union is valid. */
+union yyGLRStackItem {
+ yyGLRState yystate;
+ yySemanticOption yyoption;
+};
+
+struct yyGLRStack {
+ int yyerrState;
+]b4_locations_if([[ /* To compute the location of the error token. */
+ yyGLRStackItem yyerror_range[3];]])[
+]b4_pure_if(
+[
+ int yyerrcnt;
+ int yyrawchar;
+ YYSTYPE yyval;]b4_locations_if([[
+ YYLTYPE yyloc;]])[
+])[
+ YYJMP_BUF yyexception_buffer;
+ yyGLRStackItem* yyitems;
+ yyGLRStackItem* yynextFree;
+ size_t yyspaceLeft;
+ yyGLRState* yysplitPoint;
+ yyGLRState* yylastDeleted;
+ yyGLRStateSet yytops;
+};
+
+#if YYSTACKEXPANDABLE
+static void yyexpandGLRStack (yyGLRStack* yystackp);
+#endif
+
+static void yyFail (yyGLRStack* yystackp]b4_pure_formals[, const char* yymsg)
+ __attribute__ ((__noreturn__));
+static void
+yyFail (yyGLRStack* yystackp]b4_pure_formals[, const char* yymsg)
+{
+ if (yymsg != YY_NULL)
+ yyerror (]b4_yyerror_args[yymsg);
+ YYLONGJMP (yystackp->yyexception_buffer, 1);
+}
+
+static void yyMemoryExhausted (yyGLRStack* yystackp)
+ __attribute__ ((__noreturn__));
+static void
+yyMemoryExhausted (yyGLRStack* yystackp)
+{
+ YYLONGJMP (yystackp->yyexception_buffer, 2);
+}
+
+#if ]b4_api_PREFIX[DEBUG || YYERROR_VERBOSE
+/** A printable representation of TOKEN. */
+static inline const char*
+yytokenName (yySymbol yytoken)
+{
+ if (yytoken == YYEMPTY)
+ return "";
+
+ return yytname[yytoken];
+}
+#endif
+
+/** Fill in YYVSP[YYLOW1 .. YYLOW0-1] from the chain of states starting
+ * at YYVSP[YYLOW0].yystate.yypred. Leaves YYVSP[YYLOW1].yystate.yypred
+ * containing the pointer to the next state in the chain. */
+static void yyfillin (yyGLRStackItem *, int, int) __attribute__ ((__unused__));
+static void
+yyfillin (yyGLRStackItem *yyvsp, int yylow0, int yylow1)
+{
+ int i;
+ yyGLRState *s = yyvsp[yylow0].yystate.yypred;
+ for (i = yylow0-1; i >= yylow1; i -= 1)
+ {
+ YYASSERT (s->yyresolved);
+ yyvsp[i].yystate.yyresolved = yytrue;
+ yyvsp[i].yystate.yysemantics.yysval = s->yysemantics.yysval;]b4_locations_if([[
+ yyvsp[i].yystate.yyloc = s->yyloc;]])[
+ s = yyvsp[i].yystate.yypred = s->yypred;
+ }
+}
+
+/* Do nothing if YYNORMAL or if *YYLOW <= YYLOW1. Otherwise, fill in
+ * YYVSP[YYLOW1 .. *YYLOW-1] as in yyfillin and set *YYLOW = YYLOW1.
+ * For convenience, always return YYLOW1. */
+static inline int yyfill (yyGLRStackItem *, int *, int, yybool)
+ __attribute__ ((__unused__));
+static inline int
+yyfill (yyGLRStackItem *yyvsp, int *yylow, int yylow1, yybool yynormal)
+{
+ if (!yynormal && yylow1 < *yylow)
+ {
+ yyfillin (yyvsp, *yylow, yylow1);
+ *yylow = yylow1;
+ }
+ return yylow1;
+}
+
+/** Perform user action for rule number YYN, with RHS length YYRHSLEN,
+ * and top stack item YYVSP. YYLVALP points to place to put semantic
+ * value ($$), and yylocp points to place for location information
+ * (@@$). Returns yyok for normal return, yyaccept for YYACCEPT,
+ * yyerr for YYERROR, yyabort for YYABORT. */
+/*ARGSUSED*/ static YYRESULTTAG
+yyuserAction (yyRuleNum yyn, int yyrhslen, yyGLRStackItem* yyvsp,
+ yyGLRStack* yystackp,
+ YYSTYPE* yyvalp]b4_locuser_formals[)
+{
+ yybool yynormal __attribute__ ((__unused__)) =
+ (yystackp->yysplitPoint == YY_NULL);
+ int yylow;
+]b4_parse_param_use[]dnl
+[# undef yyerrok
+# define yyerrok (yystackp->yyerrState = 0)
+# undef YYACCEPT
+# define YYACCEPT return yyaccept
+# undef YYABORT
+# define YYABORT return yyabort
+# undef YYERROR
+# define YYERROR return yyerrok, yyerr
+# undef YYRECOVERING
+# define YYRECOVERING() (yystackp->yyerrState != 0)
+# undef yyclearin
+# define yyclearin (yychar = YYEMPTY)
+# undef YYFILL
+# define YYFILL(N) yyfill (yyvsp, &yylow, N, yynormal)
+# undef YYBACKUP
+# define YYBACKUP(Token, Value) \
+ return yyerror (]b4_yyerror_args[YY_("syntax error: cannot back up")), \
+ yyerrok, yyerr
+
+ yylow = 1;
+ if (yyrhslen == 0)
+ *yyvalp = yyval_default;
+ else
+ *yyvalp = yyvsp[YYFILL (1-yyrhslen)].yystate.yysemantics.yysval;]b4_locations_if([[
+ YYLLOC_DEFAULT ((*yylocp), (yyvsp - yyrhslen), yyrhslen);
+ yystackp->yyerror_range[1].yystate.yyloc = *yylocp;
+]])[
+ switch (yyn)
+ {
+ ]b4_user_actions[
+ default: break;
+ }
+
+ return yyok;
+# undef yyerrok
+# undef YYABORT
+# undef YYACCEPT
+# undef YYERROR
+# undef YYBACKUP
+# undef yyclearin
+# undef YYRECOVERING
+}
+\f
+
+/*ARGSUSED*/ static void
+yyuserMerge (int yyn, YYSTYPE* yy0, YYSTYPE* yy1)
+{
+ YYUSE (yy0);
+ YYUSE (yy1);
+
+ switch (yyn)
+ {
+ ]b4_mergers[
+ default: break;
+ }
+}
+
+ /* Bison grammar-table manipulation. */
+
+]b4_yydestruct_generate([b4_c_ansi_function_def])[
+
+/** Number of symbols composing the right hand side of rule #RULE. */
+static inline int
+yyrhsLength (yyRuleNum yyrule)
+{
+ return yyr2[yyrule];
+}
+
+static void
+yydestroyGLRState (char const *yymsg, yyGLRState *yys]b4_user_formals[)
+{
+ if (yys->yyresolved)
+ yydestruct (yymsg, yystos[yys->yylrState],
+ &yys->yysemantics.yysval]b4_locuser_args([&yys->yyloc])[);
+ else
+ {
+#if ]b4_api_PREFIX[DEBUG
+ if (yydebug)
+ {
+ if (yys->yysemantics.yyfirstVal)
+ YYFPRINTF (stderr, "%s unresolved ", yymsg);
+ else
+ YYFPRINTF (stderr, "%s incomplete ", yymsg);
+ yy_symbol_print (stderr, yystos[yys->yylrState],
+ YY_NULL]b4_locuser_args([&yys->yyloc])[);
+ YYFPRINTF (stderr, "\n");
+ }
+#endif
+
+ if (yys->yysemantics.yyfirstVal)
+ {
+ yySemanticOption *yyoption = yys->yysemantics.yyfirstVal;
+ yyGLRState *yyrh;
+ int yyn;
+ for (yyrh = yyoption->yystate, yyn = yyrhsLength (yyoption->yyrule);
+ yyn > 0;
+ yyrh = yyrh->yypred, yyn -= 1)
+ yydestroyGLRState (yymsg, yyrh]b4_user_args[);
+ }
+ }
+}
+
+/** Left-hand-side symbol for rule #RULE. */
+static inline yySymbol
+yylhsNonterm (yyRuleNum yyrule)
+{
+ return yyr1[yyrule];
+}
+
+#define yypact_value_is_default(Yystate) \
+ ]b4_table_value_equals([[pact]], [[Yystate]], [b4_pact_ninf])[
+
+/** True iff LR state STATE has only a default reduction (regardless
+ * of token). */
+static inline yybool
+yyisDefaultedState (yyStateNum yystate)
+{
+ return yypact_value_is_default (yypact[yystate]);
+}
+
+/** The default reduction for STATE, assuming it has one. */
+static inline yyRuleNum
+yydefaultAction (yyStateNum yystate)
+{
+ return yydefact[yystate];
+}
+
+#define yytable_value_is_error(Yytable_value) \
+ ]b4_table_value_equals([[table]], [[Yytable_value]], [b4_table_ninf])[
+
+/** Set *YYACTION to the action to take in YYSTATE on seeing YYTOKEN.
+ * Result R means
+ * R < 0: Reduce on rule -R.
+ * R = 0: Error.
+ * R > 0: Shift to state R.
+ * Set *CONFLICTS to a pointer into yyconfl to 0-terminated list of
+ * conflicting reductions.
+ */
+static inline void
+yygetLRActions (yyStateNum yystate, int yytoken,
+ int* yyaction, const short int** yyconflicts)
+{
+ int yyindex = yypact[yystate] + yytoken;
+ if (yypact_value_is_default (yypact[yystate])
+ || yyindex < 0 || YYLAST < yyindex || yycheck[yyindex] != yytoken)
+ {
+ *yyaction = -yydefact[yystate];
+ *yyconflicts = yyconfl;
+ }
+ else if (! yytable_value_is_error (yytable[yyindex]))
+ {
+ *yyaction = yytable[yyindex];
+ *yyconflicts = yyconfl + yyconflp[yyindex];
+ }
+ else
+ {
+ *yyaction = 0;
+ *yyconflicts = yyconfl + yyconflp[yyindex];
+ }
+}
+
+static inline yyStateNum
+yyLRgotoState (yyStateNum yystate, yySymbol yylhs)
+{
+ int yyr;
+ yyr = yypgoto[yylhs - YYNTOKENS] + yystate;
+ if (0 <= yyr && yyr <= YYLAST && yycheck[yyr] == yystate)
+ return yytable[yyr];
+ else
+ return yydefgoto[yylhs - YYNTOKENS];
+}
+
+static inline yybool
+yyisShiftAction (int yyaction)
+{
+ return 0 < yyaction;
+}
+
+static inline yybool
+yyisErrorAction (int yyaction)
+{
+ return yyaction == 0;
+}
+
+ /* GLRStates */
+
+/** Return a fresh GLRStackItem. Callers should call
+ * YY_RESERVE_GLRSTACK afterwards to make sure there is sufficient
+ * headroom. */
+
+static inline yyGLRStackItem*
+yynewGLRStackItem (yyGLRStack* yystackp, yybool yyisState)
+{
+ yyGLRStackItem* yynewItem = yystackp->yynextFree;
+ yystackp->yyspaceLeft -= 1;
+ yystackp->yynextFree += 1;
+ yynewItem->yystate.yyisState = yyisState;
+ return yynewItem;
+}
+
+/** Add a new semantic action that will execute the action for rule
+ * RULENUM on the semantic values in RHS to the list of
+ * alternative actions for STATE. Assumes that RHS comes from
+ * stack #K of *STACKP. */
+static void
+yyaddDeferredAction (yyGLRStack* yystackp, size_t yyk, yyGLRState* yystate,
+ yyGLRState* rhs, yyRuleNum yyrule)
+{
+ yySemanticOption* yynewOption =
+ &yynewGLRStackItem (yystackp, yyfalse)->yyoption;
+ yynewOption->yystate = rhs;
+ yynewOption->yyrule = yyrule;
+ if (yystackp->yytops.yylookaheadNeeds[yyk])
+ {
+ yynewOption->yyrawchar = yychar;
+ yynewOption->yyval = yylval;]b4_locations_if([
+ yynewOption->yyloc = yylloc;])[
+ }
+ else
+ yynewOption->yyrawchar = YYEMPTY;
+ yynewOption->yynext = yystate->yysemantics.yyfirstVal;
+ yystate->yysemantics.yyfirstVal = yynewOption;
+
+ YY_RESERVE_GLRSTACK (yystackp);
+}
+
+ /* GLRStacks */
+
+/** Initialize SET to a singleton set containing an empty stack. */
+static yybool
+yyinitStateSet (yyGLRStateSet* yyset)
+{
+ yyset->yysize = 1;
+ yyset->yycapacity = 16;
+ yyset->yystates = (yyGLRState**) YYMALLOC (16 * sizeof yyset->yystates[0]);
+ if (! yyset->yystates)
+ return yyfalse;
+ yyset->yystates[0] = YY_NULL;
+ yyset->yylookaheadNeeds =
+ (yybool*) YYMALLOC (16 * sizeof yyset->yylookaheadNeeds[0]);
+ if (! yyset->yylookaheadNeeds)
+ {
+ YYFREE (yyset->yystates);
+ return yyfalse;
+ }
+ return yytrue;
+}
+
+static void yyfreeStateSet (yyGLRStateSet* yyset)
+{
+ YYFREE (yyset->yystates);
+ YYFREE (yyset->yylookaheadNeeds);
+}
+
+/** Initialize STACK to a single empty stack, with total maximum
+ * capacity for all stacks of SIZE. */
+static yybool
+yyinitGLRStack (yyGLRStack* yystackp, size_t yysize)
+{
+ yystackp->yyerrState = 0;
+ yynerrs = 0;
+ yystackp->yyspaceLeft = yysize;
+ yystackp->yyitems =
+ (yyGLRStackItem*) YYMALLOC (yysize * sizeof yystackp->yynextFree[0]);
+ if (!yystackp->yyitems)
+ return yyfalse;
+ yystackp->yynextFree = yystackp->yyitems;
+ yystackp->yysplitPoint = YY_NULL;
+ yystackp->yylastDeleted = YY_NULL;
+ return yyinitStateSet (&yystackp->yytops);
+}
+
+
+#if YYSTACKEXPANDABLE
+# define YYRELOC(YYFROMITEMS,YYTOITEMS,YYX,YYTYPE) \
+ &((YYTOITEMS) - ((YYFROMITEMS) - (yyGLRStackItem*) (YYX)))->YYTYPE
+
+/** If STACK is expandable, extend it. WARNING: Pointers into the
+ stack from outside should be considered invalid after this call.
+ We always expand when there are 1 or fewer items left AFTER an
+ allocation, so that we can avoid having external pointers exist
+ across an allocation. */
+static void
+yyexpandGLRStack (yyGLRStack* yystackp)
+{
+ yyGLRStackItem* yynewItems;
+ yyGLRStackItem* yyp0, *yyp1;
+ size_t yynewSize;
+ size_t yyn;
+ size_t yysize = yystackp->yynextFree - yystackp->yyitems;
+ if (YYMAXDEPTH - YYHEADROOM < yysize)
+ yyMemoryExhausted (yystackp);
+ yynewSize = 2*yysize;
+ if (YYMAXDEPTH < yynewSize)
+ yynewSize = YYMAXDEPTH;
+ yynewItems = (yyGLRStackItem*) YYMALLOC (yynewSize * sizeof yynewItems[0]);
+ if (! yynewItems)
+ yyMemoryExhausted (yystackp);
+ for (yyp0 = yystackp->yyitems, yyp1 = yynewItems, yyn = yysize;
+ 0 < yyn;
+ yyn -= 1, yyp0 += 1, yyp1 += 1)
+ {
+ *yyp1 = *yyp0;
+ if (*(yybool *) yyp0)
+ {
+ yyGLRState* yys0 = &yyp0->yystate;
+ yyGLRState* yys1 = &yyp1->yystate;
+ if (yys0->yypred != YY_NULL)
+ yys1->yypred =
+ YYRELOC (yyp0, yyp1, yys0->yypred, yystate);
+ if (! yys0->yyresolved && yys0->yysemantics.yyfirstVal != YY_NULL)
+ yys1->yysemantics.yyfirstVal =
+ YYRELOC (yyp0, yyp1, yys0->yysemantics.yyfirstVal, yyoption);
+ }
+ else
+ {
+ yySemanticOption* yyv0 = &yyp0->yyoption;
+ yySemanticOption* yyv1 = &yyp1->yyoption;
+ if (yyv0->yystate != YY_NULL)
+ yyv1->yystate = YYRELOC (yyp0, yyp1, yyv0->yystate, yystate);
+ if (yyv0->yynext != YY_NULL)
+ yyv1->yynext = YYRELOC (yyp0, yyp1, yyv0->yynext, yyoption);
+ }
+ }
+ if (yystackp->yysplitPoint != YY_NULL)
+ yystackp->yysplitPoint = YYRELOC (yystackp->yyitems, yynewItems,
+ yystackp->yysplitPoint, yystate);
+
+ for (yyn = 0; yyn < yystackp->yytops.yysize; yyn += 1)
+ if (yystackp->yytops.yystates[yyn] != YY_NULL)
+ yystackp->yytops.yystates[yyn] =
+ YYRELOC (yystackp->yyitems, yynewItems,
+ yystackp->yytops.yystates[yyn], yystate);
+ YYFREE (yystackp->yyitems);
+ yystackp->yyitems = yynewItems;
+ yystackp->yynextFree = yynewItems + yysize;
+ yystackp->yyspaceLeft = yynewSize - yysize;
+}
+#endif
+
+static void
+yyfreeGLRStack (yyGLRStack* yystackp)
+{
+ YYFREE (yystackp->yyitems);
+ yyfreeStateSet (&yystackp->yytops);
+}
+
+/** Assuming that S is a GLRState somewhere on STACK, update the
+ * splitpoint of STACK, if needed, so that it is at least as deep as
+ * S. */
+static inline void
+yyupdateSplit (yyGLRStack* yystackp, yyGLRState* yys)
+{
+ if (yystackp->yysplitPoint != YY_NULL && yystackp->yysplitPoint > yys)
+ yystackp->yysplitPoint = yys;
+}
+
+/** Invalidate stack #K in STACK. */
+static inline void
+yymarkStackDeleted (yyGLRStack* yystackp, size_t yyk)
+{
+ if (yystackp->yytops.yystates[yyk] != YY_NULL)
+ yystackp->yylastDeleted = yystackp->yytops.yystates[yyk];
+ yystackp->yytops.yystates[yyk] = YY_NULL;
+}
+
+/** Undelete the last stack that was marked as deleted. Can only be
+ done once after a deletion, and only when all other stacks have
+ been deleted. */
+static void
+yyundeleteLastStack (yyGLRStack* yystackp)
+{
+ if (yystackp->yylastDeleted == YY_NULL || yystackp->yytops.yysize != 0)
+ return;
+ yystackp->yytops.yystates[0] = yystackp->yylastDeleted;
+ yystackp->yytops.yysize = 1;
+ YYDPRINTF ((stderr, "Restoring last deleted stack as stack #0.\n"));
+ yystackp->yylastDeleted = YY_NULL;
+}
+
+static inline void
+yyremoveDeletes (yyGLRStack* yystackp)
+{
+ size_t yyi, yyj;
+ yyi = yyj = 0;
+ while (yyj < yystackp->yytops.yysize)
+ {
+ if (yystackp->yytops.yystates[yyi] == YY_NULL)
+ {
+ if (yyi == yyj)
+ {
+ YYDPRINTF ((stderr, "Removing dead stacks.\n"));
+ }
+ yystackp->yytops.yysize -= 1;
+ }
+ else
+ {
+ yystackp->yytops.yystates[yyj] = yystackp->yytops.yystates[yyi];
+ /* In the current implementation, it's unnecessary to copy
+ yystackp->yytops.yylookaheadNeeds[yyi] since, after
+ yyremoveDeletes returns, the parser immediately either enters
+ deterministic operation or shifts a token. However, it doesn't
+ hurt, and the code might evolve to need it. */
+ yystackp->yytops.yylookaheadNeeds[yyj] =
+ yystackp->yytops.yylookaheadNeeds[yyi];
+ if (yyj != yyi)
+ {
+ YYDPRINTF ((stderr, "Rename stack %lu -> %lu.\n",
+ (unsigned long int) yyi, (unsigned long int) yyj));
+ }
+ yyj += 1;
+ }
+ yyi += 1;
+ }
+}
+
+/** Shift to a new state on stack #K of STACK, corresponding to LR state
+ * LRSTATE, at input position POSN, with (resolved) semantic value SVAL. */
+static inline void
+yyglrShift (yyGLRStack* yystackp, size_t yyk, yyStateNum yylrState,
+ size_t yyposn,
+ YYSTYPE* yyvalp]b4_locations_if([, YYLTYPE* yylocp])[)
+{
+ yyGLRState* yynewState = &yynewGLRStackItem (yystackp, yytrue)->yystate;
+
+ yynewState->yylrState = yylrState;
+ yynewState->yyposn = yyposn;
+ yynewState->yyresolved = yytrue;
+ yynewState->yypred = yystackp->yytops.yystates[yyk];
+ yynewState->yysemantics.yysval = *yyvalp;]b4_locations_if([
+ yynewState->yyloc = *yylocp;])[
+ yystackp->yytops.yystates[yyk] = yynewState;
+
+ YY_RESERVE_GLRSTACK (yystackp);
+}
+
+/** Shift stack #K of YYSTACK, to a new state corresponding to LR
+ * state YYLRSTATE, at input position YYPOSN, with the (unresolved)
+ * semantic value of YYRHS under the action for YYRULE. */
+static inline void
+yyglrShiftDefer (yyGLRStack* yystackp, size_t yyk, yyStateNum yylrState,
+ size_t yyposn, yyGLRState* rhs, yyRuleNum yyrule)
+{
+ yyGLRState* yynewState = &yynewGLRStackItem (yystackp, yytrue)->yystate;
+
+ yynewState->yylrState = yylrState;
+ yynewState->yyposn = yyposn;
+ yynewState->yyresolved = yyfalse;
+ yynewState->yypred = yystackp->yytops.yystates[yyk];
+ yynewState->yysemantics.yyfirstVal = YY_NULL;
+ yystackp->yytops.yystates[yyk] = yynewState;
+
+ /* Invokes YY_RESERVE_GLRSTACK. */
+ yyaddDeferredAction (yystackp, yyk, yynewState, rhs, yyrule);
+}
+
+/** Pop the symbols consumed by reduction #RULE from the top of stack
+ * #K of STACK, and perform the appropriate semantic action on their
+ * semantic values. Assumes that all ambiguities in semantic values
+ * have been previously resolved. Set *VALP to the resulting value,
+ * and *LOCP to the computed location (if any). Return value is as
+ * for userAction. */
+static inline YYRESULTTAG
+yydoAction (yyGLRStack* yystackp, size_t yyk, yyRuleNum yyrule,
+ YYSTYPE* yyvalp]b4_locuser_formals[)
+{
+ int yynrhs = yyrhsLength (yyrule);
+
+ if (yystackp->yysplitPoint == YY_NULL)
+ {
+ /* Standard special case: single stack. */
+ yyGLRStackItem* rhs = (yyGLRStackItem*) yystackp->yytops.yystates[yyk];
+ YYASSERT (yyk == 0);
+ yystackp->yynextFree -= yynrhs;
+ yystackp->yyspaceLeft += yynrhs;
+ yystackp->yytops.yystates[0] = & yystackp->yynextFree[-1].yystate;
+ return yyuserAction (yyrule, yynrhs, rhs, yystackp,
+ yyvalp]b4_locuser_args[);
+ }
+ else
+ {
+ /* At present, doAction is never called in nondeterministic
+ * mode, so this branch is never taken. It is here in
+ * anticipation of a future feature that will allow immediate
+ * evaluation of selected actions in nondeterministic mode. */
+ int yyi;
+ yyGLRState* yys;
+ yyGLRStackItem yyrhsVals[YYMAXRHS + YYMAXLEFT + 1];
+ yys = yyrhsVals[YYMAXRHS + YYMAXLEFT].yystate.yypred
+ = yystackp->yytops.yystates[yyk];]b4_locations_if([[
+ if (yynrhs == 0)
+ /* Set default location. */
+ yyrhsVals[YYMAXRHS + YYMAXLEFT - 1].yystate.yyloc = yys->yyloc;]])[
+ for (yyi = 0; yyi < yynrhs; yyi += 1)
+ {
+ yys = yys->yypred;
+ YYASSERT (yys);
+ }
+ yyupdateSplit (yystackp, yys);
+ yystackp->yytops.yystates[yyk] = yys;
+ return yyuserAction (yyrule, yynrhs, yyrhsVals + YYMAXRHS + YYMAXLEFT - 1,
+ yystackp, yyvalp]b4_locuser_args[);
+ }
+}
+
+#if !]b4_api_PREFIX[DEBUG
+# define YY_REDUCE_PRINT(Args)
+#else
+# define YY_REDUCE_PRINT(Args) \
+do { \
+ if (yydebug) \
+ yy_reduce_print Args; \
+} while (YYID (0))
+
+/*----------------------------------------------------------.
+| Report that the RULE is going to be reduced on stack #K. |
+`----------------------------------------------------------*/
+
+/*ARGSUSED*/ static inline void
+yy_reduce_print (yyGLRStack* yystackp, size_t yyk, yyRuleNum yyrule,
+ YYSTYPE* yyvalp]b4_locuser_formals[)
+{
+ int yynrhs = yyrhsLength (yyrule);
+ yybool yynormal __attribute__ ((__unused__)) =
+ (yystackp->yysplitPoint == YY_NULL);
+ yyGLRStackItem* yyvsp = (yyGLRStackItem*) yystackp->yytops.yystates[yyk];
+ int yylow = 1;
+ int yyi;
+ YYUSE (yyvalp);]b4_locations_if([
+ YYUSE (yylocp);])[
+]b4_parse_param_use[]dnl
+[ YYFPRINTF (stderr, "Reducing stack %lu by rule %d (line %lu):\n",
+ (unsigned long int) yyk, yyrule - 1,
+ (unsigned long int) yyrline[yyrule]);
+ /* The symbols being reduced. */
+ for (yyi = 0; yyi < yynrhs; yyi++)
+ {
+ YYFPRINTF (stderr, " $%d = ", yyi + 1);
+ yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
+ &]b4_rhs_value(yynrhs, yyi + 1)[
+ ]b4_locations_if([, &]b4_rhs_location(yynrhs, yyi + 1))[]dnl
+ b4_user_args[);
+ YYFPRINTF (stderr, "\n");
+ }
+}
+#endif
+
+/** Pop items off stack #K of STACK according to grammar rule RULE,
+ * and push back on the resulting nonterminal symbol. Perform the
+ * semantic action associated with RULE and store its value with the
+ * newly pushed state, if FORCEEVAL or if STACK is currently
+ * unambiguous. Otherwise, store the deferred semantic action with
+ * the new state. If the new state would have an identical input
+ * position, LR state, and predecessor to an existing state on the stack,
+ * it is identified with that existing state, eliminating stack #K from
+ * the STACK. In this case, the (necessarily deferred) semantic value is
+ * added to the options for the existing state's semantic value.
+ */
+static inline YYRESULTTAG
+yyglrReduce (yyGLRStack* yystackp, size_t yyk, yyRuleNum yyrule,
+ yybool yyforceEval]b4_user_formals[)
+{
+ size_t yyposn = yystackp->yytops.yystates[yyk]->yyposn;
+
+ if (yyforceEval || yystackp->yysplitPoint == YY_NULL)
+ {
+ YYSTYPE yysval;]b4_locations_if([
+ YYLTYPE yyloc;])[
+
+ YY_REDUCE_PRINT ((yystackp, yyk, yyrule, &yysval]b4_locuser_args([&yyloc])[));
+ YYCHK (yydoAction (yystackp, yyk, yyrule, &yysval]b4_locuser_args([&yyloc])[));
+ YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyrule], &yysval, &yyloc);
+ yyglrShift (yystackp, yyk,
+ yyLRgotoState (yystackp->yytops.yystates[yyk]->yylrState,
+ yylhsNonterm (yyrule)),
+ yyposn, &yysval]b4_locations_if([, &yyloc])[);
+ }
+ else
+ {
+ size_t yyi;
+ int yyn;
+ yyGLRState* yys, *yys0 = yystackp->yytops.yystates[yyk];
+ yyStateNum yynewLRState;
+
+ for (yys = yystackp->yytops.yystates[yyk], yyn = yyrhsLength (yyrule);
+ 0 < yyn; yyn -= 1)
+ {
+ yys = yys->yypred;
+ YYASSERT (yys);
+ }
+ yyupdateSplit (yystackp, yys);
+ yynewLRState = yyLRgotoState (yys->yylrState, yylhsNonterm (yyrule));
+ YYDPRINTF ((stderr,
+ "Reduced stack %lu by rule #%d; action deferred. Now in state %d.\n",
+ (unsigned long int) yyk, yyrule - 1, yynewLRState));
+ for (yyi = 0; yyi < yystackp->yytops.yysize; yyi += 1)
+ if (yyi != yyk && yystackp->yytops.yystates[yyi] != YY_NULL)
+ {
+ yyGLRState *yysplit = yystackp->yysplitPoint;
+ yyGLRState *yyp = yystackp->yytops.yystates[yyi];
+ while (yyp != yys && yyp != yysplit && yyp->yyposn >= yyposn)
+ {
+ if (yyp->yylrState == yynewLRState && yyp->yypred == yys)
+ {
+ yyaddDeferredAction (yystackp, yyk, yyp, yys0, yyrule);
+ yymarkStackDeleted (yystackp, yyk);
+ YYDPRINTF ((stderr, "Merging stack %lu into stack %lu.\n",
+ (unsigned long int) yyk,
+ (unsigned long int) yyi));
+ return yyok;
+ }
+ yyp = yyp->yypred;
+ }
+ }
+ yystackp->yytops.yystates[yyk] = yys;
+ yyglrShiftDefer (yystackp, yyk, yynewLRState, yyposn, yys0, yyrule);
+ }
+ return yyok;
+}
+
+static size_t
+yysplitStack (yyGLRStack* yystackp, size_t yyk)
+{
+ if (yystackp->yysplitPoint == YY_NULL)
+ {
+ YYASSERT (yyk == 0);
+ yystackp->yysplitPoint = yystackp->yytops.yystates[yyk];
+ }
+ if (yystackp->yytops.yysize >= yystackp->yytops.yycapacity)
+ {
+ yyGLRState** yynewStates;
+ yybool* yynewLookaheadNeeds;
+
+ yynewStates = YY_NULL;
+
+ if (yystackp->yytops.yycapacity
+ > (YYSIZEMAX / (2 * sizeof yynewStates[0])))
+ yyMemoryExhausted (yystackp);
+ yystackp->yytops.yycapacity *= 2;
+
+ yynewStates =
+ (yyGLRState**) YYREALLOC (yystackp->yytops.yystates,
+ (yystackp->yytops.yycapacity
+ * sizeof yynewStates[0]));
+ if (yynewStates == YY_NULL)
+ yyMemoryExhausted (yystackp);
+ yystackp->yytops.yystates = yynewStates;
+
+ yynewLookaheadNeeds =
+ (yybool*) YYREALLOC (yystackp->yytops.yylookaheadNeeds,
+ (yystackp->yytops.yycapacity
+ * sizeof yynewLookaheadNeeds[0]));
+ if (yynewLookaheadNeeds == YY_NULL)
+ yyMemoryExhausted (yystackp);
+ yystackp->yytops.yylookaheadNeeds = yynewLookaheadNeeds;
+ }
+ yystackp->yytops.yystates[yystackp->yytops.yysize]
+ = yystackp->yytops.yystates[yyk];
+ yystackp->yytops.yylookaheadNeeds[yystackp->yytops.yysize]
+ = yystackp->yytops.yylookaheadNeeds[yyk];
+ yystackp->yytops.yysize += 1;
+ return yystackp->yytops.yysize-1;
+}
+
+/** True iff Y0 and Y1 represent identical options at the top level.
+ * That is, they represent the same rule applied to RHS symbols
+ * that produce the same terminal symbols. */
+static yybool
+yyidenticalOptions (yySemanticOption* yyy0, yySemanticOption* yyy1)
+{
+ if (yyy0->yyrule == yyy1->yyrule)
+ {
+ yyGLRState *yys0, *yys1;
+ int yyn;
+ for (yys0 = yyy0->yystate, yys1 = yyy1->yystate,
+ yyn = yyrhsLength (yyy0->yyrule);
+ yyn > 0;
+ yys0 = yys0->yypred, yys1 = yys1->yypred, yyn -= 1)
+ if (yys0->yyposn != yys1->yyposn)
+ return yyfalse;
+ return yytrue;
+ }
+ else
+ return yyfalse;
+}
+
+/** Assuming identicalOptions (Y0,Y1), destructively merge the
+ * alternative semantic values for the RHS-symbols of Y1 and Y0. */
+static void
+yymergeOptionSets (yySemanticOption* yyy0, yySemanticOption* yyy1)
+{
+ yyGLRState *yys0, *yys1;
+ int yyn;
+ for (yys0 = yyy0->yystate, yys1 = yyy1->yystate,
+ yyn = yyrhsLength (yyy0->yyrule);
+ yyn > 0;
+ yys0 = yys0->yypred, yys1 = yys1->yypred, yyn -= 1)
+ {
+ if (yys0 == yys1)
+ break;
+ else if (yys0->yyresolved)
+ {
+ yys1->yyresolved = yytrue;
+ yys1->yysemantics.yysval = yys0->yysemantics.yysval;
+ }
+ else if (yys1->yyresolved)
+ {
+ yys0->yyresolved = yytrue;
+ yys0->yysemantics.yysval = yys1->yysemantics.yysval;
+ }
+ else
+ {
+ yySemanticOption** yyz0p = &yys0->yysemantics.yyfirstVal;
+ yySemanticOption* yyz1 = yys1->yysemantics.yyfirstVal;
+ while (YYID (yytrue))
+ {
+ if (yyz1 == *yyz0p || yyz1 == YY_NULL)
+ break;
+ else if (*yyz0p == YY_NULL)
+ {
+ *yyz0p = yyz1;
+ break;
+ }
+ else if (*yyz0p < yyz1)
+ {
+ yySemanticOption* yyz = *yyz0p;
+ *yyz0p = yyz1;
+ yyz1 = yyz1->yynext;
+ (*yyz0p)->yynext = yyz;
+ }
+ yyz0p = &(*yyz0p)->yynext;
+ }
+ yys1->yysemantics.yyfirstVal = yys0->yysemantics.yyfirstVal;
+ }
+ }
+}
+
+/** Y0 and Y1 represent two possible actions to take in a given
+ * parsing state; return 0 if no combination is possible,
+ * 1 if user-mergeable, 2 if Y0 is preferred, 3 if Y1 is preferred. */
+static int
+yypreference (yySemanticOption* y0, yySemanticOption* y1)
+{
+ yyRuleNum r0 = y0->yyrule, r1 = y1->yyrule;
+ int p0 = yydprec[r0], p1 = yydprec[r1];
+
+ if (p0 == p1)
+ {
+ if (yymerger[r0] == 0 || yymerger[r0] != yymerger[r1])
+ return 0;
+ else
+ return 1;
+ }
+ if (p0 == 0 || p1 == 0)
+ return 0;
+ if (p0 < p1)
+ return 3;
+ if (p1 < p0)
+ return 2;
+ return 0;
+}
+
+static YYRESULTTAG yyresolveValue (yyGLRState* yys,
+ yyGLRStack* yystackp]b4_user_formals[);
+
+
+/** Resolve the previous N states starting at and including state S. If result
+ * != yyok, some states may have been left unresolved possibly with empty
+ * semantic option chains. Regardless of whether result = yyok, each state
+ * has been left with consistent data so that yydestroyGLRState can be invoked
+ * if necessary. */
+static YYRESULTTAG
+yyresolveStates (yyGLRState* yys, int yyn,
+ yyGLRStack* yystackp]b4_user_formals[)
+{
+ if (0 < yyn)
+ {
+ YYASSERT (yys->yypred);
+ YYCHK (yyresolveStates (yys->yypred, yyn-1, yystackp]b4_user_args[));
+ if (! yys->yyresolved)
+ YYCHK (yyresolveValue (yys, yystackp]b4_user_args[));
+ }
+ return yyok;
+}
+
+/** Resolve the states for the RHS of OPT, perform its user action, and return
+ * the semantic value and location. Regardless of whether result = yyok, all
+ * RHS states have been destroyed (assuming the user action destroys all RHS
+ * semantic values if invoked). */
+static YYRESULTTAG
+yyresolveAction (yySemanticOption* yyopt, yyGLRStack* yystackp,
+ YYSTYPE* yyvalp]b4_locuser_formals[)
+{
+ yyGLRStackItem yyrhsVals[YYMAXRHS + YYMAXLEFT + 1];
+ int yynrhs = yyrhsLength (yyopt->yyrule);
+ YYRESULTTAG yyflag =
+ yyresolveStates (yyopt->yystate, yynrhs, yystackp]b4_user_args[);
+ if (yyflag != yyok)
+ {
+ yyGLRState *yys;
+ for (yys = yyopt->yystate; yynrhs > 0; yys = yys->yypred, yynrhs -= 1)
+ yydestroyGLRState ("Cleanup: popping", yys]b4_user_args[);
+ return yyflag;
+ }
+
+ yyrhsVals[YYMAXRHS + YYMAXLEFT].yystate.yypred = yyopt->yystate;]b4_locations_if([[
+ if (yynrhs == 0)
+ /* Set default location. */
+ yyrhsVals[YYMAXRHS + YYMAXLEFT - 1].yystate.yyloc = yyopt->yystate->yyloc;]])[
+ {
+ int yychar_current = yychar;
+ YYSTYPE yylval_current = yylval;]b4_locations_if([
+ YYLTYPE yylloc_current = yylloc;])[
+ yychar = yyopt->yyrawchar;
+ yylval = yyopt->yyval;]b4_locations_if([
+ yylloc = yyopt->yyloc;])[
+ yyflag = yyuserAction (yyopt->yyrule, yynrhs,
+ yyrhsVals + YYMAXRHS + YYMAXLEFT - 1,
+ yystackp, yyvalp]b4_locuser_args[);
+ yychar = yychar_current;
+ yylval = yylval_current;]b4_locations_if([
+ yylloc = yylloc_current;])[
+ }
+ return yyflag;
+}
+
+#if ]b4_api_PREFIX[DEBUG
+static void
+yyreportTree (yySemanticOption* yyx, int yyindent)
+{
+ int yynrhs = yyrhsLength (yyx->yyrule);
+ int yyi;
+ yyGLRState* yys;
+ yyGLRState* yystates[1 + YYMAXRHS];
+ yyGLRState yyleftmost_state;
+
+ for (yyi = yynrhs, yys = yyx->yystate; 0 < yyi; yyi -= 1, yys = yys->yypred)
+ yystates[yyi] = yys;
+ if (yys == YY_NULL)
+ {
+ yyleftmost_state.yyposn = 0;
+ yystates[0] = &yyleftmost_state;
+ }
+ else
+ yystates[0] = yys;
+
+ if (yyx->yystate->yyposn < yys->yyposn + 1)
+ YYFPRINTF (stderr, "%*s%s -> <Rule %d, empty>\n",
+ yyindent, "", yytokenName (yylhsNonterm (yyx->yyrule)),
+ yyx->yyrule - 1);
+ else
+ YYFPRINTF (stderr, "%*s%s -> <Rule %d, tokens %lu .. %lu>\n",
+ yyindent, "", yytokenName (yylhsNonterm (yyx->yyrule)),
+ yyx->yyrule - 1, (unsigned long int) (yys->yyposn + 1),
+ (unsigned long int) yyx->yystate->yyposn);
+ for (yyi = 1; yyi <= yynrhs; yyi += 1)
+ {
+ if (yystates[yyi]->yyresolved)
+ {
+ if (yystates[yyi-1]->yyposn+1 > yystates[yyi]->yyposn)
+ YYFPRINTF (stderr, "%*s%s <empty>\n", yyindent+2, "",
+ yytokenName (yyrhs[yyprhs[yyx->yyrule]+yyi-1]));
+ else
+ YYFPRINTF (stderr, "%*s%s <tokens %lu .. %lu>\n", yyindent+2, "",
+ yytokenName (yyrhs[yyprhs[yyx->yyrule]+yyi-1]),
+ (unsigned long int) (yystates[yyi - 1]->yyposn + 1),
+ (unsigned long int) yystates[yyi]->yyposn);
+ }
+ else
+ yyreportTree (yystates[yyi]->yysemantics.yyfirstVal, yyindent+2);
+ }
+}
+#endif
+
+/*ARGSUSED*/ static YYRESULTTAG
+yyreportAmbiguity (yySemanticOption* yyx0,
+ yySemanticOption* yyx1]b4_pure_formals[)
+{
+ YYUSE (yyx0);
+ YYUSE (yyx1);
+
+#if ]b4_api_PREFIX[DEBUG
+ YYFPRINTF (stderr, "Ambiguity detected.\n");
+ YYFPRINTF (stderr, "Option 1,\n");
+ yyreportTree (yyx0, 2);
+ YYFPRINTF (stderr, "\nOption 2,\n");
+ yyreportTree (yyx1, 2);
+ YYFPRINTF (stderr, "\n");
+#endif
+
+ yyerror (]b4_yyerror_args[YY_("syntax is ambiguous"));
+ return yyabort;
+}]b4_locations_if([[
+
+/** Starting at and including state S1, resolve the location for each of the
+ * previous N1 states that is unresolved. The first semantic option of a state
+ * is always chosen. */
+static void
+yyresolveLocations (yyGLRState* yys1, int yyn1,
+ yyGLRStack *yystackp]b4_user_formals[)
+{
+ if (0 < yyn1)
+ {
+ yyresolveLocations (yys1->yypred, yyn1 - 1, yystackp]b4_user_args[);
+ if (!yys1->yyresolved)
+ {
+ yyGLRStackItem yyrhsloc[1 + YYMAXRHS];
+ int yynrhs;
+ yySemanticOption *yyoption = yys1->yysemantics.yyfirstVal;
+ YYASSERT (yyoption != YY_NULL);
+ yynrhs = yyrhsLength (yyoption->yyrule);
+ if (yynrhs > 0)
+ {
+ yyGLRState *yys;
+ int yyn;
+ yyresolveLocations (yyoption->yystate, yynrhs,
+ yystackp]b4_user_args[);
+ for (yys = yyoption->yystate, yyn = yynrhs;
+ yyn > 0;
+ yys = yys->yypred, yyn -= 1)
+ yyrhsloc[yyn].yystate.yyloc = yys->yyloc;
+ }
+ else
+ {
+ /* Both yyresolveAction and yyresolveLocations traverse the GSS
+ in reverse rightmost order. It is only necessary to invoke
+ yyresolveLocations on a subforest for which yyresolveAction
+ would have been invoked next had an ambiguity not been
+ detected. Thus the location of the previous state (but not
+ necessarily the previous state itself) is guaranteed to be
+ resolved already. */
+ yyGLRState *yyprevious = yyoption->yystate;
+ yyrhsloc[0].yystate.yyloc = yyprevious->yyloc;
+ }
+ {
+ int yychar_current = yychar;
+ YYSTYPE yylval_current = yylval;
+ YYLTYPE yylloc_current = yylloc;
+ yychar = yyoption->yyrawchar;
+ yylval = yyoption->yyval;
+ yylloc = yyoption->yyloc;
+ YYLLOC_DEFAULT ((yys1->yyloc), yyrhsloc, yynrhs);
+ yychar = yychar_current;
+ yylval = yylval_current;
+ yylloc = yylloc_current;
+ }
+ }
+ }
+}]])[
+
+/** Resolve the ambiguity represented in state S, perform the indicated
+ * actions, and set the semantic value of S. If result != yyok, the chain of
+ * semantic options in S has been cleared instead or it has been left
+ * unmodified except that redundant options may have been removed. Regardless
+ * of whether result = yyok, S has been left with consistent data so that
+ * yydestroyGLRState can be invoked if necessary. */
+static YYRESULTTAG
+yyresolveValue (yyGLRState* yys, yyGLRStack* yystackp]b4_user_formals[)
+{
+ yySemanticOption* yyoptionList = yys->yysemantics.yyfirstVal;
+ yySemanticOption* yybest = yyoptionList;
+ yySemanticOption** yypp;
+ yybool yymerge = yyfalse;
+ YYSTYPE yysval;
+ YYRESULTTAG yyflag;]b4_locations_if([
+ YYLTYPE *yylocp = &yys->yyloc;])[
+
+ for (yypp = &yyoptionList->yynext; *yypp != YY_NULL; )
+ {
+ yySemanticOption* yyp = *yypp;
+
+ if (yyidenticalOptions (yybest, yyp))
+ {
+ yymergeOptionSets (yybest, yyp);
+ *yypp = yyp->yynext;
+ }
+ else
+ {
+ switch (yypreference (yybest, yyp))
+ {
+ case 0:]b4_locations_if([[
+ yyresolveLocations (yys, 1, yystackp]b4_user_args[);]])[
+ return yyreportAmbiguity (yybest, yyp]b4_pure_args[);
+ break;
+ case 1:
+ yymerge = yytrue;
+ break;
+ case 2:
+ break;
+ case 3:
+ yybest = yyp;
+ yymerge = yyfalse;
+ break;
+ default:
+ /* This cannot happen so it is not worth a YYASSERT (yyfalse),
+ but some compilers complain if the default case is
+ omitted. */
+ break;
+ }
+ yypp = &yyp->yynext;
+ }
+ }
+
+ if (yymerge)
+ {
+ yySemanticOption* yyp;
+ int yyprec = yydprec[yybest->yyrule];
+ yyflag = yyresolveAction (yybest, yystackp, &yysval]b4_locuser_args[);
+ if (yyflag == yyok)
+ for (yyp = yybest->yynext; yyp != YY_NULL; yyp = yyp->yynext)
+ {
+ if (yyprec == yydprec[yyp->yyrule])
+ {
+ YYSTYPE yysval_other;]b4_locations_if([
+ YYLTYPE yydummy;])[
+ yyflag = yyresolveAction (yyp, yystackp, &yysval_other]b4_locuser_args([&yydummy])[);
+ if (yyflag != yyok)
+ {
+ yydestruct ("Cleanup: discarding incompletely merged value for",
+ yystos[yys->yylrState],
+ &yysval]b4_locuser_args[);
+ break;
+ }
+ yyuserMerge (yymerger[yyp->yyrule], &yysval, &yysval_other);
+ }
+ }
+ }
+ else
+ yyflag = yyresolveAction (yybest, yystackp, &yysval]b4_locuser_args([yylocp])[);
+
+ if (yyflag == yyok)
+ {
+ yys->yyresolved = yytrue;
+ yys->yysemantics.yysval = yysval;
+ }
+ else
+ yys->yysemantics.yyfirstVal = YY_NULL;
+ return yyflag;
+}
+
+static YYRESULTTAG
+yyresolveStack (yyGLRStack* yystackp]b4_user_formals[)
+{
+ if (yystackp->yysplitPoint != YY_NULL)
+ {
+ yyGLRState* yys;
+ int yyn;
+
+ for (yyn = 0, yys = yystackp->yytops.yystates[0];
+ yys != yystackp->yysplitPoint;
+ yys = yys->yypred, yyn += 1)
+ continue;
+ YYCHK (yyresolveStates (yystackp->yytops.yystates[0], yyn, yystackp
+ ]b4_user_args[));
+ }
+ return yyok;
+}
+
+static void
+yycompressStack (yyGLRStack* yystackp)
+{
+ yyGLRState* yyp, *yyq, *yyr;
+
+ if (yystackp->yytops.yysize != 1 || yystackp->yysplitPoint == YY_NULL)
+ return;
+
+ for (yyp = yystackp->yytops.yystates[0], yyq = yyp->yypred, yyr = YY_NULL;
+ yyp != yystackp->yysplitPoint;
+ yyr = yyp, yyp = yyq, yyq = yyp->yypred)
+ yyp->yypred = yyr;
+
+ yystackp->yyspaceLeft += yystackp->yynextFree - yystackp->yyitems;
+ yystackp->yynextFree = ((yyGLRStackItem*) yystackp->yysplitPoint) + 1;
+ yystackp->yyspaceLeft -= yystackp->yynextFree - yystackp->yyitems;
+ yystackp->yysplitPoint = YY_NULL;
+ yystackp->yylastDeleted = YY_NULL;
+
+ while (yyr != YY_NULL)
+ {
+ yystackp->yynextFree->yystate = *yyr;
+ yyr = yyr->yypred;
+ yystackp->yynextFree->yystate.yypred = &yystackp->yynextFree[-1].yystate;
+ yystackp->yytops.yystates[0] = &yystackp->yynextFree->yystate;
+ yystackp->yynextFree += 1;
+ yystackp->yyspaceLeft -= 1;
+ }
+}
+
+static YYRESULTTAG
+yyprocessOneStack (yyGLRStack* yystackp, size_t yyk,
+ size_t yyposn]b4_pure_formals[)
+{
+ int yyaction;
+ const short int* yyconflicts;
+ yyRuleNum yyrule;
+
+ while (yystackp->yytops.yystates[yyk] != YY_NULL)
+ {
+ yyStateNum yystate = yystackp->yytops.yystates[yyk]->yylrState;
+ YYDPRINTF ((stderr, "Stack %lu Entering state %d\n",
+ (unsigned long int) yyk, yystate));
+
+ YYASSERT (yystate != YYFINAL);
+
+ if (yyisDefaultedState (yystate))
+ {
+ yyrule = yydefaultAction (yystate);
+ if (yyrule == 0)
+ {
+ YYDPRINTF ((stderr, "Stack %lu dies.\n",
+ (unsigned long int) yyk));
+ yymarkStackDeleted (yystackp, yyk);
+ return yyok;
+ }
+ YYCHK (yyglrReduce (yystackp, yyk, yyrule, yyfalse]b4_user_args[));
+ }
+ else
+ {
+ yySymbol yytoken;
+ yystackp->yytops.yylookaheadNeeds[yyk] = yytrue;
+ if (yychar == YYEMPTY)
+ {
+ YYDPRINTF ((stderr, "Reading a token: "));
+ yychar = YYLEX;
+ }
+
+ if (yychar <= YYEOF)
+ {
+ yychar = yytoken = YYEOF;
+ YYDPRINTF ((stderr, "Now at end of input.\n"));
+ }
+ else
+ {
+ yytoken = YYTRANSLATE (yychar);
+ YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
+ }
+
+ yygetLRActions (yystate, yytoken, &yyaction, &yyconflicts);
+
+ while (*yyconflicts != 0)
+ {
+ size_t yynewStack = yysplitStack (yystackp, yyk);
+ YYDPRINTF ((stderr, "Splitting off stack %lu from %lu.\n",
+ (unsigned long int) yynewStack,
+ (unsigned long int) yyk));
+ YYCHK (yyglrReduce (yystackp, yynewStack,
+ *yyconflicts, yyfalse]b4_user_args[));
+ YYCHK (yyprocessOneStack (yystackp, yynewStack,
+ yyposn]b4_pure_args[));
+ yyconflicts += 1;
+ }
+
+ if (yyisShiftAction (yyaction))
+ break;
+ else if (yyisErrorAction (yyaction))
+ {
+ YYDPRINTF ((stderr, "Stack %lu dies.\n",
+ (unsigned long int) yyk));
+ yymarkStackDeleted (yystackp, yyk);
+ break;
+ }
+ else
+ YYCHK (yyglrReduce (yystackp, yyk, -yyaction,
+ yyfalse]b4_user_args[));
+ }
+ }
+ return yyok;
+}
+
+/*ARGSUSED*/ static void
+yyreportSyntaxError (yyGLRStack* yystackp]b4_user_formals[)
+{
+ if (yystackp->yyerrState != 0)
+ return;
+#if ! YYERROR_VERBOSE
+ yyerror (]b4_lyyerror_args[YY_("syntax error"));
+#else
+ {
+ yySymbol yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar);
+ size_t yysize0 = yytnamerr (YY_NULL, yytokenName (yytoken));
+ size_t yysize = yysize0;
+ yybool yysize_overflow = yyfalse;
+ char* yymsg = YY_NULL;
+ enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
+ /* Internationalized format string. */
+ const char *yyformat = YY_NULL;
+ /* Arguments of yyformat. */
+ char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
+ /* Number of reported tokens (one for the "unexpected", one per
+ "expected"). */
+ int yycount = 0;
+
+ /* There are many possibilities here to consider:
+ - If this state is a consistent state with a default action, then
+ the only way this function was invoked is if the default action
+ is an error action. In that case, don't check for expected
+ tokens because there are none.
+ - The only way there can be no lookahead present (in yychar) is if
+ this state is a consistent state with a default action. Thus,
+ detecting the absence of a lookahead is sufficient to determine
+ that there is no unexpected or expected token to report. In that
+ case, just report a simple "syntax error".
+ - Don't assume there isn't a lookahead just because this state is a
+ consistent state with a default action. There might have been a
+ previous inconsistent state, consistent state with a non-default
+ action, or user semantic action that manipulated yychar.
+ - Of course, the expected token list depends on states to have
+ correct lookahead information, and it depends on the parser not
+ to perform extra reductions after fetching a lookahead from the
+ scanner and before detecting a syntax error. Thus, state merging
+ (from LALR or IELR) and default reductions corrupt the expected
+ token list. However, the list is correct for canonical LR with
+ one exception: it will still contain any token that will not be
+ accepted due to an error action in a later state.
+ */
+ if (yytoken != YYEMPTY)
+ {
+ int yyn = yypact[yystackp->yytops.yystates[0]->yylrState];
+ yyarg[yycount++] = yytokenName (yytoken);
+ if (!yypact_value_is_default (yyn))
+ {
+ /* Start YYX at -YYN if negative to avoid negative indexes in
+ YYCHECK. In other words, skip the first -YYN actions for this
+ state because they are default actions. */
+ int yyxbegin = yyn < 0 ? -yyn : 0;
+ /* Stay within bounds of both yycheck and yytname. */
+ int yychecklim = YYLAST - yyn + 1;
+ int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
+ int yyx;
+ for (yyx = yyxbegin; yyx < yyxend; ++yyx)
+ if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR
+ && !yytable_value_is_error (yytable[yyx + yyn]))
+ {
+ if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
+ {
+ yycount = 1;
+ yysize = yysize0;
+ break;
+ }
+ yyarg[yycount++] = yytokenName (yyx);
+ {
+ size_t yysz = yysize + yytnamerr (YY_NULL, yytokenName (yyx));
+ yysize_overflow |= yysz < yysize;
+ yysize = yysz;
+ }
+ }
+ }
+ }
+
+ switch (yycount)
+ {
+#define YYCASE_(N, S) \
+ case N: \
+ yyformat = S; \
+ break
+ YYCASE_(0, YY_("syntax error"));
+ YYCASE_(1, YY_("syntax error, unexpected %s"));
+ YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
+ YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s"));
+ YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
+ YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
+#undef YYCASE_
+ }
+
+ {
+ size_t yysz = yysize + strlen (yyformat);
+ yysize_overflow |= yysz < yysize;
+ yysize = yysz;
+ }
+
+ if (!yysize_overflow)
+ yymsg = (char *) YYMALLOC (yysize);
+
+ if (yymsg)
+ {
+ char *yyp = yymsg;
+ int yyi = 0;
+ while ((*yyp = *yyformat))
+ {
+ if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount)
+ {
+ yyp += yytnamerr (yyp, yyarg[yyi++]);
+ yyformat += 2;
+ }
+ else
+ {
+ yyp++;
+ yyformat++;
+ }
+ }
+ yyerror (]b4_lyyerror_args[yymsg);
+ YYFREE (yymsg);
+ }
+ else
+ {
+ yyerror (]b4_lyyerror_args[YY_("syntax error"));
+ yyMemoryExhausted (yystackp);
+ }
+ }
+#endif /* YYERROR_VERBOSE */
+ yynerrs += 1;
+}
+
+/* Recover from a syntax error on *YYSTACKP, assuming that *YYSTACKP->YYTOKENP,
+ yylval, and yylloc are the syntactic category, semantic value, and location
+ of the lookahead. */
+/*ARGSUSED*/ static void
+yyrecoverSyntaxError (yyGLRStack* yystackp]b4_user_formals[)
+{
+ size_t yyk;
+ int yyj;
+
+ if (yystackp->yyerrState == 3)
+ /* We just shifted the error token and (perhaps) took some
+ reductions. Skip tokens until we can proceed. */
+ while (YYID (yytrue))
+ {
+ yySymbol yytoken;
+ if (yychar == YYEOF)
+ yyFail (yystackp][]b4_lpure_args[, YY_NULL);
+ if (yychar != YYEMPTY)
+ {]b4_locations_if([[
+ /* We throw away the lookahead, but the error range
+ of the shifted error token must take it into account. */
+ yyGLRState *yys = yystackp->yytops.yystates[0];
+ yyGLRStackItem yyerror_range[3];
+ yyerror_range[1].yystate.yyloc = yys->yyloc;
+ yyerror_range[2].yystate.yyloc = yylloc;
+ YYLLOC_DEFAULT ((yys->yyloc), yyerror_range, 2);]])[
+ yytoken = YYTRANSLATE (yychar);
+ yydestruct ("Error: discarding",
+ yytoken, &yylval]b4_locuser_args([&yylloc])[);
+ }
+ YYDPRINTF ((stderr, "Reading a token: "));
+ yychar = YYLEX;
+ if (yychar <= YYEOF)
+ {
+ yychar = yytoken = YYEOF;
+ YYDPRINTF ((stderr, "Now at end of input.\n"));
+ }
+ else
+ {
+ yytoken = YYTRANSLATE (yychar);
+ YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
+ }
+ yyj = yypact[yystackp->yytops.yystates[0]->yylrState];
+ if (yypact_value_is_default (yyj))
+ return;
+ yyj += yytoken;
+ if (yyj < 0 || YYLAST < yyj || yycheck[yyj] != yytoken)
+ {
+ if (yydefact[yystackp->yytops.yystates[0]->yylrState] != 0)
+ return;
+ }
+ else if (! yytable_value_is_error (yytable[yyj]))
+ return;
+ }
+
+ /* Reduce to one stack. */
+ for (yyk = 0; yyk < yystackp->yytops.yysize; yyk += 1)
+ if (yystackp->yytops.yystates[yyk] != YY_NULL)
+ break;
+ if (yyk >= yystackp->yytops.yysize)
+ yyFail (yystackp][]b4_lpure_args[, YY_NULL);
+ for (yyk += 1; yyk < yystackp->yytops.yysize; yyk += 1)
+ yymarkStackDeleted (yystackp, yyk);
+ yyremoveDeletes (yystackp);
+ yycompressStack (yystackp);
+
+ /* Now pop stack until we find a state that shifts the error token. */
+ yystackp->yyerrState = 3;
+ while (yystackp->yytops.yystates[0] != YY_NULL)
+ {
+ yyGLRState *yys = yystackp->yytops.yystates[0];
+ yyj = yypact[yys->yylrState];
+ if (! yypact_value_is_default (yyj))
+ {
+ yyj += YYTERROR;
+ if (0 <= yyj && yyj <= YYLAST && yycheck[yyj] == YYTERROR
+ && yyisShiftAction (yytable[yyj]))
+ {
+ /* Shift the error token. */]b4_locations_if([[
+ /* First adjust its location.*/
+ YYLTYPE yyerrloc;
+ yystackp->yyerror_range[2].yystate.yyloc = yylloc;
+ YYLLOC_DEFAULT (yyerrloc, (yystackp->yyerror_range), 2);]])[
+ YY_SYMBOL_PRINT ("Shifting", yystos[yytable[yyj]],
+ &yylval, &yyerrloc);
+ yyglrShift (yystackp, 0, yytable[yyj],
+ yys->yyposn, &yylval]b4_locations_if([, &yyerrloc])[);
+ yys = yystackp->yytops.yystates[0];
+ break;
+ }
+ }]b4_locations_if([[
+ yystackp->yyerror_range[1].yystate.yyloc = yys->yyloc;]])[
+ if (yys->yypred != YY_NULL)
+ yydestroyGLRState ("Error: popping", yys]b4_user_args[);
+ yystackp->yytops.yystates[0] = yys->yypred;
+ yystackp->yynextFree -= 1;
+ yystackp->yyspaceLeft += 1;
+ }
+ if (yystackp->yytops.yystates[0] == YY_NULL)
+ yyFail (yystackp][]b4_lpure_args[, YY_NULL);
+}
+
+#define YYCHK1(YYE) \
+ do { \
+ switch (YYE) { \
+ case yyok: \
+ break; \
+ case yyabort: \
+ goto yyabortlab; \
+ case yyaccept: \
+ goto yyacceptlab; \
+ case yyerr: \
+ goto yyuser_error; \
+ default: \
+ goto yybuglab; \
+ } \
+ } while (YYID (0))
+
+
+/*----------.
+| yyparse. |
+`----------*/
+
+]b4_c_ansi_function_def([yyparse], [int], b4_parse_param)[
+{
+ int yyresult;
+ yyGLRStack yystack;
+ yyGLRStack* const yystackp = &yystack;
+ size_t yyposn;
+
+ YYDPRINTF ((stderr, "Starting parse\n"));
+
+ yychar = YYEMPTY;
+ yylval = yyval_default;]b4_locations_if([
+ yylloc = yyloc_default;])[
+]m4_ifdef([b4_initial_action], [
+b4_dollar_pushdef([yylval], [], [yylloc])dnl
+/* User initialization code. */
+b4_user_initial_action
+b4_dollar_popdef])[]dnl
+[
+ if (! yyinitGLRStack (yystackp, YYINITDEPTH))
+ goto yyexhaustedlab;
+ switch (YYSETJMP (yystack.yyexception_buffer))
+ {
+ case 0: break;
+ case 1: goto yyabortlab;
+ case 2: goto yyexhaustedlab;
+ default: goto yybuglab;
+ }
+ yyglrShift (&yystack, 0, 0, 0, &yylval]b4_locations_if([, &yylloc])[);
+ yyposn = 0;
+
+ while (YYID (yytrue))
+ {
+ /* For efficiency, we have two loops, the first of which is
+ specialized to deterministic operation (single stack, no
+ potential ambiguity). */
+ /* Standard mode */
+ while (YYID (yytrue))
+ {
+ yyRuleNum yyrule;
+ int yyaction;
+ const short int* yyconflicts;
+
+ yyStateNum yystate = yystack.yytops.yystates[0]->yylrState;
+ YYDPRINTF ((stderr, "Entering state %d\n", yystate));
+ if (yystate == YYFINAL)
+ goto yyacceptlab;
+ if (yyisDefaultedState (yystate))
+ {
+ yyrule = yydefaultAction (yystate);
+ if (yyrule == 0)
+ {
+]b4_locations_if([[ yystack.yyerror_range[1].yystate.yyloc = yylloc;]])[
+ yyreportSyntaxError (&yystack]b4_user_args[);
+ goto yyuser_error;
+ }
+ YYCHK1 (yyglrReduce (&yystack, 0, yyrule, yytrue]b4_user_args[));
+ }
+ else
+ {
+ yySymbol yytoken;
+ if (yychar == YYEMPTY)
+ {
+ YYDPRINTF ((stderr, "Reading a token: "));
+ yychar = YYLEX;
+ }
+
+ if (yychar <= YYEOF)
+ {
+ yychar = yytoken = YYEOF;
+ YYDPRINTF ((stderr, "Now at end of input.\n"));
+ }
+ else
+ {
+ yytoken = YYTRANSLATE (yychar);
+ YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
+ }
+
+ yygetLRActions (yystate, yytoken, &yyaction, &yyconflicts);
+ if (*yyconflicts != 0)
+ break;
+ if (yyisShiftAction (yyaction))
+ {
+ YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
+ yychar = YYEMPTY;
+ yyposn += 1;
+ yyglrShift (&yystack, 0, yyaction, yyposn, &yylval]b4_locations_if([, &yylloc])[);
+ if (0 < yystack.yyerrState)
+ yystack.yyerrState -= 1;
+ }
+ else if (yyisErrorAction (yyaction))
+ {
+]b4_locations_if([[ yystack.yyerror_range[1].yystate.yyloc = yylloc;]])[
+ yyreportSyntaxError (&yystack]b4_user_args[);
+ goto yyuser_error;
+ }
+ else
+ YYCHK1 (yyglrReduce (&yystack, 0, -yyaction, yytrue]b4_user_args[));
+ }
+ }
+
+ while (YYID (yytrue))
+ {
+ yySymbol yytoken_to_shift;
+ size_t yys;
+
+ for (yys = 0; yys < yystack.yytops.yysize; yys += 1)
+ yystackp->yytops.yylookaheadNeeds[yys] = yychar != YYEMPTY;
+
+ /* yyprocessOneStack returns one of three things:
+
+ - An error flag. If the caller is yyprocessOneStack, it
+ immediately returns as well. When the caller is finally
+ yyparse, it jumps to an error label via YYCHK1.
+
+ - yyok, but yyprocessOneStack has invoked yymarkStackDeleted
+ (&yystack, yys), which sets the top state of yys to NULL. Thus,
+ yyparse's following invocation of yyremoveDeletes will remove
+ the stack.
+
+ - yyok, when ready to shift a token.
+
+ Except in the first case, yyparse will invoke yyremoveDeletes and
+ then shift the next token onto all remaining stacks. This
+ synchronization of the shift (that is, after all preceding
+ reductions on all stacks) helps prevent double destructor calls
+ on yylval in the event of memory exhaustion. */
+
+ for (yys = 0; yys < yystack.yytops.yysize; yys += 1)
+ YYCHK1 (yyprocessOneStack (&yystack, yys, yyposn]b4_lpure_args[));
+ yyremoveDeletes (&yystack);
+ if (yystack.yytops.yysize == 0)
+ {
+ yyundeleteLastStack (&yystack);
+ if (yystack.yytops.yysize == 0)
+ yyFail (&yystack][]b4_lpure_args[, YY_("syntax error"));
+ YYCHK1 (yyresolveStack (&yystack]b4_user_args[));
+ YYDPRINTF ((stderr, "Returning to deterministic operation.\n"));
+]b4_locations_if([[ yystack.yyerror_range[1].yystate.yyloc = yylloc;]])[
+ yyreportSyntaxError (&yystack]b4_user_args[);
+ goto yyuser_error;
+ }
+
+ /* If any yyglrShift call fails, it will fail after shifting. Thus,
+ a copy of yylval will already be on stack 0 in the event of a
+ failure in the following loop. Thus, yychar is set to YYEMPTY
+ before the loop to make sure the user destructor for yylval isn't
+ called twice. */
+ yytoken_to_shift = YYTRANSLATE (yychar);
+ yychar = YYEMPTY;
+ yyposn += 1;
+ for (yys = 0; yys < yystack.yytops.yysize; yys += 1)
+ {
+ int yyaction;
+ const short int* yyconflicts;
+ yyStateNum yystate = yystack.yytops.yystates[yys]->yylrState;
+ yygetLRActions (yystate, yytoken_to_shift, &yyaction,
+ &yyconflicts);
+ /* Note that yyconflicts were handled by yyprocessOneStack. */
+ YYDPRINTF ((stderr, "On stack %lu, ", (unsigned long int) yys));
+ YY_SYMBOL_PRINT ("shifting", yytoken_to_shift, &yylval, &yylloc);
+ yyglrShift (&yystack, yys, yyaction, yyposn,
+ &yylval]b4_locations_if([, &yylloc])[);
+ YYDPRINTF ((stderr, "Stack %lu now in state #%d\n",
+ (unsigned long int) yys,
+ yystack.yytops.yystates[yys]->yylrState));
+ }
+
+ if (yystack.yytops.yysize == 1)
+ {
+ YYCHK1 (yyresolveStack (&yystack]b4_user_args[));
+ YYDPRINTF ((stderr, "Returning to deterministic operation.\n"));
+ yycompressStack (&yystack);
+ break;
+ }
+ }
+ continue;
+ yyuser_error:
+ yyrecoverSyntaxError (&yystack]b4_user_args[);
+ yyposn = yystack.yytops.yystates[0]->yyposn;
+ }
+
+ yyacceptlab:
+ yyresult = 0;
+ goto yyreturn;
+
+ yybuglab:
+ YYASSERT (yyfalse);
+ goto yyabortlab;
+
+ yyabortlab:
+ yyresult = 1;
+ goto yyreturn;
+
+ yyexhaustedlab:
+ yyerror (]b4_lyyerror_args[YY_("memory exhausted"));
+ yyresult = 2;
+ goto yyreturn;
+
+ yyreturn:
+ if (yychar != YYEMPTY)
+ yydestruct ("Cleanup: discarding lookahead",
+ YYTRANSLATE (yychar), &yylval]b4_locuser_args([&yylloc])[);
+
+ /* If the stack is well-formed, pop the stack until it is empty,
+ destroying its entries as we go. But free the stack regardless
+ of whether it is well-formed. */
+ if (yystack.yyitems)
+ {
+ yyGLRState** yystates = yystack.yytops.yystates;
+ if (yystates)
+ {
+ size_t yysize = yystack.yytops.yysize;
+ size_t yyk;
+ for (yyk = 0; yyk < yysize; yyk += 1)
+ if (yystates[yyk])
+ {
+ while (yystates[yyk])
+ {
+ yyGLRState *yys = yystates[yyk];
+]b4_locations_if([[ yystack.yyerror_range[1].yystate.yyloc = yys->yyloc;]]
+)[ if (yys->yypred != YY_NULL)
+ yydestroyGLRState ("Cleanup: popping", yys]b4_user_args[);
+ yystates[yyk] = yys->yypred;
+ yystack.yynextFree -= 1;
+ yystack.yyspaceLeft += 1;
+ }
+ break;
+ }
+ }
+ yyfreeGLRStack (&yystack);
+ }
+
+ /* Make sure YYID is used. */
+ return YYID (yyresult);
+}
+
+/* DEBUGGING ONLY */
+#if ]b4_api_PREFIX[DEBUG
+static void yypstack (yyGLRStack* yystackp, size_t yyk)
+ __attribute__ ((__unused__));
+static void yypdumpstack (yyGLRStack* yystackp) __attribute__ ((__unused__));
+
+static void
+yy_yypstack (yyGLRState* yys)
+{
+ if (yys->yypred)
+ {
+ yy_yypstack (yys->yypred);
+ YYFPRINTF (stderr, " -> ");
+ }
+ YYFPRINTF (stderr, "%d@@%lu", yys->yylrState,
+ (unsigned long int) yys->yyposn);
+}
+
+static void
+yypstates (yyGLRState* yyst)
+{
+ if (yyst == YY_NULL)
+ YYFPRINTF (stderr, "<null>");
+ else
+ yy_yypstack (yyst);
+ YYFPRINTF (stderr, "\n");
+}
+
+static void
+yypstack (yyGLRStack* yystackp, size_t yyk)
+{
+ yypstates (yystackp->yytops.yystates[yyk]);
+}
+
+#define YYINDEX(YYX) \
+ ((YYX) == YY_NULL ? -1 : (yyGLRStackItem*) (YYX) - yystackp->yyitems)
+
+
+static void
+yypdumpstack (yyGLRStack* yystackp)
+{
+ yyGLRStackItem* yyp;
+ size_t yyi;
+ for (yyp = yystackp->yyitems; yyp < yystackp->yynextFree; yyp += 1)
+ {
+ YYFPRINTF (stderr, "%3lu. ",
+ (unsigned long int) (yyp - yystackp->yyitems));
+ if (*(yybool *) yyp)
+ {
+ YYFPRINTF (stderr, "Res: %d, LR State: %d, posn: %lu, pred: %ld",
+ yyp->yystate.yyresolved, yyp->yystate.yylrState,
+ (unsigned long int) yyp->yystate.yyposn,
+ (long int) YYINDEX (yyp->yystate.yypred));
+ if (! yyp->yystate.yyresolved)
+ YYFPRINTF (stderr, ", firstVal: %ld",
+ (long int) YYINDEX (yyp->yystate
+ .yysemantics.yyfirstVal));
+ }
+ else
+ {
+ YYFPRINTF (stderr, "Option. rule: %d, state: %ld, next: %ld",
+ yyp->yyoption.yyrule - 1,
+ (long int) YYINDEX (yyp->yyoption.yystate),
+ (long int) YYINDEX (yyp->yyoption.yynext));
+ }
+ YYFPRINTF (stderr, "\n");
+ }
+ YYFPRINTF (stderr, "Tops:");
+ for (yyi = 0; yyi < yystackp->yytops.yysize; yyi += 1)
+ YYFPRINTF (stderr, "%lu: %ld; ", (unsigned long int) yyi,
+ (long int) YYINDEX (yystackp->yytops.yystates[yyi]));
+ YYFPRINTF (stderr, "\n");
+}
+#endif
+]b4_epilogue[]dnl
+b4_output_end()
+
+# glr.cc produces its own header.
+m4_if(b4_skeleton, ["glr.c"],
+[b4_defines_if(
+[b4_output_begin([b4_spec_defines_file])
+b4_copyright([Skeleton interface for Bison GLR parsers in C],
+ [2002-2012])[
+
+]b4_cpp_guard_open([b4_spec_defines_file])[
+]b4_shared_declarations[
+]b4_cpp_guard_close([b4_spec_defines_file])[
+]b4_output_end()
+])])
--- /dev/null
+ -*- C -*-\r
+\r
+# C++ GLR skeleton for Bison\r
+\r
+# Copyright (C) 2002-2012 Free Software Foundation, Inc.\r
+\r
+# This program is free software: you can redistribute it and/or modify\r
+# it under the terms of the GNU General Public License as published by\r
+# the Free Software Foundation, either version 3 of the License, or\r
+# (at your option) any later version.\r
+#\r
+# This program is distributed in the hope that it will be useful,\r
+# but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
+# GNU General Public License for more details.\r
+#\r
+# You should have received a copy of the GNU General Public License\r
+# along with this program. If not, see <http://www.gnu.org/licenses/>.\r
+\r
+\r
+# This skeleton produces a C++ class that encapsulates a C glr parser.\r
+# This is in order to reduce the maintenance burden. The glr.c\r
+# skeleton is clean and pure enough so that there are no real\r
+# problems. The C++ interface is the same as that of lalr1.cc. In\r
+# fact, glr.c can replace yacc.c without the user noticing any\r
+# difference, and similarly for glr.cc replacing lalr1.cc.\r
+#\r
+# The passing of parse-params\r
+#\r
+# The additional arguments are stored as members of the parser\r
+# object, yyparser. The C routines need to carry yyparser\r
+# throughout the C parser; that easy: just let yyparser become an\r
+# additional parse-param. But because the C++ skeleton needs to\r
+# know the "real" original parse-param, we save them\r
+# (b4_parse_param_orig). Note that b4_parse_param is overquoted\r
+# (and c.m4 strips one level of quotes). This is a PITA, and\r
+# explains why there are so many levels of quotes.\r
+#\r
+# The locations\r
+#\r
+# We use location.cc just like lalr1.cc, but because glr.c stores\r
+# the locations in a (C++) union, the position and location classes\r
+# must not have a constructor. Therefore, contrary to lalr1.cc, we\r
+# must not define "b4_location_constructors". As a consequence the\r
+# user must initialize the first positions (in particular the\r
+# filename member).\r
+\r
+# We require a pure interface using locations.\r
+m4_define([b4_locations_flag], [1])\r
+m4_define([b4_pure_flag], [1])\r
+\r
+# The header is mandatory.\r
+b4_defines_if([],\r
+ [b4_fatal([b4_skeleton[: using %%defines is mandatory]])])\r
+\r
+m4_include(b4_pkgdatadir/[c++.m4])\r
+b4_percent_define_ifdef([[api.location.type]], [],\r
+ [m4_include(b4_pkgdatadir/[location.cc])])\r
+\r
+m4_define([b4_parser_class_name],\r
+ [b4_percent_define_get([[parser_class_name]])])\r
+\r
+# Save the parse parameters.\r
+m4_define([b4_parse_param_orig], m4_defn([b4_parse_param]))\r
+\r
+\r
+# b4_yy_symbol_print_generate\r
+# ---------------------------\r
+# Bypass the default implementation to generate the "yy_symbol_print"\r
+# and "yy_symbol_value_print" functions.\r
+m4_define([b4_yy_symbol_print_generate],\r
+[[\r
+/*--------------------.\r
+| Print this symbol. |\r
+`--------------------*/\r
+\r
+]b4_c_ansi_function_def([yy_symbol_print],\r
+ [static void],\r
+ [[FILE *], []],\r
+ [[int yytype], [yytype]],\r
+ [[const ]b4_namespace_ref::b4_parser_class_name[::semantic_type *yyvaluep],\r
+ [yyvaluep]],\r
+ [[const ]b4_namespace_ref::b4_parser_class_name[::location_type *yylocationp],\r
+ [yylocationp]],\r
+ b4_parse_param)[\r
+{\r
+]b4_parse_param_use[]dnl\r
+[ yyparser.yy_symbol_print_ (yytype, yyvaluep]b4_locations_if([, yylocationp])[);\r
+}\r
+]])[\r
+\r
+# Hijack the initial action to initialize the locations.\r
+]b4_locations_if([b4_percent_define_ifdef([[api.location.type]], [],\r
+[m4_define([b4_initial_action],\r
+[yylloc.initialize ();]m4_ifdef([b4_initial_action], [\r
+m4_defn([b4_initial_action])]))])])[\r
+\r
+# Hijack the post prologue to insert early definition of YYLLOC_DEFAULT\r
+# and declaration of yyerror.\r
+]m4_append([b4_post_prologue],\r
+[b4_syncline([@oline@], [@ofile@])[\r
+]b4_yylloc_default_define[\r
+#define YYRHSLOC(Rhs, K) ((Rhs)[K].yystate.yyloc)\r
+]b4_c_ansi_function_decl([yyerror],\r
+ [static void],\r
+ [[const ]b4_namespace_ref::b4_parser_class_name[::location_type *yylocationp],\r
+ [yylocationp]],\r
+ b4_parse_param,\r
+ [[const char* msg], [msg]])])\r
+\r
+\r
+# Hijack the epilogue to define implementations (yyerror, parser member\r
+# functions etc.).\r
+m4_append([b4_epilogue],\r
+[b4_syncline([@oline@], [@ofile@])[\r
+/*------------------.\r
+| Report an error. |\r
+`------------------*/\r
+\r
+]b4_c_ansi_function_def([yyerror],\r
+ [static void],\r
+ [[const ]b4_namespace_ref::b4_parser_class_name[::location_type *yylocationp],\r
+ [yylocationp]],\r
+ b4_parse_param,\r
+ [[const char* msg], [msg]])[\r
+{\r
+]b4_parse_param_use[]dnl\r
+[ yyparser.error (*yylocationp, msg);\r
+}\r
+\r
+\r
+]b4_namespace_open[\r
+]dnl In this section, the parse param are the original parse_params.\r
+m4_pushdef([b4_parse_param], m4_defn([b4_parse_param_orig]))dnl\r
+[ /// Build a parser object.\r
+ ]b4_parser_class_name::b4_parser_class_name[ (]b4_parse_param_decl[)]m4_ifset([b4_parse_param], [\r
+ :])[\r
+#if ]b4_api_PREFIX[DEBUG\r
+ ]m4_ifset([b4_parse_param], [ ], [ :])[\r
+ yycdebug_ (&std::cerr)]m4_ifset([b4_parse_param], [,])[\r
+#endif]b4_parse_param_cons[\r
+ {\r
+ }\r
+\r
+ ]b4_parser_class_name::~b4_parser_class_name[ ()\r
+ {\r
+ }\r
+\r
+ int\r
+ ]b4_parser_class_name[::parse ()\r
+ {\r
+ return ::yyparse (*this]b4_user_args[);\r
+ }\r
+\r
+#if ]b4_api_PREFIX[DEBUG\r
+ /*--------------------.\r
+ | Print this symbol. |\r
+ `--------------------*/\r
+\r
+ inline void\r
+ ]b4_parser_class_name[::yy_symbol_value_print_ (int yytype,\r
+ const semantic_type* yyvaluep,\r
+ const location_type* yylocationp)\r
+ {\r
+ YYUSE (yylocationp);\r
+ YYUSE (yyvaluep);\r
+ std::ostream& yyoutput = debug_stream ();\r
+ std::ostream& yyo = yyoutput;\r
+ YYUSE (yyo);\r
+ switch (yytype)\r
+ {\r
+ ]m4_map([b4_symbol_actions], m4_defn([b4_symbol_printers]))dnl\r
+[ default:\r
+ break;\r
+ }\r
+ }\r
+\r
+\r
+ void\r
+ ]b4_parser_class_name[::yy_symbol_print_ (int yytype,\r
+ const semantic_type* yyvaluep,\r
+ const location_type* yylocationp)\r
+ {\r
+ *yycdebug_ << (yytype < YYNTOKENS ? "token" : "nterm")\r
+ << ' ' << yytname[yytype] << " ("\r
+ << *yylocationp << ": ";\r
+ yy_symbol_value_print_ (yytype, yyvaluep, yylocationp);\r
+ *yycdebug_ << ')';\r
+ }\r
+\r
+ std::ostream&\r
+ ]b4_parser_class_name[::debug_stream () const\r
+ {\r
+ return *yycdebug_;\r
+ }\r
+\r
+ void\r
+ ]b4_parser_class_name[::set_debug_stream (std::ostream& o)\r
+ {\r
+ yycdebug_ = &o;\r
+ }\r
+\r
+\r
+ ]b4_parser_class_name[::debug_level_type\r
+ ]b4_parser_class_name[::debug_level () const\r
+ {\r
+ return yydebug;\r
+ }\r
+\r
+ void\r
+ ]b4_parser_class_name[::set_debug_level (debug_level_type l)\r
+ {\r
+ // Actually, it is yydebug which is really used.\r
+ yydebug = l;\r
+ }\r
+\r
+#endif\r
+]m4_popdef([b4_parse_param])dnl\r
+b4_namespace_close])\r
+\r
+\r
+# Let glr.c believe that the user arguments include the parser itself.\r
+m4_ifset([b4_parse_param],\r
+[m4_pushdef([b4_parse_param],\r
+ [[b4_namespace_ref::b4_parser_class_name[& yyparser], [[yyparser]]],]\r
+m4_defn([b4_parse_param]))],\r
+[m4_pushdef([b4_parse_param],\r
+ [[b4_namespace_ref::b4_parser_class_name[& yyparser], [[yyparser]]]])\r
+])\r
+m4_include(b4_pkgdatadir/[glr.c])\r
+m4_popdef([b4_parse_param])\r
+\r
+b4_output_begin([b4_spec_defines_file])\r
+b4_copyright([Skeleton interface for Bison GLR parsers in C++],\r
+ [2002-2006, 2009-2012])[\r
+\r
+/* C++ GLR parser skeleton written by Akim Demaille. */\r
+\r
+]b4_cpp_guard_open([b4_spec_defines_file])[\r
+\r
+]b4_percent_code_get([[requires]])[\r
+\r
+# include <string>\r
+# include <iostream>\r
+]b4_percent_define_ifdef([[api.location.type]], [],\r
+ [[# include "location.hh"]])[\r
+\r
+]b4_YYDEBUG_define[\r
+\r
+]b4_namespace_open[\r
+ /// A Bison parser.\r
+ class ]b4_parser_class_name[\r
+ {\r
+ public:\r
+ /// Symbol semantic values.\r
+# ifndef ]b4_api_PREFIX[STYPE\r
+]m4_ifdef([b4_stype],\r
+[ union semantic_type\r
+ {\r
+b4_user_stype\r
+ };],\r
+[m4_if(b4_tag_seen_flag, 0,\r
+[[ typedef int semantic_type;]],\r
+[[ typedef ]b4_api_PREFIX[STYPE semantic_type;]])])[\r
+# else\r
+ typedef ]b4_api_PREFIX[STYPE semantic_type;\r
+# endif\r
+ /// Symbol locations.\r
+ typedef ]b4_percent_define_get([[api.location.type]],\r
+ [[location]])[ location_type;\r
+ /// Tokens.\r
+ struct token\r
+ {\r
+ ]b4_token_enums(b4_tokens)[\r
+ };\r
+ /// Token type.\r
+ typedef token::yytokentype token_type;\r
+\r
+ /// Build a parser object.\r
+ ]b4_parser_class_name[ (]b4_parse_param_decl[);\r
+ virtual ~]b4_parser_class_name[ ();\r
+\r
+ /// Parse.\r
+ /// \returns 0 iff parsing succeeded.\r
+ virtual int parse ();\r
+\r
+ /// The current debugging stream.\r
+ std::ostream& debug_stream () const;\r
+ /// Set the current debugging stream.\r
+ void set_debug_stream (std::ostream &);\r
+\r
+ /// Type for debugging levels.\r
+ typedef int debug_level_type;\r
+ /// The current debugging level.\r
+ debug_level_type debug_level () const;\r
+ /// Set the current debugging level.\r
+ void set_debug_level (debug_level_type l);\r
+\r
+ private:\r
+\r
+ public:\r
+ /// Report a syntax error.\r
+ /// \param loc where the syntax error is found.\r
+ /// \param msg a description of the syntax error.\r
+ virtual void error (const location_type& loc, const std::string& msg);\r
+ private:\r
+\r
+# if ]b4_api_PREFIX[DEBUG\r
+ public:\r
+ /// \brief Report a symbol value on the debug stream.\r
+ /// \param yytype The token type.\r
+ /// \param yyvaluep Its semantic value.\r
+ /// \param yylocationp Its location.\r
+ virtual void yy_symbol_value_print_ (int yytype,\r
+ const semantic_type* yyvaluep,\r
+ const location_type* yylocationp);\r
+ /// \brief Report a symbol on the debug stream.\r
+ /// \param yytype The token type.\r
+ /// \param yyvaluep Its semantic value.\r
+ /// \param yylocationp Its location.\r
+ virtual void yy_symbol_print_ (int yytype,\r
+ const semantic_type* yyvaluep,\r
+ const location_type* yylocationp);\r
+ private:\r
+ /* Debugging. */\r
+ std::ostream* yycdebug_;\r
+# endif\r
+\r
+]b4_parse_param_vars[\r
+ };\r
+\r
+]dnl Redirections for glr.c.\r
+b4_percent_define_flag_if([[global_tokens_and_yystype]],\r
+[b4_token_defines(b4_tokens)])\r
+[\r
+#ifndef ]b4_api_PREFIX[STYPE\r
+# define ]b4_api_PREFIX[STYPE ]b4_namespace_ref[::]b4_parser_class_name[::semantic_type\r
+#endif\r
+#ifndef ]b4_api_PREFIX[LTYPE\r
+# define ]b4_api_PREFIX[LTYPE ]b4_namespace_ref[::]b4_parser_class_name[::location_type\r
+#endif\r
+\r
+]b4_namespace_close[\r
+]b4_percent_code_get([[provides]])[\r
+]b4_cpp_guard_close([b4_spec_defines_file])[\r
+]b4_output_end()\r
--- /dev/null
+ -*- Autoconf -*-\r
+\r
+# Java skeleton dispatching for Bison.\r
+\r
+# Copyright (C) 2007, 2009-2012 Free Software Foundation, Inc.\r
+\r
+# This program is free software: you can redistribute it and/or modify\r
+# it under the terms of the GNU General Public License as published by\r
+# the Free Software Foundation, either version 3 of the License, or\r
+# (at your option) any later version.\r
+#\r
+# This program is distributed in the hope that it will be useful,\r
+# but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
+# GNU General Public License for more details.\r
+#\r
+# You should have received a copy of the GNU General Public License\r
+# along with this program. If not, see <http://www.gnu.org/licenses/>.\r
+\r
+b4_glr_if( [b4_complain([%%glr-parser not supported for Java])])\r
+b4_nondeterministic_if([b4_complain([%%nondeterministic-parser not supported for Java])])\r
+\r
+m4_define_default([b4_used_skeleton], [b4_pkgdatadir/[lalr1.java]])\r
+m4_define_default([b4_skeleton], ["b4_basename(b4_used_skeleton)"])\r
+\r
+m4_include(b4_used_skeleton)\r
--- /dev/null
+ -*- Autoconf -*-\r
+\r
+# Java language support for Bison\r
+\r
+# Copyright (C) 2007-2012 Free Software Foundation, Inc.\r
+\r
+# This program is free software: you can redistribute it and/or modify\r
+# it under the terms of the GNU General Public License as published by\r
+# the Free Software Foundation, either version 3 of the License, or\r
+# (at your option) any later version.\r
+#\r
+# This program is distributed in the hope that it will be useful,\r
+# but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
+# GNU General Public License for more details.\r
+#\r
+# You should have received a copy of the GNU General Public License\r
+# along with this program. If not, see <http://www.gnu.org/licenses/>.\r
+\r
+m4_include(b4_pkgdatadir/[c-like.m4])\r
+\r
+# b4_comment(TEXT)\r
+# ----------------\r
+m4_define([b4_comment], [/* m4_bpatsubst([$1], [\r
+], [\r
+ ]) */])\r
+\r
+\r
+# b4_list2(LIST1, LIST2)\r
+# --------------------------\r
+# Join two lists with a comma if necessary.\r
+m4_define([b4_list2],\r
+ [$1[]m4_ifval(m4_quote($1), [m4_ifval(m4_quote($2), [[, ]])])[]$2])\r
+\r
+\r
+# b4_percent_define_get3(DEF, PRE, POST, NOT)\r
+# -------------------------------------------\r
+# Expand to the value of DEF surrounded by PRE and POST if it's %define'ed,\r
+# otherwise NOT.\r
+m4_define([b4_percent_define_get3],\r
+ [m4_ifval(m4_quote(b4_percent_define_get([$1])),\r
+ [$2[]b4_percent_define_get([$1])[]$3], [$4])])\r
+\r
+\r
+\r
+# b4_flag_value(BOOLEAN-FLAG)\r
+# ---------------------------\r
+m4_define([b4_flag_value], [b4_flag_if([$1], [true], [false])])\r
+\r
+\r
+# b4_public_if(TRUE, FALSE)\r
+# -------------------------\r
+b4_percent_define_default([[public]], [[false]])\r
+m4_define([b4_public_if],\r
+[b4_percent_define_flag_if([public], [$1], [$2])])\r
+\r
+\r
+# b4_abstract_if(TRUE, FALSE)\r
+# ---------------------------\r
+b4_percent_define_default([[abstract]], [[false]])\r
+m4_define([b4_abstract_if],\r
+[b4_percent_define_flag_if([abstract], [$1], [$2])])\r
+\r
+\r
+# b4_final_if(TRUE, FALSE)\r
+# ---------------------------\r
+b4_percent_define_default([[final]], [[false]])\r
+m4_define([b4_final_if],\r
+[b4_percent_define_flag_if([final], [$1], [$2])])\r
+\r
+\r
+# b4_strictfp_if(TRUE, FALSE)\r
+# ---------------------------\r
+b4_percent_define_default([[strictfp]], [[false]])\r
+m4_define([b4_strictfp_if],\r
+[b4_percent_define_flag_if([strictfp], [$1], [$2])])\r
+\r
+\r
+# b4_lexer_if(TRUE, FALSE)\r
+# ------------------------\r
+m4_define([b4_lexer_if],\r
+[b4_percent_code_ifdef([[lexer]], [$1], [$2])])\r
+\r
+\r
+# b4_identification\r
+# -----------------\r
+m4_define([b4_identification],\r
+[ /** Version number for the Bison executable that generated this parser. */\r
+ public static final String bisonVersion = "b4_version";\r
+\r
+ /** Name of the skeleton that generated this parser. */\r
+ public static final String bisonSkeleton = b4_skeleton;\r
+])\r
+\r
+\r
+## ------------ ##\r
+## Data types. ##\r
+## ------------ ##\r
+\r
+# b4_int_type(MIN, MAX)\r
+# ---------------------\r
+# Return the smallest int type able to handle numbers ranging from\r
+# MIN to MAX (included).\r
+m4_define([b4_int_type],\r
+[m4_if(b4_ints_in($@, [-128], [127]), [1], [byte],\r
+ b4_ints_in($@, [-32768], [32767]), [1], [short],\r
+ [int])])\r
+\r
+# b4_int_type_for(NAME)\r
+# ---------------------\r
+# Return the smallest int type able to handle numbers ranging from\r
+# `NAME_min' to `NAME_max' (included).\r
+m4_define([b4_int_type_for],\r
+[b4_int_type($1_min, $1_max)])\r
+\r
+# b4_null\r
+# -------\r
+m4_define([b4_null], [null])\r
+\r
+\r
+## ------------------------- ##\r
+## Assigning token numbers. ##\r
+## ------------------------- ##\r
+\r
+# b4_token_enum(TOKEN-NAME, TOKEN-NUMBER)\r
+# ---------------------------------------\r
+# Output the definition of this token as an enum.\r
+m4_define([b4_token_enum],\r
+[ /** Token number, to be returned by the scanner. */\r
+ public static final int $1 = $2;\r
+])\r
+\r
+\r
+# b4_token_enums(LIST-OF-PAIRS-TOKEN-NAME-TOKEN-NUMBER)\r
+# -----------------------------------------------------\r
+# Output the definition of the tokens (if there are) as enums.\r
+m4_define([b4_token_enums],\r
+[m4_if([$#$1], [1], [],\r
+[/* Tokens. */\r
+m4_map([b4_token_enum], [$@])])\r
+])\r
+\r
+# b4-case(ID, CODE)\r
+# -----------------\r
+# We need to fool Java's stupid unreachable code detection.\r
+m4_define([b4_case], [ case $1:\r
+ if (yyn == $1)\r
+ $2;\r
+ break;\r
+ ])\r
+\r
+\r
+## ---------------- ##\r
+## Default values. ##\r
+## ---------------- ##\r
+\r
+m4_define([b4_yystype], [b4_percent_define_get([[stype]])])\r
+b4_percent_define_default([[stype]], [[Object]])\r
+\r
+# %name-prefix\r
+m4_define_default([b4_prefix], [[YY]])\r
+\r
+b4_percent_define_default([[parser_class_name]], [b4_prefix[]Parser])\r
+m4_define([b4_parser_class_name], [b4_percent_define_get([[parser_class_name]])])\r
+\r
+b4_percent_define_default([[lex_throws]], [[java.io.IOException]])\r
+m4_define([b4_lex_throws], [b4_percent_define_get([[lex_throws]])])\r
+\r
+b4_percent_define_default([[throws]], [])\r
+m4_define([b4_throws], [b4_percent_define_get([[throws]])])\r
+\r
+b4_percent_define_default([[api.location.type]], [Location])\r
+m4_define([b4_location_type], [b4_percent_define_get([[api.location.type]])])\r
+\r
+b4_percent_define_default([[api.position.type]], [Position])\r
+m4_define([b4_position_type], [b4_percent_define_get([[api.position.type]])])\r
+\r
+\r
+## ----------------- ##\r
+## Semantic Values. ##\r
+## ----------------- ##\r
+\r
+\r
+# b4_lhs_value([TYPE])\r
+# --------------------\r
+# Expansion of $<TYPE>$.\r
+m4_define([b4_lhs_value], [yyval])\r
+\r
+\r
+# b4_rhs_value(RULE-LENGTH, NUM, [TYPE])\r
+# --------------------------------------\r
+# Expansion of $<TYPE>NUM, where the current rule has RULE-LENGTH\r
+# symbols on RHS.\r
+#\r
+# In this simple implementation, %token and %type have class names\r
+# between the angle brackets.\r
+m4_define([b4_rhs_value],\r
+[(m4_ifval($3, [($3)])[](yystack.valueAt ($1-($2))))])\r
+\r
+# b4_lhs_location()\r
+# -----------------\r
+# Expansion of @$.\r
+m4_define([b4_lhs_location],\r
+[(yyloc)])\r
+\r
+\r
+# b4_rhs_location(RULE-LENGTH, NUM)\r
+# ---------------------------------\r
+# Expansion of @NUM, where the current rule has RULE-LENGTH symbols\r
+# on RHS.\r
+m4_define([b4_rhs_location],\r
+[yystack.locationAt ($1-($2))])\r
+\r
+\r
+# b4_lex_param\r
+# b4_parse_param\r
+# --------------\r
+# If defined, b4_lex_param arrives double quoted, but below we prefer\r
+# it to be single quoted. Same for b4_parse_param.\r
+\r
+# TODO: should be in bison.m4\r
+m4_define_default([b4_lex_param], [[]])\r
+m4_define([b4_lex_param], b4_lex_param)\r
+m4_define([b4_parse_param], b4_parse_param)\r
+\r
+# b4_lex_param_decl\r
+# -------------------\r
+# Extra formal arguments of the constructor.\r
+m4_define([b4_lex_param_decl],\r
+[m4_ifset([b4_lex_param],\r
+ [b4_remove_comma([$1],\r
+ b4_param_decls(b4_lex_param))],\r
+ [$1])])\r
+\r
+m4_define([b4_param_decls],\r
+ [m4_map([b4_param_decl], [$@])])\r
+m4_define([b4_param_decl], [, $1])\r
+\r
+m4_define([b4_remove_comma], [m4_ifval(m4_quote($1), [$1, ], [])m4_shift2($@)])\r
+\r
+\r
+\r
+# b4_parse_param_decl\r
+# -------------------\r
+# Extra formal arguments of the constructor.\r
+m4_define([b4_parse_param_decl],\r
+[m4_ifset([b4_parse_param],\r
+ [b4_remove_comma([$1],\r
+ b4_param_decls(b4_parse_param))],\r
+ [$1])])\r
+\r
+\r
+\r
+# b4_lex_param_call\r
+# -------------------\r
+# Delegating the lexer parameters to the lexer constructor.\r
+m4_define([b4_lex_param_call],\r
+ [m4_ifset([b4_lex_param],\r
+ [b4_remove_comma([$1],\r
+ b4_param_calls(b4_lex_param))],\r
+ [$1])])\r
+m4_define([b4_param_calls],\r
+ [m4_map([b4_param_call], [$@])])\r
+m4_define([b4_param_call], [, $2])\r
+\r
+\r
+\r
+# b4_parse_param_cons\r
+# -------------------\r
+# Extra initialisations of the constructor.\r
+m4_define([b4_parse_param_cons],\r
+ [m4_ifset([b4_parse_param],\r
+ [b4_constructor_calls(b4_parse_param)])])\r
+\r
+m4_define([b4_constructor_calls],\r
+ [m4_map([b4_constructor_call], [$@])])\r
+m4_define([b4_constructor_call],\r
+ [this.$2 = $2;\r
+ ])\r
+\r
+\r
+\r
+# b4_parse_param_vars\r
+# -------------------\r
+# Extra instance variables.\r
+m4_define([b4_parse_param_vars],\r
+ [m4_ifset([b4_parse_param],\r
+ [\r
+ /* User arguments. */\r
+b4_var_decls(b4_parse_param)])])\r
+\r
+m4_define([b4_var_decls],\r
+ [m4_map_sep([b4_var_decl], [\r
+], [$@])])\r
+m4_define([b4_var_decl],\r
+ [ protected final $1;])\r
+\r
+\r
+\r
+# b4_maybe_throws(THROWS)\r
+# -----------------------\r
+# Expand to either an empty string or "throws THROWS".\r
+m4_define([b4_maybe_throws],\r
+ [m4_ifval($1, [throws $1])])\r
--- /dev/null
+# C++ skeleton for Bison\r
+\r
+# Copyright (C) 2002-2012 Free Software Foundation, Inc.\r
+\r
+# This program is free software: you can redistribute it and/or modify\r
+# it under the terms of the GNU General Public License as published by\r
+# the Free Software Foundation, either version 3 of the License, or\r
+# (at your option) any later version.\r
+#\r
+# This program is distributed in the hope that it will be useful,\r
+# but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
+# GNU General Public License for more details.\r
+#\r
+# You should have received a copy of the GNU General Public License\r
+# along with this program. If not, see <http://www.gnu.org/licenses/>.\r
+\r
+m4_include(b4_pkgdatadir/[c++.m4])\r
+\r
+m4_define([b4_parser_class_name],\r
+ [b4_percent_define_get([[parser_class_name]])])\r
+\r
+# The header is mandatory.\r
+b4_defines_if([],\r
+ [b4_fatal([b4_skeleton[: using %%defines is mandatory]])])\r
+\r
+b4_percent_define_ifdef([[api.location.type]], [],\r
+ [# Backward compatibility.\r
+ m4_define([b4_location_constructors])\r
+ m4_include(b4_pkgdatadir/[location.cc])])\r
+m4_include(b4_pkgdatadir/[stack.hh])\r
+\r
+b4_defines_if(\r
+[b4_output_begin([b4_spec_defines_file])\r
+b4_copyright([Skeleton interface for Bison LALR(1) parsers in C++],\r
+ [2002-2012])\r
+[\r
+/**\r
+ ** \file ]b4_spec_defines_file[\r
+ ** Define the ]b4_namespace_ref[::parser class.\r
+ */\r
+\r
+/* C++ LALR(1) parser skeleton written by Akim Demaille. */\r
+\r
+]b4_cpp_guard_open([b4_spec_defines_file])[\r
+\r
+]b4_percent_code_get([[requires]])[\r
+\r
+#include <string>\r
+#include <iostream>\r
+#include "stack.hh"\r
+]b4_percent_define_ifdef([[api.location.type]], [],\r
+ [[#include "location.hh"]])[\r
+\r
+]b4_YYDEBUG_define[\r
+\r
+]b4_namespace_open[\r
+\r
+ /// A Bison parser.\r
+ class ]b4_parser_class_name[\r
+ {\r
+ public:\r
+ /// Symbol semantic values.\r
+#ifndef ]b4_api_PREFIX[STYPE\r
+]m4_ifdef([b4_stype],\r
+[ union semantic_type\r
+ {\r
+b4_user_stype\r
+ };],\r
+[m4_if(b4_tag_seen_flag, 0,\r
+[[ typedef int semantic_type;]],\r
+[[ typedef ]b4_api_PREFIX[STYPE semantic_type;]])])[\r
+#else\r
+ typedef ]b4_api_PREFIX[STYPE semantic_type;\r
+#endif\r
+ /// Symbol locations.\r
+ typedef ]b4_percent_define_get([[api.location.type]],\r
+ [[location]])[ location_type;\r
+ /// Tokens.\r
+ struct token\r
+ {\r
+ ]b4_token_enums(b4_tokens)[\r
+ };\r
+ /// Token type.\r
+ typedef token::yytokentype token_type;\r
+\r
+ /// Build a parser object.\r
+ ]b4_parser_class_name[ (]b4_parse_param_decl[);\r
+ virtual ~]b4_parser_class_name[ ();\r
+\r
+ /// Parse.\r
+ /// \returns 0 iff parsing succeeded.\r
+ virtual int parse ();\r
+\r
+#if ]b4_api_PREFIX[DEBUG\r
+ /// The current debugging stream.\r
+ std::ostream& debug_stream () const;\r
+ /// Set the current debugging stream.\r
+ void set_debug_stream (std::ostream &);\r
+\r
+ /// Type for debugging levels.\r
+ typedef int debug_level_type;\r
+ /// The current debugging level.\r
+ debug_level_type debug_level () const;\r
+ /// Set the current debugging level.\r
+ void set_debug_level (debug_level_type l);\r
+#endif\r
+\r
+ private:\r
+ /// Report a syntax error.\r
+ /// \param loc where the syntax error is found.\r
+ /// \param msg a description of the syntax error.\r
+ virtual void error (const location_type& loc, const std::string& msg);\r
+\r
+ /// Generate an error message.\r
+ /// \param state the state where the error occurred.\r
+ /// \param tok the lookahead token.\r
+ virtual std::string yysyntax_error_ (int yystate, int tok);\r
+\r
+#if ]b4_api_PREFIX[DEBUG\r
+ /// \brief Report a symbol value on the debug stream.\r
+ /// \param yytype The token type.\r
+ /// \param yyvaluep Its semantic value.\r
+ /// \param yylocationp Its location.\r
+ virtual void yy_symbol_value_print_ (int yytype,\r
+ const semantic_type* yyvaluep,\r
+ const location_type* yylocationp);\r
+ /// \brief Report a symbol on the debug stream.\r
+ /// \param yytype The token type.\r
+ /// \param yyvaluep Its semantic value.\r
+ /// \param yylocationp Its location.\r
+ virtual void yy_symbol_print_ (int yytype,\r
+ const semantic_type* yyvaluep,\r
+ const location_type* yylocationp);\r
+#endif\r
+\r
+\r
+ /// State numbers.\r
+ typedef int state_type;\r
+ /// State stack type.\r
+ typedef stack<state_type> state_stack_type;\r
+ /// Semantic value stack type.\r
+ typedef stack<semantic_type> semantic_stack_type;\r
+ /// location stack type.\r
+ typedef stack<location_type> location_stack_type;\r
+\r
+ /// The state stack.\r
+ state_stack_type yystate_stack_;\r
+ /// The semantic value stack.\r
+ semantic_stack_type yysemantic_stack_;\r
+ /// The location stack.\r
+ location_stack_type yylocation_stack_;\r
+\r
+ /// Whether the given \c yypact_ value indicates a defaulted state.\r
+ /// \param yyvalue the value to check\r
+ static bool yy_pact_value_is_default_ (int yyvalue);\r
+\r
+ /// Whether the given \c yytable_ value indicates a syntax error.\r
+ /// \param yyvalue the value to check\r
+ static bool yy_table_value_is_error_ (int yyvalue);\r
+\r
+ /// Internal symbol numbers.\r
+ typedef ]b4_int_type_for([b4_translate])[ token_number_type;\r
+ /* Tables. */\r
+ /// For a state, the index in \a yytable_ of its portion.\r
+ static const ]b4_int_type_for([b4_pact])[ yypact_[];\r
+ static const ]b4_int_type(b4_pact_ninf, b4_pact_ninf)[ yypact_ninf_;\r
+\r
+ /// For a state, default reduction number.\r
+ /// Unless\a yytable_ specifies something else to do.\r
+ /// Zero means the default is an error.\r
+ static const ]b4_int_type_for([b4_defact])[ yydefact_[];\r
+\r
+ static const ]b4_int_type_for([b4_pgoto])[ yypgoto_[];\r
+ static const ]b4_int_type_for([b4_defgoto])[ yydefgoto_[];\r
+\r
+ /// What to do in a state.\r
+ /// \a yytable_[yypact_[s]]: what to do in state \a s.\r
+ /// - if positive, shift that token.\r
+ /// - if negative, reduce the rule which number is the opposite.\r
+ /// - if zero, do what YYDEFACT says.\r
+ static const ]b4_int_type_for([b4_table])[ yytable_[];\r
+ static const ]b4_int_type(b4_table_ninf, b4_table_ninf)[ yytable_ninf_;\r
+\r
+ static const ]b4_int_type_for([b4_check])[ yycheck_[];\r
+\r
+ /// For a state, its accessing symbol.\r
+ static const ]b4_int_type_for([b4_stos])[ yystos_[];\r
+\r
+ /// For a rule, its LHS.\r
+ static const ]b4_int_type_for([b4_r1])[ yyr1_[];\r
+ /// For a rule, its RHS length.\r
+ static const ]b4_int_type_for([b4_r2])[ yyr2_[]; ]b4_error_verbose_if([\r
+\r
+ /// Convert the symbol name \a n to a form suitable for a diagnostic.\r
+ static std::string yytnamerr_ (const char *n);])[\r
+\r
+]b4_token_table_if([], [[#if ]b4_api_PREFIX[DEBUG]])[\r
+ /// For a symbol, its name in clear.\r
+ static const char* const yytname_[];\r
+]b4_token_table_if([[#if ]b4_api_PREFIX[DEBUG]])[\r
+ /// A type to store symbol numbers and -1.\r
+ typedef ]b4_int_type_for([b4_rhs])[ rhs_number_type;\r
+ /// A `-1'-separated list of the rules' RHS.\r
+ static const rhs_number_type yyrhs_[];\r
+ /// For each rule, the index of the first RHS symbol in \a yyrhs_.\r
+ static const ]b4_int_type_for([b4_prhs])[ yyprhs_[];\r
+ /// For each rule, its source line number.\r
+ static const ]b4_int_type_for([b4_rline])[ yyrline_[];\r
+ /// For each scanner token number, its symbol number.\r
+ static const ]b4_int_type_for([b4_toknum])[ yytoken_number_[];\r
+ /// Report on the debug stream that the rule \a r is going to be reduced.\r
+ virtual void yy_reduce_print_ (int r);\r
+ /// Print the state stack on the debug stream.\r
+ virtual void yystack_print_ ();\r
+\r
+ /* Debugging. */\r
+ int yydebug_;\r
+ std::ostream* yycdebug_;\r
+#endif\r
+\r
+ /// Convert a scanner token number \a t to a symbol number.\r
+ token_number_type yytranslate_ (int t);\r
+\r
+ /// \brief Reclaim the memory associated to a symbol.\r
+ /// \param yymsg Why this token is reclaimed.\r
+ /// If null, do not display the symbol, just free it.\r
+ /// \param yytype The symbol type.\r
+ /// \param yyvaluep Its semantic value.\r
+ /// \param yylocationp Its location.\r
+ inline void yydestruct_ (const char* yymsg,\r
+ int yytype,\r
+ semantic_type* yyvaluep,\r
+ location_type* yylocationp);\r
+\r
+ /// Pop \a n symbols the three stacks.\r
+ inline void yypop_ (unsigned int n = 1);\r
+\r
+ /* Constants. */\r
+ static const int yyeof_;\r
+ /* LAST_ -- Last index in TABLE_. */\r
+ static const int yylast_;\r
+ static const int yynnts_;\r
+ static const int yyempty_;\r
+ static const int yyfinal_;\r
+ static const int yyterror_;\r
+ static const int yyerrcode_;\r
+ static const int yyntokens_;\r
+ static const unsigned int yyuser_token_number_max_;\r
+ static const token_number_type yyundef_token_;\r
+]b4_parse_param_vars[\r
+ };\r
+]b4_namespace_close[\r
+\r
+]b4_percent_define_flag_if([[global_tokens_and_yystype]],\r
+[b4_token_defines(b4_tokens)\r
+\r
+#ifndef ]b4_api_PREFIX[STYPE\r
+ /* Redirection for backward compatibility. */\r
+# define ]b4_api_PREFIX[STYPE b4_namespace_ref::b4_parser_class_name::semantic_type\r
+#endif\r
+])[\r
+]b4_percent_code_get([[provides]])[\r
+]b4_cpp_guard_close([b4_spec_defines_file])\r
+b4_output_end()\r
+])\r
+\r
+\r
+b4_output_begin([b4_parser_file_name])\r
+b4_copyright([Skeleton implementation for Bison LALR(1) parsers in C++],\r
+ [2002-2012])\r
+b4_percent_code_get([[top]])[]dnl\r
+m4_if(b4_prefix, [yy], [],\r
+[\r
+// Take the name prefix into account.\r
+#define yylex b4_prefix[]lex])[\r
+\r
+/* First part of user declarations. */\r
+]b4_user_pre_prologue[\r
+\r
+]b4_defines_if([[\r
+#include "@basename(]b4_spec_defines_file[@)"]])[\r
+\r
+/* User implementation prologue. */\r
+]b4_user_post_prologue[\r
+]b4_percent_code_get[\r
+\r
+]b4_null_define[\r
+\r
+#ifndef YY_\r
+# if defined YYENABLE_NLS && YYENABLE_NLS\r
+# if ENABLE_NLS\r
+# include <libintl.h> /* FIXME: INFRINGES ON USER NAME SPACE */\r
+# define YY_(msgid) dgettext ("bison-runtime", msgid)\r
+# endif\r
+# endif\r
+# ifndef YY_\r
+# define YY_(msgid) msgid\r
+# endif\r
+#endif\r
+\r
+#define YYRHSLOC(Rhs, K) ((Rhs)[K])\r
+]b4_yylloc_default_define[\r
+\r
+/* Suppress unused-variable warnings by "using" E. */\r
+#define YYUSE(e) ((void) (e))\r
+\r
+/* Enable debugging if requested. */\r
+#if ]b4_api_PREFIX[DEBUG\r
+\r
+/* A pseudo ostream that takes yydebug_ into account. */\r
+# define YYCDEBUG if (yydebug_) (*yycdebug_)\r
+\r
+# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \\r
+do { \\r
+ if (yydebug_) \\r
+ { \\r
+ *yycdebug_ << Title << ' '; \\r
+ yy_symbol_print_ ((Type), (Value), (Location)); \\r
+ *yycdebug_ << std::endl; \\r
+ } \\r
+} while (false)\r
+\r
+# define YY_REDUCE_PRINT(Rule) \\r
+do { \\r
+ if (yydebug_) \\r
+ yy_reduce_print_ (Rule); \\r
+} while (false)\r
+\r
+# define YY_STACK_PRINT() \\r
+do { \\r
+ if (yydebug_) \\r
+ yystack_print_ (); \\r
+} while (false)\r
+\r
+#else /* !]b4_api_PREFIX[DEBUG */\r
+\r
+# define YYCDEBUG if (false) std::cerr\r
+# define YY_SYMBOL_PRINT(Title, Type, Value, Location) YYUSE(Type)\r
+# define YY_REDUCE_PRINT(Rule) static_cast<void>(0)\r
+# define YY_STACK_PRINT() static_cast<void>(0)\r
+\r
+#endif /* !]b4_api_PREFIX[DEBUG */\r
+\r
+#define yyerrok (yyerrstatus_ = 0)\r
+#define yyclearin (yychar = yyempty_)\r
+\r
+#define YYACCEPT goto yyacceptlab\r
+#define YYABORT goto yyabortlab\r
+#define YYERROR goto yyerrorlab\r
+#define YYRECOVERING() (!!yyerrstatus_)\r
+\r
+]b4_namespace_open[]b4_error_verbose_if([[\r
+\r
+ /* Return YYSTR after stripping away unnecessary quotes and\r
+ backslashes, so that it's suitable for yyerror. The heuristic is\r
+ that double-quoting is unnecessary unless the string contains an\r
+ apostrophe, a comma, or backslash (other than backslash-backslash).\r
+ YYSTR is taken from yytname. */\r
+ std::string\r
+ ]b4_parser_class_name[::yytnamerr_ (const char *yystr)\r
+ {\r
+ if (*yystr == '"')\r
+ {\r
+ std::string yyr = "";\r
+ char const *yyp = yystr;\r
+\r
+ for (;;)\r
+ switch (*++yyp)\r
+ {\r
+ case '\'':\r
+ case ',':\r
+ goto do_not_strip_quotes;\r
+\r
+ case '\\':\r
+ if (*++yyp != '\\')\r
+ goto do_not_strip_quotes;\r
+ /* Fall through. */\r
+ default:\r
+ yyr += *yyp;\r
+ break;\r
+\r
+ case '"':\r
+ return yyr;\r
+ }\r
+ do_not_strip_quotes: ;\r
+ }\r
+\r
+ return yystr;\r
+ }\r
+]])[\r
+\r
+ /// Build a parser object.\r
+ ]b4_parser_class_name::b4_parser_class_name[ (]b4_parse_param_decl[)]m4_ifset([b4_parse_param], [\r
+ :])[\r
+#if ]b4_api_PREFIX[DEBUG\r
+ ]m4_ifset([b4_parse_param], [ ], [ :])[yydebug_ (false),\r
+ yycdebug_ (&std::cerr)]m4_ifset([b4_parse_param], [,])[\r
+#endif]b4_parse_param_cons[\r
+ {\r
+ }\r
+\r
+ ]b4_parser_class_name::~b4_parser_class_name[ ()\r
+ {\r
+ }\r
+\r
+#if ]b4_api_PREFIX[DEBUG\r
+ /*--------------------------------.\r
+ | Print this symbol on YYOUTPUT. |\r
+ `--------------------------------*/\r
+\r
+ inline void\r
+ ]b4_parser_class_name[::yy_symbol_value_print_ (int yytype,\r
+ const semantic_type* yyvaluep, const location_type* yylocationp)\r
+ {\r
+ YYUSE (yylocationp);\r
+ YYUSE (yyvaluep);\r
+ std::ostream& yyo = debug_stream ();\r
+ std::ostream& yyoutput = yyo;\r
+ YYUSE (yyoutput);\r
+ switch (yytype)\r
+ {\r
+ ]m4_map([b4_symbol_actions], m4_defn([b4_symbol_printers]))dnl\r
+[ default:\r
+ break;\r
+ }\r
+ }\r
+\r
+\r
+ void\r
+ ]b4_parser_class_name[::yy_symbol_print_ (int yytype,\r
+ const semantic_type* yyvaluep, const location_type* yylocationp)\r
+ {\r
+ *yycdebug_ << (yytype < yyntokens_ ? "token" : "nterm")\r
+ << ' ' << yytname_[yytype] << " ("\r
+ << *yylocationp << ": ";\r
+ yy_symbol_value_print_ (yytype, yyvaluep, yylocationp);\r
+ *yycdebug_ << ')';\r
+ }\r
+#endif\r
+\r
+ void\r
+ ]b4_parser_class_name[::yydestruct_ (const char* yymsg,\r
+ int yytype, semantic_type* yyvaluep, location_type* yylocationp)\r
+ {\r
+ YYUSE (yylocationp);\r
+ YYUSE (yymsg);\r
+ YYUSE (yyvaluep);\r
+\r
+ if (yymsg)\r
+ YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);\r
+\r
+ switch (yytype)\r
+ {\r
+ ]m4_map([b4_symbol_actions], m4_defn([b4_symbol_destructors]))[\r
+ default:\r
+ break;\r
+ }\r
+ }\r
+\r
+ void\r
+ ]b4_parser_class_name[::yypop_ (unsigned int n)\r
+ {\r
+ yystate_stack_.pop (n);\r
+ yysemantic_stack_.pop (n);\r
+ yylocation_stack_.pop (n);\r
+ }\r
+\r
+#if ]b4_api_PREFIX[DEBUG\r
+ std::ostream&\r
+ ]b4_parser_class_name[::debug_stream () const\r
+ {\r
+ return *yycdebug_;\r
+ }\r
+\r
+ void\r
+ ]b4_parser_class_name[::set_debug_stream (std::ostream& o)\r
+ {\r
+ yycdebug_ = &o;\r
+ }\r
+\r
+\r
+ ]b4_parser_class_name[::debug_level_type\r
+ ]b4_parser_class_name[::debug_level () const\r
+ {\r
+ return yydebug_;\r
+ }\r
+\r
+ void\r
+ ]b4_parser_class_name[::set_debug_level (debug_level_type l)\r
+ {\r
+ yydebug_ = l;\r
+ }\r
+#endif\r
+\r
+ inline bool\r
+ ]b4_parser_class_name[::yy_pact_value_is_default_ (int yyvalue)\r
+ {\r
+ return yyvalue == yypact_ninf_;\r
+ }\r
+\r
+ inline bool\r
+ ]b4_parser_class_name[::yy_table_value_is_error_ (int yyvalue)\r
+ {\r
+ return yyvalue == yytable_ninf_;\r
+ }\r
+\r
+ int\r
+ ]b4_parser_class_name[::parse ()\r
+ {\r
+ /// Lookahead and lookahead in internal form.\r
+ int yychar = yyempty_;\r
+ int yytoken = 0;\r
+\r
+ // State.\r
+ int yyn;\r
+ int yylen = 0;\r
+ int yystate = 0;\r
+\r
+ // Error handling.\r
+ int yynerrs_ = 0;\r
+ int yyerrstatus_ = 0;\r
+\r
+ /// Semantic value of the lookahead.\r
+ static semantic_type yyval_default;\r
+ semantic_type yylval = yyval_default;\r
+ /// Location of the lookahead.\r
+ location_type yylloc;\r
+ /// The locations where the error started and ended.\r
+ location_type yyerror_range[3];\r
+\r
+ /// $$.\r
+ semantic_type yyval;\r
+ /// @@$.\r
+ location_type yyloc;\r
+\r
+ int yyresult;\r
+\r
+ // FIXME: This shoud be completely indented. It is not yet to\r
+ // avoid gratuitous conflicts when merging into the master branch.\r
+ try\r
+ {\r
+ YYCDEBUG << "Starting parse" << std::endl;\r
+\r
+]m4_ifdef([b4_initial_action], [\r
+b4_dollar_pushdef([yylval], [], [yylloc])dnl\r
+/* User initialization code. */\r
+b4_user_initial_action\r
+b4_dollar_popdef])[]dnl\r
+\r
+ [ /* Initialize the stacks. The initial state will be pushed in\r
+ yynewstate, since the latter expects the semantical and the\r
+ location values to have been already stored, initialize these\r
+ stacks with a primary value. */\r
+ yystate_stack_ = state_stack_type (0);\r
+ yysemantic_stack_ = semantic_stack_type (0);\r
+ yylocation_stack_ = location_stack_type (0);\r
+ yysemantic_stack_.push (yylval);\r
+ yylocation_stack_.push (yylloc);\r
+\r
+ /* New state. */\r
+ yynewstate:\r
+ yystate_stack_.push (yystate);\r
+ YYCDEBUG << "Entering state " << yystate << std::endl;\r
+\r
+ /* Accept? */\r
+ if (yystate == yyfinal_)\r
+ goto yyacceptlab;\r
+\r
+ goto yybackup;\r
+\r
+ /* Backup. */\r
+ yybackup:\r
+\r
+ /* Try to take a decision without lookahead. */\r
+ yyn = yypact_[yystate];\r
+ if (yy_pact_value_is_default_ (yyn))\r
+ goto yydefault;\r
+\r
+ /* Read a lookahead token. */\r
+ if (yychar == yyempty_)\r
+ {\r
+ YYCDEBUG << "Reading a token: ";\r
+ yychar = ]b4_c_function_call([yylex], [int],\r
+ [b4_api_PREFIX[STYPE*], [&yylval]][]dnl\r
+b4_locations_if([, [[location*], [&yylloc]]])dnl\r
+m4_ifdef([b4_lex_param], [, ]b4_lex_param))[;\r
+ }\r
+\r
+ /* Convert token to internal form. */\r
+ if (yychar <= yyeof_)\r
+ {\r
+ yychar = yytoken = yyeof_;\r
+ YYCDEBUG << "Now at end of input." << std::endl;\r
+ }\r
+ else\r
+ {\r
+ yytoken = yytranslate_ (yychar);\r
+ YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);\r
+ }\r
+\r
+ /* If the proper action on seeing token YYTOKEN is to reduce or to\r
+ detect an error, take that action. */\r
+ yyn += yytoken;\r
+ if (yyn < 0 || yylast_ < yyn || yycheck_[yyn] != yytoken)\r
+ goto yydefault;\r
+\r
+ /* Reduce or error. */\r
+ yyn = yytable_[yyn];\r
+ if (yyn <= 0)\r
+ {\r
+ if (yy_table_value_is_error_ (yyn))\r
+ goto yyerrlab;\r
+ yyn = -yyn;\r
+ goto yyreduce;\r
+ }\r
+\r
+ /* Shift the lookahead token. */\r
+ YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);\r
+\r
+ /* Discard the token being shifted. */\r
+ yychar = yyempty_;\r
+\r
+ yysemantic_stack_.push (yylval);\r
+ yylocation_stack_.push (yylloc);\r
+\r
+ /* Count tokens shifted since error; after three, turn off error\r
+ status. */\r
+ if (yyerrstatus_)\r
+ --yyerrstatus_;\r
+\r
+ yystate = yyn;\r
+ goto yynewstate;\r
+\r
+ /*-----------------------------------------------------------.\r
+ | yydefault -- do the default action for the current state. |\r
+ `-----------------------------------------------------------*/\r
+ yydefault:\r
+ yyn = yydefact_[yystate];\r
+ if (yyn == 0)\r
+ goto yyerrlab;\r
+ goto yyreduce;\r
+\r
+ /*-----------------------------.\r
+ | yyreduce -- Do a reduction. |\r
+ `-----------------------------*/\r
+ yyreduce:\r
+ yylen = yyr2_[yyn];\r
+ /* If YYLEN is nonzero, implement the default value of the action:\r
+ `$$ = $1'. Otherwise, use the top of the stack.\r
+\r
+ Otherwise, the following line sets YYVAL to garbage.\r
+ This behavior is undocumented and Bison\r
+ users should not rely upon it. */\r
+ if (yylen)\r
+ yyval = yysemantic_stack_[yylen - 1];\r
+ else\r
+ yyval = yysemantic_stack_[0];\r
+\r
+ // Compute the default @@$.\r
+ {\r
+ slice<location_type, location_stack_type> slice (yylocation_stack_, yylen);\r
+ YYLLOC_DEFAULT (yyloc, slice, yylen);\r
+ }\r
+\r
+ // Perform the reduction.\r
+ YY_REDUCE_PRINT (yyn);\r
+ switch (yyn)\r
+ {\r
+ ]b4_user_actions[\r
+ default:\r
+ break;\r
+ }\r
+\r
+ /* User semantic actions sometimes alter yychar, and that requires\r
+ that yytoken be updated with the new translation. We take the\r
+ approach of translating immediately before every use of yytoken.\r
+ One alternative is translating here after every semantic action,\r
+ but that translation would be missed if the semantic action\r
+ invokes YYABORT, YYACCEPT, or YYERROR immediately after altering\r
+ yychar. In the case of YYABORT or YYACCEPT, an incorrect\r
+ destructor might then be invoked immediately. In the case of\r
+ YYERROR, subsequent parser actions might lead to an incorrect\r
+ destructor call or verbose syntax error message before the\r
+ lookahead is translated. */\r
+ YY_SYMBOL_PRINT ("-> $$ =", yyr1_[yyn], &yyval, &yyloc);\r
+\r
+ yypop_ (yylen);\r
+ yylen = 0;\r
+ YY_STACK_PRINT ();\r
+\r
+ yysemantic_stack_.push (yyval);\r
+ yylocation_stack_.push (yyloc);\r
+\r
+ /* Shift the result of the reduction. */\r
+ yyn = yyr1_[yyn];\r
+ yystate = yypgoto_[yyn - yyntokens_] + yystate_stack_[0];\r
+ if (0 <= yystate && yystate <= yylast_\r
+ && yycheck_[yystate] == yystate_stack_[0])\r
+ yystate = yytable_[yystate];\r
+ else\r
+ yystate = yydefgoto_[yyn - yyntokens_];\r
+ goto yynewstate;\r
+\r
+ /*------------------------------------.\r
+ | yyerrlab -- here on detecting error |\r
+ `------------------------------------*/\r
+ yyerrlab:\r
+ /* Make sure we have latest lookahead translation. See comments at\r
+ user semantic actions for why this is necessary. */\r
+ yytoken = yytranslate_ (yychar);\r
+\r
+ /* If not already recovering from an error, report this error. */\r
+ if (!yyerrstatus_)\r
+ {\r
+ ++yynerrs_;\r
+ if (yychar == yyempty_)\r
+ yytoken = yyempty_;\r
+ error (yylloc, yysyntax_error_ (yystate, yytoken));\r
+ }\r
+\r
+ yyerror_range[1] = yylloc;\r
+ if (yyerrstatus_ == 3)\r
+ {\r
+ /* If just tried and failed to reuse lookahead token after an\r
+ error, discard it. */\r
+ if (yychar <= yyeof_)\r
+ {\r
+ /* Return failure if at end of input. */\r
+ if (yychar == yyeof_)\r
+ YYABORT;\r
+ }\r
+ else\r
+ {\r
+ yydestruct_ ("Error: discarding", yytoken, &yylval, &yylloc);\r
+ yychar = yyempty_;\r
+ }\r
+ }\r
+\r
+ /* Else will try to reuse lookahead token after shifting the error\r
+ token. */\r
+ goto yyerrlab1;\r
+\r
+\r
+ /*---------------------------------------------------.\r
+ | yyerrorlab -- error raised explicitly by YYERROR. |\r
+ `---------------------------------------------------*/\r
+ yyerrorlab:\r
+\r
+ /* Pacify compilers like GCC when the user code never invokes\r
+ YYERROR and the label yyerrorlab therefore never appears in user\r
+ code. */\r
+ if (false)\r
+ goto yyerrorlab;\r
+\r
+ yyerror_range[1] = yylocation_stack_[yylen - 1];\r
+ /* Do not reclaim the symbols of the rule which action triggered\r
+ this YYERROR. */\r
+ yypop_ (yylen);\r
+ yylen = 0;\r
+ yystate = yystate_stack_[0];\r
+ goto yyerrlab1;\r
+\r
+ /*-------------------------------------------------------------.\r
+ | yyerrlab1 -- common code for both syntax error and YYERROR. |\r
+ `-------------------------------------------------------------*/\r
+ yyerrlab1:\r
+ yyerrstatus_ = 3; /* Each real token shifted decrements this. */\r
+\r
+ for (;;)\r
+ {\r
+ yyn = yypact_[yystate];\r
+ if (!yy_pact_value_is_default_ (yyn))\r
+ {\r
+ yyn += yyterror_;\r
+ if (0 <= yyn && yyn <= yylast_ && yycheck_[yyn] == yyterror_)\r
+ {\r
+ yyn = yytable_[yyn];\r
+ if (0 < yyn)\r
+ break;\r
+ }\r
+ }\r
+\r
+ /* Pop the current state because it cannot handle the error token. */\r
+ if (yystate_stack_.height () == 1)\r
+ YYABORT;\r
+\r
+ yyerror_range[1] = yylocation_stack_[0];\r
+ yydestruct_ ("Error: popping",\r
+ yystos_[yystate],\r
+ &yysemantic_stack_[0], &yylocation_stack_[0]);\r
+ yypop_ ();\r
+ yystate = yystate_stack_[0];\r
+ YY_STACK_PRINT ();\r
+ }\r
+\r
+ yyerror_range[2] = yylloc;\r
+ // Using YYLLOC is tempting, but would change the location of\r
+ // the lookahead. YYLOC is available though.\r
+ YYLLOC_DEFAULT (yyloc, yyerror_range, 2);\r
+ yysemantic_stack_.push (yylval);\r
+ yylocation_stack_.push (yyloc);\r
+\r
+ /* Shift the error token. */\r
+ YY_SYMBOL_PRINT ("Shifting", yystos_[yyn],\r
+ &yysemantic_stack_[0], &yylocation_stack_[0]);\r
+\r
+ yystate = yyn;\r
+ goto yynewstate;\r
+\r
+ /* Accept. */\r
+ yyacceptlab:\r
+ yyresult = 0;\r
+ goto yyreturn;\r
+\r
+ /* Abort. */\r
+ yyabortlab:\r
+ yyresult = 1;\r
+ goto yyreturn;\r
+\r
+ yyreturn:\r
+ if (yychar != yyempty_)\r
+ {\r
+ /* Make sure we have latest lookahead translation. See comments\r
+ at user semantic actions for why this is necessary. */\r
+ yytoken = yytranslate_ (yychar);\r
+ yydestruct_ ("Cleanup: discarding lookahead", yytoken, &yylval,\r
+ &yylloc);\r
+ }\r
+\r
+ /* Do not reclaim the symbols of the rule which action triggered\r
+ this YYABORT or YYACCEPT. */\r
+ yypop_ (yylen);\r
+ while (1 < yystate_stack_.height ())\r
+ {\r
+ yydestruct_ ("Cleanup: popping",\r
+ yystos_[yystate_stack_[0]],\r
+ &yysemantic_stack_[0],\r
+ &yylocation_stack_[0]);\r
+ yypop_ ();\r
+ }\r
+\r
+ return yyresult;\r
+ }\r
+ catch (...)\r
+ {\r
+ YYCDEBUG << "Exception caught: cleaning lookahead and stack"\r
+ << std::endl;\r
+ // Do not try to display the values of the reclaimed symbols,\r
+ // as their printer might throw an exception.\r
+ if (yychar != yyempty_)\r
+ {\r
+ /* Make sure we have latest lookahead translation. See\r
+ comments at user semantic actions for why this is\r
+ necessary. */\r
+ yytoken = yytranslate_ (yychar);\r
+ yydestruct_ (YY_NULL, yytoken, &yylval, &yylloc);\r
+ }\r
+\r
+ while (1 < yystate_stack_.height ())\r
+ {\r
+ yydestruct_ (YY_NULL,\r
+ yystos_[yystate_stack_[0]],\r
+ &yysemantic_stack_[0],\r
+ &yylocation_stack_[0]);\r
+ yypop_ ();\r
+ }\r
+ throw;\r
+ }\r
+ }\r
+\r
+ // Generate an error message.\r
+ std::string\r
+ ]b4_parser_class_name[::yysyntax_error_ (]dnl\r
+b4_error_verbose_if([int yystate, int yytoken],\r
+ [int, int])[)\r
+ {]b4_error_verbose_if([[\r
+ std::string yyres;\r
+ // Number of reported tokens (one for the "unexpected", one per\r
+ // "expected").\r
+ size_t yycount = 0;\r
+ // Its maximum.\r
+ enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };\r
+ // Arguments of yyformat.\r
+ char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];\r
+\r
+ /* There are many possibilities here to consider:\r
+ - If this state is a consistent state with a default action, then\r
+ the only way this function was invoked is if the default action\r
+ is an error action. In that case, don't check for expected\r
+ tokens because there are none.\r
+ - The only way there can be no lookahead present (in yytoken) is\r
+ if this state is a consistent state with a default action.\r
+ Thus, detecting the absence of a lookahead is sufficient to\r
+ determine that there is no unexpected or expected token to\r
+ report. In that case, just report a simple "syntax error".\r
+ - Don't assume there isn't a lookahead just because this state is\r
+ a consistent state with a default action. There might have\r
+ been a previous inconsistent state, consistent state with a\r
+ non-default action, or user semantic action that manipulated\r
+ yychar.\r
+ - Of course, the expected token list depends on states to have\r
+ correct lookahead information, and it depends on the parser not\r
+ to perform extra reductions after fetching a lookahead from the\r
+ scanner and before detecting a syntax error. Thus, state\r
+ merging (from LALR or IELR) and default reductions corrupt the\r
+ expected token list. However, the list is correct for\r
+ canonical LR with one exception: it will still contain any\r
+ token that will not be accepted due to an error action in a\r
+ later state.\r
+ */\r
+ if (yytoken != yyempty_)\r
+ {\r
+ yyarg[yycount++] = yytname_[yytoken];\r
+ int yyn = yypact_[yystate];\r
+ if (!yy_pact_value_is_default_ (yyn))\r
+ {\r
+ /* Start YYX at -YYN if negative to avoid negative indexes in\r
+ YYCHECK. In other words, skip the first -YYN actions for\r
+ this state because they are default actions. */\r
+ int yyxbegin = yyn < 0 ? -yyn : 0;\r
+ /* Stay within bounds of both yycheck and yytname. */\r
+ int yychecklim = yylast_ - yyn + 1;\r
+ int yyxend = yychecklim < yyntokens_ ? yychecklim : yyntokens_;\r
+ for (int yyx = yyxbegin; yyx < yyxend; ++yyx)\r
+ if (yycheck_[yyx + yyn] == yyx && yyx != yyterror_\r
+ && !yy_table_value_is_error_ (yytable_[yyx + yyn]))\r
+ {\r
+ if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)\r
+ {\r
+ yycount = 1;\r
+ break;\r
+ }\r
+ else\r
+ yyarg[yycount++] = yytname_[yyx];\r
+ }\r
+ }\r
+ }\r
+\r
+ char const* yyformat = YY_NULL;\r
+ switch (yycount)\r
+ {\r
+#define YYCASE_(N, S) \\r
+ case N: \\r
+ yyformat = S; \\r
+ break\r
+ YYCASE_(0, YY_("syntax error"));\r
+ YYCASE_(1, YY_("syntax error, unexpected %s"));\r
+ YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));\r
+ YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s"));\r
+ YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));\r
+ YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));\r
+#undef YYCASE_\r
+ }\r
+\r
+ // Argument number.\r
+ size_t yyi = 0;\r
+ for (char const* yyp = yyformat; *yyp; ++yyp)\r
+ if (yyp[0] == '%' && yyp[1] == 's' && yyi < yycount)\r
+ {\r
+ yyres += yytnamerr_ (yyarg[yyi++]);\r
+ ++yyp;\r
+ }\r
+ else\r
+ yyres += *yyp;\r
+ return yyres;]], [[\r
+ return YY_("syntax error");]])[\r
+ }\r
+\r
+\r
+ /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing\r
+ STATE-NUM. */\r
+ const ]b4_int_type(b4_pact_ninf, b4_pact_ninf) b4_parser_class_name::yypact_ninf_ = b4_pact_ninf[;\r
+ const ]b4_int_type_for([b4_pact])[\r
+ ]b4_parser_class_name[::yypact_[] =\r
+ {\r
+ ]b4_pact[\r
+ };\r
+\r
+ /* YYDEFACT[S] -- default reduction number in state S. Performed when\r
+ YYTABLE doesn't specify something else to do. Zero means the\r
+ default is an error. */\r
+ const ]b4_int_type_for([b4_defact])[\r
+ ]b4_parser_class_name[::yydefact_[] =\r
+ {\r
+ ]b4_defact[\r
+ };\r
+\r
+ /* YYPGOTO[NTERM-NUM]. */\r
+ const ]b4_int_type_for([b4_pgoto])[\r
+ ]b4_parser_class_name[::yypgoto_[] =\r
+ {\r
+ ]b4_pgoto[\r
+ };\r
+\r
+ /* YYDEFGOTO[NTERM-NUM]. */\r
+ const ]b4_int_type_for([b4_defgoto])[\r
+ ]b4_parser_class_name[::yydefgoto_[] =\r
+ {\r
+ ]b4_defgoto[\r
+ };\r
+\r
+ /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If\r
+ positive, shift that token. If negative, reduce the rule which\r
+ number is the opposite. If YYTABLE_NINF_, syntax error. */\r
+ const ]b4_int_type(b4_table_ninf, b4_table_ninf) b4_parser_class_name::yytable_ninf_ = b4_table_ninf[;\r
+ const ]b4_int_type_for([b4_table])[\r
+ ]b4_parser_class_name[::yytable_[] =\r
+ {\r
+ ]b4_table[\r
+ };\r
+\r
+ /* YYCHECK. */\r
+ const ]b4_int_type_for([b4_check])[\r
+ ]b4_parser_class_name[::yycheck_[] =\r
+ {\r
+ ]b4_check[\r
+ };\r
+\r
+ /* STOS_[STATE-NUM] -- The (internal number of the) accessing\r
+ symbol of state STATE-NUM. */\r
+ const ]b4_int_type_for([b4_stos])[\r
+ ]b4_parser_class_name[::yystos_[] =\r
+ {\r
+ ]b4_stos[\r
+ };\r
+\r
+#if ]b4_api_PREFIX[DEBUG\r
+ /* TOKEN_NUMBER_[YYLEX-NUM] -- Internal symbol number corresponding\r
+ to YYLEX-NUM. */\r
+ const ]b4_int_type_for([b4_toknum])[\r
+ ]b4_parser_class_name[::yytoken_number_[] =\r
+ {\r
+ ]b4_toknum[\r
+ };\r
+#endif\r
+\r
+ /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */\r
+ const ]b4_int_type_for([b4_r1])[\r
+ ]b4_parser_class_name[::yyr1_[] =\r
+ {\r
+ ]b4_r1[\r
+ };\r
+\r
+ /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */\r
+ const ]b4_int_type_for([b4_r2])[\r
+ ]b4_parser_class_name[::yyr2_[] =\r
+ {\r
+ ]b4_r2[\r
+ };\r
+\r
+]b4_token_table_if([], [[#if ]b4_api_PREFIX[DEBUG]])[\r
+ /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.\r
+ First, the terminals, then, starting at \a yyntokens_, nonterminals. */\r
+ const char*\r
+ const ]b4_parser_class_name[::yytname_[] =\r
+ {\r
+ ]b4_tname[\r
+ };\r
+\r
+]b4_token_table_if([[#if ]b4_api_PREFIX[DEBUG]])[\r
+ /* YYRHS -- A `-1'-separated list of the rules' RHS. */\r
+ const ]b4_parser_class_name[::rhs_number_type\r
+ ]b4_parser_class_name[::yyrhs_[] =\r
+ {\r
+ ]b4_rhs[\r
+ };\r
+\r
+ /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in\r
+ YYRHS. */\r
+ const ]b4_int_type_for([b4_prhs])[\r
+ ]b4_parser_class_name[::yyprhs_[] =\r
+ {\r
+ ]b4_prhs[\r
+ };\r
+\r
+ /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */\r
+ const ]b4_int_type_for([b4_rline])[\r
+ ]b4_parser_class_name[::yyrline_[] =\r
+ {\r
+ ]b4_rline[\r
+ };\r
+\r
+ // Print the state stack on the debug stream.\r
+ void\r
+ ]b4_parser_class_name[::yystack_print_ ()\r
+ {\r
+ *yycdebug_ << "Stack now";\r
+ for (state_stack_type::const_iterator i = yystate_stack_.begin ();\r
+ i != yystate_stack_.end (); ++i)\r
+ *yycdebug_ << ' ' << *i;\r
+ *yycdebug_ << std::endl;\r
+ }\r
+\r
+ // Report on the debug stream that the rule \a yyrule is going to be reduced.\r
+ void\r
+ ]b4_parser_class_name[::yy_reduce_print_ (int yyrule)\r
+ {\r
+ unsigned int yylno = yyrline_[yyrule];\r
+ int yynrhs = yyr2_[yyrule];\r
+ /* Print the symbols being reduced, and their result. */\r
+ *yycdebug_ << "Reducing stack by rule " << yyrule - 1\r
+ << " (line " << yylno << "):" << std::endl;\r
+ /* The symbols being reduced. */\r
+ for (int yyi = 0; yyi < yynrhs; yyi++)\r
+ YY_SYMBOL_PRINT (" $" << yyi + 1 << " =",\r
+ yyrhs_[yyprhs_[yyrule] + yyi],\r
+ &]b4_rhs_value(yynrhs, yyi + 1)[,\r
+ &]b4_rhs_location(yynrhs, yyi + 1)[);\r
+ }\r
+#endif // ]b4_api_PREFIX[DEBUG\r
+\r
+ /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */\r
+ ]b4_parser_class_name[::token_number_type\r
+ ]b4_parser_class_name[::yytranslate_ (int t)\r
+ {\r
+ static\r
+ const token_number_type\r
+ translate_table[] =\r
+ {\r
+ ]b4_translate[\r
+ };\r
+ if ((unsigned int) t <= yyuser_token_number_max_)\r
+ return translate_table[t];\r
+ else\r
+ return yyundef_token_;\r
+ }\r
+\r
+ const int ]b4_parser_class_name[::yyeof_ = 0;\r
+ const int ]b4_parser_class_name[::yylast_ = ]b4_last[;\r
+ const int ]b4_parser_class_name[::yynnts_ = ]b4_nterms_number[;\r
+ const int ]b4_parser_class_name[::yyempty_ = -2;\r
+ const int ]b4_parser_class_name[::yyfinal_ = ]b4_final_state_number[;\r
+ const int ]b4_parser_class_name[::yyterror_ = 1;\r
+ const int ]b4_parser_class_name[::yyerrcode_ = 256;\r
+ const int ]b4_parser_class_name[::yyntokens_ = ]b4_tokens_number[;\r
+\r
+ const unsigned int ]b4_parser_class_name[::yyuser_token_number_max_ = ]b4_user_token_number_max[;\r
+ const ]b4_parser_class_name[::token_number_type ]b4_parser_class_name[::yyundef_token_ = ]b4_undef_token_number[;\r
+\r
+]b4_namespace_close[\r
+]b4_epilogue[]dnl\r
+b4_output_end()\r
--- /dev/null
+# Java skeleton for Bison -*- autoconf -*-\r
+\r
+# Copyright (C) 2007-2012 Free Software Foundation, Inc.\r
+\r
+# This program is free software: you can redistribute it and/or modify\r
+# it under the terms of the GNU General Public License as published by\r
+# the Free Software Foundation, either version 3 of the License, or\r
+# (at your option) any later version.\r
+#\r
+# This program is distributed in the hope that it will be useful,\r
+# but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
+# GNU General Public License for more details.\r
+#\r
+# You should have received a copy of the GNU General Public License\r
+# along with this program. If not, see <http://www.gnu.org/licenses/>.\r
+\r
+m4_include(b4_pkgdatadir/[java.m4])\r
+\r
+b4_defines_if([b4_fatal([%s: %%defines does not make sense in Java], [b4_skeleton])])\r
+m4_ifval(m4_defn([b4_symbol_destructors]),\r
+ [b4_fatal([%s: %%destructor does not make sense in Java], [b4_skeleton])],\r
+ [])\r
+\r
+b4_output_begin([b4_parser_file_name])\r
+b4_copyright([Skeleton implementation for Bison LALR(1) parsers in Java],\r
+ [2007-2012])\r
+\r
+b4_percent_define_ifdef([package], [package b4_percent_define_get([package]);\r
+])[/* First part of user declarations. */\r
+]b4_pre_prologue\r
+b4_percent_code_get([[imports]])\r
+[/**\r
+ * A Bison parser, automatically generated from <tt>]m4_bpatsubst(b4_file_name, [^"\(.*\)"$], [\1])[</tt>.\r
+ *\r
+ * @@author LALR (1) parser skeleton written by Paolo Bonzini.\r
+ */\r
+]b4_public_if([public ])dnl\r
+b4_abstract_if([abstract ])dnl\r
+b4_final_if([final ])dnl\r
+b4_strictfp_if([strictfp ])dnl\r
+[class ]b4_parser_class_name[]dnl\r
+b4_percent_define_get3([extends], [ extends ])dnl\r
+b4_percent_define_get3([implements], [ implements ])[\r
+{\r
+ ]b4_identification[\r
+\r
+ /** True if verbose error messages are enabled. */\r
+ public boolean errorVerbose = ]b4_flag_value([error_verbose]);\r
+\r
+b4_locations_if([[\r
+ /**\r
+ * A class defining a pair of positions. Positions, defined by the\r
+ * <code>]b4_position_type[</code> class, denote a point in the input.\r
+ * Locations represent a part of the input through the beginning\r
+ * and ending positions. */\r
+ public class ]b4_location_type[ {\r
+ /** The first, inclusive, position in the range. */\r
+ public ]b4_position_type[ begin;\r
+\r
+ /** The first position beyond the range. */\r
+ public ]b4_position_type[ end;\r
+\r
+ /**\r
+ * Create a <code>]b4_location_type[</code> denoting an empty range located at\r
+ * a given point.\r
+ * @@param loc The position at which the range is anchored. */\r
+ public ]b4_location_type[ (]b4_position_type[ loc) {\r
+ this.begin = this.end = loc;\r
+ }\r
+\r
+ /**\r
+ * Create a <code>]b4_location_type[</code> from the endpoints of the range.\r
+ * @@param begin The first position included in the range.\r
+ * @@param end The first position beyond the range. */\r
+ public ]b4_location_type[ (]b4_position_type[ begin, ]b4_position_type[ end) {\r
+ this.begin = begin;\r
+ this.end = end;\r
+ }\r
+\r
+ /**\r
+ * Print a representation of the location. For this to be correct,\r
+ * <code>]b4_position_type[</code> should override the <code>equals</code>\r
+ * method. */\r
+ public String toString () {\r
+ if (begin.equals (end))\r
+ return begin.toString ();\r
+ else\r
+ return begin.toString () + "-" + end.toString ();\r
+ }\r
+ }\r
+\r
+]])\r
+\r
+[ /** Token returned by the scanner to signal the end of its input. */\r
+ public static final int EOF = 0;]\r
+\r
+b4_token_enums(b4_tokens)\r
+\r
+ b4_locations_if([[\r
+ private ]b4_location_type[ yylloc (YYStack rhs, int n)\r
+ {\r
+ if (n > 0)\r
+ return new ]b4_location_type[ (rhs.locationAt (n-1).begin, rhs.locationAt (0).end);\r
+ else\r
+ return new ]b4_location_type[ (rhs.locationAt (0).end);\r
+ }]])[\r
+\r
+ /**\r
+ * Communication interface between the scanner and the Bison-generated\r
+ * parser <tt>]b4_parser_class_name[</tt>.\r
+ */\r
+ public interface Lexer {\r
+ ]b4_locations_if([[/**\r
+ * Method to retrieve the beginning position of the last scanned token.\r
+ * @@return the position at which the last scanned token starts. */\r
+ ]b4_position_type[ getStartPos ();\r
+\r
+ /**\r
+ * Method to retrieve the ending position of the last scanned token.\r
+ * @@return the first position beyond the last scanned token. */\r
+ ]b4_position_type[ getEndPos ();]])[\r
+\r
+ /**\r
+ * Method to retrieve the semantic value of the last scanned token.\r
+ * @@return the semantic value of the last scanned token. */\r
+ ]b4_yystype[ getLVal ();\r
+\r
+ /**\r
+ * Entry point for the scanner. Returns the token identifier corresponding\r
+ * to the next token and prepares to return the semantic value\r
+ * ]b4_locations_if([and beginning/ending positions ])[of the token.\r
+ * @@return the token identifier corresponding to the next token. */\r
+ int yylex () ]b4_maybe_throws([b4_lex_throws])[;\r
+\r
+ /**\r
+ * Entry point for error reporting. Emits an error\r
+ * ]b4_locations_if([referring to the given location ])[in a user-defined way.\r
+ *\r
+ * ]b4_locations_if([[@@param loc The location of the element to which the\r
+ * error message is related]])[\r
+ * @@param s The string for the error message. */\r
+ void yyerror (]b4_locations_if([b4_location_type[ loc, ]])[String s);]\r
+ }\r
+\r
+ b4_lexer_if([[private class YYLexer implements Lexer {\r
+]b4_percent_code_get([[lexer]])[\r
+ }\r
+\r
+ ]])[/** The object doing lexical analysis for us. */\r
+ private Lexer yylexer;\r
+ ]\r
+ b4_parse_param_vars\r
+\r
+b4_lexer_if([[\r
+ /**\r
+ * Instantiates the Bison-generated parser.\r
+ */\r
+ public ]b4_parser_class_name (b4_parse_param_decl([b4_lex_param_decl])[) {\r
+ this.yylexer = new YYLexer(]b4_lex_param_call[);\r
+ ]b4_parse_param_cons[\r
+ }\r
+]])\r
+\r
+ /**\r
+ * Instantiates the Bison-generated parser.\r
+ * @@param yylexer The scanner that will supply tokens to the parser.\r
+ */\r
+ b4_lexer_if([[protected]], [[public]]) b4_parser_class_name[ (]b4_parse_param_decl([[Lexer yylexer]])[) {\r
+ this.yylexer = yylexer;\r
+ ]b4_parse_param_cons[\r
+ }\r
+\r
+ private java.io.PrintStream yyDebugStream = System.err;\r
+\r
+ /**\r
+ * Return the <tt>PrintStream</tt> on which the debugging output is\r
+ * printed.\r
+ */\r
+ public final java.io.PrintStream getDebugStream () { return yyDebugStream; }\r
+\r
+ /**\r
+ * Set the <tt>PrintStream</tt> on which the debug output is printed.\r
+ * @@param s The stream that is used for debugging output.\r
+ */\r
+ public final void setDebugStream(java.io.PrintStream s) { yyDebugStream = s; }\r
+\r
+ private int yydebug = 0;\r
+\r
+ /**\r
+ * Answer the verbosity of the debugging output; 0 means that all kinds of\r
+ * output from the parser are suppressed.\r
+ */\r
+ public final int getDebugLevel() { return yydebug; }\r
+\r
+ /**\r
+ * Set the verbosity of the debugging output; 0 means that all kinds of\r
+ * output from the parser are suppressed.\r
+ * @@param level The verbosity level for debugging output.\r
+ */\r
+ public final void setDebugLevel(int level) { yydebug = level; }\r
+\r
+ private final int yylex () ]b4_maybe_throws([b4_lex_throws]) [{\r
+ return yylexer.yylex ();\r
+ }\r
+ protected final void yyerror (]b4_locations_if([b4_location_type[ loc, ]])[String s) {\r
+ yylexer.yyerror (]b4_locations_if([loc, ])[s);\r
+ }\r
+\r
+ ]b4_locations_if([\r
+ protected final void yyerror (String s) {\r
+ yylexer.yyerror ((]b4_location_type[)null, s);\r
+ }\r
+ protected final void yyerror (]b4_position_type[ loc, String s) {\r
+ yylexer.yyerror (new ]b4_location_type[ (loc), s);\r
+ }])\r
+\r
+ [protected final void yycdebug (String s) {\r
+ if (yydebug > 0)\r
+ yyDebugStream.println (s);\r
+ }\r
+\r
+ private final class YYStack {\r
+ private int[] stateStack = new int[16];\r
+ ]b4_locations_if([[private ]b4_location_type[[] locStack = new ]b4_location_type[[16];]])[\r
+ private ]b4_yystype[[] valueStack = new ]b4_yystype[[16];\r
+\r
+ public int size = 16;\r
+ public int height = -1;\r
+\r
+ public final void push (int state, ]b4_yystype[ value]dnl\r
+ b4_locations_if([, ]b4_location_type[ loc])[) {\r
+ height++;\r
+ if (size == height)\r
+ {\r
+ int[] newStateStack = new int[size * 2];\r
+ System.arraycopy (stateStack, 0, newStateStack, 0, height);\r
+ stateStack = newStateStack;\r
+ ]b4_locations_if([[\r
+ ]b4_location_type[[] newLocStack = new ]b4_location_type[[size * 2];\r
+ System.arraycopy (locStack, 0, newLocStack, 0, height);\r
+ locStack = newLocStack;]])\r
+\r
+ b4_yystype[[] newValueStack = new ]b4_yystype[[size * 2];\r
+ System.arraycopy (valueStack, 0, newValueStack, 0, height);\r
+ valueStack = newValueStack;\r
+\r
+ size *= 2;\r
+ }\r
+\r
+ stateStack[height] = state;\r
+ ]b4_locations_if([[locStack[height] = loc;]])[\r
+ valueStack[height] = value;\r
+ }\r
+\r
+ public final void pop () {\r
+ pop (1);\r
+ }\r
+\r
+ public final void pop (int num) {\r
+ // Avoid memory leaks... garbage collection is a white lie!\r
+ if (num > 0) {\r
+ java.util.Arrays.fill (valueStack, height - num + 1, height + 1, null);\r
+ ]b4_locations_if([[java.util.Arrays.fill (locStack, height - num + 1, height + 1, null);]])[\r
+ }\r
+ height -= num;\r
+ }\r
+\r
+ public final int stateAt (int i) {\r
+ return stateStack[height - i];\r
+ }\r
+\r
+ ]b4_locations_if([[public final ]b4_location_type[ locationAt (int i) {\r
+ return locStack[height - i];\r
+ }\r
+\r
+ ]])[public final ]b4_yystype[ valueAt (int i) {\r
+ return valueStack[height - i];\r
+ }\r
+\r
+ // Print the state stack on the debug stream.\r
+ public void print (java.io.PrintStream out)\r
+ {\r
+ out.print ("Stack now");\r
+\r
+ for (int i = 0; i <= height; i++)\r
+ {\r
+ out.print (' ');\r
+ out.print (stateStack[i]);\r
+ }\r
+ out.println ();\r
+ }\r
+ }\r
+\r
+ /**\r
+ * Returned by a Bison action in order to stop the parsing process and\r
+ * return success (<tt>true</tt>). */\r
+ public static final int YYACCEPT = 0;\r
+\r
+ /**\r
+ * Returned by a Bison action in order to stop the parsing process and\r
+ * return failure (<tt>false</tt>). */\r
+ public static final int YYABORT = 1;\r
+\r
+ /**\r
+ * Returned by a Bison action in order to start error recovery without\r
+ * printing an error message. */\r
+ public static final int YYERROR = 2;\r
+\r
+ // Internal return codes that are not supported for user semantic\r
+ // actions.\r
+ private static final int YYERRLAB = 3;\r
+ private static final int YYNEWSTATE = 4;\r
+ private static final int YYDEFAULT = 5;\r
+ private static final int YYREDUCE = 6;\r
+ private static final int YYERRLAB1 = 7;\r
+ private static final int YYRETURN = 8;\r
+\r
+ private int yyerrstatus_ = 0;\r
+\r
+ /**\r
+ * Return whether error recovery is being done. In this state, the parser\r
+ * reads token until it reaches a known state, and then restarts normal\r
+ * operation. */\r
+ public final boolean recovering ()\r
+ {\r
+ return yyerrstatus_ == 0;\r
+ }\r
+\r
+ private int yyaction (int yyn, YYStack yystack, int yylen) ]b4_maybe_throws([b4_throws])[\r
+ {\r
+ ]b4_yystype[ yyval;\r
+ ]b4_locations_if([b4_location_type[ yyloc = yylloc (yystack, yylen);]])[\r
+\r
+ /* If YYLEN is nonzero, implement the default value of the action:\r
+ `$$ = $1'. Otherwise, use the top of the stack.\r
+\r
+ Otherwise, the following line sets YYVAL to garbage.\r
+ This behavior is undocumented and Bison\r
+ users should not rely upon it. */\r
+ if (yylen > 0)\r
+ yyval = yystack.valueAt (yylen - 1);\r
+ else\r
+ yyval = yystack.valueAt (0);\r
+\r
+ yy_reduce_print (yyn, yystack);\r
+\r
+ switch (yyn)\r
+ {\r
+ ]b4_user_actions[\r
+ default: break;\r
+ }\r
+\r
+ yy_symbol_print ("-> $$ =", yyr1_[yyn], yyval]b4_locations_if([, yyloc])[);\r
+\r
+ yystack.pop (yylen);\r
+ yylen = 0;\r
+\r
+ /* Shift the result of the reduction. */\r
+ yyn = yyr1_[yyn];\r
+ int yystate = yypgoto_[yyn - yyntokens_] + yystack.stateAt (0);\r
+ if (0 <= yystate && yystate <= yylast_\r
+ && yycheck_[yystate] == yystack.stateAt (0))\r
+ yystate = yytable_[yystate];\r
+ else\r
+ yystate = yydefgoto_[yyn - yyntokens_];\r
+\r
+ yystack.push (yystate, yyval]b4_locations_if([, yyloc])[);\r
+ return YYNEWSTATE;\r
+ }\r
+\r
+ /* Return YYSTR after stripping away unnecessary quotes and\r
+ backslashes, so that it's suitable for yyerror. The heuristic is\r
+ that double-quoting is unnecessary unless the string contains an\r
+ apostrophe, a comma, or backslash (other than backslash-backslash).\r
+ YYSTR is taken from yytname. */\r
+ private final String yytnamerr_ (String yystr)\r
+ {\r
+ if (yystr.charAt (0) == '"')\r
+ {\r
+ StringBuffer yyr = new StringBuffer ();\r
+ strip_quotes: for (int i = 1; i < yystr.length (); i++)\r
+ switch (yystr.charAt (i))\r
+ {\r
+ case '\'':\r
+ case ',':\r
+ break strip_quotes;\r
+\r
+ case '\\':\r
+ if (yystr.charAt(++i) != '\\')\r
+ break strip_quotes;\r
+ /* Fall through. */\r
+ default:\r
+ yyr.append (yystr.charAt (i));\r
+ break;\r
+\r
+ case '"':\r
+ return yyr.toString ();\r
+ }\r
+ }\r
+ else if (yystr.equals ("$end"))\r
+ return "end of input";\r
+\r
+ return yystr;\r
+ }\r
+\r
+ /*--------------------------------.\r
+ | Print this symbol on YYOUTPUT. |\r
+ `--------------------------------*/\r
+\r
+ private void yy_symbol_print (String s, int yytype,\r
+ ]b4_yystype[ yyvaluep]dnl\r
+ b4_locations_if([, Object yylocationp])[)\r
+ {\r
+ if (yydebug > 0)\r
+ yycdebug (s + (yytype < yyntokens_ ? " token " : " nterm ")\r
+ + yytname_[yytype] + " ("]b4_locations_if([\r
+ + yylocationp + ": "])[\r
+ + (yyvaluep == null ? "(null)" : yyvaluep.toString ()) + ")");\r
+ }\r
+\r
+ /**\r
+ * Parse input from the scanner that was specified at object construction\r
+ * time. Return whether the end of the input was reached successfully.\r
+ *\r
+ * @@return <tt>true</tt> if the parsing succeeds. Note that this does not\r
+ * imply that there were no syntax errors.\r
+ */\r
+ public boolean parse () ]b4_maybe_throws([b4_list2([b4_lex_throws], [b4_throws])])[\r
+ {\r
+ /// Lookahead and lookahead in internal form.\r
+ int yychar = yyempty_;\r
+ int yytoken = 0;\r
+\r
+ /* State. */\r
+ int yyn = 0;\r
+ int yylen = 0;\r
+ int yystate = 0;\r
+\r
+ YYStack yystack = new YYStack ();\r
+\r
+ /* Error handling. */\r
+ int yynerrs_ = 0;\r
+ ]b4_locations_if([/// The location where the error started.\r
+ ]b4_location_type[ yyerrloc = null;\r
+\r
+ /// ]b4_location_type[ of the lookahead.\r
+ ]b4_location_type[ yylloc = new ]b4_location_type[ (null, null);\r
+\r
+ /// @@$.\r
+ ]b4_location_type[ yyloc;])\r
+\r
+ /// Semantic value of the lookahead.\r
+ b4_yystype[ yylval = null;\r
+\r
+ yycdebug ("Starting parse\n");\r
+ yyerrstatus_ = 0;\r
+\r
+]m4_ifdef([b4_initial_action], [\r
+b4_dollar_pushdef([yylval], [], [yylloc])dnl\r
+/* User initialization code. */\r
+b4_user_initial_action\r
+b4_dollar_popdef])[]dnl\r
+\r
+ [ /* Initialize the stack. */\r
+ yystack.push (yystate, yylval]b4_locations_if([, yylloc])[);\r
+\r
+ int label = YYNEWSTATE;\r
+ for (;;)\r
+ switch (label)\r
+ {\r
+ /* New state. Unlike in the C/C++ skeletons, the state is already\r
+ pushed when we come here. */\r
+ case YYNEWSTATE:\r
+ yycdebug ("Entering state " + yystate + "\n");\r
+ if (yydebug > 0)\r
+ yystack.print (yyDebugStream);\r
+\r
+ /* Accept? */\r
+ if (yystate == yyfinal_)\r
+ return true;\r
+\r
+ /* Take a decision. First try without lookahead. */\r
+ yyn = yypact_[yystate];\r
+ if (yy_pact_value_is_default_ (yyn))\r
+ {\r
+ label = YYDEFAULT;\r
+ break;\r
+ }\r
+\r
+ /* Read a lookahead token. */\r
+ if (yychar == yyempty_)\r
+ {\r
+ yycdebug ("Reading a token: ");\r
+ yychar = yylex ();]\r
+ b4_locations_if([[\r
+ yylloc = new ]b4_location_type[(yylexer.getStartPos (),\r
+ yylexer.getEndPos ());]])\r
+ yylval = yylexer.getLVal ();[\r
+ }\r
+\r
+ /* Convert token to internal form. */\r
+ if (yychar <= EOF)\r
+ {\r
+ yychar = yytoken = EOF;\r
+ yycdebug ("Now at end of input.\n");\r
+ }\r
+ else\r
+ {\r
+ yytoken = yytranslate_ (yychar);\r
+ yy_symbol_print ("Next token is", yytoken,\r
+ yylval]b4_locations_if([, yylloc])[);\r
+ }\r
+\r
+ /* If the proper action on seeing token YYTOKEN is to reduce or to\r
+ detect an error, take that action. */\r
+ yyn += yytoken;\r
+ if (yyn < 0 || yylast_ < yyn || yycheck_[yyn] != yytoken)\r
+ label = YYDEFAULT;\r
+\r
+ /* <= 0 means reduce or error. */\r
+ else if ((yyn = yytable_[yyn]) <= 0)\r
+ {\r
+ if (yy_table_value_is_error_ (yyn))\r
+ label = YYERRLAB;\r
+ else\r
+ {\r
+ yyn = -yyn;\r
+ label = YYREDUCE;\r
+ }\r
+ }\r
+\r
+ else\r
+ {\r
+ /* Shift the lookahead token. */\r
+ yy_symbol_print ("Shifting", yytoken,\r
+ yylval]b4_locations_if([, yylloc])[);\r
+\r
+ /* Discard the token being shifted. */\r
+ yychar = yyempty_;\r
+\r
+ /* Count tokens shifted since error; after three, turn off error\r
+ status. */\r
+ if (yyerrstatus_ > 0)\r
+ --yyerrstatus_;\r
+\r
+ yystate = yyn;\r
+ yystack.push (yystate, yylval]b4_locations_if([, yylloc])[);\r
+ label = YYNEWSTATE;\r
+ }\r
+ break;\r
+\r
+ /*-----------------------------------------------------------.\r
+ | yydefault -- do the default action for the current state. |\r
+ `-----------------------------------------------------------*/\r
+ case YYDEFAULT:\r
+ yyn = yydefact_[yystate];\r
+ if (yyn == 0)\r
+ label = YYERRLAB;\r
+ else\r
+ label = YYREDUCE;\r
+ break;\r
+\r
+ /*-----------------------------.\r
+ | yyreduce -- Do a reduction. |\r
+ `-----------------------------*/\r
+ case YYREDUCE:\r
+ yylen = yyr2_[yyn];\r
+ label = yyaction (yyn, yystack, yylen);\r
+ yystate = yystack.stateAt (0);\r
+ break;\r
+\r
+ /*------------------------------------.\r
+ | yyerrlab -- here on detecting error |\r
+ `------------------------------------*/\r
+ case YYERRLAB:\r
+ /* If not already recovering from an error, report this error. */\r
+ if (yyerrstatus_ == 0)\r
+ {\r
+ ++yynerrs_;\r
+ if (yychar == yyempty_)\r
+ yytoken = yyempty_;\r
+ yyerror (]b4_locations_if([yylloc, ])[yysyntax_error (yystate, yytoken));\r
+ }\r
+\r
+ ]b4_locations_if([yyerrloc = yylloc;])[\r
+ if (yyerrstatus_ == 3)\r
+ {\r
+ /* If just tried and failed to reuse lookahead token after an\r
+ error, discard it. */\r
+\r
+ if (yychar <= EOF)\r
+ {\r
+ /* Return failure if at end of input. */\r
+ if (yychar == EOF)\r
+ return false;\r
+ }\r
+ else\r
+ yychar = yyempty_;\r
+ }\r
+\r
+ /* Else will try to reuse lookahead token after shifting the error\r
+ token. */\r
+ label = YYERRLAB1;\r
+ break;\r
+\r
+ /*---------------------------------------------------.\r
+ | errorlab -- error raised explicitly by YYERROR. |\r
+ `---------------------------------------------------*/\r
+ case YYERROR:\r
+\r
+ ]b4_locations_if([yyerrloc = yystack.locationAt (yylen - 1);])[\r
+ /* Do not reclaim the symbols of the rule which action triggered\r
+ this YYERROR. */\r
+ yystack.pop (yylen);\r
+ yylen = 0;\r
+ yystate = yystack.stateAt (0);\r
+ label = YYERRLAB1;\r
+ break;\r
+\r
+ /*-------------------------------------------------------------.\r
+ | yyerrlab1 -- common code for both syntax error and YYERROR. |\r
+ `-------------------------------------------------------------*/\r
+ case YYERRLAB1:\r
+ yyerrstatus_ = 3; /* Each real token shifted decrements this. */\r
+\r
+ for (;;)\r
+ {\r
+ yyn = yypact_[yystate];\r
+ if (!yy_pact_value_is_default_ (yyn))\r
+ {\r
+ yyn += yyterror_;\r
+ if (0 <= yyn && yyn <= yylast_ && yycheck_[yyn] == yyterror_)\r
+ {\r
+ yyn = yytable_[yyn];\r
+ if (0 < yyn)\r
+ break;\r
+ }\r
+ }\r
+\r
+ /* Pop the current state because it cannot handle the error token. */\r
+ if (yystack.height == 0)\r
+ return false;\r
+\r
+ ]b4_locations_if([yyerrloc = yystack.locationAt (0);])[\r
+ yystack.pop ();\r
+ yystate = yystack.stateAt (0);\r
+ if (yydebug > 0)\r
+ yystack.print (yyDebugStream);\r
+ }\r
+\r
+ ]b4_locations_if([\r
+ /* Muck with the stack to setup for yylloc. */\r
+ yystack.push (0, null, yylloc);\r
+ yystack.push (0, null, yyerrloc);\r
+ yyloc = yylloc (yystack, 2);\r
+ yystack.pop (2);])[\r
+\r
+ /* Shift the error token. */\r
+ yy_symbol_print ("Shifting", yystos_[yyn],\r
+ yylval]b4_locations_if([, yyloc])[);\r
+\r
+ yystate = yyn;\r
+ yystack.push (yyn, yylval]b4_locations_if([, yyloc])[);\r
+ label = YYNEWSTATE;\r
+ break;\r
+\r
+ /* Accept. */\r
+ case YYACCEPT:\r
+ return true;\r
+\r
+ /* Abort. */\r
+ case YYABORT:\r
+ return false;\r
+ }\r
+ }\r
+\r
+ // Generate an error message.\r
+ private String yysyntax_error (int yystate, int tok)\r
+ {\r
+ if (errorVerbose)\r
+ {\r
+ /* There are many possibilities here to consider:\r
+ - Assume YYFAIL is not used. It's too flawed to consider.\r
+ See\r
+ <http://lists.gnu.org/archive/html/bison-patches/2009-12/msg00024.html>\r
+ for details. YYERROR is fine as it does not invoke this\r
+ function.\r
+ - If this state is a consistent state with a default action,\r
+ then the only way this function was invoked is if the\r
+ default action is an error action. In that case, don't\r
+ check for expected tokens because there are none.\r
+ - The only way there can be no lookahead present (in tok) is\r
+ if this state is a consistent state with a default action.\r
+ Thus, detecting the absence of a lookahead is sufficient to\r
+ determine that there is no unexpected or expected token to\r
+ report. In that case, just report a simple "syntax error".\r
+ - Don't assume there isn't a lookahead just because this\r
+ state is a consistent state with a default action. There\r
+ might have been a previous inconsistent state, consistent\r
+ state with a non-default action, or user semantic action\r
+ that manipulated yychar. (However, yychar is currently out\r
+ of scope during semantic actions.)\r
+ - Of course, the expected token list depends on states to\r
+ have correct lookahead information, and it depends on the\r
+ parser not to perform extra reductions after fetching a\r
+ lookahead from the scanner and before detecting a syntax\r
+ error. Thus, state merging (from LALR or IELR) and default\r
+ reductions corrupt the expected token list. However, the\r
+ list is correct for canonical LR with one exception: it\r
+ will still contain any token that will not be accepted due\r
+ to an error action in a later state.\r
+ */\r
+ if (tok != yyempty_)\r
+ {\r
+ // FIXME: This method of building the message is not compatible\r
+ // with internationalization.\r
+ StringBuffer res =\r
+ new StringBuffer ("syntax error, unexpected ");\r
+ res.append (yytnamerr_ (yytname_[tok]));\r
+ int yyn = yypact_[yystate];\r
+ if (!yy_pact_value_is_default_ (yyn))\r
+ {\r
+ /* Start YYX at -YYN if negative to avoid negative\r
+ indexes in YYCHECK. In other words, skip the first\r
+ -YYN actions for this state because they are default\r
+ actions. */\r
+ int yyxbegin = yyn < 0 ? -yyn : 0;\r
+ /* Stay within bounds of both yycheck and yytname. */\r
+ int yychecklim = yylast_ - yyn + 1;\r
+ int yyxend = yychecklim < yyntokens_ ? yychecklim : yyntokens_;\r
+ int count = 0;\r
+ for (int x = yyxbegin; x < yyxend; ++x)\r
+ if (yycheck_[x + yyn] == x && x != yyterror_\r
+ && !yy_table_value_is_error_ (yytable_[x + yyn]))\r
+ ++count;\r
+ if (count < 5)\r
+ {\r
+ count = 0;\r
+ for (int x = yyxbegin; x < yyxend; ++x)\r
+ if (yycheck_[x + yyn] == x && x != yyterror_\r
+ && !yy_table_value_is_error_ (yytable_[x + yyn]))\r
+ {\r
+ res.append (count++ == 0 ? ", expecting " : " or ");\r
+ res.append (yytnamerr_ (yytname_[x]));\r
+ }\r
+ }\r
+ }\r
+ return res.toString ();\r
+ }\r
+ }\r
+\r
+ return "syntax error";\r
+ }\r
+\r
+ /**\r
+ * Whether the given <code>yypact_</code> value indicates a defaulted state.\r
+ * @@param yyvalue the value to check\r
+ */\r
+ private static boolean yy_pact_value_is_default_ (int yyvalue)\r
+ {\r
+ return yyvalue == yypact_ninf_;\r
+ }\r
+\r
+ /**\r
+ * Whether the given <code>yytable_</code> value indicates a syntax error.\r
+ * @@param yyvalue the value to check\r
+ */\r
+ private static boolean yy_table_value_is_error_ (int yyvalue)\r
+ {\r
+ return yyvalue == yytable_ninf_;\r
+ }\r
+\r
+ /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing\r
+ STATE-NUM. */\r
+ private static final ]b4_int_type_for([b4_pact])[ yypact_ninf_ = ]b4_pact_ninf[;\r
+ private static final ]b4_int_type_for([b4_pact])[ yypact_[] =\r
+ {\r
+ ]b4_pact[\r
+ };\r
+\r
+ /* YYDEFACT[S] -- default reduction number in state S. Performed when\r
+ YYTABLE doesn't specify something else to do. Zero means the\r
+ default is an error. */\r
+ private static final ]b4_int_type_for([b4_defact])[ yydefact_[] =\r
+ {\r
+ ]b4_defact[\r
+ };\r
+\r
+ /* YYPGOTO[NTERM-NUM]. */\r
+ private static final ]b4_int_type_for([b4_pgoto])[ yypgoto_[] =\r
+ {\r
+ ]b4_pgoto[\r
+ };\r
+\r
+ /* YYDEFGOTO[NTERM-NUM]. */\r
+ private static final ]b4_int_type_for([b4_defgoto])[\r
+ yydefgoto_[] =\r
+ {\r
+ ]b4_defgoto[\r
+ };\r
+\r
+ /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If\r
+ positive, shift that token. If negative, reduce the rule which\r
+ number is the opposite. If YYTABLE_NINF_, syntax error. */\r
+ private static final ]b4_int_type_for([b4_table])[ yytable_ninf_ = ]b4_table_ninf[;\r
+ private static final ]b4_int_type_for([b4_table])[\r
+ yytable_[] =\r
+ {\r
+ ]b4_table[\r
+ };\r
+\r
+ /* YYCHECK. */\r
+ private static final ]b4_int_type_for([b4_check])[\r
+ yycheck_[] =\r
+ {\r
+ ]b4_check[\r
+ };\r
+\r
+ /* STOS_[STATE-NUM] -- The (internal number of the) accessing\r
+ symbol of state STATE-NUM. */\r
+ private static final ]b4_int_type_for([b4_stos])[\r
+ yystos_[] =\r
+ {\r
+ ]b4_stos[\r
+ };\r
+\r
+ /* TOKEN_NUMBER_[YYLEX-NUM] -- Internal symbol number corresponding\r
+ to YYLEX-NUM. */\r
+ private static final ]b4_int_type_for([b4_toknum])[\r
+ yytoken_number_[] =\r
+ {\r
+ ]b4_toknum[\r
+ };\r
+\r
+ /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */\r
+ private static final ]b4_int_type_for([b4_r1])[\r
+ yyr1_[] =\r
+ {\r
+ ]b4_r1[\r
+ };\r
+\r
+ /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */\r
+ private static final ]b4_int_type_for([b4_r2])[\r
+ yyr2_[] =\r
+ {\r
+ ]b4_r2[\r
+ };\r
+\r
+ /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.\r
+ First, the terminals, then, starting at \a yyntokens_, nonterminals. */\r
+ private static final String yytname_[] =\r
+ {\r
+ ]b4_tname[\r
+ };\r
+\r
+ /* YYRHS -- A `-1'-separated list of the rules' RHS. */\r
+ private static final ]b4_int_type_for([b4_rhs])[ yyrhs_[] =\r
+ {\r
+ ]b4_rhs[\r
+ };\r
+\r
+ /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in\r
+ YYRHS. */\r
+ private static final ]b4_int_type_for([b4_prhs])[ yyprhs_[] =\r
+ {\r
+ ]b4_prhs[\r
+ };\r
+\r
+ /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */\r
+ private static final ]b4_int_type_for([b4_rline])[ yyrline_[] =\r
+ {\r
+ ]b4_rline[\r
+ };\r
+\r
+ // Report on the debug stream that the rule yyrule is going to be reduced.\r
+ private void yy_reduce_print (int yyrule, YYStack yystack)\r
+ {\r
+ if (yydebug == 0)\r
+ return;\r
+\r
+ int yylno = yyrline_[yyrule];\r
+ int yynrhs = yyr2_[yyrule];\r
+ /* Print the symbols being reduced, and their result. */\r
+ yycdebug ("Reducing stack by rule " + (yyrule - 1)\r
+ + " (line " + yylno + "), ");\r
+\r
+ /* The symbols being reduced. */\r
+ for (int yyi = 0; yyi < yynrhs; yyi++)\r
+ yy_symbol_print (" $" + (yyi + 1) + " =",\r
+ yyrhs_[yyprhs_[yyrule] + yyi],\r
+ ]b4_rhs_value(yynrhs, yyi + 1)b4_locations_if([,\r
+ b4_rhs_location(yynrhs, yyi + 1)])[);\r
+ }\r
+\r
+ /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */\r
+ private static final ]b4_int_type_for([b4_translate])[ yytranslate_table_[] =\r
+ {\r
+ ]b4_translate[\r
+ };\r
+\r
+ private static final ]b4_int_type_for([b4_translate])[ yytranslate_ (int t)\r
+ {\r
+ if (t >= 0 && t <= yyuser_token_number_max_)\r
+ return yytranslate_table_[t];\r
+ else\r
+ return yyundef_token_;\r
+ }\r
+\r
+ private static final int yylast_ = ]b4_last[;\r
+ private static final int yynnts_ = ]b4_nterms_number[;\r
+ private static final int yyempty_ = -2;\r
+ private static final int yyfinal_ = ]b4_final_state_number[;\r
+ private static final int yyterror_ = 1;\r
+ private static final int yyerrcode_ = 256;\r
+ private static final int yyntokens_ = ]b4_tokens_number[;\r
+\r
+ private static final int yyuser_token_number_max_ = ]b4_user_token_number_max[;\r
+ private static final int yyundef_token_ = ]b4_undef_token_number[;\r
+\r
+]/* User implementation code. */\r
+b4_percent_code_get[]dnl\r
+\r
+}\r
+\r
+b4_epilogue\r
+b4_output_end()\r
--- /dev/null
+# C++ skeleton for Bison\r
+\r
+# Copyright (C) 2002-2007, 2009-2012 Free Software Foundation, Inc.\r
+\r
+# This program is free software: you can redistribute it and/or modify\r
+# it under the terms of the GNU General Public License as published by\r
+# the Free Software Foundation, either version 3 of the License, or\r
+# (at your option) any later version.\r
+#\r
+# This program is distributed in the hope that it will be useful,\r
+# but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
+# GNU General Public License for more details.\r
+#\r
+# You should have received a copy of the GNU General Public License\r
+# along with this program. If not, see <http://www.gnu.org/licenses/>.\r
+\r
+\r
+b4_output_begin([b4_dir_prefix[]position.hh])\r
+b4_copyright([Positions for Bison parsers in C++],\r
+ [2002-2007, 2009-2012])[\r
+\r
+/**\r
+ ** \file ]b4_dir_prefix[position.hh\r
+ ** Define the ]b4_namespace_ref[::position class.\r
+ */\r
+\r
+]b4_cpp_guard_open([b4_dir_prefix[]position.hh])[\r
+\r
+# include <algorithm> // std::max\r
+# include <iostream>\r
+# include <string>\r
+\r
+]b4_null_define[\r
+\r
+]b4_namespace_open[\r
+ /// Abstract a position.\r
+ class position\r
+ {\r
+ public:\r
+]m4_ifdef([b4_location_constructors], [[\r
+ /// Construct a position.\r
+ explicit position (]b4_percent_define_get([[filename_type]])[* f = YY_NULL,\r
+ unsigned int l = ]b4_location_initial_line[u,\r
+ unsigned int c = ]b4_location_initial_column[u)\r
+ : filename (f)\r
+ , line (l)\r
+ , column (c)\r
+ {\r
+ }\r
+\r
+]])[\r
+ /// Initialization.\r
+ void initialize (]b4_percent_define_get([[filename_type]])[* fn = YY_NULL,\r
+ unsigned int l = ]b4_location_initial_line[u,\r
+ unsigned int c = ]b4_location_initial_column[u)\r
+ {\r
+ filename = fn;\r
+ line = l;\r
+ column = c;\r
+ }\r
+\r
+ /** \name Line and Column related manipulators\r
+ ** \{ */\r
+ /// (line related) Advance to the COUNT next lines.\r
+ void lines (int count = 1)\r
+ {\r
+ column = ]b4_location_initial_column[u;\r
+ line += count;\r
+ }\r
+\r
+ /// (column related) Advance to the COUNT next columns.\r
+ void columns (int count = 1)\r
+ {\r
+ column = std::max (]b4_location_initial_column[u, column + count);\r
+ }\r
+ /** \} */\r
+\r
+ /// File name to which this position refers.\r
+ ]b4_percent_define_get([[filename_type]])[* filename;\r
+ /// Current line number.\r
+ unsigned int line;\r
+ /// Current column number.\r
+ unsigned int column;\r
+ };\r
+\r
+ /// Add and assign a position.\r
+ inline position&\r
+ operator+= (position& res, const int width)\r
+ {\r
+ res.columns (width);\r
+ return res;\r
+ }\r
+\r
+ /// Add two position objects.\r
+ inline const position\r
+ operator+ (const position& begin, const int width)\r
+ {\r
+ position res = begin;\r
+ return res += width;\r
+ }\r
+\r
+ /// Add and assign a position.\r
+ inline position&\r
+ operator-= (position& res, const int width)\r
+ {\r
+ return res += -width;\r
+ }\r
+\r
+ /// Add two position objects.\r
+ inline const position\r
+ operator- (const position& begin, const int width)\r
+ {\r
+ return begin + -width;\r
+ }\r
+]b4_percent_define_flag_if([[define_location_comparison]], [[\r
+ /// Compare two position objects.\r
+ inline bool\r
+ operator== (const position& pos1, const position& pos2)\r
+ {\r
+ return (pos1.line == pos2.line\r
+ && pos1.column == pos2.column\r
+ && (pos1.filename == pos2.filename\r
+ || (pos1.filename && pos2.filename\r
+ && *pos1.filename == *pos2.filename)));\r
+ }\r
+\r
+ /// Compare two position objects.\r
+ inline bool\r
+ operator!= (const position& pos1, const position& pos2)\r
+ {\r
+ return !(pos1 == pos2);\r
+ }\r
+]])[\r
+ /** \brief Intercept output stream redirection.\r
+ ** \param ostr the destination output stream\r
+ ** \param pos a reference to the position to redirect\r
+ */\r
+ template <typename YYChar>\r
+ inline std::basic_ostream<YYChar>&\r
+ operator<< (std::basic_ostream<YYChar>& ostr, const position& pos)\r
+ {\r
+ if (pos.filename)\r
+ ostr << *pos.filename << ':';\r
+ return ostr << pos.line << '.' << pos.column;\r
+ }\r
+\r
+]b4_namespace_close[\r
+]b4_cpp_guard_close([b4_dir_prefix[]position.hh])\r
+b4_output_end()\r
+\r
+\r
+b4_output_begin([b4_dir_prefix[]location.hh])\r
+b4_copyright([Locations for Bison parsers in C++],\r
+ [2002-2007, 2009-2012])[\r
+\r
+/**\r
+ ** \file ]b4_dir_prefix[location.hh\r
+ ** Define the ]b4_namespace_ref[::location class.\r
+ */\r
+\r
+]b4_cpp_guard_open([b4_dir_prefix[]location.hh])[\r
+\r
+# include "position.hh"\r
+\r
+]b4_namespace_open[\r
+\r
+ /// Abstract a location.\r
+ class location\r
+ {\r
+ public:\r
+]m4_ifdef([b4_location_constructors], [\r
+ /// Construct a location from \a b to \a e.\r
+ location (const position& b, const position& e)\r
+ : begin (b)\r
+ , end (e)\r
+ {\r
+ }\r
+\r
+ /// Construct a 0-width location in \a p.\r
+ explicit location (const position& p = position ())\r
+ : begin (p)\r
+ , end (p)\r
+ {\r
+ }\r
+\r
+ /// Construct a 0-width location in \a f, \a l, \a c.\r
+ explicit location (]b4_percent_define_get([[filename_type]])[* f,\r
+ unsigned int l = ]b4_location_initial_line[u,\r
+ unsigned int c = ]b4_location_initial_column[u)\r
+ : begin (f, l, c)\r
+ , end (f, l, c)\r
+ {\r
+ }\r
+\r
+])[\r
+ /// Initialization.\r
+ void initialize (]b4_percent_define_get([[filename_type]])[* f = YY_NULL,\r
+ unsigned int l = ]b4_location_initial_line[u,\r
+ unsigned int c = ]b4_location_initial_column[u)\r
+ {\r
+ begin.initialize (f, l, c);\r
+ end = begin;\r
+ }\r
+\r
+ /** \name Line and Column related manipulators\r
+ ** \{ */\r
+ public:\r
+ /// Reset initial location to final location.\r
+ void step ()\r
+ {\r
+ begin = end;\r
+ }\r
+\r
+ /// Extend the current location to the COUNT next columns.\r
+ void columns (unsigned int count = 1)\r
+ {\r
+ end += count;\r
+ }\r
+\r
+ /// Extend the current location to the COUNT next lines.\r
+ void lines (unsigned int count = 1)\r
+ {\r
+ end.lines (count);\r
+ }\r
+ /** \} */\r
+\r
+\r
+ public:\r
+ /// Beginning of the located region.\r
+ position begin;\r
+ /// End of the located region.\r
+ position end;\r
+ };\r
+\r
+ /// Join two location objects to create a location.\r
+ inline const location operator+ (const location& begin, const location& end)\r
+ {\r
+ location res = begin;\r
+ res.end = end.end;\r
+ return res;\r
+ }\r
+\r
+ /// Add two location objects.\r
+ inline const location operator+ (const location& begin, unsigned int width)\r
+ {\r
+ location res = begin;\r
+ res.columns (width);\r
+ return res;\r
+ }\r
+\r
+ /// Add and assign a location.\r
+ inline location& operator+= (location& res, unsigned int width)\r
+ {\r
+ res.columns (width);\r
+ return res;\r
+ }\r
+]b4_percent_define_flag_if([[define_location_comparison]], [[\r
+ /// Compare two location objects.\r
+ inline bool\r
+ operator== (const location& loc1, const location& loc2)\r
+ {\r
+ return loc1.begin == loc2.begin && loc1.end == loc2.end;\r
+ }\r
+\r
+ /// Compare two location objects.\r
+ inline bool\r
+ operator!= (const location& loc1, const location& loc2)\r
+ {\r
+ return !(loc1 == loc2);\r
+ }\r
+]])[\r
+ /** \brief Intercept output stream redirection.\r
+ ** \param ostr the destination output stream\r
+ ** \param loc a reference to the location to redirect\r
+ **\r
+ ** Avoid duplicate information.\r
+ */\r
+ template <typename YYChar>\r
+ inline std::basic_ostream<YYChar>&\r
+ operator<< (std::basic_ostream<YYChar>& ostr, const location& loc)\r
+ {\r
+ position last = loc.end - 1;\r
+ ostr << loc.begin;\r
+ if (last.filename\r
+ && (!loc.begin.filename\r
+ || *loc.begin.filename != *last.filename))\r
+ ostr << '-' << last;\r
+ else if (loc.begin.line != last.line)\r
+ ostr << '-' << last.line << '.' << last.column;\r
+ else if (loc.begin.column != last.column)\r
+ ostr << '-' << last.column;\r
+ return ostr;\r
+ }\r
+\r
+]b4_namespace_close[\r
+\r
+]b4_cpp_guard_close([b4_dir_prefix[]location.hh])\r
+b4_output_end()\r
--- /dev/null
+# -*- Autoconf -*-\r
+# This file is part of Autoconf.\r
+# foreach-based replacements for recursive functions.\r
+# Speeds up GNU M4 1.4.x by avoiding quadratic $@ recursion, but penalizes\r
+# GNU M4 1.6 by requiring more memory and macro expansions.\r
+#\r
+# Copyright (C) 2008-2012 Free Software Foundation, Inc.\r
+\r
+# This file is part of Autoconf. This program is free\r
+# software; you can redistribute it and/or modify it under the\r
+# terms of the GNU General Public License as published by the\r
+# Free Software Foundation, either version 3 of the License, or\r
+# (at your option) any later version.\r
+#\r
+# This program is distributed in the hope that it will be useful,\r
+# but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
+# GNU General Public License for more details.\r
+#\r
+# Under Section 7 of GPL version 3, you are granted additional\r
+# permissions described in the Autoconf Configure Script Exception,\r
+# version 3.0, as published by the Free Software Foundation.\r
+#\r
+# You should have received a copy of the GNU General Public License\r
+# and a copy of the Autoconf Configure Script Exception along with\r
+# this program; see the files COPYINGv3 and COPYING.EXCEPTION\r
+# respectively. If not, see <http://www.gnu.org/licenses/>.\r
+\r
+# Written by Eric Blake.\r
+\r
+# In M4 1.4.x, every byte of $@ is rescanned. This means that an\r
+# algorithm on n arguments that recurses with one less argument each\r
+# iteration will scan n * (n + 1) / 2 arguments, for O(n^2) time. In\r
+# M4 1.6, this was fixed so that $@ is only scanned once, then\r
+# back-references are made to information stored about the scan.\r
+# Thus, n iterations need only scan n arguments, for O(n) time.\r
+# Additionally, in M4 1.4.x, recursive algorithms did not clean up\r
+# memory very well, requiring O(n^2) memory rather than O(n) for n\r
+# iterations.\r
+#\r
+# This file is designed to overcome the quadratic nature of $@\r
+# recursion by writing a variant of m4_foreach that uses m4_for rather\r
+# than $@ recursion to operate on the list. This involves more macro\r
+# expansions, but avoids the need to rescan a quadratic number of\r
+# arguments, making these replacements very attractive for M4 1.4.x.\r
+# On the other hand, in any version of M4, expanding additional macros\r
+# costs additional time; therefore, in M4 1.6, where $@ recursion uses\r
+# fewer macros, these replacements actually pessimize performance.\r
+# Additionally, the use of $10 to mean the tenth argument violates\r
+# POSIX; although all versions of m4 1.4.x support this meaning, a\r
+# future m4 version may switch to take it as the first argument\r
+# concatenated with a literal 0, so the implementations in this file\r
+# are not future-proof. Thus, this file is conditionally included as\r
+# part of m4_init(), only when it is detected that M4 probably has\r
+# quadratic behavior (ie. it lacks the macro __m4_version__).\r
+#\r
+# Please keep this file in sync with m4sugar.m4.\r
+\r
+# _m4_foreach(PRE, POST, IGNORED, ARG...)\r
+# ---------------------------------------\r
+# Form the common basis of the m4_foreach and m4_map macros. For each\r
+# ARG, expand PRE[ARG]POST[]. The IGNORED argument makes recursion\r
+# easier, and must be supplied rather than implicit.\r
+#\r
+# This version minimizes the number of times that $@ is evaluated by\r
+# using m4_for to generate a boilerplate into _m4_f then passing $@ to\r
+# that temporary macro. Thus, the recursion is done in m4_for without\r
+# reparsing any user input, and is not quadratic. For an idea of how\r
+# this works, note that m4_foreach(i,[1,2],[i]) calls\r
+# _m4_foreach([m4_define([i],],[)i],[],[1],[2])\r
+# which defines _m4_f:\r
+# $1[$4]$2[]$1[$5]$2[]_m4_popdef([_m4_f])\r
+# then calls _m4_f([m4_define([i],],[)i],[],[1],[2]) for a net result:\r
+# m4_define([i],[1])i[]m4_define([i],[2])i[]_m4_popdef([_m4_f]).\r
+m4_define([_m4_foreach],\r
+[m4_if([$#], [3], [],\r
+ [m4_pushdef([_m4_f], _m4_for([4], [$#], [1],\r
+ [$0_([1], [2],], [)])[_m4_popdef([_m4_f])])_m4_f($@)])])\r
+\r
+m4_define([_m4_foreach_],\r
+[[$$1[$$3]$$2[]]])\r
+\r
+# m4_case(SWITCH, VAL1, IF-VAL1, VAL2, IF-VAL2, ..., DEFAULT)\r
+# -----------------------------------------------------------\r
+# Find the first VAL that SWITCH matches, and expand the corresponding\r
+# IF-VAL. If there are no matches, expand DEFAULT.\r
+#\r
+# Use m4_for to create a temporary macro in terms of a boilerplate\r
+# m4_if with final cleanup. If $# is even, we have DEFAULT; if it is\r
+# odd, then rounding the last $# up in the temporary macro is\r
+# harmless. For example, both m4_case(1,2,3,4,5) and\r
+# m4_case(1,2,3,4,5,6) result in the intermediate _m4_case being\r
+# m4_if([$1],[$2],[$3],[$1],[$4],[$5],_m4_popdef([_m4_case])[$6])\r
+m4_define([m4_case],\r
+[m4_if(m4_eval([$# <= 2]), [1], [$2],\r
+[m4_pushdef([_$0], [m4_if(]_m4_for([2], m4_eval([($# - 1) / 2 * 2]), [2],\r
+ [_$0_(], [)])[_m4_popdef(\r
+ [_$0])]m4_dquote($m4_eval([($# + 1) & ~1]))[)])_$0($@)])])\r
+\r
+m4_define([_m4_case_],\r
+[$0_([1], [$1], m4_incr([$1]))])\r
+\r
+m4_define([_m4_case__],\r
+[[[$$1],[$$2],[$$3],]])\r
+\r
+# m4_bmatch(SWITCH, RE1, VAL1, RE2, VAL2, ..., DEFAULT)\r
+# -----------------------------------------------------\r
+# m4 equivalent of\r
+#\r
+# if (SWITCH =~ RE1)\r
+# VAL1;\r
+# elif (SWITCH =~ RE2)\r
+# VAL2;\r
+# elif ...\r
+# ...\r
+# else\r
+# DEFAULT\r
+#\r
+# We build the temporary macro _m4_b:\r
+# m4_define([_m4_b], _m4_defn([_m4_bmatch]))_m4_b([$1], [$2], [$3])...\r
+# _m4_b([$1], [$m-1], [$m])_m4_b([], [], [$m+1]_m4_popdef([_m4_b]))\r
+# then invoke m4_unquote(_m4_b($@)), for concatenation with later text.\r
+m4_define([m4_bmatch],\r
+[m4_if([$#], 0, [m4_fatal([$0: too few arguments: $#])],\r
+ [$#], 1, [m4_fatal([$0: too few arguments: $#: $1])],\r
+ [$#], 2, [$2],\r
+ [m4_pushdef([_m4_b], [m4_define([_m4_b],\r
+ _m4_defn([_$0]))]_m4_for([3], m4_eval([($# + 1) / 2 * 2 - 1]),\r
+ [2], [_$0_(], [)])[_m4_b([], [],]m4_dquote([$]m4_eval(\r
+ [($# + 1) / 2 * 2]))[_m4_popdef([_m4_b]))])m4_unquote(_m4_b($@))])])\r
+\r
+m4_define([_m4_bmatch],\r
+[m4_if(m4_bregexp([$1], [$2]), [-1], [], [[$3]m4_define([$0])])])\r
+\r
+m4_define([_m4_bmatch_],\r
+[$0_([1], m4_decr([$1]), [$1])])\r
+\r
+m4_define([_m4_bmatch__],\r
+[[_m4_b([$$1], [$$2], [$$3])]])\r
+\r
+\r
+# m4_cond(TEST1, VAL1, IF-VAL1, TEST2, VAL2, IF-VAL2, ..., [DEFAULT])\r
+# -------------------------------------------------------------------\r
+# Similar to m4_if, except that each TEST is expanded when encountered.\r
+# If the expansion of TESTn matches the string VALn, the result is IF-VALn.\r
+# The result is DEFAULT if no tests passed. This macro allows\r
+# short-circuiting of expensive tests, where it pays to arrange quick\r
+# filter tests to run first.\r
+#\r
+# m4_cond already guarantees either 3*n or 3*n + 1 arguments, 1 <= n.\r
+# We only have to speed up _m4_cond, by building the temporary _m4_c:\r
+# m4_define([_m4_c], _m4_defn([m4_unquote]))_m4_c([m4_if(($1), [($2)],\r
+# [[$3]m4_define([_m4_c])])])_m4_c([m4_if(($4), [($5)],\r
+# [[$6]m4_define([_m4_c])])])..._m4_c([m4_if(($m-2), [($m-1)],\r
+# [[$m]m4_define([_m4_c])])])_m4_c([[$m+1]]_m4_popdef([_m4_c]))\r
+# We invoke m4_unquote(_m4_c($@)), for concatenation with later text.\r
+m4_define([_m4_cond],\r
+[m4_pushdef([_m4_c], [m4_define([_m4_c],\r
+ _m4_defn([m4_unquote]))]_m4_for([2], m4_eval([$# / 3 * 3 - 1]), [3],\r
+ [$0_(], [)])[_m4_c(]m4_dquote(m4_dquote(\r
+ [$]m4_eval([$# / 3 * 3 + 1])))[_m4_popdef([_m4_c]))])m4_unquote(_m4_c($@))])\r
+\r
+m4_define([_m4_cond_],\r
+[$0_(m4_decr([$1]), [$1], m4_incr([$1]))])\r
+\r
+m4_define([_m4_cond__],\r
+[[_m4_c([m4_if(($$1), [($$2)], [[$$3]m4_define([_m4_c])])])]])\r
+\r
+# m4_bpatsubsts(STRING, RE1, SUBST1, RE2, SUBST2, ...)\r
+# ----------------------------------------------------\r
+# m4 equivalent of\r
+#\r
+# $_ = STRING;\r
+# s/RE1/SUBST1/g;\r
+# s/RE2/SUBST2/g;\r
+# ...\r
+#\r
+# m4_bpatsubsts already validated an odd number of arguments; we only\r
+# need to speed up _m4_bpatsubsts. To avoid nesting, we build the\r
+# temporary _m4_p:\r
+# m4_define([_m4_p], [$1])m4_define([_m4_p],\r
+# m4_bpatsubst(m4_dquote(_m4_defn([_m4_p])), [$2], [$3]))m4_define([_m4_p],\r
+# m4_bpatsubst(m4_dquote(_m4_defn([_m4_p])), [$4], [$5]))m4_define([_m4_p],...\r
+# m4_bpatsubst(m4_dquote(_m4_defn([_m4_p])), [$m-1], [$m]))m4_unquote(\r
+# _m4_defn([_m4_p])_m4_popdef([_m4_p]))\r
+m4_define([_m4_bpatsubsts],\r
+[m4_pushdef([_m4_p], [m4_define([_m4_p],\r
+ ]m4_dquote([$]1)[)]_m4_for([3], [$#], [2], [$0_(],\r
+ [)])[m4_unquote(_m4_defn([_m4_p])_m4_popdef([_m4_p]))])_m4_p($@)])\r
+\r
+m4_define([_m4_bpatsubsts_],\r
+[$0_(m4_decr([$1]), [$1])])\r
+\r
+m4_define([_m4_bpatsubsts__],\r
+[[m4_define([_m4_p],\r
+m4_bpatsubst(m4_dquote(_m4_defn([_m4_p])), [$$1], [$$2]))]])\r
+\r
+# m4_shiftn(N, ...)\r
+# -----------------\r
+# Returns ... shifted N times. Useful for recursive "varargs" constructs.\r
+#\r
+# m4_shiftn already validated arguments; we only need to speed up\r
+# _m4_shiftn. If N is 3, then we build the temporary _m4_s, defined as\r
+# ,[$5],[$6],...,[$m]_m4_popdef([_m4_s])\r
+# before calling m4_shift(_m4_s($@)).\r
+m4_define([_m4_shiftn],\r
+[m4_if(m4_incr([$1]), [$#], [], [m4_pushdef([_m4_s],\r
+ _m4_for(m4_eval([$1 + 2]), [$#], [1],\r
+ [[,]m4_dquote($], [)])[_m4_popdef([_m4_s])])m4_shift(_m4_s($@))])])\r
+\r
+# m4_do(STRING, ...)\r
+# ------------------\r
+# This macro invokes all its arguments (in sequence, of course). It is\r
+# useful for making your macros more structured and readable by dropping\r
+# unnecessary dnl's and have the macros indented properly.\r
+#\r
+# Here, we use the temporary macro _m4_do, defined as\r
+# $1[]$2[]...[]$n[]_m4_popdef([_m4_do])\r
+m4_define([m4_do],\r
+[m4_if([$#], [0], [],\r
+ [m4_pushdef([_$0], _m4_for([1], [$#], [1],\r
+ [$], [[[]]])[_m4_popdef([_$0])])_$0($@)])])\r
+\r
+# m4_dquote_elt(ARGS)\r
+# -------------------\r
+# Return ARGS as an unquoted list of double-quoted arguments.\r
+#\r
+# _m4_foreach to the rescue.\r
+m4_define([m4_dquote_elt],\r
+[m4_if([$#], [0], [], [[[$1]]_m4_foreach([,m4_dquote(], [)], $@)])])\r
+\r
+# m4_reverse(ARGS)\r
+# ----------------\r
+# Output ARGS in reverse order.\r
+#\r
+# Invoke _m4_r($@) with the temporary _m4_r built as\r
+# [$m], [$m-1], ..., [$2], [$1]_m4_popdef([_m4_r])\r
+m4_define([m4_reverse],\r
+[m4_if([$#], [0], [], [$#], [1], [[$1]],\r
+[m4_pushdef([_m4_r], [[$$#]]_m4_for(m4_decr([$#]), [1], [-1],\r
+ [[, ]m4_dquote($], [)])[_m4_popdef([_m4_r])])_m4_r($@)])])\r
+\r
+\r
+# m4_map_args_pair(EXPRESSION, [END-EXPR = EXPRESSION], ARG...)\r
+# -------------------------------------------------------------\r
+# Perform a pairwise grouping of consecutive ARGs, by expanding\r
+# EXPRESSION([ARG1], [ARG2]). If there are an odd number of ARGs, the\r
+# final argument is expanded with END-EXPR([ARGn]).\r
+#\r
+# Build the temporary macro _m4_map_args_pair, with the $2([$m+1])\r
+# only output if $# is odd:\r
+# $1([$3], [$4])[]$1([$5], [$6])[]...$1([$m-1],\r
+# [$m])[]m4_default([$2], [$1])([$m+1])[]_m4_popdef([_m4_map_args_pair])\r
+m4_define([m4_map_args_pair],\r
+[m4_if([$#], [0], [m4_fatal([$0: too few arguments: $#])],\r
+ [$#], [1], [m4_fatal([$0: too few arguments: $#: $1])],\r
+ [$#], [2], [],\r
+ [$#], [3], [m4_default([$2], [$1])([$3])[]],\r
+ [m4_pushdef([_$0], _m4_for([3],\r
+ m4_eval([$# / 2 * 2 - 1]), [2], [_$0_(], [)])_$0_end(\r
+ [1], [2], [$#])[_m4_popdef([_$0])])_$0($@)])])\r
+\r
+m4_define([_m4_map_args_pair_],\r
+[$0_([1], [$1], m4_incr([$1]))])\r
+\r
+m4_define([_m4_map_args_pair__],\r
+[[$$1([$$2], [$$3])[]]])\r
+\r
+m4_define([_m4_map_args_pair_end],\r
+[m4_if(m4_eval([$3 & 1]), [1], [[m4_default([$$2], [$$1])([$$3])[]]])])\r
+\r
+# m4_join(SEP, ARG1, ARG2...)\r
+# ---------------------------\r
+# Produce ARG1SEPARG2...SEPARGn. Avoid back-to-back SEP when a given ARG\r
+# is the empty string. No expansion is performed on SEP or ARGs.\r
+#\r
+# Use a self-modifying separator, since we don't know how many\r
+# arguments might be skipped before a separator is first printed, but\r
+# be careful if the separator contains $. _m4_foreach to the rescue.\r
+m4_define([m4_join],\r
+[m4_pushdef([_m4_sep], [m4_define([_m4_sep], _m4_defn([m4_echo]))])]dnl\r
+[_m4_foreach([_$0([$1],], [)], $@)_m4_popdef([_m4_sep])])\r
+\r
+m4_define([_m4_join],\r
+[m4_if([$2], [], [], [_m4_sep([$1])[$2]])])\r
+\r
+# m4_joinall(SEP, ARG1, ARG2...)\r
+# ------------------------------\r
+# Produce ARG1SEPARG2...SEPARGn. An empty ARG results in back-to-back SEP.\r
+# No expansion is performed on SEP or ARGs.\r
+#\r
+# A bit easier than m4_join. _m4_foreach to the rescue.\r
+m4_define([m4_joinall],\r
+[[$2]m4_if(m4_eval([$# <= 2]), [1], [],\r
+ [_m4_foreach([$1], [], m4_shift($@))])])\r
+\r
+# m4_list_cmp(A, B)\r
+# -----------------\r
+# Compare the two lists of integer expressions A and B.\r
+#\r
+# m4_list_cmp takes care of any side effects; we only override\r
+# _m4_list_cmp_raw, where we can safely expand lists multiple times.\r
+# First, insert padding so that both lists are the same length; the\r
+# trailing +0 is necessary to handle a missing list. Next, create a\r
+# temporary macro to perform pairwise comparisons until an inequality\r
+# is found. For example, m4_list_cmp([1], [1,2]) creates _m4_cmp as\r
+# m4_if(m4_eval([($1) != ($3)]), [1], [m4_cmp([$1], [$3])],\r
+# m4_eval([($2) != ($4)]), [1], [m4_cmp([$2], [$4])],\r
+# [0]_m4_popdef([_m4_cmp]))\r
+# then calls _m4_cmp([1+0], [0*2], [1], [2+0])\r
+m4_define([_m4_list_cmp_raw],\r
+[m4_if([$1], [$2], 0,\r
+ [_m4_list_cmp($1+0_m4_list_pad(m4_count($1), m4_count($2)),\r
+ $2+0_m4_list_pad(m4_count($2), m4_count($1)))])])\r
+\r
+m4_define([_m4_list_pad],\r
+[m4_if(m4_eval($1 < $2), [1],\r
+ [_m4_for(m4_incr([$1]), [$2], [1], [,0*])])])\r
+\r
+m4_define([_m4_list_cmp],\r
+[m4_pushdef([_m4_cmp], [m4_if(]_m4_for(\r
+ [1], m4_eval([$# >> 1]), [1], [$0_(], [,]m4_eval([$# >> 1])[)])[\r
+ [0]_m4_popdef([_m4_cmp]))])_m4_cmp($@)])\r
+\r
+m4_define([_m4_list_cmp_],\r
+[$0_([$1], m4_eval([$1 + $2]))])\r
+\r
+m4_define([_m4_list_cmp__],\r
+[[m4_eval([($$1) != ($$2)]), [1], [m4_cmp([$$1], [$$2])],\r
+]])\r
+\r
+# m4_max(EXPR, ...)\r
+# m4_min(EXPR, ...)\r
+# -----------------\r
+# Return the decimal value of the maximum (or minimum) in a series of\r
+# integer expressions.\r
+#\r
+# _m4_foreach to the rescue; we only need to replace _m4_minmax. Here,\r
+# we need a temporary macro to track the best answer so far, so that\r
+# the foreach expression is tractable.\r
+m4_define([_m4_minmax],\r
+[m4_pushdef([_m4_best], m4_eval([$2]))_m4_foreach(\r
+ [m4_define([_m4_best], $1(_m4_best,], [))], m4_shift($@))]dnl\r
+[_m4_best[]_m4_popdef([_m4_best])])\r
+\r
+# m4_set_add_all(SET, VALUE...)\r
+# -----------------------------\r
+# Add each VALUE into SET. This is O(n) in the number of VALUEs, and\r
+# can be faster than calling m4_set_add for each VALUE.\r
+#\r
+# _m4_foreach to the rescue. If no deletions have occurred, then\r
+# avoid the speed penalty of m4_set_add.\r
+m4_define([m4_set_add_all],\r
+[m4_if([$#], [0], [], [$#], [1], [],\r
+ [m4_define([_m4_set_size($1)], m4_eval(m4_set_size([$1])\r
+ + m4_len(_m4_foreach(m4_ifdef([_m4_set_cleanup($1)],\r
+ [[m4_set_add]], [[_$0]])[([$1],], [)], $@))))])])\r
+\r
+m4_define([_m4_set_add_all],\r
+[m4_ifdef([_m4_set([$1],$2)], [],\r
+ [m4_define([_m4_set([$1],$2)],\r
+ [1])m4_pushdef([_m4_set([$1])], [$2])-])])\r
--- /dev/null
+divert(-1)# -*- Autoconf -*-\r
+# This file is part of Autoconf.\r
+# Base M4 layer.\r
+# Requires GNU M4.\r
+#\r
+# Copyright (C) 1999-2012 Free Software Foundation, Inc.\r
+\r
+# This file is part of Autoconf. This program is free\r
+# software; you can redistribute it and/or modify it under the\r
+# terms of the GNU General Public License as published by the\r
+# Free Software Foundation, either version 3 of the License, or\r
+# (at your option) any later version.\r
+#\r
+# This program is distributed in the hope that it will be useful,\r
+# but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
+# GNU General Public License for more details.\r
+#\r
+# Under Section 7 of GPL version 3, you are granted additional\r
+# permissions described in the Autoconf Configure Script Exception,\r
+# version 3.0, as published by the Free Software Foundation.\r
+#\r
+# You should have received a copy of the GNU General Public License\r
+# and a copy of the Autoconf Configure Script Exception along with\r
+# this program; see the files COPYINGv3 and COPYING.EXCEPTION\r
+# respectively. If not, see <http://www.gnu.org/licenses/>.\r
+\r
+# Written by Akim Demaille.\r
+\r
+# Set the quotes, whatever the current quoting system.\r
+changequote()\r
+changequote([, ])\r
+\r
+# Some old m4's don't support m4exit. But they provide\r
+# equivalent functionality by core dumping because of the\r
+# long macros we define.\r
+ifdef([__gnu__], ,\r
+[errprint(M4sugar requires GNU M4. Install it before installing M4sugar or\r
+set the M4 environment variable to its absolute file name.)\r
+m4exit(2)])\r
+\r
+\r
+## ------------------------------- ##\r
+## 1. Simulate --prefix-builtins. ##\r
+## ------------------------------- ##\r
+\r
+# m4_define\r
+# m4_defn\r
+# m4_undefine\r
+define([m4_define], defn([define]))\r
+define([m4_defn], defn([defn]))\r
+define([m4_undefine], defn([undefine]))\r
+\r
+m4_undefine([define])\r
+m4_undefine([defn])\r
+m4_undefine([undefine])\r
+\r
+\r
+# m4_copy(SRC, DST)\r
+# -----------------\r
+# Define DST as the definition of SRC.\r
+# What's the difference between:\r
+# 1. m4_copy([from], [to])\r
+# 2. m4_define([to], [from($@)])\r
+# Well, obviously 1 is more expensive in space. Maybe 2 is more expensive\r
+# in time, but because of the space cost of 1, it's not that obvious.\r
+# Nevertheless, one huge difference is the handling of `$0'. If `from'\r
+# uses `$0', then with 1, `to''s `$0' is `to', while it is `from' in 2.\r
+# The user would certainly prefer to see `to'.\r
+#\r
+# This definition is in effect during m4sugar initialization, when\r
+# there are no pushdef stacks; later on, we redefine it to something\r
+# more powerful for all other clients to use.\r
+m4_define([m4_copy],\r
+[m4_define([$2], m4_defn([$1]))])\r
+\r
+\r
+# m4_rename(SRC, DST)\r
+# -------------------\r
+# Rename the macro SRC to DST.\r
+m4_define([m4_rename],\r
+[m4_copy([$1], [$2])m4_undefine([$1])])\r
+\r
+\r
+# m4_rename_m4(MACRO-NAME)\r
+# ------------------------\r
+# Rename MACRO-NAME to m4_MACRO-NAME.\r
+m4_define([m4_rename_m4],\r
+[m4_rename([$1], [m4_$1])])\r
+\r
+\r
+# m4_copy_unm4(m4_MACRO-NAME)\r
+# ---------------------------\r
+# Copy m4_MACRO-NAME to MACRO-NAME.\r
+m4_define([m4_copy_unm4],\r
+[m4_copy([$1], m4_bpatsubst([$1], [^m4_\(.*\)], [[\1]]))])\r
+\r
+\r
+# Some m4 internals have names colliding with tokens we might use.\r
+# Rename them a` la `m4 --prefix-builtins'. Conditionals first, since\r
+# some subsequent renames are conditional.\r
+m4_rename_m4([ifdef])\r
+m4_rename([ifelse], [m4_if])\r
+\r
+m4_rename_m4([builtin])\r
+m4_rename_m4([changecom])\r
+m4_rename_m4([changequote])\r
+m4_ifdef([changeword],dnl conditionally available in 1.4.x\r
+[m4_undefine([changeword])])\r
+m4_rename_m4([debugfile])\r
+m4_rename_m4([debugmode])\r
+m4_rename_m4([decr])\r
+m4_rename_m4([divnum])\r
+m4_rename_m4([dumpdef])\r
+m4_rename_m4([errprint])\r
+m4_rename_m4([esyscmd])\r
+m4_rename_m4([eval])\r
+m4_rename_m4([format])\r
+m4_undefine([include])\r
+m4_rename_m4([incr])\r
+m4_rename_m4([index])\r
+m4_rename_m4([indir])\r
+m4_rename_m4([len])\r
+m4_rename([m4exit], [m4_exit])\r
+m4_undefine([m4wrap])\r
+m4_ifdef([mkstemp],dnl added in M4 1.4.8\r
+[m4_rename_m4([mkstemp])\r
+m4_copy([m4_mkstemp], [m4_maketemp])\r
+m4_undefine([maketemp])],\r
+[m4_rename_m4([maketemp])\r
+m4_copy([m4_maketemp], [m4_mkstemp])])\r
+m4_rename([patsubst], [m4_bpatsubst])\r
+m4_rename_m4([popdef])\r
+m4_rename_m4([pushdef])\r
+m4_rename([regexp], [m4_bregexp])\r
+m4_rename_m4([shift])\r
+m4_undefine([sinclude])\r
+m4_rename_m4([substr])\r
+m4_ifdef([symbols],dnl present only in alpha-quality 1.4o\r
+[m4_rename_m4([symbols])])\r
+m4_rename_m4([syscmd])\r
+m4_rename_m4([sysval])\r
+m4_rename_m4([traceoff])\r
+m4_rename_m4([traceon])\r
+m4_rename_m4([translit])\r
+\r
+# _m4_defn(ARG)\r
+# -------------\r
+# _m4_defn is for internal use only - it bypasses the wrapper, so it\r
+# must only be used on one argument at a time, and only on macros\r
+# known to be defined. Make sure this still works if the user renames\r
+# m4_defn but not _m4_defn.\r
+m4_copy([m4_defn], [_m4_defn])\r
+\r
+# _m4_divert_raw(NUM)\r
+# -------------------\r
+# _m4_divert_raw is for internal use only. Use this instead of\r
+# m4_builtin([divert], NUM), so that tracing diversion flow is easier.\r
+m4_rename([divert], [_m4_divert_raw])\r
+\r
+# _m4_popdef(ARG...)\r
+# ------------------\r
+# _m4_popdef is for internal use only - it bypasses the wrapper, so it\r
+# must only be used on macros known to be defined. Make sure this\r
+# still works if the user renames m4_popdef but not _m4_popdef.\r
+m4_copy([m4_popdef], [_m4_popdef])\r
+\r
+# _m4_undefine(ARG...)\r
+# --------------------\r
+# _m4_undefine is for internal use only - it bypasses the wrapper, so\r
+# it must only be used on macros known to be defined. Make sure this\r
+# still works if the user renames m4_undefine but not _m4_undefine.\r
+m4_copy([m4_undefine], [_m4_undefine])\r
+\r
+# _m4_undivert(NUM...)\r
+# --------------------\r
+# _m4_undivert is for internal use only, and should always be given\r
+# arguments. Use this instead of m4_builtin([undivert], NUM...), so\r
+# that tracing diversion flow is easier.\r
+m4_rename([undivert], [_m4_undivert])\r
+\r
+\r
+## ------------------- ##\r
+## 2. Error messages. ##\r
+## ------------------- ##\r
+\r
+\r
+# m4_location\r
+# -----------\r
+# Output the current file, colon, and the current line number.\r
+m4_define([m4_location],\r
+[__file__:__line__])\r
+\r
+\r
+# m4_errprintn(MSG)\r
+# -----------------\r
+# Same as `errprint', but with the missing end of line.\r
+m4_define([m4_errprintn],\r
+[m4_errprint([$1\r
+])])\r
+\r
+\r
+# m4_warning(MSG)\r
+# ---------------\r
+# Warn the user.\r
+m4_define([m4_warning],\r
+[m4_errprintn(m4_location[: warning: $1])])\r
+\r
+\r
+# m4_fatal(MSG, [EXIT-STATUS])\r
+# ----------------------------\r
+# Fatal the user. :)\r
+m4_define([m4_fatal],\r
+[m4_errprintn(m4_location[: error: $1]\r
+m4_expansion_stack)m4_exit(m4_if([$2],, 1, [$2]))])\r
+\r
+\r
+# m4_assert(EXPRESSION, [EXIT-STATUS = 1])\r
+# ----------------------------------------\r
+# This macro ensures that EXPRESSION evaluates to true, and exits if\r
+# EXPRESSION evaluates to false.\r
+m4_define([m4_assert],\r
+[m4_if(m4_eval([$1]), 0,\r
+ [m4_fatal([assert failed: $1], [$2])])])\r
+\r
+\r
+\r
+## ------------- ##\r
+## 3. Warnings. ##\r
+## ------------- ##\r
+\r
+\r
+# _m4_warn(CATEGORY, MESSAGE, [STACK-TRACE])\r
+# ------------------------------------------\r
+# Report a MESSAGE to the user if the CATEGORY of warnings is enabled.\r
+# This is for traces only.\r
+# If present, STACK-TRACE is a \n-separated list of "LOCATION: MESSAGE",\r
+# where the last line (and no other) ends with "the top level".\r
+#\r
+# Within m4, the macro is a no-op. This macro really matters\r
+# when autom4te post-processes the trace output.\r
+m4_define([_m4_warn], [])\r
+\r
+\r
+# m4_warn(CATEGORY, MESSAGE)\r
+# --------------------------\r
+# Report a MESSAGE to the user if the CATEGORY of warnings is enabled.\r
+m4_define([m4_warn],\r
+[_m4_warn([$1], [$2],\r
+m4_ifdef([_m4_expansion_stack], [m4_expansion_stack]))])\r
+\r
+\r
+\r
+## ------------------- ##\r
+## 4. File inclusion. ##\r
+## ------------------- ##\r
+\r
+\r
+# We also want to neutralize include (and sinclude for symmetry),\r
+# but we want to extend them slightly: warn when a file is included\r
+# several times. This is, in general, a dangerous operation, because\r
+# too many people forget to quote the first argument of m4_define.\r
+#\r
+# For instance in the following case:\r
+# m4_define(foo, [bar])\r
+# then a second reading will turn into\r
+# m4_define(bar, [bar])\r
+# which is certainly not what was meant.\r
+\r
+# m4_include_unique(FILE)\r
+# -----------------------\r
+# Declare that the FILE was loading; and warn if it has already\r
+# been included.\r
+m4_define([m4_include_unique],\r
+[m4_ifdef([m4_include($1)],\r
+ [m4_warn([syntax], [file `$1' included several times])])dnl\r
+m4_define([m4_include($1)])])\r
+\r
+\r
+# m4_include(FILE)\r
+# ----------------\r
+# Like the builtin include, but warns against multiple inclusions.\r
+m4_define([m4_include],\r
+[m4_include_unique([$1])dnl\r
+m4_builtin([include], [$1])])\r
+\r
+\r
+# m4_sinclude(FILE)\r
+# -----------------\r
+# Like the builtin sinclude, but warns against multiple inclusions.\r
+m4_define([m4_sinclude],\r
+[m4_include_unique([$1])dnl\r
+m4_builtin([sinclude], [$1])])\r
+\r
+\r
+\r
+## ------------------------------------ ##\r
+## 5. Additional branching constructs. ##\r
+## ------------------------------------ ##\r
+\r
+# Both `m4_ifval' and `m4_ifset' tests against the empty string. The\r
+# difference is that `m4_ifset' is specialized on macros.\r
+#\r
+# In case of arguments of macros, eg. $1, it makes little difference.\r
+# In the case of a macro `FOO', you don't want to check `m4_ifval(FOO,\r
+# TRUE)', because if `FOO' expands with commas, there is a shifting of\r
+# the arguments. So you want to run `m4_ifval([FOO])', but then you just\r
+# compare the *string* `FOO' against `', which, of course fails.\r
+#\r
+# So you want the variation `m4_ifset' that expects a macro name as $1.\r
+# If this macro is both defined and defined to a non empty value, then\r
+# it runs TRUE, etc.\r
+\r
+\r
+# m4_ifblank(COND, [IF-BLANK], [IF-TEXT])\r
+# m4_ifnblank(COND, [IF-TEXT], [IF-BLANK])\r
+# ----------------------------------------\r
+# If COND is empty, or consists only of blanks (space, tab, newline),\r
+# then expand IF-BLANK, otherwise expand IF-TEXT. This differs from\r
+# m4_ifval only if COND has just whitespace, but it helps optimize in\r
+# spite of users who mistakenly leave trailing space after what they\r
+# thought was an empty argument:\r
+# macro(\r
+# []\r
+# )\r
+#\r
+# Writing one macro in terms of the other causes extra overhead, so\r
+# we inline both definitions.\r
+m4_define([m4_ifblank],\r
+[m4_if(m4_translit([[$1]], [ ][ ][\r
+]), [], [$2], [$3])])\r
+\r
+m4_define([m4_ifnblank],\r
+[m4_if(m4_translit([[$1]], [ ][ ][\r
+]), [], [$3], [$2])])\r
+\r
+\r
+# m4_ifval(COND, [IF-TRUE], [IF-FALSE])\r
+# -------------------------------------\r
+# If COND is not the empty string, expand IF-TRUE, otherwise IF-FALSE.\r
+# Comparable to m4_ifdef.\r
+m4_define([m4_ifval],\r
+[m4_if([$1], [], [$3], [$2])])\r
+\r
+\r
+# m4_n(TEXT)\r
+# ----------\r
+# If TEXT is not empty, return TEXT and a new line, otherwise nothing.\r
+m4_define([m4_n],\r
+[m4_if([$1],\r
+ [], [],\r
+ [$1\r
+])])\r
+\r
+\r
+# m4_ifvaln(COND, [IF-TRUE], [IF-FALSE])\r
+# --------------------------------------\r
+# Same as `m4_ifval', but add an extra newline to IF-TRUE or IF-FALSE\r
+# unless that argument is empty.\r
+m4_define([m4_ifvaln],\r
+[m4_if([$1],\r
+ [], [m4_n([$3])],\r
+ [m4_n([$2])])])\r
+\r
+\r
+# m4_ifset(MACRO, [IF-TRUE], [IF-FALSE])\r
+# --------------------------------------\r
+# If MACRO has no definition, or of its definition is the empty string,\r
+# expand IF-FALSE, otherwise IF-TRUE.\r
+m4_define([m4_ifset],\r
+[m4_ifdef([$1],\r
+ [m4_ifval(_m4_defn([$1]), [$2], [$3])],\r
+ [$3])])\r
+\r
+\r
+# m4_ifndef(NAME, [IF-NOT-DEFINED], [IF-DEFINED])\r
+# -----------------------------------------------\r
+m4_define([m4_ifndef],\r
+[m4_ifdef([$1], [$3], [$2])])\r
+\r
+\r
+# m4_case(SWITCH, VAL1, IF-VAL1, VAL2, IF-VAL2, ..., DEFAULT)\r
+# -----------------------------------------------------------\r
+# m4 equivalent of\r
+# switch (SWITCH)\r
+# {\r
+# case VAL1:\r
+# IF-VAL1;\r
+# break;\r
+# case VAL2:\r
+# IF-VAL2;\r
+# break;\r
+# ...\r
+# default:\r
+# DEFAULT;\r
+# break;\r
+# }.\r
+# All the values are optional, and the macro is robust to active\r
+# symbols properly quoted.\r
+#\r
+# Please keep foreach.m4 in sync with any adjustments made here.\r
+m4_define([m4_case],\r
+[m4_if([$#], 0, [],\r
+ [$#], 1, [],\r
+ [$#], 2, [$2],\r
+ [$1], [$2], [$3],\r
+ [$0([$1], m4_shift3($@))])])\r
+\r
+\r
+# m4_bmatch(SWITCH, RE1, VAL1, RE2, VAL2, ..., DEFAULT)\r
+# -----------------------------------------------------\r
+# m4 equivalent of\r
+#\r
+# if (SWITCH =~ RE1)\r
+# VAL1;\r
+# elif (SWITCH =~ RE2)\r
+# VAL2;\r
+# elif ...\r
+# ...\r
+# else\r
+# DEFAULT\r
+#\r
+# All the values are optional, and the macro is robust to active symbols\r
+# properly quoted.\r
+#\r
+# Please keep foreach.m4 in sync with any adjustments made here.\r
+m4_define([m4_bmatch],\r
+[m4_if([$#], 0, [m4_fatal([$0: too few arguments: $#])],\r
+ [$#], 1, [m4_fatal([$0: too few arguments: $#: $1])],\r
+ [$#], 2, [$2],\r
+ [m4_if(m4_bregexp([$1], [$2]), -1, [$0([$1], m4_shift3($@))],\r
+ [$3])])])\r
+\r
+# m4_argn(N, ARGS...)\r
+# -------------------\r
+# Extract argument N (greater than 0) from ARGS. Example:\r
+# m4_define([b], [B])\r
+# m4_argn([2], [a], [b], [c]) => b\r
+#\r
+# Rather than using m4_car(m4_shiftn([$1], $@)), we exploit the fact that\r
+# GNU m4 can directly reference any argument, through an indirect macro.\r
+m4_define([m4_argn],\r
+[m4_assert([0 < $1])]dnl\r
+[m4_pushdef([_$0], [_m4_popdef([_$0])]m4_dquote([$]m4_incr([$1])))_$0($@)])\r
+\r
+\r
+# m4_car(ARGS...)\r
+# m4_cdr(ARGS...)\r
+# ---------------\r
+# Manipulate m4 lists. m4_car returns the first argument. m4_cdr\r
+# bundles all but the first argument into a quoted list. These two\r
+# macros are generally used with list arguments, with quoting removed\r
+# to break the list into multiple m4 ARGS.\r
+m4_define([m4_car], [[$1]])\r
+m4_define([m4_cdr],\r
+[m4_if([$#], 0, [m4_fatal([$0: cannot be called without arguments])],\r
+ [$#], 1, [],\r
+ [m4_dquote(m4_shift($@))])])\r
+\r
+# _m4_cdr(ARGS...)\r
+# ----------------\r
+# Like m4_cdr, except include a leading comma unless only one argument\r
+# remains. Why? Because comparing a large list against [] is more\r
+# expensive in expansion time than comparing the number of arguments; so\r
+# _m4_cdr can be used to reduce the number of arguments when it is time\r
+# to end recursion.\r
+m4_define([_m4_cdr],\r
+[m4_if([$#], 1, [],\r
+ [, m4_dquote(m4_shift($@))])])\r
+\r
+\r
+\r
+# m4_cond(TEST1, VAL1, IF-VAL1, TEST2, VAL2, IF-VAL2, ..., [DEFAULT])\r
+# -------------------------------------------------------------------\r
+# Similar to m4_if, except that each TEST is expanded when encountered.\r
+# If the expansion of TESTn matches the string VALn, the result is IF-VALn.\r
+# The result is DEFAULT if no tests passed. This macro allows\r
+# short-circuiting of expensive tests, where it pays to arrange quick\r
+# filter tests to run first.\r
+#\r
+# For an example, consider a previous implementation of _AS_QUOTE_IFELSE:\r
+#\r
+# m4_if(m4_index([$1], [\]), [-1], [$2],\r
+# m4_eval(m4_index([$1], [\\]) >= 0), [1], [$2],\r
+# m4_eval(m4_index([$1], [\$]) >= 0), [1], [$2],\r
+# m4_eval(m4_index([$1], [\`]) >= 0), [1], [$3],\r
+# m4_eval(m4_index([$1], [\"]) >= 0), [1], [$3],\r
+# [$2])\r
+#\r
+# Here, m4_index is computed 5 times, and m4_eval 4, even if $1 contains\r
+# no backslash. It is more efficient to do:\r
+#\r
+# m4_cond([m4_index([$1], [\])], [-1], [$2],\r
+# [m4_eval(m4_index([$1], [\\]) >= 0)], [1], [$2],\r
+# [m4_eval(m4_index([$1], [\$]) >= 0)], [1], [$2],\r
+# [m4_eval(m4_index([$1], [\`]) >= 0)], [1], [$3],\r
+# [m4_eval(m4_index([$1], [\"]) >= 0)], [1], [$3],\r
+# [$2])\r
+#\r
+# In the common case of $1 with no backslash, only one m4_index expansion\r
+# occurs, and m4_eval is avoided altogether.\r
+#\r
+# Please keep foreach.m4 in sync with any adjustments made here.\r
+m4_define([m4_cond],\r
+[m4_if([$#], [0], [m4_fatal([$0: cannot be called without arguments])],\r
+ [$#], [1], [$1],\r
+ m4_eval([$# % 3]), [2], [m4_fatal([$0: missing an argument])],\r
+ [_$0($@)])])\r
+\r
+m4_define([_m4_cond],\r
+[m4_if(($1), [($2)], [$3],\r
+ [$#], [3], [],\r
+ [$#], [4], [$4],\r
+ [$0(m4_shift3($@))])])\r
+\r
+\r
+## ---------------------------------------- ##\r
+## 6. Enhanced version of some primitives. ##\r
+## ---------------------------------------- ##\r
+\r
+# m4_bpatsubsts(STRING, RE1, SUBST1, RE2, SUBST2, ...)\r
+# ----------------------------------------------------\r
+# m4 equivalent of\r
+#\r
+# $_ = STRING;\r
+# s/RE1/SUBST1/g;\r
+# s/RE2/SUBST2/g;\r
+# ...\r
+#\r
+# All the values are optional, and the macro is robust to active symbols\r
+# properly quoted.\r
+#\r
+# I would have liked to name this macro `m4_bpatsubst', unfortunately,\r
+# due to quotation problems, I need to double quote $1 below, therefore\r
+# the anchors are broken :( I can't let users be trapped by that.\r
+#\r
+# Recall that m4_shift3 always results in an argument. Hence, we need\r
+# to distinguish between a final deletion vs. ending recursion.\r
+#\r
+# Please keep foreach.m4 in sync with any adjustments made here.\r
+m4_define([m4_bpatsubsts],\r
+[m4_if([$#], 0, [m4_fatal([$0: too few arguments: $#])],\r
+ [$#], 1, [m4_fatal([$0: too few arguments: $#: $1])],\r
+ [$#], 2, [m4_unquote(m4_builtin([patsubst], [[$1]], [$2]))],\r
+ [$#], 3, [m4_unquote(m4_builtin([patsubst], [[$1]], [$2], [$3]))],\r
+ [_$0($@m4_if(m4_eval($# & 1), 0, [,]))])])\r
+m4_define([_m4_bpatsubsts],\r
+[m4_if([$#], 2, [$1],\r
+ [$0(m4_builtin([patsubst], [[$1]], [$2], [$3]),\r
+ m4_shift3($@))])])\r
+\r
+\r
+# m4_copy(SRC, DST)\r
+# -----------------\r
+# Define the pushdef stack DST as a copy of the pushdef stack SRC;\r
+# give an error if DST is already defined. This is particularly nice\r
+# for copying self-modifying pushdef stacks, where the top definition\r
+# includes one-shot initialization that is later popped to the normal\r
+# definition. This version intentionally does nothing if SRC is\r
+# undefined.\r
+#\r
+# Some macros simply can't be renamed with this method: namely, anything\r
+# involved in the implementation of m4_stack_foreach_sep.\r
+m4_define([m4_copy],\r
+[m4_ifdef([$2], [m4_fatal([$0: won't overwrite defined macro: $2])],\r
+ [m4_stack_foreach_sep([$1], [m4_pushdef([$2],], [)])])]dnl\r
+[m4_ifdef([m4_location($1)], [m4_define([m4_location($2)], m4_location)])])\r
+\r
+\r
+# m4_copy_force(SRC, DST)\r
+# m4_rename_force(SRC, DST)\r
+# -------------------------\r
+# Like m4_copy/m4_rename, except blindly overwrite any existing DST.\r
+# Note that m4_copy_force tolerates undefined SRC, while m4_rename_force\r
+# does not.\r
+m4_define([m4_copy_force],\r
+[m4_ifdef([$2], [_m4_undefine([$2])])m4_copy($@)])\r
+\r
+m4_define([m4_rename_force],\r
+[m4_ifdef([$2], [_m4_undefine([$2])])m4_rename($@)])\r
+\r
+\r
+# m4_define_default(MACRO, VALUE)\r
+# -------------------------------\r
+# If MACRO is undefined, set it to VALUE.\r
+m4_define([m4_define_default],\r
+[m4_ifndef([$1], [m4_define($@)])])\r
+\r
+\r
+# m4_default(EXP1, EXP2)\r
+# m4_default_nblank(EXP1, EXP2)\r
+# -----------------------------\r
+# Returns EXP1 if not empty/blank, otherwise EXP2. Expand the result.\r
+#\r
+# m4_default is called on hot paths, so inline the contents of m4_ifval,\r
+# for one less round of expansion.\r
+m4_define([m4_default],\r
+[m4_if([$1], [], [$2], [$1])])\r
+\r
+m4_define([m4_default_nblank],\r
+[m4_ifblank([$1], [$2], [$1])])\r
+\r
+\r
+# m4_default_quoted(EXP1, EXP2)\r
+# m4_default_nblank_quoted(EXP1, EXP2)\r
+# ------------------------------------\r
+# Returns EXP1 if non empty/blank, otherwise EXP2. Leave the result quoted.\r
+#\r
+# For comparison:\r
+# m4_define([active], [ACTIVE])\r
+# m4_default([active], [default]) => ACTIVE\r
+# m4_default([], [active]) => ACTIVE\r
+# -m4_default([ ], [active])- => - -\r
+# -m4_default_nblank([ ], [active])- => -ACTIVE-\r
+# m4_default_quoted([active], [default]) => active\r
+# m4_default_quoted([], [active]) => active\r
+# -m4_default_quoted([ ], [active])- => - -\r
+# -m4_default_nblank_quoted([ ], [active])- => -active-\r
+#\r
+# m4_default macro is called on hot paths, so inline the contents of m4_ifval,\r
+# for one less round of expansion.\r
+m4_define([m4_default_quoted],\r
+[m4_if([$1], [], [[$2]], [[$1]])])\r
+\r
+m4_define([m4_default_nblank_quoted],\r
+[m4_ifblank([$1], [[$2]], [[$1]])])\r
+\r
+\r
+# m4_defn(NAME)\r
+# -------------\r
+# Like the original, except guarantee a warning when using something which is\r
+# undefined (unlike M4 1.4.x). This replacement is not a full-featured\r
+# replacement: if any of the defined macros contain unbalanced quoting, but\r
+# when pasted together result in a well-quoted string, then only native m4\r
+# support is able to get it correct. But that's where quadrigraphs come in\r
+# handy, if you really need unbalanced quotes inside your macros.\r
+#\r
+# This macro is called frequently, so minimize the amount of additional\r
+# expansions by skipping m4_ifndef. Better yet, if __m4_version__ exists,\r
+# (added in M4 1.6), then let m4 do the job for us (see m4_init).\r
+m4_define([m4_defn],\r
+[m4_if([$#], [0], [[$0]],\r
+ [$#], [1], [m4_ifdef([$1], [_m4_defn([$1])],\r
+ [m4_fatal([$0: undefined macro: $1])])],\r
+ [m4_map_args([$0], $@)])])\r
+\r
+\r
+# m4_dumpdef(NAME...)\r
+# -------------------\r
+# In m4 1.4.x, dumpdef writes to the current debugfile, rather than\r
+# stderr. This in turn royally confuses autom4te; so we follow the\r
+# lead of newer m4 and always dump to stderr. Unlike the original,\r
+# this version requires an argument, since there is no convenient way\r
+# in m4 1.4.x to grab the names of all defined macros. Newer m4\r
+# always dumps to stderr, regardless of the current debugfile; it also\r
+# provides m4symbols as a way to grab all current macro names. But\r
+# dumpdefs is not frequently called, so we don't need to worry about\r
+# conditionally using these newer features. Also, this version\r
+# doesn't sort multiple arguments.\r
+#\r
+# If we detect m4 1.6 or newer, then provide an alternate definition,\r
+# installed during m4_init, that allows builtins through.\r
+# Unfortunately, there is no nice way in m4 1.4.x to dump builtins.\r
+m4_define([m4_dumpdef],\r
+[m4_if([$#], [0], [m4_fatal([$0: missing argument])],\r
+ [$#], [1], [m4_ifdef([$1], [m4_errprintn(\r
+ [$1: ]m4_dquote(_m4_defn([$1])))], [m4_fatal([$0: undefined macro: $1])])],\r
+ [m4_map_args([$0], $@)])])\r
+\r
+m4_define([_m4_dumpdef],\r
+[m4_if([$#], [0], [m4_fatal([$0: missing argument])],\r
+ [$#], [1], [m4_builtin([dumpdef], [$1])],\r
+ [m4_map_args_sep([m4_builtin([dumpdef],], [)], [], $@)])])\r
+\r
+\r
+# m4_dumpdefs(NAME...)\r
+# --------------------\r
+# Similar to `m4_dumpdef(NAME)', but if NAME was m4_pushdef'ed, display its\r
+# value stack (most recent displayed first). Also, this version silently\r
+# ignores undefined macros, rather than erroring out.\r
+#\r
+# This macro cheats, because it relies on the current definition of NAME\r
+# while the second argument of m4_stack_foreach_lifo is evaluated (which\r
+# would be undefined according to the API).\r
+m4_define([m4_dumpdefs],\r
+[m4_if([$#], [0], [m4_fatal([$0: missing argument])],\r
+ [$#], [1], [m4_stack_foreach_lifo([$1], [m4_dumpdef([$1])m4_ignore])],\r
+ [m4_map_args([$0], $@)])])\r
+\r
+# m4_esyscmd_s(COMMAND)\r
+# ---------------------\r
+# Like m4_esyscmd, except strip any trailing newlines, thus behaving\r
+# more like shell command substitution.\r
+m4_define([m4_esyscmd_s],\r
+[m4_chomp_all(m4_esyscmd([$1]))])\r
+\r
+\r
+# m4_popdef(NAME)\r
+# ---------------\r
+# Like the original, except guarantee a warning when using something which is\r
+# undefined (unlike M4 1.4.x).\r
+#\r
+# This macro is called frequently, so minimize the amount of additional\r
+# expansions by skipping m4_ifndef. Better yet, if __m4_version__ exists,\r
+# (added in M4 1.6), then let m4 do the job for us (see m4_init).\r
+m4_define([m4_popdef],\r
+[m4_if([$#], [0], [[$0]],\r
+ [$#], [1], [m4_ifdef([$1], [_m4_popdef([$1])],\r
+ [m4_fatal([$0: undefined macro: $1])])],\r
+ [m4_map_args([$0], $@)])])\r
+\r
+\r
+# m4_shiftn(N, ...)\r
+# -----------------\r
+# Returns ... shifted N times. Useful for recursive "varargs" constructs.\r
+#\r
+# Autoconf does not use this macro, because it is inherently slower than\r
+# calling the common cases of m4_shift2 or m4_shift3 directly. But it\r
+# might as well be fast for other clients, such as Libtool. One way to\r
+# do this is to expand $@ only once in _m4_shiftn (otherwise, for long\r
+# lists, the expansion of m4_if takes twice as much memory as what the\r
+# list itself occupies, only to throw away the unused branch). The end\r
+# result is strictly equivalent to\r
+# m4_if([$1], 1, [m4_shift(,m4_shift(m4_shift($@)))],\r
+# [_m4_shiftn(m4_decr([$1]), m4_shift(m4_shift($@)))])\r
+# but with the final `m4_shift(m4_shift($@)))' shared between the two\r
+# paths. The first leg uses a no-op m4_shift(,$@) to balance out the ().\r
+#\r
+# Please keep foreach.m4 in sync with any adjustments made here.\r
+m4_define([m4_shiftn],\r
+[m4_assert(0 < $1 && $1 < $#)_$0($@)])\r
+\r
+m4_define([_m4_shiftn],\r
+[m4_if([$1], 1, [m4_shift(],\r
+ [$0(m4_decr([$1])]), m4_shift(m4_shift($@)))])\r
+\r
+# m4_shift2(...)\r
+# m4_shift3(...)\r
+# --------------\r
+# Returns ... shifted twice, and three times. Faster than m4_shiftn.\r
+m4_define([m4_shift2], [m4_shift(m4_shift($@))])\r
+m4_define([m4_shift3], [m4_shift(m4_shift(m4_shift($@)))])\r
+\r
+# _m4_shift2(...)\r
+# _m4_shift3(...)\r
+# ---------------\r
+# Like m4_shift2 or m4_shift3, except include a leading comma unless shifting\r
+# consumes all arguments. Why? Because in recursion, it is nice to\r
+# distinguish between 1 element left and 0 elements left, based on how many\r
+# arguments this shift expands to.\r
+m4_define([_m4_shift2],\r
+[m4_if([$#], [2], [],\r
+ [, m4_shift(m4_shift($@))])])\r
+m4_define([_m4_shift3],\r
+[m4_if([$#], [3], [],\r
+ [, m4_shift(m4_shift(m4_shift($@)))])])\r
+\r
+\r
+# m4_undefine(NAME)\r
+# -----------------\r
+# Like the original, except guarantee a warning when using something which is\r
+# undefined (unlike M4 1.4.x).\r
+#\r
+# This macro is called frequently, so minimize the amount of additional\r
+# expansions by skipping m4_ifndef. Better yet, if __m4_version__ exists,\r
+# (added in M4 1.6), then let m4 do the job for us (see m4_init).\r
+m4_define([m4_undefine],\r
+[m4_if([$#], [0], [[$0]],\r
+ [$#], [1], [m4_ifdef([$1], [_m4_undefine([$1])],\r
+ [m4_fatal([$0: undefined macro: $1])])],\r
+ [m4_map_args([$0], $@)])])\r
+\r
+# _m4_wrap(PRE, POST)\r
+# -------------------\r
+# Helper macro for m4_wrap and m4_wrap_lifo. Allows nested calls to\r
+# m4_wrap within wrapped text. Use _m4_defn and _m4_popdef for speed.\r
+m4_define([_m4_wrap],\r
+[m4_ifdef([$0_text],\r
+ [m4_define([$0_text], [$1]_m4_defn([$0_text])[$2])],\r
+ [m4_builtin([m4wrap], [m4_unquote(\r
+ _m4_defn([$0_text])_m4_popdef([$0_text]))])m4_define([$0_text], [$1$2])])])\r
+\r
+# m4_wrap(TEXT)\r
+# -------------\r
+# Append TEXT to the list of hooks to be executed at the end of input.\r
+# Whereas the order of the original may be LIFO in the underlying m4,\r
+# this version is always FIFO.\r
+m4_define([m4_wrap],\r
+[_m4_wrap([], [$1[]])])\r
+\r
+# m4_wrap_lifo(TEXT)\r
+# ------------------\r
+# Prepend TEXT to the list of hooks to be executed at the end of input.\r
+# Whereas the order of m4_wrap may be FIFO in the underlying m4, this\r
+# version is always LIFO.\r
+m4_define([m4_wrap_lifo],\r
+[_m4_wrap([$1[]])])\r
+\r
+## ------------------------- ##\r
+## 7. Quoting manipulation. ##\r
+## ------------------------- ##\r
+\r
+\r
+# m4_apply(MACRO, LIST)\r
+# ---------------------\r
+# Invoke MACRO, with arguments provided from the quoted list of\r
+# comma-separated quoted arguments. If LIST is empty, invoke MACRO\r
+# without arguments. The expansion will not be concatenated with\r
+# subsequent text.\r
+m4_define([m4_apply],\r
+[m4_if([$2], [], [$1], [$1($2)])[]])\r
+\r
+# _m4_apply(MACRO, LIST)\r
+# ----------------------\r
+# Like m4_apply, except do nothing if LIST is empty.\r
+m4_define([_m4_apply],\r
+[m4_if([$2], [], [], [$1($2)[]])])\r
+\r
+\r
+# m4_count(ARGS)\r
+# --------------\r
+# Return a count of how many ARGS are present.\r
+m4_define([m4_count], [$#])\r
+\r
+\r
+# m4_curry(MACRO, ARG...)\r
+# -----------------------\r
+# Perform argument currying. The expansion of this macro is another\r
+# macro that takes exactly one argument, appends it to the end of the\r
+# original ARG list, then invokes MACRO. For example:\r
+# m4_curry([m4_curry], [m4_reverse], [1])([2])([3]) => 3, 2, 1\r
+# Not quite as practical as m4_incr, but you could also do:\r
+# m4_define([add], [m4_eval(([$1]) + ([$2]))])\r
+# m4_define([add_one], [m4_curry([add], [1])])\r
+# add_one()([2]) => 3\r
+m4_define([m4_curry], [$1(m4_shift($@,)_$0])\r
+m4_define([_m4_curry], [[$1])])\r
+\r
+\r
+# m4_do(STRING, ...)\r
+# ------------------\r
+# This macro invokes all its arguments (in sequence, of course). It is\r
+# useful for making your macros more structured and readable by dropping\r
+# unnecessary dnl's and have the macros indented properly. No concatenation\r
+# occurs after a STRING; use m4_unquote(m4_join(,STRING)) for that.\r
+#\r
+# Please keep foreach.m4 in sync with any adjustments made here.\r
+m4_define([m4_do],\r
+[m4_if([$#], 0, [],\r
+ [$#], 1, [$1[]],\r
+ [$1[]$0(m4_shift($@))])])\r
+\r
+\r
+# m4_dquote(ARGS)\r
+# ---------------\r
+# Return ARGS as a quoted list of quoted arguments.\r
+m4_define([m4_dquote], [[$@]])\r
+\r
+\r
+# m4_dquote_elt(ARGS)\r
+# -------------------\r
+# Return ARGS as an unquoted list of double-quoted arguments.\r
+#\r
+# Please keep foreach.m4 in sync with any adjustments made here.\r
+m4_define([m4_dquote_elt],\r
+[m4_if([$#], [0], [],\r
+ [$#], [1], [[[$1]]],\r
+ [[[$1]],$0(m4_shift($@))])])\r
+\r
+\r
+# m4_echo(ARGS)\r
+# -------------\r
+# Return the ARGS, with the same level of quoting. Whitespace after\r
+# unquoted commas are consumed.\r
+m4_define([m4_echo], [$@])\r
+\r
+\r
+# m4_expand(ARG)\r
+# _m4_expand(ARG)\r
+# ---------------\r
+# Return the expansion of ARG as a single string. Unlike\r
+# m4_quote($1), this preserves whitespace following single-quoted\r
+# commas that appear within ARG. It also deals with shell case\r
+# statements.\r
+#\r
+# m4_define([active], [ACT, IVE])\r
+# m4_define([active2], [[ACT, IVE]])\r
+# m4_quote(active, active2)\r
+# => ACT,IVE,ACT, IVE\r
+# m4_expand([active, active2])\r
+# => ACT, IVE, ACT, IVE\r
+#\r
+# Unfortunately, due to limitations in m4, ARG must expand to\r
+# something with balanced quotes (use quadrigraphs to get around\r
+# this), and should not contain the unlikely delimiters -=<{( or\r
+# )}>=-. It is possible to have unbalanced quoted `(' or `)', as well\r
+# as unbalanced unquoted `)'. m4_expand can handle unterminated\r
+# comments or dnl on the final line, at the expense of speed; it also\r
+# aids in detecting attempts to incorrectly change the current\r
+# diversion inside ARG. Meanwhile, _m4_expand is faster but must be\r
+# given a terminated expansion, and has no safety checks for\r
+# mis-diverted text.\r
+#\r
+# Exploit that extra unquoted () will group unquoted commas and the\r
+# following whitespace. m4_bpatsubst can't handle newlines inside $1,\r
+# and m4_substr strips quoting. So we (ab)use m4_changequote, using\r
+# temporary quotes to remove the delimiters that conveniently included\r
+# the unquoted () that were added prior to the changequote.\r
+#\r
+# Thanks to shell case statements, too many people are prone to pass\r
+# underquoted `)', so we try to detect that by passing a marker as a\r
+# fourth argument; if the marker is not present, then we assume that\r
+# we encountered an early `)', and re-expand the first argument, but\r
+# this time with one more `(' in the second argument and in the\r
+# open-quote delimiter. We must also ignore the slop from the\r
+# previous try. The final macro is thus half line-noise, half art.\r
+m4_define([m4_expand],\r
+[m4_pushdef([m4_divert], _m4_defn([_m4_divert_unsafe]))]dnl\r
+[m4_pushdef([m4_divert_push], _m4_defn([_m4_divert_unsafe]))]dnl\r
+[m4_chomp(_$0([$1\r
+]))_m4_popdef([m4_divert], [m4_divert_push])])\r
+\r
+m4_define([_m4_expand], [$0_([$1], [(], -=<{($1)}>=-, [}>=-])])\r
+\r
+m4_define([_m4_expand_],\r
+[m4_if([$4], [}>=-],\r
+ [m4_changequote([-=<{$2], [)}>=-])$3m4_changequote([, ])],\r
+ [$0([$1], [($2], -=<{($2$1)}>=-, [}>=-])m4_ignore$2])])\r
+\r
+\r
+# m4_ignore(ARGS)\r
+# ---------------\r
+# Expands to nothing. Useful for conditionally ignoring an arbitrary\r
+# number of arguments (see _m4_list_cmp for an example).\r
+m4_define([m4_ignore])\r
+\r
+\r
+# m4_make_list(ARGS)\r
+# ------------------\r
+# Similar to m4_dquote, this creates a quoted list of quoted ARGS. This\r
+# version is less efficient than m4_dquote, but separates each argument\r
+# with a comma and newline, rather than just comma, for readability.\r
+# When developing an m4sugar algorithm, you could temporarily use\r
+# m4_pushdef([m4_dquote],m4_defn([m4_make_list]))\r
+# around your code to make debugging easier.\r
+m4_define([m4_make_list], [m4_join([,\r
+], m4_dquote_elt($@))])\r
+\r
+\r
+# m4_noquote(STRING)\r
+# ------------------\r
+# Return the result of ignoring all quotes in STRING and invoking the\r
+# macros it contains. Among other things, this is useful for enabling\r
+# macro invocations inside strings with [] blocks (for instance regexps\r
+# and help-strings). On the other hand, since all quotes are disabled,\r
+# any macro expanded during this time that relies on nested [] quoting\r
+# will likely crash and burn. This macro is seldom useful; consider\r
+# m4_unquote or m4_expand instead.\r
+m4_define([m4_noquote],\r
+[m4_changequote([-=<{(],[)}>=-])$1-=<{()}>=-m4_changequote([,])])\r
+\r
+\r
+# m4_quote(ARGS)\r
+# --------------\r
+# Return ARGS as a single argument. Any whitespace after unquoted commas\r
+# is stripped. There is always output, even when there were no arguments.\r
+#\r
+# It is important to realize the difference between `m4_quote(exp)' and\r
+# `[exp]': in the first case you obtain the quoted *result* of the\r
+# expansion of EXP, while in the latter you just obtain the string\r
+# `exp'.\r
+m4_define([m4_quote], [[$*]])\r
+\r
+\r
+# _m4_quote(ARGS)\r
+# ---------------\r
+# Like m4_quote, except that when there are no arguments, there is no\r
+# output. For conditional scenarios (such as passing _m4_quote as the\r
+# macro name in m4_mapall), this feature can be used to distinguish between\r
+# one argument of the empty string vs. no arguments. However, in the\r
+# normal case with arguments present, this is less efficient than m4_quote.\r
+m4_define([_m4_quote],\r
+[m4_if([$#], [0], [], [[$*]])])\r
+\r
+\r
+# m4_reverse(ARGS)\r
+# ----------------\r
+# Output ARGS in reverse order.\r
+#\r
+# Please keep foreach.m4 in sync with any adjustments made here.\r
+m4_define([m4_reverse],\r
+[m4_if([$#], [0], [], [$#], [1], [[$1]],\r
+ [$0(m4_shift($@)), [$1]])])\r
+\r
+\r
+# m4_unquote(ARGS)\r
+# ----------------\r
+# Remove one layer of quotes from each ARG, performing one level of\r
+# expansion. For one argument, m4_unquote([arg]) is more efficient than\r
+# m4_do([arg]), but for multiple arguments, the difference is that\r
+# m4_unquote separates arguments with commas while m4_do concatenates.\r
+# Follow this macro with [] if concatenation with subsequent text is\r
+# undesired.\r
+m4_define([m4_unquote], [$*])\r
+\r
+\r
+## -------------------------- ##\r
+## 8. Implementing m4 loops. ##\r
+## -------------------------- ##\r
+\r
+\r
+# m4_for(VARIABLE, FIRST, LAST, [STEP = +/-1], EXPRESSION)\r
+# --------------------------------------------------------\r
+# Expand EXPRESSION defining VARIABLE to FROM, FROM + 1, ..., TO with\r
+# increments of STEP. Both limits are included, and bounds are\r
+# checked for consistency. The algorithm is robust to indirect\r
+# VARIABLE names. Changing VARIABLE inside EXPRESSION will not impact\r
+# the number of iterations.\r
+#\r
+# Uses _m4_defn for speed, and avoid dnl in the macro body. Factor\r
+# the _m4_for call so that EXPRESSION is only parsed once.\r
+m4_define([m4_for],\r
+[m4_pushdef([$1], m4_eval([$2]))]dnl\r
+[m4_cond([m4_eval(([$3]) > ([$2]))], 1,\r
+ [m4_pushdef([_m4_step], m4_eval(m4_default_quoted([$4],\r
+ 1)))m4_assert(_m4_step > 0)_$0(_m4_defn([$1]),\r
+ m4_eval((([$3]) - ([$2])) / _m4_step * _m4_step + ([$2])), _m4_step,],\r
+ [m4_eval(([$3]) < ([$2]))], 1,\r
+ [m4_pushdef([_m4_step], m4_eval(m4_default_quoted([$4],\r
+ -1)))m4_assert(_m4_step < 0)_$0(_m4_defn([$1]),\r
+ m4_eval((([$2]) - ([$3])) / -(_m4_step) * _m4_step + ([$2])), _m4_step,],\r
+ [m4_pushdef([_m4_step])_$0(_m4_defn([$1]), _m4_defn([$1]), 0,])]dnl\r
+[[m4_define([$1],], [)$5])m4_popdef([_m4_step], [$1])])\r
+\r
+# _m4_for(COUNT, LAST, STEP, PRE, POST)\r
+# -------------------------------------\r
+# Core of the loop, no consistency checks, all arguments are plain\r
+# numbers. Expand PRE[COUNT]POST, then alter COUNT by STEP and\r
+# iterate if COUNT is not LAST.\r
+m4_define([_m4_for],\r
+[$4[$1]$5[]m4_if([$1], [$2], [],\r
+ [$0(m4_eval([$1 + $3]), [$2], [$3], [$4], [$5])])])\r
+\r
+\r
+# Implementing `foreach' loops in m4 is much more tricky than it may\r
+# seem. For example, the old M4 1.4.4 manual had an incorrect example,\r
+# which looked like this (when translated to m4sugar):\r
+#\r
+# | # foreach(VAR, (LIST), STMT)\r
+# | m4_define([foreach],\r
+# | [m4_pushdef([$1])_foreach([$1], [$2], [$3])m4_popdef([$1])])\r
+# | m4_define([_arg1], [$1])\r
+# | m4_define([_foreach],\r
+# | [m4_if([$2], [()], ,\r
+# | [m4_define([$1], _arg1$2)$3[]_foreach([$1], (m4_shift$2), [$3])])])\r
+#\r
+# But then if you run\r
+#\r
+# | m4_define(a, 1)\r
+# | m4_define(b, 2)\r
+# | m4_define(c, 3)\r
+# | foreach([f], [([a], [(b], [c)])], [echo f\r
+# | ])\r
+#\r
+# it gives\r
+#\r
+# => echo 1\r
+# => echo (2,3)\r
+#\r
+# which is not what is expected.\r
+#\r
+# Of course the problem is that many quotes are missing. So you add\r
+# plenty of quotes at random places, until you reach the expected\r
+# result. Alternatively, if you are a quoting wizard, you directly\r
+# reach the following implementation (but if you really did, then\r
+# apply to the maintenance of m4sugar!).\r
+#\r
+# | # foreach(VAR, (LIST), STMT)\r
+# | m4_define([foreach], [m4_pushdef([$1])_foreach($@)m4_popdef([$1])])\r
+# | m4_define([_arg1], [[$1]])\r
+# | m4_define([_foreach],\r
+# | [m4_if($2, [()], ,\r
+# | [m4_define([$1], [_arg1$2])$3[]_foreach([$1], [(m4_shift$2)], [$3])])])\r
+#\r
+# which this time answers\r
+#\r
+# => echo a\r
+# => echo (b\r
+# => echo c)\r
+#\r
+# Bingo!\r
+#\r
+# Well, not quite.\r
+#\r
+# With a better look, you realize that the parens are more a pain than\r
+# a help: since anyway you need to quote properly the list, you end up\r
+# with always using an outermost pair of parens and an outermost pair\r
+# of quotes. Rejecting the parens both eases the implementation, and\r
+# simplifies the use:\r
+#\r
+# | # foreach(VAR, (LIST), STMT)\r
+# | m4_define([foreach], [m4_pushdef([$1])_foreach($@)m4_popdef([$1])])\r
+# | m4_define([_arg1], [$1])\r
+# | m4_define([_foreach],\r
+# | [m4_if($2, [], ,\r
+# | [m4_define([$1], [_arg1($2)])$3[]_foreach([$1], [m4_shift($2)], [$3])])])\r
+#\r
+#\r
+# Now, just replace the `$2' with `m4_quote($2)' in the outer `m4_if'\r
+# to improve robustness, and you come up with a nice implementation\r
+# that doesn't require extra parentheses in the user's LIST.\r
+#\r
+# But wait - now the algorithm is quadratic, because every recursion of\r
+# the algorithm keeps the entire LIST and merely adds another m4_shift to\r
+# the quoted text. If the user has a lot of elements in LIST, you can\r
+# bring the system to its knees with the memory m4 then requires, or trip\r
+# the m4 --nesting-limit recursion factor. The only way to avoid\r
+# quadratic growth is ensure m4_shift is expanded prior to the recursion.\r
+# Hence the design below.\r
+#\r
+# The M4 manual now includes a chapter devoted to this issue, with\r
+# the lessons learned from m4sugar. And still, this design is only\r
+# optimal for M4 1.6; see foreach.m4 for yet more comments on why\r
+# M4 1.4.x uses yet another implementation.\r
+\r
+\r
+# m4_foreach(VARIABLE, LIST, EXPRESSION)\r
+# --------------------------------------\r
+#\r
+# Expand EXPRESSION assigning each value of the LIST to VARIABLE.\r
+# LIST should have the form `item_1, item_2, ..., item_n', i.e. the\r
+# whole list must *quoted*. Quote members too if you don't want them\r
+# to be expanded.\r
+#\r
+# This macro is robust to active symbols:\r
+# | m4_define(active, [ACT, IVE])\r
+# | m4_foreach(Var, [active, active], [-Var-])\r
+# => -ACT--IVE--ACT--IVE-\r
+#\r
+# | m4_foreach(Var, [[active], [active]], [-Var-])\r
+# => -ACT, IVE--ACT, IVE-\r
+#\r
+# | m4_foreach(Var, [[[active]], [[active]]], [-Var-])\r
+# => -active--active-\r
+#\r
+# This macro is called frequently, so avoid extra expansions such as\r
+# m4_ifval and dnl. Also, since $2 might be quite large, try to use it\r
+# as little as possible in _m4_foreach; each extra use requires that much\r
+# more memory for expansion. So, rather than directly compare $2 against\r
+# [] and use m4_car/m4_cdr for recursion, we instead unbox the list (which\r
+# requires swapping the argument order in the helper), insert an ignored\r
+# third argument, and use m4_shift3 to detect when recursion is complete,\r
+# at which point this looks very much like m4_map_args.\r
+m4_define([m4_foreach],\r
+[m4_if([$2], [], [],\r
+ [m4_pushdef([$1])_$0([m4_define([$1],], [)$3], [],\r
+ $2)m4_popdef([$1])])])\r
+\r
+# _m4_foreach(PRE, POST, IGNORED, ARG...)\r
+# ---------------------------------------\r
+# Form the common basis of the m4_foreach and m4_map macros. For each\r
+# ARG, expand PRE[ARG]POST[]. The IGNORED argument makes recursion\r
+# easier, and must be supplied rather than implicit.\r
+#\r
+# Please keep foreach.m4 in sync with any adjustments made here.\r
+m4_define([_m4_foreach],\r
+[m4_if([$#], [3], [],\r
+ [$1[$4]$2[]$0([$1], [$2], m4_shift3($@))])])\r
+\r
+\r
+# m4_foreach_w(VARIABLE, LIST, EXPRESSION)\r
+# ----------------------------------------\r
+# Like m4_foreach, but the list is whitespace separated. Depending on\r
+# EXPRESSION, it may be more efficient to use m4_map_args_w.\r
+#\r
+# This macro is robust to active symbols:\r
+# m4_foreach_w([Var], [ active\r
+# b act\\r
+# ive ], [-Var-])end\r
+# => -active--b--active-end\r
+#\r
+# This used to use a slower implementation based on m4_foreach:\r
+# m4_foreach([$1], m4_split(m4_normalize([$2]), [ ]), [$3])\r
+m4_define([m4_foreach_w],\r
+[m4_pushdef([$1])m4_map_args_w([$2],\r
+ [m4_define([$1],], [)$3])m4_popdef([$1])])\r
+\r
+\r
+# m4_map(MACRO, LIST)\r
+# m4_mapall(MACRO, LIST)\r
+# ----------------------\r
+# Invoke MACRO($1), MACRO($2) etc. where $1, $2... are the elements of\r
+# LIST. $1, $2... must in turn be lists, appropriate for m4_apply.\r
+# If LIST contains an empty sublist, m4_map skips the expansion of\r
+# MACRO, while m4_mapall expands MACRO with no arguments.\r
+#\r
+# Since LIST may be quite large, we want to minimize how often it\r
+# appears in the expansion. Rather than use m4_car/m4_cdr iteration,\r
+# we unbox the list, and use _m4_foreach for iteration. For m4_map,\r
+# an empty list behaves like an empty sublist and gets ignored; for\r
+# m4_mapall, we must special-case the empty list.\r
+m4_define([m4_map],\r
+[_m4_foreach([_m4_apply([$1],], [)], [], $2)])\r
+\r
+m4_define([m4_mapall],\r
+[m4_if([$2], [], [],\r
+ [_m4_foreach([m4_apply([$1],], [)], [], $2)])])\r
+\r
+\r
+# m4_map_sep(MACRO, [SEPARATOR], LIST)\r
+# m4_mapall_sep(MACRO, [SEPARATOR], LIST)\r
+# ---------------------------------------\r
+# Invoke MACRO($1), SEPARATOR, MACRO($2), ..., MACRO($N) where $1,\r
+# $2... $N are the elements of LIST, and are in turn lists appropriate\r
+# for m4_apply. SEPARATOR is expanded, in order to allow the creation\r
+# of a list of arguments by using a single-quoted comma as the\r
+# separator. For each empty sublist, m4_map_sep skips the expansion\r
+# of MACRO and SEPARATOR, while m4_mapall_sep expands MACRO with no\r
+# arguments.\r
+#\r
+# For m4_mapall_sep, merely expand the first iteration without the\r
+# separator, then include separator as part of subsequent recursion;\r
+# but avoid extra expansion of LIST's side-effects via a helper macro.\r
+# For m4_map_sep, things are trickier - we don't know if the first\r
+# list element is an empty sublist, so we must define a self-modifying\r
+# helper macro and use that as the separator instead.\r
+m4_define([m4_map_sep],\r
+[m4_pushdef([m4_Sep], [m4_define([m4_Sep], _m4_defn([m4_unquote]))])]dnl\r
+[_m4_foreach([_m4_apply([m4_Sep([$2])[]$1],], [)], [], $3)m4_popdef([m4_Sep])])\r
+\r
+m4_define([m4_mapall_sep],\r
+[m4_if([$3], [], [], [_$0([$1], [$2], $3)])])\r
+\r
+m4_define([_m4_mapall_sep],\r
+[m4_apply([$1], [$3])_m4_foreach([m4_apply([$2[]$1],], [)], m4_shift2($@))])\r
+\r
+# m4_map_args(EXPRESSION, ARG...)\r
+# -------------------------------\r
+# Expand EXPRESSION([ARG]) for each argument. More efficient than\r
+# m4_foreach([var], [ARG...], [EXPRESSION(m4_defn([var]))])\r
+# Shorthand for m4_map_args_sep([EXPRESSION(], [)], [], ARG...).\r
+m4_define([m4_map_args],\r
+[m4_if([$#], [0], [m4_fatal([$0: too few arguments: $#])],\r
+ [$#], [1], [],\r
+ [$#], [2], [$1([$2])[]],\r
+ [_m4_foreach([$1(], [)], $@)])])\r
+\r
+\r
+# m4_map_args_pair(EXPRESSION, [END-EXPR = EXPRESSION], ARG...)\r
+# -------------------------------------------------------------\r
+# Perform a pairwise grouping of consecutive ARGs, by expanding\r
+# EXPRESSION([ARG1], [ARG2]). If there are an odd number of ARGs, the\r
+# final argument is expanded with END-EXPR([ARGn]).\r
+#\r
+# For example:\r
+# m4_define([show], [($*)m4_newline])dnl\r
+# m4_map_args_pair([show], [], [a], [b], [c], [d], [e])dnl\r
+# => (a,b)\r
+# => (c,d)\r
+# => (e)\r
+#\r
+# Please keep foreach.m4 in sync with any adjustments made here.\r
+m4_define([m4_map_args_pair],\r
+[m4_if([$#], [0], [m4_fatal([$0: too few arguments: $#])],\r
+ [$#], [1], [m4_fatal([$0: too few arguments: $#: $1])],\r
+ [$#], [2], [],\r
+ [$#], [3], [m4_default([$2], [$1])([$3])[]],\r
+ [$#], [4], [$1([$3], [$4])[]],\r
+ [$1([$3], [$4])[]$0([$1], [$2], m4_shift(m4_shift3($@)))])])\r
+\r
+\r
+# m4_map_args_sep([PRE], [POST], [SEP], ARG...)\r
+# ---------------------------------------------\r
+# Expand PRE[ARG]POST for each argument, with SEP between arguments.\r
+m4_define([m4_map_args_sep],\r
+[m4_if([$#], [0], [m4_fatal([$0: too few arguments: $#])],\r
+ [$#], [1], [],\r
+ [$#], [2], [],\r
+ [$#], [3], [],\r
+ [$#], [4], [$1[$4]$2[]],\r
+ [$1[$4]$2[]_m4_foreach([$3[]$1], [$2], m4_shift3($@))])])\r
+\r
+\r
+# m4_map_args_w(STRING, [PRE], [POST], [SEP])\r
+# -------------------------------------------\r
+# Perform the expansion of PRE[word]POST[] for each word in STRING\r
+# separated by whitespace. More efficient than:\r
+# m4_foreach_w([var], [STRING], [PRE[]m4_defn([var])POST])\r
+# Additionally, expand SEP between words.\r
+#\r
+# As long as we have to use m4_bpatsubst to split the string, we might\r
+# as well make it also apply PRE and POST; this avoids iteration\r
+# altogether. But we must be careful of any \ in PRE or POST.\r
+# _m4_strip returns a quoted string, but that's okay, since it also\r
+# supplies an empty leading and trailing argument due to our\r
+# intentional whitespace around STRING. We use m4_substr to strip the\r
+# empty elements and remove the extra layer of quoting.\r
+m4_define([m4_map_args_w],\r
+[_$0(_m4_split([ ]m4_flatten([$1])[ ], [[ ]+],\r
+ m4_if(m4_index([$2$3$4], [\]), [-1], [[$3[]$4[]$2]],\r
+ [m4_bpatsubst([[$3[]$4[]$2]], [\\], [\\\\])])),\r
+ m4_len([[]$3[]$4]), m4_len([$4[]$2[]]))])\r
+\r
+m4_define([_m4_map_args_w],\r
+[m4_substr([$1], [$2], m4_eval(m4_len([$1]) - [$2] - [$3]))])\r
+\r
+\r
+# m4_stack_foreach(MACRO, FUNC)\r
+# m4_stack_foreach_lifo(MACRO, FUNC)\r
+# ----------------------------------\r
+# Pass each stacked definition of MACRO to the one-argument macro FUNC.\r
+# m4_stack_foreach proceeds in FIFO order, while m4_stack_foreach_lifo\r
+# processes the topmost definitions first. In addition, FUNC should\r
+# not push or pop definitions of MACRO, and should not expect anything about\r
+# the active definition of MACRO (it will not be the topmost, and may not\r
+# be the one passed to FUNC either).\r
+#\r
+# Some macros simply can't be examined with this method: namely,\r
+# anything involved in the implementation of _m4_stack_reverse.\r
+m4_define([m4_stack_foreach],\r
+[_m4_stack_reverse([$1], [m4_tmp-$1])]dnl\r
+[_m4_stack_reverse([m4_tmp-$1], [$1], [$2(_m4_defn([m4_tmp-$1]))])])\r
+\r
+m4_define([m4_stack_foreach_lifo],\r
+[_m4_stack_reverse([$1], [m4_tmp-$1], [$2(_m4_defn([m4_tmp-$1]))])]dnl\r
+[_m4_stack_reverse([m4_tmp-$1], [$1])])\r
+\r
+# m4_stack_foreach_sep(MACRO, [PRE], [POST], [SEP])\r
+# m4_stack_foreach_sep_lifo(MACRO, [PRE], [POST], [SEP])\r
+# ------------------------------------------------------\r
+# Similar to m4_stack_foreach and m4_stack_foreach_lifo, in that every\r
+# definition of a pushdef stack will be visited. But rather than\r
+# passing the definition as a single argument to a macro, this variant\r
+# expands the concatenation of PRE[]definition[]POST, and expands SEP\r
+# between consecutive expansions. Note that m4_stack_foreach([a], [b])\r
+# is equivalent to m4_stack_foreach_sep([a], [b(], [)]).\r
+m4_define([m4_stack_foreach_sep],\r
+[_m4_stack_reverse([$1], [m4_tmp-$1])]dnl\r
+[_m4_stack_reverse([m4_tmp-$1], [$1], [$2[]_m4_defn([m4_tmp-$1])$3], [$4[]])])\r
+\r
+m4_define([m4_stack_foreach_sep_lifo],\r
+[_m4_stack_reverse([$1], [m4_tmp-$1], [$2[]_m4_defn([m4_tmp-$1])$3], [$4[]])]dnl\r
+[_m4_stack_reverse([m4_tmp-$1], [$1])])\r
+\r
+\r
+# _m4_stack_reverse(OLD, NEW, [ACTION], [SEP])\r
+# --------------------------------------------\r
+# A recursive worker for pushdef stack manipulation. Destructively\r
+# copy the OLD stack into the NEW, and expanding ACTION for each\r
+# iteration. After the first iteration, SEP is promoted to the front\r
+# of ACTION (note that SEP should include a trailing [] if it is to\r
+# avoid interfering with ACTION). The current definition is examined\r
+# after the NEW has been pushed but before OLD has been popped; this\r
+# order is important, as ACTION is permitted to operate on either\r
+# _m4_defn([OLD]) or _m4_defn([NEW]). Since the operation is\r
+# destructive, this macro is generally used twice, with a temporary\r
+# macro name holding the swapped copy.\r
+m4_define([_m4_stack_reverse],\r
+[m4_ifdef([$1], [m4_pushdef([$2],\r
+ _m4_defn([$1]))$3[]_m4_popdef([$1])$0([$1], [$2], [$4$3])])])\r
+\r
+\r
+\r
+## --------------------------- ##\r
+## 9. More diversion support. ##\r
+## --------------------------- ##\r
+\r
+\r
+# m4_cleardivert(DIVERSION-NAME...)\r
+# ---------------------------------\r
+# Discard any text in DIVERSION-NAME.\r
+#\r
+# This works even inside m4_expand.\r
+m4_define([m4_cleardivert],\r
+[m4_if([$#], [0], [m4_fatal([$0: missing argument])],\r
+ [_m4_divert_raw([-1])m4_undivert($@)_m4_divert_raw(\r
+ _m4_divert(_m4_defn([_m4_divert_diversion]), [-]))])])\r
+\r
+\r
+# _m4_divert(DIVERSION-NAME or NUMBER, [NOWARN])\r
+# ----------------------------------------------\r
+# If DIVERSION-NAME is the name of a diversion, return its number,\r
+# otherwise if it is a NUMBER return it. Issue a warning about\r
+# the use of a number instead of a name, unless NOWARN is provided.\r
+m4_define([_m4_divert],\r
+[m4_ifdef([_m4_divert($1)],\r
+ [m4_indir([_m4_divert($1)])],\r
+ [m4_if([$2], [], [m4_warn([syntax],\r
+ [prefer named diversions])])$1])])\r
+\r
+# KILL is only used to suppress output.\r
+m4_define([_m4_divert(KILL)], -1)\r
+\r
+# The empty diversion name is a synonym for 0.\r
+m4_define([_m4_divert()], 0)\r
+\r
+\r
+# m4_divert_stack\r
+# ---------------\r
+# Print the diversion stack, if it's nonempty. The caller is\r
+# responsible for any leading or trailing newline.\r
+m4_define([m4_divert_stack],\r
+[m4_stack_foreach_sep_lifo([_m4_divert_stack], [], [], [\r
+])])\r
+\r
+\r
+# m4_divert_stack_push(MACRO-NAME, DIVERSION-NAME)\r
+# ------------------------------------------------\r
+# Form an entry of the diversion stack from caller MACRO-NAME and\r
+# entering DIVERSION-NAME and push it.\r
+m4_define([m4_divert_stack_push],\r
+[m4_pushdef([_m4_divert_stack], m4_location[: $1: $2])])\r
+\r
+\r
+# m4_divert(DIVERSION-NAME)\r
+# -------------------------\r
+# Change the diversion stream to DIVERSION-NAME.\r
+m4_define([m4_divert],\r
+[m4_popdef([_m4_divert_stack])]dnl\r
+[m4_define([_m4_divert_diversion], [$1])]dnl\r
+[m4_divert_stack_push([$0], [$1])]dnl\r
+[_m4_divert_raw(_m4_divert([$1]))])\r
+\r
+\r
+# m4_divert_push(DIVERSION-NAME, [NOWARN])\r
+# ----------------------------------------\r
+# Change the diversion stream to DIVERSION-NAME, while stacking old values.\r
+# For internal use only: if NOWARN is not empty, DIVERSION-NAME can be a\r
+# number instead of a name.\r
+m4_define([m4_divert_push],\r
+[m4_divert_stack_push([$0], [$1])]dnl\r
+[m4_pushdef([_m4_divert_diversion], [$1])]dnl\r
+[_m4_divert_raw(_m4_divert([$1], [$2]))])\r
+\r
+\r
+# m4_divert_pop([DIVERSION-NAME])\r
+# -------------------------------\r
+# Change the diversion stream to its previous value, unstacking it.\r
+# If specified, verify we left DIVERSION-NAME.\r
+# When we pop the last value from the stack, we divert to -1.\r
+m4_define([m4_divert_pop],\r
+[m4_if([$1], [], [],\r
+ [$1], _m4_defn([_m4_divert_diversion]), [],\r
+ [m4_fatal([$0($1): diversion mismatch:\r
+]m4_divert_stack)])]dnl\r
+[_m4_popdef([_m4_divert_stack], [_m4_divert_diversion])]dnl\r
+[m4_ifdef([_m4_divert_diversion], [],\r
+ [m4_fatal([too many m4_divert_pop])])]dnl\r
+[_m4_divert_raw(_m4_divert(_m4_defn([_m4_divert_diversion]), [-]))])\r
+\r
+\r
+# m4_divert_text(DIVERSION-NAME, CONTENT)\r
+# ---------------------------------------\r
+# Output CONTENT into DIVERSION-NAME (which may be a number actually).\r
+# An end of line is appended for free to CONTENT.\r
+m4_define([m4_divert_text],\r
+[m4_divert_push([$1])$2\r
+m4_divert_pop([$1])])\r
+\r
+\r
+# m4_divert_once(DIVERSION-NAME, CONTENT)\r
+# ---------------------------------------\r
+# Output CONTENT into DIVERSION-NAME once, if not already there.\r
+# An end of line is appended for free to CONTENT.\r
+m4_define([m4_divert_once],\r
+[m4_expand_once([m4_divert_text([$1], [$2])])])\r
+\r
+\r
+# _m4_divert_unsafe(DIVERSION-NAME)\r
+# ---------------------------------\r
+# Issue a warning that the attempt to change the current diversion to\r
+# DIVERSION-NAME is unsafe, because this macro is being expanded\r
+# during argument collection of m4_expand.\r
+m4_define([_m4_divert_unsafe],\r
+[m4_fatal([$0: cannot change diversion to `$1' inside m4_expand])])\r
+\r
+\r
+# m4_undivert(DIVERSION-NAME...)\r
+# ------------------------------\r
+# Undivert DIVERSION-NAME. Unlike the M4 version, this requires at\r
+# least one DIVERSION-NAME; also, due to support for named diversions,\r
+# this should not be used to undivert files.\r
+m4_define([m4_undivert],\r
+[m4_if([$#], [0], [m4_fatal([$0: missing argument])],\r
+ [$#], [1], [_m4_undivert(_m4_divert([$1]))],\r
+ [m4_map_args([$0], $@)])])\r
+\r
+\r
+## --------------------------------------------- ##\r
+## 10. Defining macros with bells and whistles. ##\r
+## --------------------------------------------- ##\r
+\r
+# `m4_defun' is basically `m4_define' but it equips the macro with the\r
+# needed machinery for `m4_require'. A macro must be m4_defun'd if\r
+# either it is m4_require'd, or it m4_require's.\r
+#\r
+# Two things deserve attention and are detailed below:\r
+# 1. Implementation of m4_require\r
+# 2. Keeping track of the expansion stack\r
+#\r
+# 1. Implementation of m4_require\r
+# ===============================\r
+#\r
+# Of course m4_defun calls m4_provide, so that a macro which has\r
+# been expanded is not expanded again when m4_require'd, but the\r
+# difficult part is the proper expansion of macros when they are\r
+# m4_require'd.\r
+#\r
+# The implementation is based on three ideas, (i) using diversions to\r
+# prepare the expansion of the macro and its dependencies (by Franc,ois\r
+# Pinard), (ii) expand the most recently m4_require'd macros _after_\r
+# the previous macros (by Axel Thimm), and (iii) track instances of\r
+# provide before require (by Eric Blake).\r
+#\r
+#\r
+# The first idea: why use diversions?\r
+# -----------------------------------\r
+#\r
+# When a macro requires another, the other macro is expanded in new\r
+# diversion, GROW. When the outer macro is fully expanded, we first\r
+# undivert the most nested diversions (GROW - 1...), and finally\r
+# undivert GROW. To understand why we need several diversions,\r
+# consider the following example:\r
+#\r
+# | m4_defun([TEST1], [Test...m4_require([TEST2])1])\r
+# | m4_defun([TEST2], [Test...m4_require([TEST3])2])\r
+# | m4_defun([TEST3], [Test...3])\r
+#\r
+# Because m4_require is not required to be first in the outer macros, we\r
+# must keep the expansions of the various levels of m4_require separated.\r
+# Right before executing the epilogue of TEST1, we have:\r
+#\r
+# GROW - 2: Test...3\r
+# GROW - 1: Test...2\r
+# GROW: Test...1\r
+# BODY:\r
+#\r
+# Finally the epilogue of TEST1 undiverts GROW - 2, GROW - 1, and\r
+# GROW into the regular flow, BODY.\r
+#\r
+# GROW - 2:\r
+# GROW - 1:\r
+# GROW:\r
+# BODY: Test...3; Test...2; Test...1\r
+#\r
+# (The semicolons are here for clarification, but of course are not\r
+# emitted.) This is what Autoconf 2.0 (I think) to 2.13 (I'm sure)\r
+# implement.\r
+#\r
+#\r
+# The second idea: first required first out\r
+# -----------------------------------------\r
+#\r
+# The natural implementation of the idea above is buggy and produces\r
+# very surprising results in some situations. Let's consider the\r
+# following example to explain the bug:\r
+#\r
+# | m4_defun([TEST1], [m4_require([TEST2a])m4_require([TEST2b])])\r
+# | m4_defun([TEST2a], [])\r
+# | m4_defun([TEST2b], [m4_require([TEST3])])\r
+# | m4_defun([TEST3], [m4_require([TEST2a])])\r
+# |\r
+# | AC_INIT\r
+# | TEST1\r
+#\r
+# The dependencies between the macros are:\r
+#\r
+# 3 --- 2b\r
+# / \ is m4_require'd by\r
+# / \ left -------------------- right\r
+# 2a ------------ 1\r
+#\r
+# If you strictly apply the rules given in the previous section you get:\r
+#\r
+# GROW - 2: TEST3\r
+# GROW - 1: TEST2a; TEST2b\r
+# GROW: TEST1\r
+# BODY:\r
+#\r
+# (TEST2a, although required by TEST3 is not expanded in GROW - 3\r
+# because is has already been expanded before in GROW - 1, so it has\r
+# been AC_PROVIDE'd, so it is not expanded again) so when you undivert\r
+# the stack of diversions, you get:\r
+#\r
+# GROW - 2:\r
+# GROW - 1:\r
+# GROW:\r
+# BODY: TEST3; TEST2a; TEST2b; TEST1\r
+#\r
+# i.e., TEST2a is expanded after TEST3 although the latter required the\r
+# former.\r
+#\r
+# Starting from 2.50, we use an implementation provided by Axel Thimm.\r
+# The idea is simple: the order in which macros are emitted must be the\r
+# same as the one in which macros are expanded. (The bug above can\r
+# indeed be described as: a macro has been m4_provide'd before its\r
+# dependent, but it is emitted after: the lack of correlation between\r
+# emission and expansion order is guilty).\r
+#\r
+# How to do that? You keep the stack of diversions to elaborate the\r
+# macros, but each time a macro is fully expanded, emit it immediately.\r
+#\r
+# In the example above, when TEST2a is expanded, but it's epilogue is\r
+# not run yet, you have:\r
+#\r
+# GROW - 2:\r
+# GROW - 1: TEST2a\r
+# GROW: Elaboration of TEST1\r
+# BODY:\r
+#\r
+# The epilogue of TEST2a emits it immediately:\r
+#\r
+# GROW - 2:\r
+# GROW - 1:\r
+# GROW: Elaboration of TEST1\r
+# BODY: TEST2a\r
+#\r
+# TEST2b then requires TEST3, so right before the epilogue of TEST3, you\r
+# have:\r
+#\r
+# GROW - 2: TEST3\r
+# GROW - 1: Elaboration of TEST2b\r
+# GROW: Elaboration of TEST1\r
+# BODY: TEST2a\r
+#\r
+# The epilogue of TEST3 emits it:\r
+#\r
+# GROW - 2:\r
+# GROW - 1: Elaboration of TEST2b\r
+# GROW: Elaboration of TEST1\r
+# BODY: TEST2a; TEST3\r
+#\r
+# TEST2b is now completely expanded, and emitted:\r
+#\r
+# GROW - 2:\r
+# GROW - 1:\r
+# GROW: Elaboration of TEST1\r
+# BODY: TEST2a; TEST3; TEST2b\r
+#\r
+# and finally, TEST1 is finished and emitted:\r
+#\r
+# GROW - 2:\r
+# GROW - 1:\r
+# GROW:\r
+# BODY: TEST2a; TEST3; TEST2b: TEST1\r
+#\r
+# The idea is simple, but the implementation is a bit involved. If\r
+# you are like me, you will want to see the actual functioning of this\r
+# implementation to be convinced. The next section gives the full\r
+# details.\r
+#\r
+#\r
+# The Axel Thimm implementation at work\r
+# -------------------------------------\r
+#\r
+# We consider the macros above, and this configure.ac:\r
+#\r
+# AC_INIT\r
+# TEST1\r
+#\r
+# You should keep the definitions of _m4_defun_pro, _m4_defun_epi, and\r
+# m4_require at hand to follow the steps.\r
+#\r
+# This implementation tries not to assume that the current diversion is\r
+# BODY, so as soon as a macro (m4_defun'd) is expanded, we first\r
+# record the current diversion under the name _m4_divert_dump (denoted\r
+# DUMP below for short). This introduces an important difference with\r
+# the previous versions of Autoconf: you cannot use m4_require if you\r
+# are not inside an m4_defun'd macro, and especially, you cannot\r
+# m4_require directly from the top level.\r
+#\r
+# We have not tried to simulate the old behavior (better yet, we\r
+# diagnose it), because it is too dangerous: a macro m4_require'd from\r
+# the top level is expanded before the body of `configure', i.e., before\r
+# any other test was run. I let you imagine the result of requiring\r
+# AC_STDC_HEADERS for instance, before AC_PROG_CC was actually run....\r
+#\r
+# After AC_INIT was run, the current diversion is BODY.\r
+# * AC_INIT was run\r
+# DUMP: undefined\r
+# diversion stack: BODY |-\r
+#\r
+# * TEST1 is expanded\r
+# The prologue of TEST1 sets _m4_divert_dump, which is the diversion\r
+# where the current elaboration will be dumped, to the current\r
+# diversion. It also m4_divert_push to GROW, where the full\r
+# expansion of TEST1 and its dependencies will be elaborated.\r
+# DUMP: BODY\r
+# BODY: empty\r
+# diversions: GROW, BODY |-\r
+#\r
+# * TEST1 requires TEST2a\r
+# _m4_require_call m4_divert_pushes another temporary diversion,\r
+# GROW - 1, and expands TEST2a in there.\r
+# DUMP: BODY\r
+# BODY: empty\r
+# GROW - 1: TEST2a\r
+# diversions: GROW - 1, GROW, BODY |-\r
+# Then the content of the temporary diversion is moved to DUMP and the\r
+# temporary diversion is popped.\r
+# DUMP: BODY\r
+# BODY: TEST2a\r
+# diversions: GROW, BODY |-\r
+#\r
+# * TEST1 requires TEST2b\r
+# Again, _m4_require_call pushes GROW - 1 and heads to expand TEST2b.\r
+# DUMP: BODY\r
+# BODY: TEST2a\r
+# diversions: GROW - 1, GROW, BODY |-\r
+#\r
+# * TEST2b requires TEST3\r
+# _m4_require_call pushes GROW - 2 and expands TEST3 here.\r
+# (TEST3 requires TEST2a, but TEST2a has already been m4_provide'd, so\r
+# nothing happens.)\r
+# DUMP: BODY\r
+# BODY: TEST2a\r
+# GROW - 2: TEST3\r
+# diversions: GROW - 2, GROW - 1, GROW, BODY |-\r
+# Then the diversion is appended to DUMP, and popped.\r
+# DUMP: BODY\r
+# BODY: TEST2a; TEST3\r
+# diversions: GROW - 1, GROW, BODY |-\r
+#\r
+# * TEST1 requires TEST2b (contd.)\r
+# The content of TEST2b is expanded...\r
+# DUMP: BODY\r
+# BODY: TEST2a; TEST3\r
+# GROW - 1: TEST2b,\r
+# diversions: GROW - 1, GROW, BODY |-\r
+# ... and moved to DUMP.\r
+# DUMP: BODY\r
+# BODY: TEST2a; TEST3; TEST2b\r
+# diversions: GROW, BODY |-\r
+#\r
+# * TEST1 is expanded: epilogue\r
+# TEST1's own content is in GROW...\r
+# DUMP: BODY\r
+# BODY: TEST2a; TEST3; TEST2b\r
+# GROW: TEST1\r
+# diversions: BODY |-\r
+# ... and it's epilogue moves it to DUMP and then undefines DUMP.\r
+# DUMP: undefined\r
+# BODY: TEST2a; TEST3; TEST2b; TEST1\r
+# diversions: BODY |-\r
+#\r
+#\r
+# The third idea: track macros provided before they were required\r
+# ---------------------------------------------------------------\r
+#\r
+# Using just the first two ideas, Autoconf 2.50 through 2.63 still had\r
+# a subtle bug for more than seven years. Let's consider the\r
+# following example to explain the bug:\r
+#\r
+# | m4_defun([TEST1], [1])\r
+# | m4_defun([TEST2], [2[]m4_require([TEST1])])\r
+# | m4_defun([TEST3], [3 TEST1 m4_require([TEST2])])\r
+# | TEST3\r
+#\r
+# After the prologue of TEST3, we are collecting text in GROW with the\r
+# intent of dumping it in BODY during the epilogue. Next, we\r
+# encounter the direct invocation of TEST1, which provides the macro\r
+# in place in GROW. From there, we encounter a requirement for TEST2,\r
+# which must be collected in a new diversion. While expanding TEST2,\r
+# we encounter a requirement for TEST1, but since it has already been\r
+# expanded, the Axel Thimm algorithm states that we can treat it as a\r
+# no-op. But that would lead to an end result of `2 3 1', meaning\r
+# that we have once again output a macro (TEST2) prior to its\r
+# requirements (TEST1).\r
+#\r
+# The problem can only occur if a single defun'd macro first provides,\r
+# then later indirectly requires, the same macro. Note that directly\r
+# expanding then requiring a macro is okay: because the dependency was\r
+# met, the require phase can be a no-op. For that matter, the outer\r
+# macro can even require two helpers, where the first helper expands\r
+# the macro, and the second helper indirectly requires the macro.\r
+# Out-of-order expansion is only present if the inner macro is\r
+# required by something that will be hoisted in front of where the\r
+# direct expansion occurred. In other words, we must be careful not\r
+# to warn on:\r
+#\r
+# | m4_defun([TEST4], [4])\r
+# | m4_defun([TEST5], [5 TEST4 m4_require([TEST4])])\r
+# | TEST5 => 5 4\r
+#\r
+# or even the more complex:\r
+#\r
+# | m4_defun([TEST6], [6])\r
+# | m4_defun([TEST7], [7 TEST6])\r
+# | m4_defun([TEST8], [8 m4_require([TEST6])])\r
+# | m4_defun([TEST9], [9 m4_require([TEST8])])\r
+# | m4_defun([TEST10], [10 m4_require([TEST7]) m4_require([TEST9])])\r
+# | TEST10 => 7 6 8 9 10\r
+#\r
+# So, to detect whether a require was direct or indirect, m4_defun and\r
+# m4_require track the name of the macro that caused a diversion to be\r
+# created (using the stack _m4_diverting, coupled with an O(1) lookup\r
+# _m4_diverting([NAME])), and m4_provide stores the name associated\r
+# with the diversion at which a macro was provided. A require call is\r
+# direct if it occurs within the same diversion where the macro was\r
+# provided, or if the diversion associated with the providing context\r
+# has been collected.\r
+#\r
+# The implementation of the warning involves tracking the set of\r
+# macros which have been provided since the start of the outermost\r
+# defun'd macro (the set is named _m4_provide). When starting an\r
+# outermost macro, the set is emptied; when a macro is provided, it is\r
+# added to the set; when require expands the body of a macro, it is\r
+# removed from the set; and when a macro is indirectly required, the\r
+# set is checked. If a macro is in the set, then it has been provided\r
+# before it was required, and we satisfy dependencies by expanding the\r
+# macro as if it had never been provided; in the example given above,\r
+# this means we now output `1 2 3 1'. Meanwhile, a warning is issued\r
+# to inform the user that her macros trigger the bug in older autoconf\r
+# versions, and that her output file now contains redundant contents\r
+# (and possibly new problems, if the repeated macro was not\r
+# idempotent). Meanwhile, macros defined by m4_defun_once instead of\r
+# m4_defun are idempotent, avoiding any warning or duplicate output.\r
+#\r
+#\r
+# 2. Keeping track of the expansion stack\r
+# =======================================\r
+#\r
+# When M4 expansion goes wrong it is often extremely hard to find the\r
+# path amongst macros that drove to the failure. What is needed is\r
+# the stack of macro `calls'. One could imagine that GNU M4 would\r
+# maintain a stack of macro expansions, unfortunately it doesn't, so\r
+# we do it by hand. This is of course extremely costly, but the help\r
+# this stack provides is worth it. Nevertheless to limit the\r
+# performance penalty this is implemented only for m4_defun'd macros,\r
+# not for define'd macros.\r
+#\r
+# Each time we enter an m4_defun'd macros, we add a definition in\r
+# _m4_expansion_stack, and when we exit the macro, we remove it (thanks\r
+# to pushdef/popdef). m4_stack_foreach is used to print the expansion\r
+# stack in the rare cases when it's needed.\r
+#\r
+# In addition, we want to detect circular m4_require dependencies.\r
+# Each time we expand a macro FOO we define _m4_expanding(FOO); and\r
+# m4_require(BAR) simply checks whether _m4_expanding(BAR) is defined.\r
+\r
+\r
+# m4_expansion_stack\r
+# ------------------\r
+# Expands to the entire contents of the expansion stack. The caller\r
+# must supply a trailing newline. This macro always prints a\r
+# location; check whether _m4_expansion_stack is defined to filter out\r
+# the case when no defun'd macro is in force.\r
+m4_define([m4_expansion_stack],\r
+[m4_stack_foreach_sep_lifo([_$0], [_$0_entry(], [)\r
+])m4_location[: the top level]])\r
+\r
+# _m4_expansion_stack_entry(MACRO)\r
+# --------------------------------\r
+# Format an entry for MACRO found on the expansion stack.\r
+m4_define([_m4_expansion_stack_entry],\r
+[_m4_defn([m4_location($1)])[: $1 is expanded from...]])\r
+\r
+# m4_expansion_stack_push(MACRO)\r
+# ------------------------------\r
+# Form an entry of the expansion stack on entry to MACRO and push it.\r
+m4_define([m4_expansion_stack_push],\r
+[m4_pushdef([_m4_expansion_stack], [$1])])\r
+\r
+\r
+# _m4_divert(GROW)\r
+# ----------------\r
+# This diversion is used by the m4_defun/m4_require machinery. It is\r
+# important to keep room before GROW because for each nested\r
+# AC_REQUIRE we use an additional diversion (i.e., two m4_require's\r
+# will use GROW - 2. More than 3 levels has never seemed to be\r
+# needed.)\r
+#\r
+# ...\r
+# - GROW - 2\r
+# m4_require'd code, 2 level deep\r
+# - GROW - 1\r
+# m4_require'd code, 1 level deep\r
+# - GROW\r
+# m4_defun'd macros are elaborated here.\r
+\r
+m4_define([_m4_divert(GROW)], 10000)\r
+\r
+\r
+# _m4_defun_pro(MACRO-NAME)\r
+# -------------------------\r
+# The prologue for Autoconf macros.\r
+#\r
+# This is called frequently, so minimize the number of macro invocations\r
+# by avoiding dnl and m4_defn overhead.\r
+m4_define([_m4_defun_pro],\r
+[m4_ifdef([_m4_expansion_stack], [], [_m4_defun_pro_outer([$1])])]dnl\r
+[m4_expansion_stack_push([$1])m4_pushdef([_m4_expanding($1)])])\r
+\r
+m4_define([_m4_defun_pro_outer],\r
+[m4_set_delete([_m4_provide])]dnl\r
+[m4_pushdef([_m4_diverting([$1])])m4_pushdef([_m4_diverting], [$1])]dnl\r
+[m4_pushdef([_m4_divert_dump], m4_divnum)m4_divert_push([GROW])])\r
+\r
+# _m4_defun_epi(MACRO-NAME)\r
+# -------------------------\r
+# The Epilogue for Autoconf macros. MACRO-NAME only helps tracing\r
+# the PRO/EPI pairs.\r
+#\r
+# This is called frequently, so minimize the number of macro invocations\r
+# by avoiding dnl and m4_popdef overhead.\r
+m4_define([_m4_defun_epi],\r
+[_m4_popdef([_m4_expanding($1)], [_m4_expansion_stack])]dnl\r
+[m4_ifdef([_m4_expansion_stack], [], [_m4_defun_epi_outer([$1])])]dnl\r
+[m4_provide([$1])])\r
+\r
+m4_define([_m4_defun_epi_outer],\r
+[_m4_popdef([_m4_divert_dump], [_m4_diverting([$1])], [_m4_diverting])]dnl\r
+[m4_divert_pop([GROW])m4_undivert([GROW])])\r
+\r
+\r
+# _m4_divert_dump\r
+# ---------------\r
+# If blank, we are outside of any defun'd macro. Otherwise, expands\r
+# to the diversion number (not name) where require'd macros should be\r
+# moved once completed.\r
+m4_define([_m4_divert_dump])\r
+\r
+\r
+# m4_divert_require(DIVERSION, NAME-TO-CHECK, [BODY-TO-EXPAND])\r
+# -------------------------------------------------------------\r
+# Same as m4_require, but BODY-TO-EXPAND goes into the named DIVERSION;\r
+# requirements still go in the current diversion though.\r
+#\r
+m4_define([m4_divert_require],\r
+[m4_ifdef([_m4_expanding($2)],\r
+ [m4_fatal([$0: circular dependency of $2])])]dnl\r
+[m4_if(_m4_divert_dump, [],\r
+ [m4_fatal([$0($2): cannot be used outside of an m4_defun'd macro])])]dnl\r
+[m4_provide_if([$2], [],\r
+ [_m4_require_call([$2], [$3], _m4_divert([$1], [-]))])])\r
+\r
+\r
+# m4_defun(NAME, EXPANSION, [MACRO = m4_define])\r
+# ----------------------------------------------\r
+# Define a macro NAME which automatically provides itself. Add\r
+# machinery so the macro automatically switches expansion to the\r
+# diversion stack if it is not already using it, prior to EXPANSION.\r
+# In this case, once finished, it will bring back all the code\r
+# accumulated in the diversion stack. This, combined with m4_require,\r
+# achieves the topological ordering of macros. We don't use this\r
+# macro to define some frequently called macros that are not involved\r
+# in ordering constraints, to save m4 processing.\r
+#\r
+# MACRO is an undocumented argument; when set to m4_pushdef, and NAME\r
+# is already defined, the new definition is added to the pushdef\r
+# stack, rather than overwriting the current definition. It can thus\r
+# be used to write self-modifying macros, which pop themselves to a\r
+# previously m4_define'd definition so that subsequent use of the\r
+# macro is faster.\r
+m4_define([m4_defun],\r
+[m4_define([m4_location($1)], m4_location)]dnl\r
+[m4_default([$3], [m4_define])([$1],\r
+ [_m4_defun_pro(]m4_dquote($[0])[)$2[]_m4_defun_epi(]m4_dquote($[0])[)])])\r
+\r
+\r
+# m4_defun_init(NAME, INIT, COMMON)\r
+# ---------------------------------\r
+# Like m4_defun, but split EXPANSION into two portions: INIT which is\r
+# done only the first time NAME is invoked, and COMMON which is\r
+# expanded every time.\r
+#\r
+# For now, the COMMON definition is always m4_define'd, giving an even\r
+# lighter-weight definition. m4_defun allows self-providing, but once\r
+# a macro is provided, m4_require no longer cares if it is m4_define'd\r
+# or m4_defun'd. m4_defun also provides location tracking to identify\r
+# dependency bugs, but once the INIT has been expanded, we know there\r
+# are no dependency bugs. However, if a future use needs COMMON to be\r
+# m4_defun'd, we can add a parameter, similar to the third parameter\r
+# to m4_defun.\r
+m4_define([m4_defun_init],\r
+[m4_define([$1], [$3[]])m4_defun([$1],\r
+ [$2[]_m4_popdef(]m4_dquote($[0])[)m4_indir(]m4_dquote($[0])dnl\r
+[m4_if(]m4_dquote($[#])[, [0], [], ]m4_dquote([,$]@)[))], [m4_pushdef])])\r
+\r
+\r
+# m4_defun_once(NAME, EXPANSION)\r
+# ------------------------------\r
+# Like m4_defun, but guarantee that EXPANSION only happens once\r
+# (thereafter, using NAME is a no-op).\r
+#\r
+# If _m4_divert_dump is empty, we are called at the top level;\r
+# otherwise, we must ensure that we are required in front of the\r
+# current defun'd macro. Use a helper macro so that EXPANSION need\r
+# only occur once in the definition of NAME, since it might be large.\r
+m4_define([m4_defun_once],\r
+[m4_define([m4_location($1)], m4_location)]dnl\r
+[m4_define([$1], [_m4_defun_once([$1], [$2], m4_if(_m4_divert_dump, [],\r
+ [[_m4_defun_pro([$1])m4_unquote(], [)_m4_defun_epi([$1])]],\r
+m4_ifdef([_m4_diverting([$1])], [-]), [-], [[m4_unquote(], [)]],\r
+ [[_m4_require_call([$1],], [, _m4_divert_dump)]]))])])\r
+\r
+m4_define([_m4_defun_once],\r
+[m4_pushdef([$1])$3[$2[]m4_provide([$1])]$4])\r
+\r
+\r
+# m4_pattern_forbid(ERE, [WHY])\r
+# -----------------------------\r
+# Declare that no token matching the forbidden extended regular\r
+# expression ERE should be seen in the output unless...\r
+m4_define([m4_pattern_forbid], [])\r
+\r
+\r
+# m4_pattern_allow(ERE)\r
+# ---------------------\r
+# ... that token also matches the allowed extended regular expression ERE.\r
+# Both used via traces.\r
+m4_define([m4_pattern_allow], [])\r
+\r
+\r
+## --------------------------------- ##\r
+## 11. Dependencies between macros. ##\r
+## --------------------------------- ##\r
+\r
+\r
+# m4_before(THIS-MACRO-NAME, CALLED-MACRO-NAME)\r
+# ---------------------------------------------\r
+# Issue a warning if CALLED-MACRO-NAME was called before THIS-MACRO-NAME.\r
+m4_define([m4_before],\r
+[m4_provide_if([$2],\r
+ [m4_warn([syntax], [$2 was called before $1])])])\r
+\r
+\r
+# m4_require(NAME-TO-CHECK, [BODY-TO-EXPAND = NAME-TO-CHECK])\r
+# -----------------------------------------------------------\r
+# If NAME-TO-CHECK has never been expanded (actually, if it is not\r
+# m4_provide'd), expand BODY-TO-EXPAND *before* the current macro\r
+# expansion; follow the expansion with a newline. Once expanded, emit\r
+# it in _m4_divert_dump. Keep track of the m4_require chain in\r
+# _m4_expansion_stack.\r
+#\r
+# The normal cases are:\r
+#\r
+# - NAME-TO-CHECK == BODY-TO-EXPAND\r
+# Which you can use for regular macros with or without arguments, e.g.,\r
+# m4_require([AC_PROG_CC], [AC_PROG_CC])\r
+# m4_require([AC_CHECK_HEADERS(threads.h)], [AC_CHECK_HEADERS(threads.h)])\r
+# which is just the same as\r
+# m4_require([AC_PROG_CC])\r
+# m4_require([AC_CHECK_HEADERS(threads.h)])\r
+#\r
+# - BODY-TO-EXPAND == m4_indir([NAME-TO-CHECK])\r
+# In the case of macros with irregular names. For instance:\r
+# m4_require([AC_LANG_COMPILER(C)], [indir([AC_LANG_COMPILER(C)])])\r
+# which means `if the macro named `AC_LANG_COMPILER(C)' (the parens are\r
+# part of the name, it is not an argument) has not been run, then\r
+# call it.'\r
+# Had you used\r
+# m4_require([AC_LANG_COMPILER(C)], [AC_LANG_COMPILER(C)])\r
+# then m4_require would have tried to expand `AC_LANG_COMPILER(C)', i.e.,\r
+# call the macro `AC_LANG_COMPILER' with `C' as argument.\r
+#\r
+# You could argue that `AC_LANG_COMPILER', when it receives an argument\r
+# such as `C' should dispatch the call to `AC_LANG_COMPILER(C)'. But this\r
+# `extension' prevents `AC_LANG_COMPILER' from having actual arguments that\r
+# it passes to `AC_LANG_COMPILER(C)'.\r
+#\r
+# This is called frequently, so minimize the number of macro invocations\r
+# by avoiding dnl and other overhead on the common path.\r
+m4_define([m4_require],\r
+[m4_ifdef([_m4_expanding($1)],\r
+ [m4_fatal([$0: circular dependency of $1])])]dnl\r
+[m4_if(_m4_divert_dump, [],\r
+ [m4_fatal([$0($1): cannot be used outside of an ]dnl\r
+m4_if([$0], [m4_require], [[m4_defun]], [[AC_DEFUN]])['d macro])])]dnl\r
+[m4_provide_if([$1], [m4_set_contains([_m4_provide], [$1],\r
+ [_m4_require_check([$1], _m4_defn([m4_provide($1)]), [$0])], [m4_ignore])],\r
+ [_m4_require_call])([$1], [$2], _m4_divert_dump)])\r
+\r
+\r
+# _m4_require_call(NAME-TO-CHECK, [BODY-TO-EXPAND = NAME-TO-CHECK],\r
+# DIVERSION-NUMBER)\r
+# -----------------------------------------------------------------\r
+# If m4_require decides to expand the body, it calls this macro. The\r
+# expansion is placed in DIVERSION-NUMBER.\r
+#\r
+# This is called frequently, so minimize the number of macro invocations\r
+# by avoiding dnl and other overhead on the common path.\r
+m4_define([_m4_require_call],\r
+[m4_pushdef([_m4_divert_grow], m4_decr(_m4_divert_grow))]dnl\r
+[m4_pushdef([_m4_diverting([$1])])m4_pushdef([_m4_diverting], [$1])]dnl\r
+[m4_divert_push(_m4_divert_grow, [-])]dnl\r
+[m4_if([$2], [], [$1], [$2])\r
+m4_provide_if([$1], [m4_set_remove([_m4_provide], [$1])],\r
+ [m4_warn([syntax], [$1 is m4_require'd but not m4_defun'd])])]dnl\r
+[_m4_divert_raw($3)_m4_undivert(_m4_divert_grow)]dnl\r
+[m4_divert_pop(_m4_divert_grow)_m4_popdef([_m4_divert_grow],\r
+[_m4_diverting([$1])], [_m4_diverting])])\r
+\r
+\r
+# _m4_require_check(NAME-TO-CHECK, OWNER, CALLER)\r
+# -----------------------------------------------\r
+# NAME-TO-CHECK has been identified as previously expanded in the\r
+# diversion owned by OWNER. If this is a problem, warn on behalf of\r
+# CALLER and return _m4_require_call; otherwise return m4_ignore.\r
+m4_define([_m4_require_check],\r
+[m4_if(_m4_defn([_m4_diverting]), [$2], [m4_ignore],\r
+ m4_ifdef([_m4_diverting([$2])], [-]), [-], [m4_warn([syntax],\r
+ [$3: `$1' was expanded before it was required\r
+http://www.gnu.org/software/autoconf/manual/autoconf.html#Expanded-Before-Required])_m4_require_call],\r
+ [m4_ignore])])\r
+\r
+\r
+# _m4_divert_grow\r
+# ---------------\r
+# The counter for _m4_require_call.\r
+m4_define([_m4_divert_grow], _m4_divert([GROW]))\r
+\r
+\r
+# m4_expand_once(TEXT, [WITNESS = TEXT])\r
+# --------------------------------------\r
+# If TEXT has never been expanded, expand it *here*. Use WITNESS as\r
+# as a memory that TEXT has already been expanded.\r
+m4_define([m4_expand_once],\r
+[m4_provide_if(m4_default_quoted([$2], [$1]),\r
+ [],\r
+ [m4_provide(m4_default_quoted([$2], [$1]))[]$1])])\r
+\r
+\r
+# m4_provide(MACRO-NAME)\r
+# ----------------------\r
+m4_define([m4_provide],\r
+[m4_ifdef([m4_provide($1)], [],\r
+[m4_set_add([_m4_provide], [$1], [m4_define([m4_provide($1)],\r
+ m4_ifdef([_m4_diverting], [_m4_defn([_m4_diverting])]))])])])\r
+\r
+\r
+# m4_provide_if(MACRO-NAME, IF-PROVIDED, IF-NOT-PROVIDED)\r
+# -------------------------------------------------------\r
+# If MACRO-NAME is provided do IF-PROVIDED, else IF-NOT-PROVIDED.\r
+# The purpose of this macro is to provide the user with a means to\r
+# check macros which are provided without letting her know how the\r
+# information is coded.\r
+m4_define([m4_provide_if],\r
+[m4_ifdef([m4_provide($1)],\r
+ [$2], [$3])])\r
+\r
+\r
+## --------------------- ##\r
+## 12. Text processing. ##\r
+## --------------------- ##\r
+\r
+\r
+# m4_cr_letters\r
+# m4_cr_LETTERS\r
+# m4_cr_Letters\r
+# -------------\r
+m4_define([m4_cr_letters], [abcdefghijklmnopqrstuvwxyz])\r
+m4_define([m4_cr_LETTERS], [ABCDEFGHIJKLMNOPQRSTUVWXYZ])\r
+m4_define([m4_cr_Letters],\r
+m4_defn([m4_cr_letters])dnl\r
+m4_defn([m4_cr_LETTERS])dnl\r
+)\r
+\r
+\r
+# m4_cr_digits\r
+# ------------\r
+m4_define([m4_cr_digits], [0123456789])\r
+\r
+\r
+# m4_cr_alnum\r
+# -----------\r
+m4_define([m4_cr_alnum],\r
+m4_defn([m4_cr_Letters])dnl\r
+m4_defn([m4_cr_digits])dnl\r
+)\r
+\r
+\r
+# m4_cr_symbols1\r
+# m4_cr_symbols2\r
+# --------------\r
+m4_define([m4_cr_symbols1],\r
+m4_defn([m4_cr_Letters])dnl\r
+_)\r
+\r
+m4_define([m4_cr_symbols2],\r
+m4_defn([m4_cr_symbols1])dnl\r
+m4_defn([m4_cr_digits])dnl\r
+)\r
+\r
+# m4_cr_all\r
+# ---------\r
+# The character range representing everything, with `-' as the last\r
+# character, since it is special to m4_translit. Use with care, because\r
+# it contains characters special to M4 (fortunately, both ASCII and EBCDIC\r
+# have [] in order, so m4_defn([m4_cr_all]) remains a valid string). It\r
+# also contains characters special to terminals, so it should never be\r
+# displayed in an error message. Also, attempts to map [ and ] to other\r
+# characters via m4_translit must deal with the fact that m4_translit does\r
+# not add quotes to the output.\r
+#\r
+# In EBCDIC, $ is immediately followed by *, which leads to problems\r
+# if m4_cr_all is inlined into a macro definition; so swap them.\r
+#\r
+# It is mainly useful in generating inverted character range maps, for use\r
+# in places where m4_translit is faster than an equivalent m4_bpatsubst;\r
+# the regex `[^a-z]' is equivalent to:\r
+# m4_translit(m4_dquote(m4_defn([m4_cr_all])), [a-z])\r
+m4_define([m4_cr_all],\r
+m4_translit(m4_dquote(m4_format(m4_dquote(m4_for(\r
+ ,1,255,,[[%c]]))m4_for([i],1,255,,[,i]))), [$*-], [*$])-)\r
+\r
+\r
+# _m4_define_cr_not(CATEGORY)\r
+# ---------------------------\r
+# Define m4_cr_not_CATEGORY as the inverse of m4_cr_CATEGORY.\r
+m4_define([_m4_define_cr_not],\r
+[m4_define([m4_cr_not_$1],\r
+ m4_translit(m4_dquote(m4_defn([m4_cr_all])),\r
+ m4_defn([m4_cr_$1])))])\r
+\r
+\r
+# m4_cr_not_letters\r
+# m4_cr_not_LETTERS\r
+# m4_cr_not_Letters\r
+# m4_cr_not_digits\r
+# m4_cr_not_alnum\r
+# m4_cr_not_symbols1\r
+# m4_cr_not_symbols2\r
+# ------------------\r
+# Inverse character sets\r
+_m4_define_cr_not([letters])\r
+_m4_define_cr_not([LETTERS])\r
+_m4_define_cr_not([Letters])\r
+_m4_define_cr_not([digits])\r
+_m4_define_cr_not([alnum])\r
+_m4_define_cr_not([symbols1])\r
+_m4_define_cr_not([symbols2])\r
+\r
+\r
+# m4_newline([STRING])\r
+# --------------------\r
+# Expands to a newline, possibly followed by STRING. Exists mostly for\r
+# formatting reasons.\r
+m4_define([m4_newline], [\r
+$1])\r
+\r
+\r
+# m4_re_escape(STRING)\r
+# --------------------\r
+# Escape RE active characters in STRING.\r
+m4_define([m4_re_escape],\r
+[m4_bpatsubst([$1],\r
+ [[][*+.?\^$]], [\\\&])])\r
+\r
+\r
+# m4_re_string\r
+# ------------\r
+# Regexp for `[a-zA-Z_0-9]*'\r
+# m4_dquote provides literal [] for the character class.\r
+m4_define([m4_re_string],\r
+m4_dquote(m4_defn([m4_cr_symbols2]))dnl\r
+[*]dnl\r
+)\r
+\r
+\r
+# m4_re_word\r
+# ----------\r
+# Regexp for `[a-zA-Z_][a-zA-Z_0-9]*'\r
+m4_define([m4_re_word],\r
+m4_dquote(m4_defn([m4_cr_symbols1]))dnl\r
+m4_defn([m4_re_string])dnl\r
+)\r
+\r
+\r
+# m4_tolower(STRING)\r
+# m4_toupper(STRING)\r
+# ------------------\r
+# These macros convert STRING to lowercase or uppercase.\r
+#\r
+# Rather than expand the m4_defn each time, we inline them up front.\r
+m4_define([m4_tolower],\r
+[m4_translit([[$1]], ]m4_dquote(m4_defn([m4_cr_LETTERS]))[,\r
+ ]m4_dquote(m4_defn([m4_cr_letters]))[)])\r
+m4_define([m4_toupper],\r
+[m4_translit([[$1]], ]m4_dquote(m4_defn([m4_cr_letters]))[,\r
+ ]m4_dquote(m4_defn([m4_cr_LETTERS]))[)])\r
+\r
+\r
+# m4_split(STRING, [REGEXP])\r
+# --------------------------\r
+# Split STRING into an m4 list of quoted elements. The elements are\r
+# quoted with [ and ]. Beginning spaces and end spaces *are kept*.\r
+# Use m4_strip to remove them.\r
+#\r
+# REGEXP specifies where to split. Default is [\t ]+.\r
+#\r
+# If STRING is empty, the result is an empty list.\r
+#\r
+# Pay attention to the m4_changequotes. When m4 reads the definition of\r
+# m4_split, it still has quotes set to [ and ]. Luckily, these are matched\r
+# in the macro body, so the definition is stored correctly. Use the same\r
+# alternate quotes as m4_noquote; it must be unlikely to appear in $1.\r
+#\r
+# Also, notice that $1 is quoted twice, since we want the result to\r
+# be quoted. Then you should understand that the argument of\r
+# patsubst is -=<{(STRING)}>=- (i.e., with additional -=<{( and )}>=-).\r
+#\r
+# This macro is safe on active symbols, i.e.:\r
+# m4_define(active, ACTIVE)\r
+# m4_split([active active ])end\r
+# => [active], [active], []end\r
+#\r
+# Optimize on regex of ` ' (space), since m4_foreach_w already guarantees\r
+# that the list contains single space separators, and a common case is\r
+# splitting a single-element list. This macro is called frequently,\r
+# so avoid unnecessary dnl inside the definition.\r
+m4_define([m4_split],\r
+[m4_if([$1], [], [],\r
+ [$2], [ ], [m4_if(m4_index([$1], [ ]), [-1], [[[$1]]],\r
+ [_$0([$1], [$2], [, ])])],\r
+ [$2], [], [_$0([$1], [[ ]+], [, ])],\r
+ [_$0([$1], [$2], [, ])])])\r
+\r
+m4_define([_m4_split],\r
+[m4_changequote([-=<{(],[)}>=-])]dnl\r
+[[m4_bpatsubst(-=<{(-=<{($1)}>=-)}>=-, -=<{($2)}>=-,\r
+ -=<{(]$3[)}>=-)]m4_changequote([, ])])\r
+\r
+\r
+# m4_chomp(STRING)\r
+# m4_chomp_all(STRING)\r
+# --------------------\r
+# Return STRING quoted, but without a trailing newline. m4_chomp\r
+# removes at most one newline, while m4_chomp_all removes all\r
+# consecutive trailing newlines. Embedded newlines are not touched,\r
+# and a trailing backslash-newline leaves just a trailing backslash.\r
+#\r
+# m4_bregexp is slower than m4_index, and we don't always want to\r
+# remove all newlines; hence the two variants. We massage characters\r
+# to give a nicer pattern to match, particularly since m4_bregexp is\r
+# line-oriented. Both versions must guarantee a match, to avoid bugs\r
+# with precision -1 in m4_format in older m4.\r
+m4_define([m4_chomp],\r
+[m4_format([[%.*s]], m4_index(m4_translit([[$1]], [\r
+/.], [/ ])[./.], [/.]), [$1])])\r
+\r
+m4_define([m4_chomp_all],\r
+[m4_format([[%.*s]], m4_bregexp(m4_translit([[$1]], [\r
+/], [/ ]), [/*$]), [$1])])\r
+\r
+\r
+# m4_flatten(STRING)\r
+# ------------------\r
+# If STRING contains end of lines, replace them with spaces. If there\r
+# are backslashed end of lines, remove them. This macro is safe with\r
+# active symbols.\r
+# m4_define(active, ACTIVE)\r
+# m4_flatten([active\r
+# act\\r
+# ive])end\r
+# => active activeend\r
+#\r
+# In m4, m4_bpatsubst is expensive, so first check for a newline.\r
+m4_define([m4_flatten],\r
+[m4_if(m4_index([$1], [\r
+]), [-1], [[$1]],\r
+ [m4_translit(m4_bpatsubst([[[$1]]], [\\\r
+]), [\r
+], [ ])])])\r
+\r
+\r
+# m4_strip(STRING)\r
+# ----------------\r
+# Expands into STRING with tabs and spaces singled out into a single\r
+# space, and removing leading and trailing spaces.\r
+#\r
+# This macro is robust to active symbols.\r
+# m4_define(active, ACTIVE)\r
+# m4_strip([ active <tab> <tab>active ])end\r
+# => active activeend\r
+#\r
+# First, notice that we guarantee trailing space. Why? Because regular\r
+# expressions are greedy, and `.* ?' would always group the space into the\r
+# .* portion. The algorithm is simpler by avoiding `?' at the end. The\r
+# algorithm correctly strips everything if STRING is just ` '.\r
+#\r
+# Then notice the second pattern: it is in charge of removing the\r
+# leading/trailing spaces. Why not just `[^ ]'? Because they are\r
+# applied to over-quoted strings, i.e. more or less [STRING], due\r
+# to the limitations of m4_bpatsubsts. So the leading space in STRING\r
+# is the *second* character; equally for the trailing space.\r
+m4_define([m4_strip],\r
+[m4_bpatsubsts([$1 ],\r
+ [[ ]+], [ ],\r
+ [^. ?\(.*\) .$], [[[\1]]])])\r
+\r
+\r
+# m4_normalize(STRING)\r
+# --------------------\r
+# Apply m4_flatten and m4_strip to STRING.\r
+#\r
+# The argument is quoted, so that the macro is robust to active symbols:\r
+#\r
+# m4_define(active, ACTIVE)\r
+# m4_normalize([ act\\r
+# ive\r
+# active ])end\r
+# => active activeend\r
+\r
+m4_define([m4_normalize],\r
+[m4_strip(m4_flatten([$1]))])\r
+\r
+\r
+\r
+# m4_join(SEP, ARG1, ARG2...)\r
+# ---------------------------\r
+# Produce ARG1SEPARG2...SEPARGn. Avoid back-to-back SEP when a given ARG\r
+# is the empty string. No expansion is performed on SEP or ARGs.\r
+#\r
+# Since the number of arguments to join can be arbitrarily long, we\r
+# want to avoid having more than one $@ in the macro definition;\r
+# otherwise, the expansion would require twice the memory of the already\r
+# long list. Hence, m4_join merely looks for the first non-empty element,\r
+# and outputs just that element; while _m4_join looks for all non-empty\r
+# elements, and outputs them following a separator. The final trick to\r
+# note is that we decide between recursing with $0 or _$0 based on the\r
+# nested m4_if ending with `_'.\r
+#\r
+# Please keep foreach.m4 in sync with any adjustments made here.\r
+m4_define([m4_join],\r
+[m4_if([$#], [1], [],\r
+ [$#], [2], [[$2]],\r
+ [m4_if([$2], [], [], [[$2]_])$0([$1], m4_shift2($@))])])\r
+m4_define([_m4_join],\r
+[m4_if([$#$2], [2], [],\r
+ [m4_if([$2], [], [], [[$1$2]])$0([$1], m4_shift2($@))])])\r
+\r
+# m4_joinall(SEP, ARG1, ARG2...)\r
+# ------------------------------\r
+# Produce ARG1SEPARG2...SEPARGn. An empty ARG results in back-to-back SEP.\r
+# No expansion is performed on SEP or ARGs.\r
+#\r
+# Please keep foreach.m4 in sync with any adjustments made here.\r
+m4_define([m4_joinall], [[$2]_$0([$1], m4_shift($@))])\r
+m4_define([_m4_joinall],\r
+[m4_if([$#], [2], [], [[$1$3]$0([$1], m4_shift2($@))])])\r
+\r
+# m4_combine([SEPARATOR], PREFIX-LIST, [INFIX], SUFFIX...)\r
+# --------------------------------------------------------\r
+# Produce the pairwise combination of every element in the quoted,\r
+# comma-separated PREFIX-LIST with every element from the SUFFIX arguments.\r
+# Each pair is joined with INFIX, and pairs are separated by SEPARATOR.\r
+# No expansion occurs on SEPARATOR, INFIX, or elements of either list.\r
+#\r
+# For example:\r
+# m4_combine([, ], [[a], [b], [c]], [-], [1], [2], [3])\r
+# => a-1, a-2, a-3, b-1, b-2, b-3, c-1, c-2, c-3\r
+#\r
+# This definition is a bit hairy; the thing to realize is that we want\r
+# to construct m4_map_args_sep([[prefix$3]], [], [[$1]], m4_shift3($@))\r
+# as the inner loop, using each prefix generated by the outer loop,\r
+# and without recalculating m4_shift3 every outer iteration.\r
+m4_define([m4_combine],\r
+[m4_if([$2], [], [], m4_eval([$# > 3]), [1],\r
+[m4_map_args_sep([m4_map_args_sep(m4_dquote(], [)[[$3]], [], [[$1]],]]]dnl\r
+[m4_dquote(m4_dquote(m4_shift3($@)))[[)], [[$1]], $2)])])\r
+\r
+\r
+# m4_append(MACRO-NAME, STRING, [SEPARATOR])\r
+# ------------------------------------------\r
+# Redefine MACRO-NAME to hold its former content plus `SEPARATOR`'STRING'\r
+# at the end. It is valid to use this macro with MACRO-NAME undefined,\r
+# in which case no SEPARATOR is added. Be aware that the criterion is\r
+# `not being defined', and not `not being empty'.\r
+#\r
+# Note that neither STRING nor SEPARATOR are expanded here; rather, when\r
+# you expand MACRO-NAME, they will be expanded at that point in time.\r
+#\r
+# This macro is robust to active symbols. It can be used to grow\r
+# strings.\r
+#\r
+# | m4_define(active, ACTIVE)dnl\r
+# | m4_append([sentence], [This is an])dnl\r
+# | m4_append([sentence], [ active ])dnl\r
+# | m4_append([sentence], [symbol.])dnl\r
+# | sentence\r
+# | m4_undefine([active])dnl\r
+# | sentence\r
+# => This is an ACTIVE symbol.\r
+# => This is an active symbol.\r
+#\r
+# It can be used to define hooks.\r
+#\r
+# | m4_define(active, ACTIVE)dnl\r
+# | m4_append([hooks], [m4_define([act1], [act2])])dnl\r
+# | m4_append([hooks], [m4_define([act2], [active])])dnl\r
+# | m4_undefine([active])dnl\r
+# | act1\r
+# | hooks\r
+# | act1\r
+# => act1\r
+# =>\r
+# => active\r
+#\r
+# It can also be used to create lists, although this particular usage was\r
+# broken prior to autoconf 2.62.\r
+# | m4_append([list], [one], [, ])dnl\r
+# | m4_append([list], [two], [, ])dnl\r
+# | m4_append([list], [three], [, ])dnl\r
+# | list\r
+# | m4_dquote(list)\r
+# => one, two, three\r
+# => [one],[two],[three]\r
+#\r
+# Note that m4_append can benefit from amortized O(n) m4 behavior, if\r
+# the underlying m4 implementation is smart enough to avoid copying existing\r
+# contents when enlarging a macro's definition into any pre-allocated storage\r
+# (m4 1.4.x unfortunately does not implement this optimization). We do\r
+# not implement m4_prepend, since it is inherently O(n^2) (pre-allocated\r
+# storage only occurs at the end of a macro, so the existing contents must\r
+# always be moved).\r
+#\r
+# Use _m4_defn for speed.\r
+m4_define([m4_append],\r
+[m4_define([$1], m4_ifdef([$1], [_m4_defn([$1])[$3]])[$2])])\r
+\r
+\r
+# m4_append_uniq(MACRO-NAME, STRING, [SEPARATOR], [IF-UNIQ], [IF-DUP])\r
+# --------------------------------------------------------------------\r
+# Like `m4_append', but append only if not yet present. Additionally,\r
+# expand IF-UNIQ if STRING was appended, or IF-DUP if STRING was already\r
+# present. Also, warn if SEPARATOR is not empty and occurs within STRING,\r
+# as the algorithm no longer guarantees uniqueness.\r
+#\r
+# Note that while m4_append can be O(n) (depending on the quality of the\r
+# underlying M4 implementation), m4_append_uniq is inherently O(n^2)\r
+# because each append operation searches the entire string.\r
+m4_define([m4_append_uniq],\r
+[m4_ifval([$3], [m4_if(m4_index([$2], [$3]), [-1], [],\r
+ [m4_warn([syntax],\r
+ [$0: `$2' contains `$3'])])])_$0($@)])\r
+m4_define([_m4_append_uniq],\r
+[m4_ifdef([$1],\r
+ [m4_if(m4_index([$3]_m4_defn([$1])[$3], [$3$2$3]), [-1],\r
+ [m4_append([$1], [$2], [$3])$4], [$5])],\r
+ [m4_define([$1], [$2])$4])])\r
+\r
+# m4_append_uniq_w(MACRO-NAME, STRINGS)\r
+# -------------------------------------\r
+# For each of the words in the whitespace separated list STRINGS, append\r
+# only the unique strings to the definition of MACRO-NAME.\r
+#\r
+# Use _m4_defn for speed.\r
+m4_define([m4_append_uniq_w],\r
+[m4_map_args_w([$2], [_m4_append_uniq([$1],], [, [ ])])])\r
+\r
+\r
+# m4_escape(STRING)\r
+# -----------------\r
+# Output quoted STRING, but with embedded #, $, [ and ] turned into\r
+# quadrigraphs.\r
+#\r
+# It is faster to check if STRING is already good using m4_translit\r
+# than to blindly perform four m4_bpatsubst.\r
+#\r
+# Because the translit is stripping quotes, it must also neutralize\r
+# anything that might be in a macro name, as well as comments, commas,\r
+# and parentheses. All the problem characters are unified so that a\r
+# single m4_index can scan the result.\r
+#\r
+# Rather than expand m4_defn every time m4_escape is expanded, we\r
+# inline its expansion up front.\r
+m4_define([m4_escape],\r
+[m4_if(m4_index(m4_translit([$1],\r
+ [[]#,()]]m4_dquote(m4_defn([m4_cr_symbols2]))[, [$$$]), [$]),\r
+ [-1], [m4_echo], [_$0])([$1])])\r
+\r
+m4_define([_m4_escape],\r
+[m4_changequote([-=<{(],[)}>=-])]dnl\r
+[m4_bpatsubst(m4_bpatsubst(m4_bpatsubst(m4_bpatsubst(\r
+ -=<{(-=<{(-=<{(-=<{(-=<{($1)}>=-)}>=-)}>=-)}>=-)}>=-,\r
+ -=<{(#)}>=-, -=<{(@%:@)}>=-),\r
+ -=<{(\[)}>=-, -=<{(@<:@)}>=-),\r
+ -=<{(\])}>=-, -=<{(@:>@)}>=-),\r
+ -=<{(\$)}>=-, -=<{(@S|@)}>=-)m4_changequote([,])])\r
+\r
+\r
+# m4_text_wrap(STRING, [PREFIX], [FIRST-PREFIX], [WIDTH])\r
+# -------------------------------------------------------\r
+# Expands into STRING wrapped to hold in WIDTH columns (default = 79).\r
+# If PREFIX is given, each line is prefixed with it. If FIRST-PREFIX is\r
+# specified, then the first line is prefixed with it. As a special case,\r
+# if the length of FIRST-PREFIX is greater than that of PREFIX, then\r
+# FIRST-PREFIX will be left alone on the first line.\r
+#\r
+# No expansion occurs on the contents STRING, PREFIX, or FIRST-PREFIX,\r
+# although quadrigraphs are correctly recognized. More precisely,\r
+# you may redefine m4_qlen to recognize whatever escape sequences that\r
+# you will post-process.\r
+#\r
+# Typical outputs are:\r
+#\r
+# m4_text_wrap([Short string */], [ ], [/* ], 20)\r
+# => /* Short string */\r
+#\r
+# m4_text_wrap([Much longer string */], [ ], [/* ], 20)\r
+# => /* Much longer\r
+# => string */\r
+#\r
+# m4_text_wrap([Short doc.], [ ], [ --short ], 30)\r
+# => --short Short doc.\r
+#\r
+# m4_text_wrap([Short doc.], [ ], [ --too-wide ], 30)\r
+# => --too-wide\r
+# => Short doc.\r
+#\r
+# m4_text_wrap([Super long documentation.], [ ], [ --too-wide ], 30)\r
+# => --too-wide\r
+# => Super long\r
+# => documentation.\r
+#\r
+# FIXME: there is no checking of a longer PREFIX than WIDTH, but do\r
+# we really want to bother with people trying each single corner\r
+# of a software?\r
+#\r
+# This macro does not leave a trailing space behind the last word of a line,\r
+# which complicates it a bit. The algorithm is otherwise stupid and simple:\r
+# all the words are preceded by m4_Separator which is defined to empty for\r
+# the first word, and then ` ' (single space) for all the others.\r
+#\r
+# The algorithm uses a helper that uses $2 through $4 directly, rather than\r
+# using local variables, to avoid m4_defn overhead, or expansion swallowing\r
+# any $. It also bypasses m4_popdef overhead with _m4_popdef since no user\r
+# macro expansion occurs in the meantime. Also, the definition is written\r
+# with m4_do, to avoid time wasted on dnl during expansion (since this is\r
+# already a time-consuming macro).\r
+m4_define([m4_text_wrap],\r
+[_$0(m4_escape([$1]), [$2], m4_default_quoted([$3], [$2]),\r
+ m4_default_quoted([$4], [79]))])\r
+\r
+m4_define([_m4_text_wrap],\r
+m4_do(dnl set up local variables, to avoid repeated calculations\r
+[[m4_pushdef([m4_Indent], m4_qlen([$2]))]],\r
+[[m4_pushdef([m4_Cursor], m4_qlen([$3]))]],\r
+[[m4_pushdef([m4_Separator], [m4_define([m4_Separator], [ ])])]],\r
+dnl expand the first prefix, then check its length vs. regular prefix\r
+dnl same length: nothing special\r
+dnl prefix1 longer: output on line by itself, and reset cursor\r
+dnl prefix1 shorter: pad to length of prefix, and reset cursor\r
+[[[$3]m4_cond([m4_Cursor], m4_Indent, [],\r
+ [m4_eval(m4_Cursor > m4_Indent)], [1], [\r
+[$2]m4_define([m4_Cursor], m4_Indent)],\r
+ [m4_format([%*s], m4_max([0],\r
+ m4_eval(m4_Indent - m4_Cursor)), [])m4_define([m4_Cursor], m4_Indent)])]],\r
+dnl now, for each word, compute the cursor after the word is output, then\r
+dnl check if the cursor would exceed the wrap column\r
+dnl if so, reset cursor, and insert newline and prefix\r
+dnl if not, insert the separator (usually a space)\r
+dnl either way, insert the word\r
+[[m4_map_args_w([$1], [$0_word(], [, [$2], [$4])])]],\r
+dnl finally, clean up the local variables\r
+[[_m4_popdef([m4_Separator], [m4_Cursor], [m4_Indent])]]))\r
+\r
+m4_define([_m4_text_wrap_word],\r
+[m4_define([m4_Cursor], m4_eval(m4_Cursor + m4_qlen([$1]) + 1))]dnl\r
+[m4_if(m4_eval(m4_Cursor > ([$3])),\r
+ [1], [m4_define([m4_Cursor], m4_eval(m4_Indent + m4_qlen([$1]) + 1))\r
+[$2]],\r
+ [m4_Separator[]])[$1]])\r
+\r
+# m4_text_box(MESSAGE, [FRAME-CHARACTER = `-'])\r
+# ---------------------------------------------\r
+# Turn MESSAGE into:\r
+# ## ------- ##\r
+# ## MESSAGE ##\r
+# ## ------- ##\r
+# using FRAME-CHARACTER in the border.\r
+#\r
+# Quadrigraphs are correctly recognized. More precisely, you may\r
+# redefine m4_qlen to recognize whatever escape sequences that you\r
+# will post-process.\r
+m4_define([m4_text_box],\r
+[m4_pushdef([m4_Border],\r
+ m4_translit(m4_format([[[%*s]]], m4_decr(m4_qlen(_m4_expand([$1\r
+]))), []), [ ], m4_default_quoted([$2], [-])))]dnl\r
+[[##] _m4_defn([m4_Border]) [##]\r
+[##] $1 [##]\r
+[##] _m4_defn([m4_Border]) [##]_m4_popdef([m4_Border])])\r
+\r
+\r
+# m4_qlen(STRING)\r
+# ---------------\r
+# Expands to the length of STRING after autom4te converts all quadrigraphs.\r
+#\r
+# If you use some other means of post-processing m4 output rather than\r
+# autom4te, then you may redefine this macro to recognize whatever\r
+# escape sequences your post-processor will handle. For that matter,\r
+# m4_define([m4_qlen], m4_defn([m4_len])) is sufficient if you don't\r
+# do any post-processing.\r
+#\r
+# Avoid bpatsubsts for the common case of no quadrigraphs. Cache\r
+# results, as configure scripts tend to ask about lengths of common\r
+# strings like `/*' and `*/' rather frequently. Minimize the number\r
+# of times that $1 occurs in m4_qlen, so there is less text to parse\r
+# on a cache hit.\r
+m4_define([m4_qlen],\r
+[m4_ifdef([$0-$1], [_m4_defn([$0-]], [_$0(])[$1])])\r
+m4_define([_m4_qlen],\r
+[m4_define([m4_qlen-$1],\r
+m4_if(m4_index([$1], [@]), [-1], [m4_len([$1])],\r
+ [m4_len(m4_bpatsubst([[$1]],\r
+ [@\(\(<:\|:>\|S|\|%:\|\{:\|:\}\)\(@\)\|&t@\)],\r
+ [\3]))]))_m4_defn([m4_qlen-$1])])\r
+\r
+# m4_copyright_condense(TEXT)\r
+# ---------------------------\r
+# Condense the copyright notice in TEXT to only display the final\r
+# year, wrapping the results to fit in 80 columns.\r
+m4_define([m4_copyright_condense],\r
+[m4_text_wrap(m4_bpatsubst(m4_flatten([[$1]]),\r
+[(C)[- ,0-9]*\([1-9][0-9][0-9][0-9]\)], [(C) \1]))])\r
+\r
+## ----------------------- ##\r
+## 13. Number processing. ##\r
+## ----------------------- ##\r
+\r
+# m4_cmp(A, B)\r
+# ------------\r
+# Compare two integer expressions.\r
+# A < B -> -1\r
+# A = B -> 0\r
+# A > B -> 1\r
+m4_define([m4_cmp],\r
+[m4_eval((([$1]) > ([$2])) - (([$1]) < ([$2])))])\r
+\r
+\r
+# m4_list_cmp(A, B)\r
+# -----------------\r
+#\r
+# Compare the two lists of integer expressions A and B. For instance:\r
+# m4_list_cmp([1, 0], [1]) -> 0\r
+# m4_list_cmp([1, 0], [1, 0]) -> 0\r
+# m4_list_cmp([1, 2], [1, 0]) -> 1\r
+# m4_list_cmp([1, 2, 3], [1, 2]) -> 1\r
+# m4_list_cmp([1, 2, -3], [1, 2]) -> -1\r
+# m4_list_cmp([1, 0], [1, 2]) -> -1\r
+# m4_list_cmp([1], [1, 2]) -> -1\r
+# m4_define([xa], [oops])dnl\r
+# m4_list_cmp([[0xa]], [5+5]) -> 0\r
+#\r
+# Rather than face the overhead of m4_case, we use a helper function whose\r
+# expansion includes the name of the macro to invoke on the tail, either\r
+# m4_ignore or m4_unquote. This is particularly useful when comparing\r
+# long lists, since less text is being expanded for deciding when to end\r
+# recursion. The recursion is between a pair of macros that alternate\r
+# which list is trimmed by one element; this is more efficient than\r
+# calling m4_cdr on both lists from a single macro. Guarantee exactly\r
+# one expansion of both lists' side effects.\r
+#\r
+# Please keep foreach.m4 in sync with any adjustments made here.\r
+m4_define([m4_list_cmp],\r
+[_$0_raw(m4_dquote($1), m4_dquote($2))])\r
+\r
+m4_define([_m4_list_cmp_raw],\r
+[m4_if([$1], [$2], [0], [_m4_list_cmp_1([$1], $2)])])\r
+\r
+m4_define([_m4_list_cmp],\r
+[m4_if([$1], [], [0m4_ignore], [$2], [0], [m4_unquote], [$2m4_ignore])])\r
+\r
+m4_define([_m4_list_cmp_1],\r
+[_m4_list_cmp_2([$2], [m4_shift2($@)], $1)])\r
+\r
+m4_define([_m4_list_cmp_2],\r
+[_m4_list_cmp([$1$3], m4_cmp([$3+0], [$1+0]))(\r
+ [_m4_list_cmp_1(m4_dquote(m4_shift3($@)), $2)])])\r
+\r
+# m4_max(EXPR, ...)\r
+# m4_min(EXPR, ...)\r
+# -----------------\r
+# Return the decimal value of the maximum (or minimum) in a series of\r
+# integer expressions.\r
+#\r
+# M4 1.4.x doesn't provide ?:. Hence this huge m4_eval. Avoid m4_eval\r
+# if both arguments are identical, but be aware of m4_max(0xa, 10) (hence\r
+# the use of <=, not just <, in the second multiply).\r
+#\r
+# Please keep foreach.m4 in sync with any adjustments made here.\r
+m4_define([m4_max],\r
+[m4_if([$#], [0], [m4_fatal([too few arguments to $0])],\r
+ [$#], [1], [m4_eval([$1])],\r
+ [$#$1], [2$2], [m4_eval([$1])],\r
+ [$#], [2], [_$0($@)],\r
+ [_m4_minmax([_$0], $@)])])\r
+\r
+m4_define([_m4_max],\r
+[m4_eval((([$1]) > ([$2])) * ([$1]) + (([$1]) <= ([$2])) * ([$2]))])\r
+\r
+m4_define([m4_min],\r
+[m4_if([$#], [0], [m4_fatal([too few arguments to $0])],\r
+ [$#], [1], [m4_eval([$1])],\r
+ [$#$1], [2$2], [m4_eval([$1])],\r
+ [$#], [2], [_$0($@)],\r
+ [_m4_minmax([_$0], $@)])])\r
+\r
+m4_define([_m4_min],\r
+[m4_eval((([$1]) < ([$2])) * ([$1]) + (([$1]) >= ([$2])) * ([$2]))])\r
+\r
+# _m4_minmax(METHOD, ARG1, ARG2...)\r
+# ---------------------------------\r
+# Common recursion code for m4_max and m4_min. METHOD must be _m4_max\r
+# or _m4_min, and there must be at least two arguments to combine.\r
+#\r
+# Please keep foreach.m4 in sync with any adjustments made here.\r
+m4_define([_m4_minmax],\r
+[m4_if([$#], [3], [$1([$2], [$3])],\r
+ [$0([$1], $1([$2], [$3]), m4_shift3($@))])])\r
+\r
+\r
+# m4_sign(A)\r
+# ----------\r
+# The sign of the integer expression A.\r
+m4_define([m4_sign],\r
+[m4_eval((([$1]) > 0) - (([$1]) < 0))])\r
+\r
+\r
+\r
+## ------------------------ ##\r
+## 14. Version processing. ##\r
+## ------------------------ ##\r
+\r
+\r
+# m4_version_unletter(VERSION)\r
+# ----------------------------\r
+# Normalize beta version numbers with letters to numeric expressions, which\r
+# can then be handed to m4_eval for the purpose of comparison.\r
+#\r
+# Nl -> (N+1).-1.(l#)\r
+#\r
+# for example:\r
+# [2.14a] -> [0,2,14+1,-1,[0r36:a]] -> 2.15.-1.10\r
+# [2.14b] -> [0,2,15+1,-1,[0r36:b]] -> 2.15.-1.11\r
+# [2.61aa.b] -> [0,2.61,1,-1,[0r36:aa],+1,-1,[0r36:b]] -> 2.62.-1.370.1.-1.11\r
+# [08] -> [0,[0r10:0]8] -> 8\r
+#\r
+# This macro expects reasonable version numbers, but can handle double\r
+# letters and does not expand any macros. Original version strings can\r
+# use both `.' and `-' separators.\r
+#\r
+# Inline constant expansions, to avoid m4_defn overhead.\r
+# _m4_version_unletter is the real workhorse used by m4_version_compare,\r
+# but since [0r36:a] and commas are less readable than 10 and dots, we\r
+# provide a wrapper for human use.\r
+m4_define([m4_version_unletter],\r
+[m4_substr(m4_map_args([.m4_eval], m4_unquote(_$0([$1]))), [3])])\r
+m4_define([_m4_version_unletter],\r
+[m4_bpatsubst(m4_bpatsubst(m4_translit([[[[0,$1]]]], [.-], [,,]),]dnl\r
+m4_dquote(m4_dquote(m4_defn([m4_cr_Letters])))[[+],\r
+ [+1,-1,[0r36:\&]]), [,0], [,[0r10:0]])])\r
+\r
+\r
+# m4_version_compare(VERSION-1, VERSION-2)\r
+# ----------------------------------------\r
+# Compare the two version numbers and expand into\r
+# -1 if VERSION-1 < VERSION-2\r
+# 0 if =\r
+# 1 if >\r
+#\r
+# Since _m4_version_unletter does not output side effects, we can\r
+# safely bypass the overhead of m4_version_cmp.\r
+m4_define([m4_version_compare],\r
+[_m4_list_cmp_raw(_m4_version_unletter([$1]), _m4_version_unletter([$2]))])\r
+\r
+\r
+# m4_PACKAGE_NAME\r
+# m4_PACKAGE_TARNAME\r
+# m4_PACKAGE_VERSION\r
+# m4_PACKAGE_STRING\r
+# m4_PACKAGE_BUGREPORT\r
+# --------------------\r
+# If m4sugar/version.m4 is present, then define version strings. This\r
+# file is optional, provided by Autoconf but absent in Bison.\r
+m4_sinclude([m4sugar/version.m4])\r
+\r
+\r
+# m4_version_prereq(VERSION, [IF-OK], [IF-NOT = FAIL])\r
+# ----------------------------------------------------\r
+# Check this Autoconf version against VERSION.\r
+m4_define([m4_version_prereq],\r
+m4_ifdef([m4_PACKAGE_VERSION],\r
+[[m4_if(m4_version_compare(]m4_dquote(m4_defn([m4_PACKAGE_VERSION]))[, [$1]),\r
+ [-1],\r
+ [m4_default([$3],\r
+ [m4_fatal([Autoconf version $1 or higher is required],\r
+ [63])])],\r
+ [$2])]],\r
+[[m4_fatal([m4sugar/version.m4 not found])]]))\r
+\r
+\r
+## ------------------ ##\r
+## 15. Set handling. ##\r
+## ------------------ ##\r
+\r
+# Autoconf likes to create arbitrarily large sets; for example, as of\r
+# this writing, the configure.ac for coreutils tracks a set of more\r
+# than 400 AC_SUBST. How do we track all of these set members,\r
+# without introducing duplicates? We could use m4_append_uniq, with\r
+# the set NAME residing in the contents of the macro NAME.\r
+# Unfortunately, m4_append_uniq is quadratic for set creation, because\r
+# it costs O(n) to search the string for each of O(n) insertions; not\r
+# to mention that with m4 1.4.x, even using m4_append is slow, costing\r
+# O(n) rather than O(1) per insertion. Other set operations, not used\r
+# by Autoconf but still possible by manipulation of the definition\r
+# tracked in macro NAME, include O(n) deletion of one element and O(n)\r
+# computation of set size. Because the set is exposed to the user via\r
+# the definition of a single macro, we cannot cache any data about the\r
+# set without risking the cache being invalidated by the user\r
+# redefining NAME.\r
+#\r
+# Can we do better? Yes, because m4 gives us an O(1) search function\r
+# for free: ifdef. Additionally, even m4 1.4.x gives us an O(1)\r
+# insert operation for free: pushdef. But to use these, we must\r
+# represent the set via a group of macros; to keep the set consistent,\r
+# we must hide the set so that the user can only manipulate it through\r
+# accessor macros. The contents of the set are maintained through two\r
+# access points; _m4_set([name]) is a pushdef stack of values in the\r
+# set, useful for O(n) traversal of the set contents; while the\r
+# existence of _m4_set([name],value) with no particular value is\r
+# useful for O(1) querying of set membership. And since the user\r
+# cannot externally manipulate the set, we are free to add additional\r
+# caching macros for other performance improvements. Deletion can be\r
+# O(1) per element rather than O(n), by reworking the definition of\r
+# _m4_set([name],value) to be 0 or 1 based on current membership, and\r
+# adding _m4_set_cleanup(name) to defer the O(n) cleanup of\r
+# _m4_set([name]) until we have another reason to do an O(n)\r
+# traversal. The existence of _m4_set_cleanup(name) can then be used\r
+# elsewhere to determine if we must dereference _m4_set([name],value),\r
+# or assume that definition implies set membership. Finally, size can\r
+# be tracked in an O(1) fashion with _m4_set_size(name).\r
+#\r
+# The quoting in _m4_set([name],value) is chosen so that there is no\r
+# ambiguity with a set whose name contains a comma, and so that we can\r
+# supply the value via _m4_defn([_m4_set([name])]) without needing any\r
+# quote manipulation.\r
+\r
+# m4_set_add(SET, VALUE, [IF-UNIQ], [IF-DUP])\r
+# -------------------------------------------\r
+# Add VALUE as an element of SET. Expand IF-UNIQ on the first\r
+# addition, and IF-DUP if it is already in the set. Addition of one\r
+# element is O(1), such that overall set creation is O(n).\r
+#\r
+# We do not want to add a duplicate for a previously deleted but\r
+# unpruned element, but it is just as easy to check existence directly\r
+# as it is to query _m4_set_cleanup($1).\r
+m4_define([m4_set_add],\r
+[m4_ifdef([_m4_set([$1],$2)],\r
+ [m4_if(m4_indir([_m4_set([$1],$2)]), [0],\r
+ [m4_define([_m4_set([$1],$2)],\r
+ [1])_m4_set_size([$1], [m4_incr])$3], [$4])],\r
+ [m4_define([_m4_set([$1],$2)],\r
+ [1])m4_pushdef([_m4_set([$1])],\r
+ [$2])_m4_set_size([$1], [m4_incr])$3])])\r
+\r
+# m4_set_add_all(SET, VALUE...)\r
+# -----------------------------\r
+# Add each VALUE into SET. This is O(n) in the number of VALUEs, and\r
+# can be faster than calling m4_set_add for each VALUE.\r
+#\r
+# Implement two recursion helpers; the check variant is slower but\r
+# handles the case where an element has previously been removed but\r
+# not pruned. The recursion helpers ignore their second argument, so\r
+# that we can use the faster m4_shift2 and 2 arguments, rather than\r
+# _m4_shift2 and one argument, as the signal to end recursion.\r
+#\r
+# Please keep foreach.m4 in sync with any adjustments made here.\r
+m4_define([m4_set_add_all],\r
+[m4_define([_m4_set_size($1)], m4_eval(m4_set_size([$1])\r
+ + m4_len(m4_ifdef([_m4_set_cleanup($1)], [_$0_check], [_$0])([$1], $@))))])\r
+\r
+m4_define([_m4_set_add_all],\r
+[m4_if([$#], [2], [],\r
+ [m4_ifdef([_m4_set([$1],$3)], [],\r
+ [m4_define([_m4_set([$1],$3)], [1])m4_pushdef([_m4_set([$1])],\r
+ [$3])-])$0([$1], m4_shift2($@))])])\r
+\r
+m4_define([_m4_set_add_all_check],\r
+[m4_if([$#], [2], [],\r
+ [m4_set_add([$1], [$3])$0([$1], m4_shift2($@))])])\r
+\r
+# m4_set_contains(SET, VALUE, [IF-PRESENT], [IF-ABSENT])\r
+# ------------------------------------------------------\r
+# Expand IF-PRESENT if SET contains VALUE, otherwise expand IF-ABSENT.\r
+# This is always O(1).\r
+m4_define([m4_set_contains],\r
+[m4_ifdef([_m4_set_cleanup($1)],\r
+ [m4_if(m4_ifdef([_m4_set([$1],$2)],\r
+ [m4_indir([_m4_set([$1],$2)])], [0]), [1], [$3], [$4])],\r
+ [m4_ifdef([_m4_set([$1],$2)], [$3], [$4])])])\r
+\r
+# m4_set_contents(SET, [SEP])\r
+# ---------------------------\r
+# Expand to a single string containing all the elements in SET,\r
+# separated by SEP, without modifying SET. No provision is made for\r
+# disambiguating set elements that contain non-empty SEP as a\r
+# sub-string, or for recognizing a set that contains only the empty\r
+# string. Order of the output is not guaranteed. If any elements\r
+# have been previously removed from the set, this action will prune\r
+# the unused memory. This is O(n) in the size of the set before\r
+# pruning.\r
+#\r
+# Use _m4_popdef for speed. The existence of _m4_set_cleanup($1)\r
+# determines which version of _1 helper we use.\r
+m4_define([m4_set_contents],\r
+[m4_set_map_sep([$1], [], [], [[$2]])])\r
+\r
+# _m4_set_contents_1(SET)\r
+# _m4_set_contents_1c(SET)\r
+# _m4_set_contents_2(SET, [PRE], [POST], [SEP])\r
+# ---------------------------------------------\r
+# Expand to a list of quoted elements currently in the set, each\r
+# surrounded by PRE and POST, and moving SEP in front of PRE on\r
+# recursion. To avoid nesting limit restrictions, the algorithm must\r
+# be broken into two parts; _1 destructively copies the stack in\r
+# reverse into _m4_set_($1), producing no output; then _2\r
+# destructively copies _m4_set_($1) back into the stack in reverse.\r
+# If no elements were deleted, then this visits the set in the order\r
+# that elements were inserted. Behavior is undefined if PRE/POST/SEP\r
+# tries to recursively list or modify SET in any way other than\r
+# calling m4_set_remove on the current element. Use _1 if all entries\r
+# in the stack are guaranteed to be in the set, and _1c to prune\r
+# removed entries. Uses _m4_defn and _m4_popdef for speed.\r
+m4_define([_m4_set_contents_1],\r
+[_m4_stack_reverse([_m4_set([$1])], [_m4_set_($1)])])\r
+\r
+m4_define([_m4_set_contents_1c],\r
+[m4_ifdef([_m4_set([$1])],\r
+ [m4_set_contains([$1], _m4_defn([_m4_set([$1])]),\r
+ [m4_pushdef([_m4_set_($1)], _m4_defn([_m4_set([$1])]))],\r
+ [_m4_popdef([_m4_set([$1],]_m4_defn(\r
+ [_m4_set([$1])])[)])])_m4_popdef([_m4_set([$1])])$0([$1])],\r
+ [_m4_popdef([_m4_set_cleanup($1)])])])\r
+\r
+m4_define([_m4_set_contents_2],\r
+[_m4_stack_reverse([_m4_set_($1)], [_m4_set([$1])],\r
+ [$2[]_m4_defn([_m4_set_($1)])$3], [$4[]])])\r
+\r
+# m4_set_delete(SET)\r
+# ------------------\r
+# Delete all elements in SET, and reclaim any memory occupied by the\r
+# set. This is O(n) in the set size.\r
+#\r
+# Use _m4_defn and _m4_popdef for speed.\r
+m4_define([m4_set_delete],\r
+[m4_ifdef([_m4_set([$1])],\r
+ [_m4_popdef([_m4_set([$1],]_m4_defn([_m4_set([$1])])[)],\r
+ [_m4_set([$1])])$0([$1])],\r
+ [m4_ifdef([_m4_set_cleanup($1)],\r
+ [_m4_popdef([_m4_set_cleanup($1)])])m4_ifdef(\r
+ [_m4_set_size($1)],\r
+ [_m4_popdef([_m4_set_size($1)])])])])\r
+\r
+# m4_set_difference(SET1, SET2)\r
+# -----------------------------\r
+# Produce a LIST of quoted elements that occur in SET1 but not SET2.\r
+# Output a comma prior to any elements, to distinguish the empty\r
+# string from no elements. This can be directly used as a series of\r
+# arguments, such as for m4_join, or wrapped inside quotes for use in\r
+# m4_foreach. Order of the output is not guaranteed.\r
+#\r
+# Short-circuit the idempotence relation.\r
+m4_define([m4_set_difference],\r
+[m4_if([$1], [$2], [], [m4_set_map_sep([$1], [_$0([$2],], [)])])])\r
+\r
+m4_define([_m4_set_difference],\r
+[m4_set_contains([$1], [$2], [], [,[$2]])])\r
+\r
+# m4_set_dump(SET, [SEP])\r
+# -----------------------\r
+# Expand to a single string containing all the elements in SET,\r
+# separated by SEP, then delete SET. In general, if you only need to\r
+# list the contents once, this is faster than m4_set_contents. No\r
+# provision is made for disambiguating set elements that contain\r
+# non-empty SEP as a sub-string. Order of the output is not\r
+# guaranteed. This is O(n) in the size of the set before pruning.\r
+#\r
+# Use _m4_popdef for speed. Use existence of _m4_set_cleanup($1) to\r
+# decide if more expensive recursion is needed.\r
+m4_define([m4_set_dump],\r
+[m4_ifdef([_m4_set_size($1)],\r
+ [_m4_popdef([_m4_set_size($1)])])m4_ifdef([_m4_set_cleanup($1)],\r
+ [_$0_check], [_$0])([$1], [], [$2])])\r
+\r
+# _m4_set_dump(SET, [SEP], [PREP])\r
+# _m4_set_dump_check(SET, [SEP], [PREP])\r
+# --------------------------------------\r
+# Print SEP and the current element, then delete the element and\r
+# recurse with empty SEP changed to PREP. The check variant checks\r
+# whether the element has been previously removed. Use _m4_defn and\r
+# _m4_popdef for speed.\r
+m4_define([_m4_set_dump],\r
+[m4_ifdef([_m4_set([$1])],\r
+ [[$2]_m4_defn([_m4_set([$1])])_m4_popdef([_m4_set([$1],]_m4_defn(\r
+ [_m4_set([$1])])[)], [_m4_set([$1])])$0([$1], [$2$3])])])\r
+\r
+m4_define([_m4_set_dump_check],\r
+[m4_ifdef([_m4_set([$1])],\r
+ [m4_set_contains([$1], _m4_defn([_m4_set([$1])]),\r
+ [[$2]_m4_defn([_m4_set([$1])])])_m4_popdef(\r
+ [_m4_set([$1],]_m4_defn([_m4_set([$1])])[)],\r
+ [_m4_set([$1])])$0([$1], [$2$3])],\r
+ [_m4_popdef([_m4_set_cleanup($1)])])])\r
+\r
+# m4_set_empty(SET, [IF-EMPTY], [IF-ELEMENTS])\r
+# --------------------------------------------\r
+# Expand IF-EMPTY if SET has no elements, otherwise IF-ELEMENTS.\r
+m4_define([m4_set_empty],\r
+[m4_ifdef([_m4_set_size($1)],\r
+ [m4_if(m4_indir([_m4_set_size($1)]), [0], [$2], [$3])], [$2])])\r
+\r
+# m4_set_foreach(SET, VAR, ACTION)\r
+# --------------------------------\r
+# For each element of SET, define VAR to the element and expand\r
+# ACTION. ACTION should not recursively list SET's contents, add\r
+# elements to SET, nor delete any element from SET except the one\r
+# currently in VAR. The order that the elements are visited in is not\r
+# guaranteed. This is faster than the corresponding m4_foreach([VAR],\r
+# m4_indir([m4_dquote]m4_set_listc([SET])), [ACTION])\r
+m4_define([m4_set_foreach],\r
+[m4_pushdef([$2])m4_set_map_sep([$1], [m4_define([$2],], [)$3])])\r
+\r
+# m4_set_intersection(SET1, SET2)\r
+# -------------------------------\r
+# Produce a LIST of quoted elements that occur in both SET1 or SET2.\r
+# Output a comma prior to any elements, to distinguish the empty\r
+# string from no elements. This can be directly used as a series of\r
+# arguments, such as for m4_join, or wrapped inside quotes for use in\r
+# m4_foreach. Order of the output is not guaranteed.\r
+#\r
+# Iterate over the smaller set, and short-circuit the idempotence\r
+# relation.\r
+m4_define([m4_set_intersection],\r
+[m4_if([$1], [$2], [m4_set_listc([$1])],\r
+ m4_eval(m4_set_size([$2]) < m4_set_size([$1])), [1], [$0([$2], [$1])],\r
+ [m4_set_map_sep([$1], [_$0([$2],], [)])])])\r
+\r
+m4_define([_m4_set_intersection],\r
+[m4_set_contains([$1], [$2], [,[$2]])])\r
+\r
+# m4_set_list(SET)\r
+# m4_set_listc(SET)\r
+# -----------------\r
+# Produce a LIST of quoted elements of SET. This can be directly used\r
+# as a series of arguments, such as for m4_join or m4_set_add_all, or\r
+# wrapped inside quotes for use in m4_foreach or m4_map. With\r
+# m4_set_list, there is no way to distinguish an empty set from a set\r
+# containing only the empty string; with m4_set_listc, a leading comma\r
+# is output if there are any elements.\r
+m4_define([m4_set_list],\r
+[m4_set_map_sep([$1], [], [], [,])])\r
+\r
+m4_define([m4_set_listc],\r
+[m4_set_map_sep([$1], [,])])\r
+\r
+# m4_set_map(SET, ACTION)\r
+# -----------------------\r
+# For each element of SET, expand ACTION with a single argument of the\r
+# current element. ACTION should not recursively list SET's contents,\r
+# add elements to SET, nor delete any element from SET except the one\r
+# passed as an argument. The order that the elements are visited in\r
+# is not guaranteed. This is faster than either of the corresponding\r
+# m4_map_args([ACTION]m4_set_listc([SET]))\r
+# m4_set_foreach([SET], [VAR], [ACTION(m4_defn([VAR]))])\r
+m4_define([m4_set_map],\r
+[m4_set_map_sep([$1], [$2(], [)])])\r
+\r
+# m4_set_map_sep(SET, [PRE], [POST], [SEP])\r
+# -----------------------------------------\r
+# For each element of SET, expand PRE[value]POST[], and expand SEP\r
+# between elements.\r
+m4_define([m4_set_map_sep],\r
+[m4_ifdef([_m4_set_cleanup($1)], [_m4_set_contents_1c],\r
+ [_m4_set_contents_1])([$1])_m4_set_contents_2($@)])\r
+\r
+# m4_set_remove(SET, VALUE, [IF-PRESENT], [IF-ABSENT])\r
+# ----------------------------------------------------\r
+# If VALUE is an element of SET, delete it and expand IF-PRESENT.\r
+# Otherwise expand IF-ABSENT. Deleting a single value is O(1),\r
+# although it leaves memory occupied until the next O(n) traversal of\r
+# the set which will compact the set.\r
+#\r
+# Optimize if the element being removed is the most recently added,\r
+# since defining _m4_set_cleanup($1) slows down so many other macros.\r
+# In particular, this plays well with m4_set_foreach and m4_set_map.\r
+m4_define([m4_set_remove],\r
+[m4_set_contains([$1], [$2], [_m4_set_size([$1],\r
+ [m4_decr])m4_if(_m4_defn([_m4_set([$1])]), [$2],\r
+ [_m4_popdef([_m4_set([$1],$2)], [_m4_set([$1])])],\r
+ [m4_define([_m4_set_cleanup($1)])m4_define(\r
+ [_m4_set([$1],$2)], [0])])$3], [$4])])\r
+\r
+# m4_set_size(SET)\r
+# ----------------\r
+# Expand to the number of elements currently in SET. This operation\r
+# is O(1), and thus more efficient than m4_count(m4_set_list([SET])).\r
+m4_define([m4_set_size],\r
+[m4_ifdef([_m4_set_size($1)], [m4_indir([_m4_set_size($1)])], [0])])\r
+\r
+# _m4_set_size(SET, ACTION)\r
+# -------------------------\r
+# ACTION must be either m4_incr or m4_decr, and the size of SET is\r
+# changed accordingly. If the set is empty, ACTION must not be\r
+# m4_decr.\r
+m4_define([_m4_set_size],\r
+[m4_define([_m4_set_size($1)],\r
+ m4_ifdef([_m4_set_size($1)], [$2(m4_indir([_m4_set_size($1)]))],\r
+ [1]))])\r
+\r
+# m4_set_union(SET1, SET2)\r
+# ------------------------\r
+# Produce a LIST of double quoted elements that occur in either SET1\r
+# or SET2, without duplicates. Output a comma prior to any elements,\r
+# to distinguish the empty string from no elements. This can be\r
+# directly used as a series of arguments, such as for m4_join, or\r
+# wrapped inside quotes for use in m4_foreach. Order of the output is\r
+# not guaranteed.\r
+#\r
+# We can rely on the fact that m4_set_listc prunes SET1, so we don't\r
+# need to check _m4_set([$1],element) for 0. Short-circuit the\r
+# idempotence relation.\r
+m4_define([m4_set_union],\r
+[m4_set_listc([$1])m4_if([$1], [$2], [],\r
+ [m4_set_map_sep([$2], [_$0([$1],], [)])])])\r
+\r
+m4_define([_m4_set_union],\r
+[m4_ifdef([_m4_set([$1],$2)], [], [,[$2]])])\r
+\r
+\r
+## ------------------- ##\r
+## 16. File handling. ##\r
+## ------------------- ##\r
+\r
+\r
+# It is a real pity that M4 comes with no macros to bind a diversion\r
+# to a file. So we have to deal without, which makes us a lot more\r
+# fragile than we should.\r
+\r
+\r
+# m4_file_append(FILE-NAME, CONTENT)\r
+# ----------------------------------\r
+m4_define([m4_file_append],\r
+[m4_syscmd([cat >>$1 <<_m4eof\r
+$2\r
+_m4eof\r
+])\r
+m4_if(m4_sysval, [0], [],\r
+ [m4_fatal([$0: cannot write: $1])])])\r
+\r
+\r
+\r
+## ------------------------ ##\r
+## 17. Setting M4sugar up. ##\r
+## ------------------------ ##\r
+\r
+# _m4_divert_diversion should be defined.\r
+m4_divert_push([KILL])\r
+\r
+# m4_init\r
+# -------\r
+# Initialize the m4sugar language.\r
+m4_define([m4_init],\r
+[# All the M4sugar macros start with `m4_', except `dnl' kept as is\r
+# for sake of simplicity.\r
+m4_pattern_forbid([^_?m4_])\r
+m4_pattern_forbid([^dnl$])\r
+\r
+# If __m4_version__ is defined, we assume that we are being run by M4\r
+# 1.6 or newer, thus $@ recursion is linear, and debugmode(+do)\r
+# is available for faster checks of dereferencing undefined macros\r
+# and forcing dumpdef to print to stderr regardless of debugfile.\r
+# But if it is missing, we assume we are being run by M4 1.4.x, that\r
+# $@ recursion is quadratic, and that we need foreach-based\r
+# replacement macros. Also, m4 prior to 1.4.8 loses track of location\r
+# during m4wrap text; __line__ should never be 0.\r
+#\r
+# Use the raw builtin to avoid tripping up include tracing.\r
+# Meanwhile, avoid m4_copy, since it temporarily undefines m4_defn.\r
+m4_ifdef([__m4_version__],\r
+[m4_debugmode([+do])\r
+m4_define([m4_defn], _m4_defn([_m4_defn]))\r
+m4_define([m4_dumpdef], _m4_defn([_m4_dumpdef]))\r
+m4_define([m4_popdef], _m4_defn([_m4_popdef]))\r
+m4_define([m4_undefine], _m4_defn([_m4_undefine]))],\r
+[m4_builtin([include], [m4sugar/foreach.m4])\r
+m4_wrap_lifo([m4_if(__line__, [0], [m4_pushdef([m4_location],\r
+]]m4_dquote(m4_dquote(m4_dquote(__file__:__line__)))[[)])])])\r
+\r
+# Rewrite the first entry of the diversion stack.\r
+m4_divert([KILL])\r
+\r
+# Check the divert push/pop perfect balance.\r
+# Some users are prone to also use m4_wrap to register last-minute\r
+# m4_divert_text; so after our diversion cleanups, we restore\r
+# KILL as the bottom of the diversion stack.\r
+m4_wrap([m4_popdef([_m4_divert_diversion])m4_ifdef(\r
+ [_m4_divert_diversion], [m4_fatal([$0: unbalanced m4_divert_push:\r
+]m4_divert_stack)])_m4_popdef([_m4_divert_stack])m4_divert_push([KILL])])\r
+])\r
--- /dev/null
+# C++ skeleton for Bison\r
+\r
+# Copyright (C) 2002-2012 Free Software Foundation, Inc.\r
+\r
+# This program is free software: you can redistribute it and/or modify\r
+# it under the terms of the GNU General Public License as published by\r
+# the Free Software Foundation, either version 3 of the License, or\r
+# (at your option) any later version.\r
+#\r
+# This program is distributed in the hope that it will be useful,\r
+# but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
+# GNU General Public License for more details.\r
+#\r
+# You should have received a copy of the GNU General Public License\r
+# along with this program. If not, see <http://www.gnu.org/licenses/>.\r
+\r
+m4_pushdef([b4_copyright_years],\r
+ [2002-2012])\r
+\r
+b4_output_begin([b4_dir_prefix[]stack.hh])\r
+b4_copyright([Stack handling for Bison parsers in C++],\r
+ [2002-2012])[\r
+\r
+/**\r
+ ** \file ]b4_dir_prefix[stack.hh\r
+ ** Define the ]b4_namespace_ref[::stack class.\r
+ */\r
+\r
+]b4_cpp_guard_open([b4_dir_prefix[]stack.hh])[\r
+\r
+# include <deque>\r
+\r
+]b4_namespace_open[\r
+ template <class T, class S = std::deque<T> >\r
+ class stack\r
+ {\r
+ public:\r
+ // Hide our reversed order.\r
+ typedef typename S::reverse_iterator iterator;\r
+ typedef typename S::const_reverse_iterator const_iterator;\r
+\r
+ stack () : seq_ ()\r
+ {\r
+ }\r
+\r
+ stack (unsigned int n) : seq_ (n)\r
+ {\r
+ }\r
+\r
+ inline\r
+ T&\r
+ operator [] (unsigned int i)\r
+ {\r
+ return seq_[i];\r
+ }\r
+\r
+ inline\r
+ const T&\r
+ operator [] (unsigned int i) const\r
+ {\r
+ return seq_[i];\r
+ }\r
+\r
+ inline\r
+ void\r
+ push (const T& t)\r
+ {\r
+ seq_.push_front (t);\r
+ }\r
+\r
+ inline\r
+ void\r
+ pop (unsigned int n = 1)\r
+ {\r
+ for (; n; --n)\r
+ seq_.pop_front ();\r
+ }\r
+\r
+ inline\r
+ unsigned int\r
+ height () const\r
+ {\r
+ return seq_.size ();\r
+ }\r
+\r
+ inline const_iterator begin () const { return seq_.rbegin (); }\r
+ inline const_iterator end () const { return seq_.rend (); }\r
+\r
+ private:\r
+ S seq_;\r
+ };\r
+\r
+ /// Present a slice of the top of a stack.\r
+ template <class T, class S = stack<T> >\r
+ class slice\r
+ {\r
+ public:\r
+ slice (const S& stack, unsigned int range)\r
+ : stack_ (stack)\r
+ , range_ (range)\r
+ {\r
+ }\r
+\r
+ inline\r
+ const T&\r
+ operator [] (unsigned int i) const\r
+ {\r
+ return stack_[range_ - i];\r
+ }\r
+\r
+ private:\r
+ const S& stack_;\r
+ unsigned int range_;\r
+ };\r
+]b4_namespace_close[\r
+\r
+]b4_cpp_guard_close([b4_dir_prefix[]stack.hh])\r
+b4_output_end()\r
+\r
+m4_popdef([b4_copyright_years])\r
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>\r
+\r
+<!--\r
+ bison.xsl - common templates for Bison XSLT.\r
+\r
+ Copyright (C) 2007-2012 Free Software Foundation, Inc.\r
+\r
+ This file is part of Bison, the GNU Compiler Compiler.\r
+\r
+ This program is free software: you can redistribute it and/or modify\r
+ it under the terms of the GNU General Public License as published by\r
+ the Free Software Foundation, either version 3 of the License, or\r
+ (at your option) any later version.\r
+\r
+ This program is distributed in the hope that it will be useful,\r
+ but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
+ GNU General Public License for more details.\r
+\r
+ You should have received a copy of the GNU General Public License\r
+ along with this program. If not, see <http://www.gnu.org/licenses/>.\r
+ -->\r
+\r
+<xsl:stylesheet version="1.0"\r
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"\r
+ xmlns:bison="http://www.gnu.org/software/bison/">\r
+\r
+<xsl:key\r
+ name="bison:symbolByName"\r
+ match="/bison-xml-report/grammar/nonterminals/nonterminal"\r
+ use="@name"\r
+/>\r
+<xsl:key\r
+ name="bison:symbolByName"\r
+ match="/bison-xml-report/grammar/terminals/terminal"\r
+ use="@name"\r
+/>\r
+<xsl:key\r
+ name="bison:ruleByNumber"\r
+ match="/bison-xml-report/grammar/rules/rule"\r
+ use="@number"\r
+/>\r
+<xsl:key\r
+ name="bison:ruleByLhs"\r
+ match="/bison-xml-report/grammar/rules/rule[\r
+ @usefulness != 'useless-in-grammar']"\r
+ use="lhs"\r
+/>\r
+<xsl:key\r
+ name="bison:ruleByRhs"\r
+ match="/bison-xml-report/grammar/rules/rule[\r
+ @usefulness != 'useless-in-grammar']"\r
+ use="rhs/symbol"\r
+/>\r
+\r
+<!-- For the specified state, output: #sr-conflicts,#rr-conflicts -->\r
+<xsl:template match="state" mode="bison:count-conflicts">\r
+ <xsl:variable name="transitions" select="actions/transitions"/>\r
+ <xsl:variable name="reductions" select="actions/reductions"/>\r
+ <xsl:variable\r
+ name="terminals"\r
+ select="\r
+ $transitions/transition[@type='shift']/@symbol\r
+ | $reductions/reduction/@symbol\r
+ "\r
+ />\r
+ <xsl:variable name="conflict-data">\r
+ <xsl:for-each select="$terminals">\r
+ <xsl:variable name="name" select="."/>\r
+ <xsl:if test="generate-id($terminals[. = $name][1]) = generate-id(.)">\r
+ <xsl:variable\r
+ name="shift-count"\r
+ select="count($transitions/transition[@symbol=$name])"\r
+ />\r
+ <xsl:variable\r
+ name="reduce-count"\r
+ select="count($reductions/reduction[@symbol=$name])"\r
+ />\r
+ <xsl:if test="$shift-count > 0 and $reduce-count > 0">\r
+ <xsl:text>s</xsl:text>\r
+ </xsl:if>\r
+ <xsl:if test="$reduce-count > 1">\r
+ <xsl:text>r</xsl:text>\r
+ </xsl:if>\r
+ </xsl:if>\r
+ </xsl:for-each>\r
+ </xsl:variable>\r
+ <xsl:value-of select="string-length(translate($conflict-data, 'r', ''))"/>\r
+ <xsl:text>,</xsl:text>\r
+ <xsl:value-of select="string-length(translate($conflict-data, 's', ''))"/>\r
+</xsl:template>\r
+\r
+<xsl:template name="space">\r
+ <xsl:param name="repeat">0</xsl:param>\r
+ <xsl:param name="fill" select="' '"/>\r
+ <xsl:if test="number($repeat) >= 1">\r
+ <xsl:call-template name="space">\r
+ <xsl:with-param name="repeat" select="$repeat - 1"/>\r
+ <xsl:with-param name="fill" select="$fill"/>\r
+ </xsl:call-template>\r
+ <xsl:value-of select="$fill"/>\r
+ </xsl:if>\r
+</xsl:template>\r
+\r
+</xsl:stylesheet>\r
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>\r
+\r
+<!--\r
+ xml2dot.xsl - transform Bison XML Report into DOT.\r
+\r
+ Copyright (C) 2007-2012 Free Software Foundation, Inc.\r
+\r
+ This file is part of Bison, the GNU Compiler Compiler.\r
+\r
+ This program is free software: you can redistribute it and/or modify\r
+ it under the terms of the GNU General Public License as published by\r
+ the Free Software Foundation, either version 3 of the License, or\r
+ (at your option) any later version.\r
+\r
+ This program is distributed in the hope that it will be useful,\r
+ but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
+ GNU General Public License for more details.\r
+\r
+ You should have received a copy of the GNU General Public License\r
+ along with this program. If not, see <http://www.gnu.org/licenses/>.\r
+\r
+ Written by Wojciech Polak <polak@gnu.org>.\r
+ -->\r
+\r
+<xsl:stylesheet version="1.0"\r
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"\r
+ xmlns:bison="http://www.gnu.org/software/bison/">\r
+\r
+<xsl:import href="bison.xsl"/>\r
+<xsl:output method="text" encoding="UTF-8" indent="no"/>\r
+\r
+<xsl:template match="/">\r
+ <xsl:apply-templates select="bison-xml-report"/>\r
+</xsl:template>\r
+\r
+<xsl:template match="bison-xml-report">\r
+ <xsl:text>// Generated by GNU Bison </xsl:text>\r
+ <xsl:value-of select="@version"/>\r
+ <xsl:text>. </xsl:text>\r
+ <xsl:text>// Report bugs to <</xsl:text>\r
+ <xsl:value-of select="@bug-report"/>\r
+ <xsl:text>>. </xsl:text>\r
+ <xsl:text>// Home page: <</xsl:text>\r
+ <xsl:value-of select="@url"/>\r
+ <xsl:text>>. </xsl:text>\r
+ <xsl:apply-templates select="automaton">\r
+ <xsl:with-param name="filename" select="filename"/>\r
+ </xsl:apply-templates>\r
+</xsl:template>\r
+\r
+<xsl:template match="automaton">\r
+ <xsl:param name="filename"/>\r
+ <xsl:text>digraph "</xsl:text>\r
+ <xsl:call-template name="escape">\r
+ <xsl:with-param name="subject" select="$filename"/>\r
+ </xsl:call-template>\r
+ <xsl:text>" {\r
+ node [fontname = courier, shape = box, colorscheme = paired6]\r
+ edge [fontname = courier]\r
+\r
+</xsl:text>\r
+ <xsl:apply-templates select="state"/>\r
+ <xsl:text>} </xsl:text>\r
+</xsl:template>\r
+\r
+<xsl:template match="automaton/state">\r
+ <xsl:call-template name="output-node">\r
+ <xsl:with-param name="number" select="@number"/>\r
+ <xsl:with-param name="label">\r
+ <xsl:apply-templates select="itemset/item"/>\r
+ </xsl:with-param>\r
+ </xsl:call-template>\r
+ <xsl:apply-templates select="actions/transitions"/>\r
+ <xsl:apply-templates select="actions/reductions">\r
+ <xsl:with-param name="staten">\r
+ <xsl:value-of select="@number"/>\r
+ </xsl:with-param>\r
+ </xsl:apply-templates>\r
+</xsl:template>\r
+\r
+<xsl:template match="actions/reductions">\r
+ <xsl:param name="staten"/>\r
+ <xsl:for-each select='reduction'>\r
+ <!-- These variables are needed because the current context can't be\r
+ refered to directly in XPath expressions. -->\r
+ <xsl:variable name="rul">\r
+ <xsl:value-of select="@rule"/>\r
+ </xsl:variable>\r
+ <xsl:variable name="ena">\r
+ <xsl:value-of select="@enabled"/>\r
+ </xsl:variable>\r
+ <!-- The foreach's body is protected by this, so that we are actually\r
+ going to iterate once per reduction rule, and not per lookahead. -->\r
+ <xsl:if test='not(preceding-sibling::*[@rule=$rul and @enabled=$ena])'>\r
+ <xsl:variable name="rule">\r
+ <xsl:choose>\r
+ <!-- The acceptation state is refered to as 'accept' in the XML, but\r
+ just as '0' in the DOT. -->\r
+ <xsl:when test="@rule='accept'">\r
+ <xsl:text>0</xsl:text>\r
+ </xsl:when>\r
+ <xsl:otherwise>\r
+ <xsl:value-of select="@rule"/>\r
+ </xsl:otherwise>\r
+ </xsl:choose>\r
+ </xsl:variable>\r
+\r
+ <!-- The edge's beginning -->\r
+ <xsl:call-template name="reduction-edge-start">\r
+ <xsl:with-param name="state" select="$staten"/>\r
+ <xsl:with-param name="rule" select="$rule"/>\r
+ <xsl:with-param name="enabled" select="@enabled"/>\r
+ </xsl:call-template>\r
+\r
+ <!-- The edge's tokens -->\r
+ <!-- Don't show labels for the default action. In other cases, there will\r
+ always be at least one token, so 'label="[]"' will not occur. -->\r
+ <xsl:if test='$rule!=0 and not(../reduction[@enabled=$ena and @rule=$rule and @symbol="$default"])'>\r
+ <xsl:text>label="[</xsl:text>\r
+ <xsl:for-each select='../reduction[@enabled=$ena and @rule=$rule]'>\r
+ <xsl:call-template name="escape">\r
+ <xsl:with-param name="subject" select="@symbol"/>\r
+ </xsl:call-template>\r
+ <xsl:if test="position() != last ()">\r
+ <xsl:text>, </xsl:text>\r
+ </xsl:if>\r
+ </xsl:for-each>\r
+ <xsl:text>]", </xsl:text>\r
+ </xsl:if>\r
+\r
+ <!-- The edge's end -->\r
+ <xsl:text>style=solid] </xsl:text>\r
+\r
+ <!-- The diamond representing the reduction -->\r
+ <xsl:call-template name="reduction-node">\r
+ <xsl:with-param name="state" select="$staten"/>\r
+ <xsl:with-param name="rule" select="$rule"/>\r
+ <xsl:with-param name="color">\r
+ <xsl:choose>\r
+ <xsl:when test='@enabled="true"'>\r
+ <xsl:text>3</xsl:text>\r
+ </xsl:when>\r
+ <xsl:otherwise>\r
+ <xsl:text>5</xsl:text>\r
+ </xsl:otherwise>\r
+ </xsl:choose>\r
+ </xsl:with-param>\r
+ </xsl:call-template>\r
+ </xsl:if>\r
+ </xsl:for-each>\r
+</xsl:template>\r
+\r
+<xsl:template match="actions/transitions">\r
+ <xsl:apply-templates select="transition"/>\r
+</xsl:template>\r
+\r
+<xsl:template match="item">\r
+ <xsl:param name="prev-rule-number"\r
+ select="preceding-sibling::item[1]/@rule-number"/>\r
+ <xsl:apply-templates select="key('bison:ruleByNumber', @rule-number)">\r
+ <xsl:with-param name="point" select="@point"/>\r
+ <xsl:with-param name="num" select="@rule-number"/>\r
+ <xsl:with-param name="prev-lhs"\r
+ select="key('bison:ruleByNumber', $prev-rule-number)/lhs[text()]"\r
+ />\r
+ </xsl:apply-templates>\r
+ <xsl:apply-templates select="lookaheads"/>\r
+</xsl:template>\r
+\r
+<xsl:template match="rule">\r
+ <xsl:param name="point"/>\r
+ <xsl:param name="num"/>\r
+ <xsl:param name="prev-lhs"/>\r
+ <xsl:text> </xsl:text>\r
+ <xsl:choose>\r
+ <xsl:when test="$num < 10">\r
+ <xsl:text> </xsl:text>\r
+ </xsl:when>\r
+ <xsl:when test="$num < 100">\r
+ <xsl:text> </xsl:text>\r
+ </xsl:when>\r
+ <xsl:otherwise>\r
+ <xsl:text></xsl:text>\r
+ </xsl:otherwise>\r
+ </xsl:choose>\r
+ <xsl:value-of select="$num"/>\r
+ <xsl:text> </xsl:text>\r
+ <xsl:choose>\r
+ <xsl:when test="$prev-lhs = lhs[text()]">\r
+ <xsl:call-template name="lpad">\r
+ <xsl:with-param name="str" select="'|'"/>\r
+ <xsl:with-param name="pad" select="number(string-length(lhs[text()])) + 1"/>\r
+ </xsl:call-template>\r
+ </xsl:when>\r
+ <xsl:otherwise>\r
+ <xsl:value-of select="lhs"/>\r
+ <xsl:text>:</xsl:text>\r
+ </xsl:otherwise>\r
+ </xsl:choose>\r
+ <xsl:if test="$point = 0">\r
+ <xsl:text> .</xsl:text>\r
+ </xsl:if>\r
+ <xsl:for-each select="rhs/symbol|rhs/empty">\r
+ <xsl:apply-templates select="."/>\r
+ <xsl:if test="$point = position()">\r
+ <xsl:text> .</xsl:text>\r
+ </xsl:if>\r
+ </xsl:for-each>\r
+</xsl:template>\r
+\r
+<xsl:template match="symbol">\r
+ <xsl:text> </xsl:text>\r
+ <xsl:value-of select="."/>\r
+</xsl:template>\r
+\r
+<xsl:template match="empty"/>\r
+\r
+<xsl:template match="lookaheads">\r
+ <xsl:text> [</xsl:text>\r
+ <xsl:apply-templates select="symbol"/>\r
+ <xsl:text>]</xsl:text>\r
+</xsl:template>\r
+\r
+<xsl:template match="lookaheads/symbol">\r
+ <xsl:value-of select="."/>\r
+ <xsl:if test="position() != last()">\r
+ <xsl:text>, </xsl:text>\r
+ </xsl:if>\r
+</xsl:template>\r
+\r
+<xsl:template name="reduction-edge-start">\r
+ <xsl:param name="state"/>\r
+ <xsl:param name="rule"/>\r
+ <xsl:param name="enabled"/>\r
+\r
+ <xsl:text> </xsl:text>\r
+ <xsl:value-of select="$state"/>\r
+ <xsl:text> -> "</xsl:text>\r
+ <xsl:value-of select="$state"/>\r
+ <xsl:text>R</xsl:text>\r
+ <xsl:value-of select="$rule"/>\r
+ <xsl:if test='$enabled = "false"'>\r
+ <xsl:text>d</xsl:text>\r
+ </xsl:if>\r
+ <xsl:text>" [</xsl:text>\r
+</xsl:template>\r
+\r
+<xsl:template name="reduction-node">\r
+ <xsl:param name="state"/>\r
+ <xsl:param name="rule"/>\r
+ <xsl:param name="color"/>\r
+\r
+ <xsl:text> "</xsl:text>\r
+ <xsl:value-of select="$state"/>\r
+ <xsl:text>R</xsl:text>\r
+ <xsl:value-of select="$rule"/>\r
+ <xsl:if test="$color = 5">\r
+ <xsl:text>d</xsl:text>\r
+ </xsl:if>\r
+ <xsl:text>" [label="</xsl:text>\r
+ <xsl:choose>\r
+ <xsl:when test="$rule = 0">\r
+ <xsl:text>Acc", fillcolor=1</xsl:text>\r
+ </xsl:when>\r
+ <xsl:otherwise>\r
+ <xsl:text>R</xsl:text>\r
+ <xsl:value-of select="$rule"/>\r
+ <xsl:text>", fillcolor=</xsl:text>\r
+ <xsl:value-of select="$color"/>\r
+ </xsl:otherwise>\r
+ </xsl:choose>\r
+ <xsl:text>, shape=diamond, style=filled] </xsl:text>\r
+</xsl:template>\r
+\r
+<xsl:template match="transition">\r
+ <xsl:call-template name="output-edge">\r
+ <xsl:with-param name="src" select="../../../@number"/>\r
+ <xsl:with-param name="dst" select="@state"/>\r
+ <xsl:with-param name="style">\r
+ <xsl:choose>\r
+ <xsl:when test="@symbol = 'error'">\r
+ <xsl:text>dotted</xsl:text>\r
+ </xsl:when>\r
+ <xsl:when test="@type = 'shift'">\r
+ <xsl:text>solid</xsl:text>\r
+ </xsl:when>\r
+ <xsl:otherwise>\r
+ <xsl:text>dashed</xsl:text>\r
+ </xsl:otherwise>\r
+ </xsl:choose>\r
+ </xsl:with-param>\r
+ <xsl:with-param name="label">\r
+ <xsl:if test="not(@symbol = 'error')">\r
+ <xsl:value-of select="@symbol"/>\r
+ </xsl:if>\r
+ </xsl:with-param>\r
+ </xsl:call-template>\r
+</xsl:template>\r
+\r
+<xsl:template name="output-node">\r
+ <xsl:param name="number"/>\r
+ <xsl:param name="label"/>\r
+ <xsl:text> </xsl:text>\r
+ <xsl:value-of select="$number"/>\r
+ <xsl:text> [label="</xsl:text>\r
+ <xsl:text>State </xsl:text>\r
+ <xsl:value-of select="$number"/>\r
+ <xsl:text>\n</xsl:text>\r
+ <xsl:call-template name="escape">\r
+ <xsl:with-param name="subject" select="$label"/>\r
+ </xsl:call-template>\r
+ <xsl:text>\l"] </xsl:text>\r
+</xsl:template>\r
+\r
+<xsl:template name="output-edge">\r
+ <xsl:param name="src"/>\r
+ <xsl:param name="dst"/>\r
+ <xsl:param name="style"/>\r
+ <xsl:param name="label"/>\r
+ <xsl:text> </xsl:text>\r
+ <xsl:value-of select="$src"/>\r
+ <xsl:text> -> </xsl:text>\r
+ <xsl:value-of select="$dst"/>\r
+ <xsl:text> [style=</xsl:text>\r
+ <xsl:value-of select="$style"/>\r
+ <xsl:if test="$label and $label != ''">\r
+ <xsl:text> label="</xsl:text>\r
+ <xsl:call-template name="escape">\r
+ <xsl:with-param name="subject" select="$label"/>\r
+ </xsl:call-template>\r
+ <xsl:text>"</xsl:text>\r
+ </xsl:if>\r
+ <xsl:text>] </xsl:text>\r
+</xsl:template>\r
+\r
+<xsl:template name="escape">\r
+ <xsl:param name="subject"/> <!-- required -->\r
+ <xsl:call-template name="string-replace">\r
+ <xsl:with-param name="subject">\r
+ <xsl:call-template name="string-replace">\r
+ <xsl:with-param name="subject">\r
+ <xsl:call-template name="string-replace">\r
+ <xsl:with-param name="subject" select="$subject"/>\r
+ <xsl:with-param name="search" select="'\'"/>\r
+ <xsl:with-param name="replace" select="'\\'"/>\r
+ </xsl:call-template>\r
+ </xsl:with-param>\r
+ <xsl:with-param name="search" select="'"'"/>\r
+ <xsl:with-param name="replace" select="'\"'"/>\r
+ </xsl:call-template>\r
+ </xsl:with-param>\r
+ <xsl:with-param name="search" select="' '"/>\r
+ <xsl:with-param name="replace" select="'\l'"/>\r
+ </xsl:call-template>\r
+</xsl:template>\r
+\r
+<xsl:template name="string-replace">\r
+ <xsl:param name="subject"/>\r
+ <xsl:param name="search"/>\r
+ <xsl:param name="replace"/>\r
+ <xsl:choose>\r
+ <xsl:when test="contains($subject, $search)">\r
+ <xsl:variable name="before" select="substring-before($subject, $search)"/>\r
+ <xsl:variable name="after" select="substring-after($subject, $search)"/>\r
+ <xsl:value-of select="$before"/>\r
+ <xsl:value-of select="$replace"/>\r
+ <xsl:call-template name="string-replace">\r
+ <xsl:with-param name="subject" select="$after"/>\r
+ <xsl:with-param name="search" select="$search"/>\r
+ <xsl:with-param name="replace" select="$replace"/>\r
+ </xsl:call-template>\r
+ </xsl:when>\r
+ <xsl:otherwise>\r
+ <xsl:value-of select="$subject"/>\r
+ </xsl:otherwise>\r
+ </xsl:choose>\r
+</xsl:template>\r
+\r
+<xsl:template name="lpad">\r
+ <xsl:param name="str" select="''"/>\r
+ <xsl:param name="pad" select="0"/>\r
+ <xsl:variable name="diff" select="$pad - string-length($str)" />\r
+ <xsl:choose>\r
+ <xsl:when test="$diff < 0">\r
+ <xsl:value-of select="$str"/>\r
+ </xsl:when>\r
+ <xsl:otherwise>\r
+ <xsl:call-template name="space">\r
+ <xsl:with-param name="repeat" select="$diff"/>\r
+ </xsl:call-template>\r
+ <xsl:value-of select="$str"/>\r
+ </xsl:otherwise>\r
+ </xsl:choose>\r
+</xsl:template>\r
+\r
+</xsl:stylesheet>\r
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>\r
+\r
+<!--\r
+ xml2text.xsl - transform Bison XML Report into plain text.\r
+\r
+ Copyright (C) 2007-2012 Free Software Foundation, Inc.\r
+\r
+ This file is part of Bison, the GNU Compiler Compiler.\r
+\r
+ This program is free software: you can redistribute it and/or modify\r
+ it under the terms of the GNU General Public License as published by\r
+ the Free Software Foundation, either version 3 of the License, or\r
+ (at your option) any later version.\r
+\r
+ This program is distributed in the hope that it will be useful,\r
+ but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
+ GNU General Public License for more details.\r
+\r
+ You should have received a copy of the GNU General Public License\r
+ along with this program. If not, see <http://www.gnu.org/licenses/>.\r
+\r
+ Written by Wojciech Polak <polak@gnu.org>.\r
+ -->\r
+\r
+<xsl:stylesheet version="1.0"\r
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"\r
+ xmlns:bison="http://www.gnu.org/software/bison/">\r
+\r
+<xsl:import href="bison.xsl"/>\r
+<xsl:output method="text" encoding="UTF-8" indent="no"/>\r
+\r
+<xsl:template match="/">\r
+ <xsl:apply-templates select="bison-xml-report"/>\r
+</xsl:template>\r
+\r
+<xsl:template match="bison-xml-report">\r
+ <xsl:apply-templates select="grammar" mode="reductions"/>\r
+ <xsl:apply-templates select="grammar" mode="useless-in-parser"/>\r
+ <xsl:apply-templates select="automaton" mode="conflicts"/>\r
+ <xsl:apply-templates select="grammar"/>\r
+ <xsl:apply-templates select="automaton"/>\r
+</xsl:template>\r
+\r
+<xsl:template match="grammar" mode="reductions">\r
+ <xsl:apply-templates select="nonterminals" mode="useless-in-grammar"/>\r
+ <xsl:apply-templates select="terminals" mode="unused-in-grammar"/>\r
+ <xsl:apply-templates select="rules" mode="useless-in-grammar"/>\r
+</xsl:template>\r
+\r
+<xsl:template match="nonterminals" mode="useless-in-grammar">\r
+ <xsl:if test="nonterminal[@usefulness='useless-in-grammar']">\r
+ <xsl:text>Nonterminals useless in grammar </xsl:text>\r
+ <xsl:for-each select="nonterminal[@usefulness='useless-in-grammar']">\r
+ <xsl:text> </xsl:text>\r
+ <xsl:value-of select="@name"/>\r
+ <xsl:text> </xsl:text>\r
+ </xsl:for-each>\r
+ <xsl:text> </xsl:text>\r
+ </xsl:if>\r
+</xsl:template>\r
+\r
+<xsl:template match="terminals" mode="unused-in-grammar">\r
+ <xsl:if test="terminal[@usefulness='unused-in-grammar']">\r
+ <xsl:text>Terminals unused in grammar </xsl:text>\r
+ <xsl:for-each select="terminal[@usefulness='unused-in-grammar']">\r
+ <xsl:sort select="@symbol-number" data-type="number"/>\r
+ <xsl:text> </xsl:text>\r
+ <xsl:value-of select="@name"/>\r
+ <xsl:text> </xsl:text>\r
+ </xsl:for-each>\r
+ <xsl:text> </xsl:text>\r
+ </xsl:if>\r
+</xsl:template>\r
+\r
+<xsl:template match="rules" mode="useless-in-grammar">\r
+ <xsl:variable name="set" select="rule[@usefulness='useless-in-grammar']"/>\r
+ <xsl:if test="$set">\r
+ <xsl:text>Rules useless in grammar </xsl:text>\r
+ <xsl:call-template name="style-rule-set">\r
+ <xsl:with-param name="rule-set" select="$set"/>\r
+ </xsl:call-template>\r
+ <xsl:text> </xsl:text>\r
+ </xsl:if>\r
+</xsl:template>\r
+\r
+<xsl:template match="grammar" mode="useless-in-parser">\r
+ <xsl:variable\r
+ name="set" select="rules/rule[@usefulness='useless-in-parser']"\r
+ />\r
+ <xsl:if test="$set">\r
+ <xsl:text>Rules useless in parser due to conflicts </xsl:text>\r
+ <xsl:call-template name="style-rule-set">\r
+ <xsl:with-param name="rule-set" select="$set"/>\r
+ </xsl:call-template>\r
+ <xsl:text> </xsl:text>\r
+ </xsl:if>\r
+</xsl:template>\r
+\r
+<xsl:template match="grammar">\r
+ <xsl:text>Grammar </xsl:text>\r
+ <xsl:call-template name="style-rule-set">\r
+ <xsl:with-param\r
+ name="rule-set" select="rules/rule[@usefulness!='useless-in-grammar']"\r
+ />\r
+ </xsl:call-template>\r
+ <xsl:text> </xsl:text>\r
+ <xsl:apply-templates select="terminals"/>\r
+ <xsl:apply-templates select="nonterminals"/>\r
+</xsl:template>\r
+\r
+<xsl:template name="style-rule-set">\r
+ <xsl:param name="rule-set"/>\r
+ <xsl:for-each select="$rule-set">\r
+ <xsl:apply-templates select=".">\r
+ <xsl:with-param name="pad" select="'3'"/>\r
+ <xsl:with-param name="prev-lhs">\r
+ <xsl:if test="position()>1">\r
+ <xsl:variable name="position" select="position()"/>\r
+ <xsl:value-of select="$rule-set[$position - 1]/lhs"/>\r
+ </xsl:if>\r
+ </xsl:with-param>\r
+ </xsl:apply-templates>\r
+ </xsl:for-each>\r
+</xsl:template>\r
+\r
+<xsl:template match="grammar/terminals">\r
+ <xsl:text>Terminals, with rules where they appear </xsl:text>\r
+ <xsl:apply-templates select="terminal"/>\r
+ <xsl:text> </xsl:text>\r
+</xsl:template>\r
+\r
+<xsl:template match="grammar/nonterminals">\r
+ <xsl:text>Nonterminals, with rules where they appear </xsl:text>\r
+ <xsl:apply-templates select="nonterminal[@usefulness!='useless-in-grammar']"/>\r
+</xsl:template>\r
+\r
+<xsl:template match="terminal">\r
+ <xsl:value-of select="@name"/>\r
+ <xsl:call-template name="line-wrap">\r
+ <xsl:with-param name="first-line-length">\r
+ <xsl:choose>\r
+ <xsl:when test="string-length(@name) > 66">0</xsl:when>\r
+ <xsl:otherwise>\r
+ <xsl:value-of select="66 - string-length(@name)" />\r
+ </xsl:otherwise>\r
+ </xsl:choose>\r
+ </xsl:with-param>\r
+ <xsl:with-param name="line-length" select="66" />\r
+ <xsl:with-param name="text">\r
+ <xsl:value-of select="concat(' (', @token-number, ')')"/>\r
+ <xsl:for-each select="key('bison:ruleByRhs', @name)">\r
+ <xsl:value-of select="concat(' ', @number)"/>\r
+ </xsl:for-each>\r
+ </xsl:with-param>\r
+ </xsl:call-template>\r
+</xsl:template>\r
+\r
+<xsl:template match="nonterminal">\r
+ <xsl:value-of select="@name"/>\r
+ <xsl:value-of select="concat(' (', @symbol-number, ')')"/>\r
+ <xsl:text> </xsl:text>\r
+ <xsl:variable name="output">\r
+ <xsl:call-template name="line-wrap">\r
+ <xsl:with-param name="line-length" select="66" />\r
+ <xsl:with-param name="text">\r
+ <xsl:text> </xsl:text>\r
+ <xsl:if test="key('bison:ruleByLhs', @name)">\r
+ <xsl:text>on@left:</xsl:text>\r
+ <xsl:for-each select="key('bison:ruleByLhs', @name)">\r
+ <xsl:value-of select="concat(' ', @number)"/>\r
+ </xsl:for-each>\r
+ </xsl:if>\r
+ <xsl:if test="key('bison:ruleByRhs', @name)">\r
+ <xsl:if test="key('bison:ruleByLhs', @name)">\r
+ <xsl:text>, </xsl:text>\r
+ </xsl:if>\r
+ <xsl:text>on@right:</xsl:text>\r
+ <xsl:for-each select="key('bison:ruleByRhs', @name)">\r
+ <xsl:value-of select="concat(' ', @number)"/>\r
+ </xsl:for-each>\r
+ </xsl:if>\r
+ </xsl:with-param>\r
+ </xsl:call-template>\r
+ </xsl:variable>\r
+ <xsl:value-of select="translate($output, '@', ' ')" />\r
+</xsl:template>\r
+\r
+<xsl:template match="automaton" mode="conflicts">\r
+ <xsl:variable name="conflict-report">\r
+ <xsl:apply-templates select="state" mode="conflicts"/>\r
+ </xsl:variable>\r
+ <xsl:if test="string-length($conflict-report) != 0">\r
+ <xsl:value-of select="$conflict-report"/>\r
+ <xsl:text> </xsl:text>\r
+ </xsl:if>\r
+</xsl:template>\r
+\r
+<xsl:template match="state" mode="conflicts">\r
+ <xsl:variable name="conflict-counts">\r
+ <xsl:apply-templates select="." mode="bison:count-conflicts" />\r
+ </xsl:variable>\r
+ <xsl:variable\r
+ name="sr-count" select="substring-before($conflict-counts, ',')"\r
+ />\r
+ <xsl:variable\r
+ name="rr-count" select="substring-after($conflict-counts, ',')"\r
+ />\r
+ <xsl:if test="$sr-count > 0 or $rr-count > 0">\r
+ <xsl:value-of select="concat('State ', @number, ' conflicts:')"/>\r
+ <xsl:if test="$sr-count > 0">\r
+ <xsl:value-of select="concat(' ', $sr-count, ' shift/reduce')"/>\r
+ <xsl:if test="$rr-count > 0">\r
+ <xsl:value-of select="(',')"/>\r
+ </xsl:if>\r
+ </xsl:if>\r
+ <xsl:if test="$rr-count > 0">\r
+ <xsl:value-of select="concat(' ', $rr-count, ' reduce/reduce')"/>\r
+ </xsl:if>\r
+ <xsl:value-of select="' '"/>\r
+ </xsl:if>\r
+</xsl:template>\r
+\r
+<xsl:template match="automaton">\r
+ <xsl:apply-templates select="state">\r
+ <xsl:with-param name="pad" select="'3'"/>\r
+ </xsl:apply-templates>\r
+</xsl:template>\r
+\r
+<xsl:template match="automaton/state">\r
+ <xsl:param name="pad"/>\r
+ <xsl:text> </xsl:text>\r
+ <xsl:text>State </xsl:text>\r
+ <xsl:value-of select="@number"/>\r
+ <xsl:text> </xsl:text>\r
+ <xsl:apply-templates select="itemset/item">\r
+ <xsl:with-param name="pad" select="$pad"/>\r
+ </xsl:apply-templates>\r
+ <xsl:apply-templates select="actions/transitions">\r
+ <xsl:with-param name="type" select="'shift'"/>\r
+ </xsl:apply-templates>\r
+ <xsl:apply-templates select="actions/errors"/>\r
+ <xsl:apply-templates select="actions/reductions"/>\r
+ <xsl:apply-templates select="actions/transitions">\r
+ <xsl:with-param name="type" select="'goto'"/>\r
+ </xsl:apply-templates>\r
+ <xsl:apply-templates select="solved-conflicts"/>\r
+</xsl:template>\r
+\r
+<xsl:template match="actions/transitions">\r
+ <xsl:param name="type"/>\r
+ <xsl:if test="transition[@type = $type]">\r
+ <xsl:text> </xsl:text>\r
+ <xsl:apply-templates select="transition[@type = $type]">\r
+ <xsl:with-param name="pad">\r
+ <xsl:call-template name="max-width-symbol">\r
+ <xsl:with-param name="node" select="transition[@type = $type]"/>\r
+ </xsl:call-template>\r
+ </xsl:with-param>\r
+ </xsl:apply-templates>\r
+ </xsl:if>\r
+</xsl:template>\r
+\r
+<xsl:template match="actions/errors">\r
+ <xsl:if test="error">\r
+ <xsl:text> </xsl:text>\r
+ <xsl:apply-templates select="error">\r
+ <xsl:with-param name="pad">\r
+ <xsl:call-template name="max-width-symbol">\r
+ <xsl:with-param name="node" select="error"/>\r
+ </xsl:call-template>\r
+ </xsl:with-param>\r
+ </xsl:apply-templates>\r
+ </xsl:if>\r
+</xsl:template>\r
+\r
+<xsl:template match="actions/reductions">\r
+ <xsl:if test="reduction">\r
+ <xsl:text> </xsl:text>\r
+ <xsl:apply-templates select="reduction">\r
+ <xsl:with-param name="pad">\r
+ <xsl:call-template name="max-width-symbol">\r
+ <xsl:with-param name="node" select="reduction"/>\r
+ </xsl:call-template>\r
+ </xsl:with-param>\r
+ </xsl:apply-templates>\r
+ </xsl:if>\r
+</xsl:template>\r
+\r
+<xsl:template match="item">\r
+ <xsl:param name="pad"/>\r
+ <xsl:param name="prev-rule-number"\r
+ select="preceding-sibling::item[1]/@rule-number"/>\r
+ <xsl:apply-templates\r
+ select="key('bison:ruleByNumber', current()/@rule-number)"\r
+ >\r
+ <xsl:with-param name="itemset" select="'true'"/>\r
+ <xsl:with-param name="pad" select="$pad"/>\r
+ <xsl:with-param\r
+ name="prev-lhs"\r
+ select="key('bison:ruleByNumber', $prev-rule-number)/lhs[text()]"\r
+ />\r
+ <xsl:with-param name="point" select="@point"/>\r
+ <xsl:with-param name="lookaheads">\r
+ <xsl:apply-templates select="lookaheads"/>\r
+ </xsl:with-param>\r
+ </xsl:apply-templates>\r
+</xsl:template>\r
+\r
+<xsl:template match="rule">\r
+ <xsl:param name="itemset"/>\r
+ <xsl:param name="pad"/>\r
+ <xsl:param name="prev-lhs"/>\r
+ <xsl:param name="point"/>\r
+ <xsl:param name="lookaheads"/>\r
+\r
+ <xsl:if test="$itemset != 'true' and not($prev-lhs = lhs[text()])">\r
+ <xsl:text> </xsl:text>\r
+ </xsl:if>\r
+\r
+ <xsl:text> </xsl:text>\r
+ <xsl:call-template name="lpad">\r
+ <xsl:with-param name="str" select="string(@number)"/>\r
+ <xsl:with-param name="pad" select="number($pad)"/>\r
+ </xsl:call-template>\r
+ <xsl:text> </xsl:text>\r
+\r
+ <!-- LHS -->\r
+ <xsl:choose>\r
+ <xsl:when test="$itemset != 'true' and $prev-lhs = lhs[text()]">\r
+ <xsl:call-template name="lpad">\r
+ <xsl:with-param name="str" select="'|'"/>\r
+ <xsl:with-param name="pad" select="number(string-length(lhs[text()])) + 1"/>\r
+ </xsl:call-template>\r
+ </xsl:when>\r
+ <xsl:when test="$itemset = 'true' and $prev-lhs = lhs[text()]">\r
+ <xsl:call-template name="lpad">\r
+ <xsl:with-param name="str" select="'|'"/>\r
+ <xsl:with-param name="pad" select="number(string-length(lhs[text()])) + 1"/>\r
+ </xsl:call-template>\r
+ </xsl:when>\r
+ <xsl:otherwise>\r
+ <xsl:value-of select="lhs"/>\r
+ <xsl:text>:</xsl:text>\r
+ </xsl:otherwise>\r
+ </xsl:choose>\r
+\r
+ <!-- RHS -->\r
+ <xsl:for-each select="rhs/*">\r
+ <xsl:if test="position() = $point + 1">\r
+ <xsl:text> .</xsl:text>\r
+ </xsl:if>\r
+ <xsl:if test="$itemset = 'true' and name(.) != 'empty'">\r
+ <xsl:apply-templates select="."/>\r
+ </xsl:if>\r
+ <xsl:if test="$itemset != 'true'">\r
+ <xsl:apply-templates select="."/>\r
+ </xsl:if>\r
+ <xsl:if test="position() = last() and position() = $point">\r
+ <xsl:text> .</xsl:text>\r
+ </xsl:if>\r
+ </xsl:for-each>\r
+ <xsl:if test="$lookaheads">\r
+ <xsl:value-of select="$lookaheads"/>\r
+ </xsl:if>\r
+\r
+ <xsl:text> </xsl:text>\r
+</xsl:template>\r
+\r
+<xsl:template match="symbol">\r
+ <xsl:text> </xsl:text>\r
+ <xsl:value-of select="."/>\r
+</xsl:template>\r
+\r
+<xsl:template match="empty">\r
+ <xsl:text> /* empty */</xsl:text>\r
+</xsl:template>\r
+\r
+<xsl:template match="lookaheads">\r
+ <xsl:text> [</xsl:text>\r
+ <xsl:apply-templates select="symbol"/>\r
+ <xsl:text>]</xsl:text>\r
+</xsl:template>\r
+\r
+<xsl:template match="lookaheads/symbol">\r
+ <xsl:value-of select="."/>\r
+ <xsl:if test="position() != last()">\r
+ <xsl:text>, </xsl:text>\r
+ </xsl:if>\r
+</xsl:template>\r
+\r
+<xsl:template match="transition">\r
+ <xsl:param name="pad"/>\r
+ <xsl:text> </xsl:text>\r
+ <xsl:call-template name="rpad">\r
+ <xsl:with-param name="str" select="string(@symbol)"/>\r
+ <xsl:with-param name="pad" select="number($pad) + 2"/>\r
+ </xsl:call-template>\r
+ <xsl:choose>\r
+ <xsl:when test="@type = 'shift'">\r
+ <xsl:text>shift, and go to state </xsl:text>\r
+ <xsl:value-of select="@state"/>\r
+ </xsl:when>\r
+ <xsl:when test="@type = 'goto'">\r
+ <xsl:text>go to state </xsl:text>\r
+ <xsl:value-of select="@state"/>\r
+ </xsl:when>\r
+ </xsl:choose>\r
+ <xsl:text> </xsl:text>\r
+</xsl:template>\r
+\r
+<xsl:template match="error">\r
+ <xsl:param name="pad"/>\r
+ <xsl:text> </xsl:text>\r
+ <xsl:call-template name="rpad">\r
+ <xsl:with-param name="str" select="string(@symbol)"/>\r
+ <xsl:with-param name="pad" select="number($pad) + 2"/>\r
+ </xsl:call-template>\r
+ <xsl:text>error</xsl:text>\r
+ <xsl:text> (</xsl:text>\r
+ <xsl:value-of select="text()"/>\r
+ <xsl:text>)</xsl:text>\r
+ <xsl:text> </xsl:text>\r
+</xsl:template>\r
+\r
+<xsl:template match="reduction">\r
+ <xsl:param name="pad"/>\r
+ <xsl:text> </xsl:text>\r
+ <xsl:call-template name="rpad">\r
+ <xsl:with-param name="str" select="string(@symbol)"/>\r
+ <xsl:with-param name="pad" select="number($pad) + 2"/>\r
+ </xsl:call-template>\r
+ <xsl:if test="@enabled = 'false'">\r
+ <xsl:text>[</xsl:text>\r
+ </xsl:if>\r
+ <xsl:choose>\r
+ <xsl:when test="@rule = 'accept'">\r
+ <xsl:text>accept</xsl:text>\r
+ </xsl:when>\r
+ <xsl:otherwise>\r
+ <xsl:text>reduce using rule </xsl:text>\r
+ <xsl:value-of select="@rule"/>\r
+ <xsl:text> (</xsl:text>\r
+ <xsl:value-of\r
+ select="key('bison:ruleByNumber', current()/@rule)/lhs[text()]"/>\r
+ <xsl:text>)</xsl:text>\r
+ </xsl:otherwise>\r
+ </xsl:choose>\r
+ <xsl:if test="@enabled = 'false'">\r
+ <xsl:text>]</xsl:text>\r
+ </xsl:if>\r
+ <xsl:text> </xsl:text>\r
+</xsl:template>\r
+\r
+<xsl:template match="solved-conflicts">\r
+ <xsl:if test="resolution">\r
+ <xsl:text> </xsl:text>\r
+ <xsl:apply-templates select="resolution"/>\r
+ </xsl:if>\r
+</xsl:template>\r
+\r
+<xsl:template match="resolution">\r
+ <xsl:text> Conflict between rule </xsl:text>\r
+ <xsl:value-of select="@rule"/>\r
+ <xsl:text> and token </xsl:text>\r
+ <xsl:value-of select="@symbol"/>\r
+ <xsl:text> resolved as </xsl:text>\r
+ <xsl:if test="@type = 'error'">\r
+ <xsl:text>an </xsl:text>\r
+ </xsl:if>\r
+ <xsl:value-of select="@type"/>\r
+ <xsl:text> (</xsl:text>\r
+ <xsl:value-of select="."/>\r
+ <xsl:text>). </xsl:text>\r
+</xsl:template>\r
+\r
+<xsl:template name="max-width-symbol">\r
+ <xsl:param name="node"/>\r
+ <xsl:variable name="longest">\r
+ <xsl:for-each select="$node">\r
+ <xsl:sort data-type="number" select="string-length(@symbol)"\r
+ order="descending"/>\r
+ <xsl:if test="position() = 1">\r
+ <xsl:value-of select="string-length(@symbol)"/>\r
+ </xsl:if>\r
+ </xsl:for-each>\r
+ </xsl:variable>\r
+ <xsl:value-of select="$longest"/>\r
+</xsl:template>\r
+\r
+<xsl:template name="lpad">\r
+ <xsl:param name="str" select="''"/>\r
+ <xsl:param name="pad" select="0"/>\r
+ <xsl:variable name="diff" select="$pad - string-length($str)" />\r
+ <xsl:choose>\r
+ <xsl:when test="$diff < 0">\r
+ <xsl:value-of select="$str"/>\r
+ </xsl:when>\r
+ <xsl:otherwise>\r
+ <xsl:call-template name="space">\r
+ <xsl:with-param name="repeat" select="$diff"/>\r
+ </xsl:call-template>\r
+ <xsl:value-of select="$str"/>\r
+ </xsl:otherwise>\r
+ </xsl:choose>\r
+</xsl:template>\r
+\r
+<xsl:template name="rpad">\r
+ <xsl:param name="str" select="''"/>\r
+ <xsl:param name="pad" select="0"/>\r
+ <xsl:variable name="diff" select="$pad - string-length($str)"/>\r
+ <xsl:choose>\r
+ <xsl:when test="$diff < 0">\r
+ <xsl:value-of select="$str"/>\r
+ </xsl:when>\r
+ <xsl:otherwise>\r
+ <xsl:value-of select="$str"/>\r
+ <xsl:call-template name="space">\r
+ <xsl:with-param name="repeat" select="$diff"/>\r
+ </xsl:call-template>\r
+ </xsl:otherwise>\r
+ </xsl:choose>\r
+</xsl:template>\r
+\r
+<xsl:template name="line-wrap">\r
+ <xsl:param name="line-length"/> <!-- required -->\r
+ <xsl:param name="first-line-length" select="$line-length"/>\r
+ <xsl:param name="text"/> <!-- required -->\r
+ <xsl:choose>\r
+ <xsl:when test="normalize-space($text) = ''" />\r
+ <xsl:when test="string-length($text) <= $first-line-length">\r
+ <xsl:value-of select="concat($text, ' ')" />\r
+ </xsl:when>\r
+ <xsl:otherwise>\r
+ <xsl:variable name="break-pos">\r
+ <xsl:call-template name="ws-search">\r
+ <xsl:with-param name="text" select="$text" />\r
+ <xsl:with-param name="start" select="$first-line-length+1" />\r
+ </xsl:call-template>\r
+ </xsl:variable>\r
+ <xsl:value-of select="substring($text, 1, $break-pos - 1)" />\r
+ <xsl:text> </xsl:text>\r
+ <xsl:call-template name="line-wrap">\r
+ <xsl:with-param name="line-length" select="$line-length" />\r
+ <xsl:with-param\r
+ name="text" select="concat(' ', substring($text, $break-pos+1))"\r
+ />\r
+ </xsl:call-template>\r
+ </xsl:otherwise>\r
+ </xsl:choose>\r
+</xsl:template>\r
+\r
+<xsl:template name="ws-search">\r
+ <xsl:param name="text"/> <!-- required -->\r
+ <xsl:param name="start"/> <!-- required -->\r
+ <xsl:variable name="search-text" select="substring($text, $start)" />\r
+ <xsl:choose>\r
+ <xsl:when test="not(contains($search-text, ' '))">\r
+ <xsl:value-of select="string-length($text)+1" />\r
+ </xsl:when>\r
+ <xsl:otherwise>\r
+ <xsl:value-of\r
+ select="$start + string-length(substring-before($search-text, ' '))"\r
+ />\r
+ </xsl:otherwise>\r
+ </xsl:choose>\r
+</xsl:template>\r
+\r
+</xsl:stylesheet>\r
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>\r
+\r
+<!--\r
+ xml2html.xsl - transform Bison XML Report into XHTML.\r
+\r
+ Copyright (C) 2007-2012 Free Software Foundation, Inc.\r
+\r
+ This file is part of Bison, the GNU Compiler Compiler.\r
+\r
+ This program is free software: you can redistribute it and/or modify\r
+ it under the terms of the GNU General Public License as published by\r
+ the Free Software Foundation, either version 3 of the License, or\r
+ (at your option) any later version.\r
+\r
+ This program is distributed in the hope that it will be useful,\r
+ but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
+ GNU General Public License for more details.\r
+\r
+ You should have received a copy of the GNU General Public License\r
+ along with this program. If not, see <http://www.gnu.org/licenses/>.\r
+\r
+ Written by Wojciech Polak <polak@gnu.org>.\r
+ -->\r
+\r
+<xsl:stylesheet version="1.0"\r
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"\r
+ xmlns="http://www.w3.org/1999/xhtml"\r
+ xmlns:bison="http://www.gnu.org/software/bison/">\r
+\r
+<xsl:import href="bison.xsl"/>\r
+\r
+<xsl:output method="xml" encoding="UTF-8"\r
+ doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN"\r
+ doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"\r
+ indent="yes"/>\r
+\r
+<xsl:template match="/">\r
+ <html>\r
+ <head>\r
+ <title>\r
+ <xsl:value-of select="bison-xml-report/filename"/>\r
+ <xsl:text> - GNU Bison XML Automaton Report</xsl:text>\r
+ </title>\r
+ <style type="text/css"><![CDATA[\r
+ body {\r
+ font-family: "Nimbus Sans L", Arial, sans-serif;\r
+ font-size: 9pt;\r
+ }\r
+ a:link {\r
+ color: #1f00ff;\r
+ text-decoration: none;\r
+ }\r
+ a:visited {\r
+ color: #1f00ff;\r
+ text-decoration: none;\r
+ }\r
+ a:hover {\r
+ color: red;\r
+ }\r
+ #menu a {\r
+ text-decoration: underline;\r
+ }\r
+ .i {\r
+ font-style: italic;\r
+ }\r
+ .pre {\r
+ font-family: monospace;\r
+ white-space: pre;\r
+ }\r
+ ol.decimal {\r
+ list-style-type: decimal;\r
+ }\r
+ ol.lower-alpha {\r
+ list-style-type: lower-alpha;\r
+ }\r
+ .point {\r
+ color: #cc0000;\r
+ }\r
+ #footer {\r
+ margin-top: 3.5em;\r
+ font-size: 7pt;\r
+ }\r
+ ]]></style>\r
+ </head>\r
+ <body>\r
+ <xsl:apply-templates select="bison-xml-report"/>\r
+ <xsl:text> </xsl:text>\r
+ <div id="footer"><hr />This document was generated using\r
+ <a href="http://www.gnu.org/software/bison/" title="GNU Bison">\r
+ GNU Bison <xsl:value-of select="/bison-xml-report/@version"/></a>\r
+ XML Automaton Report.<br />\r
+ <!-- default copying notice -->\r
+ Verbatim copying and distribution of this entire page is\r
+ permitted in any medium, provided this notice is preserved.</div>\r
+ </body>\r
+ </html>\r
+</xsl:template>\r
+\r
+<xsl:template match="bison-xml-report">\r
+ <h1>GNU Bison XML Automaton Report</h1>\r
+ <p>\r
+ input grammar: <span class="i"><xsl:value-of select="filename"/></span>\r
+ </p>\r
+\r
+ <xsl:text> </xsl:text>\r
+ <h3>Table of Contents</h3>\r
+ <ul id="menu">\r
+ <li>\r
+ <a href="#reductions">Reductions</a>\r
+ <ul class="lower-alpha">\r
+ <li><a href="#nonterminals_useless_in_grammar">Nonterminals useless in grammar</a></li>\r
+ <li><a href="#terminals_unused_in_grammar">Terminals unused in grammar</a></li>\r
+ <li><a href="#rules_useless_in_grammar">Rules useless in grammar</a></li>\r
+ <xsl:if test="grammar/rules/rule[@usefulness='useless-in-parser']">\r
+ <li><a href="#rules_useless_in_parser">Rules useless in parser due to conflicts</a></li>\r
+ </xsl:if>\r
+ </ul>\r
+ </li>\r
+ <li><a href="#conflicts">Conflicts</a></li>\r
+ <li>\r
+ <a href="#grammar">Grammar</a>\r
+ <ul class="lower-alpha">\r
+ <li><a href="#grammar">Itemset</a></li>\r
+ <li><a href="#terminals">Terminal symbols</a></li>\r
+ <li><a href="#nonterminals">Nonterminal symbols</a></li>\r
+ </ul>\r
+ </li>\r
+ <li><a href="#automaton">Automaton</a></li>\r
+ </ul>\r
+ <xsl:apply-templates select="grammar" mode="reductions"/>\r
+ <xsl:apply-templates select="grammar" mode="useless-in-parser"/>\r
+ <xsl:apply-templates select="automaton" mode="conflicts"/>\r
+ <xsl:apply-templates select="grammar"/>\r
+ <xsl:apply-templates select="automaton"/>\r
+</xsl:template>\r
+\r
+<xsl:template match="grammar" mode="reductions">\r
+ <h2>\r
+ <a name="reductions"/>\r
+ <xsl:text> Reductions</xsl:text>\r
+ </h2>\r
+ <xsl:apply-templates select="nonterminals" mode="useless-in-grammar"/>\r
+ <xsl:apply-templates select="terminals" mode="unused-in-grammar"/>\r
+ <xsl:apply-templates select="rules" mode="useless-in-grammar"/>\r
+</xsl:template>\r
+\r
+<xsl:template match="nonterminals" mode="useless-in-grammar">\r
+ <h3>\r
+ <a name="nonterminals_useless_in_grammar"/>\r
+ <xsl:text> Nonterminals useless in grammar</xsl:text>\r
+ </h3>\r
+ <xsl:text> </xsl:text>\r
+ <xsl:if test="nonterminal[@usefulness='useless-in-grammar']">\r
+ <p class="pre">\r
+ <xsl:for-each select="nonterminal[@usefulness='useless-in-grammar']">\r
+ <xsl:text> </xsl:text>\r
+ <xsl:value-of select="@name"/>\r
+ <xsl:text> </xsl:text>\r
+ </xsl:for-each>\r
+ <xsl:text> </xsl:text>\r
+ </p>\r
+ </xsl:if>\r
+</xsl:template>\r
+\r
+<xsl:template match="terminals" mode="unused-in-grammar">\r
+ <h3>\r
+ <a name="terminals_unused_in_grammar"/>\r
+ <xsl:text> Terminals unused in grammar</xsl:text>\r
+ </h3>\r
+ <xsl:text> </xsl:text>\r
+ <xsl:if test="terminal[@usefulness='unused-in-grammar']">\r
+ <p class="pre">\r
+ <xsl:for-each select="terminal[@usefulness='unused-in-grammar']">\r
+ <xsl:sort select="@symbol-number" data-type="number"/>\r
+ <xsl:text> </xsl:text>\r
+ <xsl:value-of select="@name"/>\r
+ <xsl:text> </xsl:text>\r
+ </xsl:for-each>\r
+ <xsl:text> </xsl:text>\r
+ </p>\r
+ </xsl:if>\r
+</xsl:template>\r
+\r
+<xsl:template match="rules" mode="useless-in-grammar">\r
+ <h3>\r
+ <a name="rules_useless_in_grammar"/>\r
+ <xsl:text> Rules useless in grammar</xsl:text>\r
+ </h3>\r
+ <xsl:text> </xsl:text>\r
+ <xsl:variable name="set" select="rule[@usefulness='useless-in-grammar']"/>\r
+ <xsl:if test="$set">\r
+ <p class="pre">\r
+ <xsl:call-template name="style-rule-set">\r
+ <xsl:with-param name="rule-set" select="$set"/>\r
+ </xsl:call-template>\r
+ <xsl:text> </xsl:text>\r
+ </p>\r
+ </xsl:if>\r
+</xsl:template>\r
+\r
+<xsl:template match="grammar" mode="useless-in-parser">\r
+ <xsl:variable\r
+ name="set" select="rules/rule[@usefulness='useless-in-parser']"\r
+ />\r
+ <xsl:if test="$set">\r
+ <h2>\r
+ <a name="rules_useless_in_parser"/>\r
+ <xsl:text> Rules useless in parser due to conflicts</xsl:text>\r
+ </h2>\r
+ <xsl:text> </xsl:text>\r
+ <p class="pre">\r
+ <xsl:call-template name="style-rule-set">\r
+ <xsl:with-param name="rule-set" select="$set"/>\r
+ </xsl:call-template>\r
+ </p>\r
+ <xsl:text> </xsl:text>\r
+ </xsl:if>\r
+</xsl:template>\r
+\r
+<xsl:template match="grammar">\r
+ <h2>\r
+ <a name="grammar"/>\r
+ <xsl:text> Grammar</xsl:text>\r
+ </h2>\r
+ <xsl:text> </xsl:text>\r
+ <p class="pre">\r
+ <xsl:call-template name="style-rule-set">\r
+ <xsl:with-param\r
+ name="rule-set" select="rules/rule[@usefulness!='useless-in-grammar']"\r
+ />\r
+ </xsl:call-template>\r
+ </p>\r
+ <xsl:text> </xsl:text>\r
+ <xsl:apply-templates select="terminals"/>\r
+ <xsl:apply-templates select="nonterminals"/>\r
+</xsl:template>\r
+\r
+<xsl:template name="style-rule-set">\r
+ <xsl:param name="rule-set"/>\r
+ <xsl:for-each select="$rule-set">\r
+ <xsl:apply-templates select=".">\r
+ <xsl:with-param name="pad" select="'3'"/>\r
+ <xsl:with-param name="prev-lhs">\r
+ <xsl:if test="position()>1">\r
+ <xsl:variable name="position" select="position()"/>\r
+ <xsl:value-of select="$rule-set[$position - 1]/lhs"/>\r
+ </xsl:if>\r
+ </xsl:with-param>\r
+ </xsl:apply-templates>\r
+ </xsl:for-each>\r
+</xsl:template>\r
+\r
+<xsl:template match="automaton" mode="conflicts">\r
+ <h2>\r
+ <a name="conflicts"/>\r
+ <xsl:text> Conflicts</xsl:text>\r
+ </h2>\r
+ <xsl:text> </xsl:text>\r
+ <xsl:variable name="conflict-report">\r
+ <xsl:apply-templates select="state" mode="conflicts"/>\r
+ </xsl:variable>\r
+ <xsl:if test="string-length($conflict-report) != 0">\r
+ <p class="pre">\r
+ <xsl:copy-of select="$conflict-report"/>\r
+ <xsl:text> </xsl:text>\r
+ </p>\r
+ </xsl:if>\r
+</xsl:template>\r
+\r
+<xsl:template match="state" mode="conflicts">\r
+ <xsl:variable name="conflict-counts">\r
+ <xsl:apply-templates select="." mode="bison:count-conflicts" />\r
+ </xsl:variable>\r
+ <xsl:variable\r
+ name="sr-count" select="substring-before($conflict-counts, ',')"\r
+ />\r
+ <xsl:variable\r
+ name="rr-count" select="substring-after($conflict-counts, ',')"\r
+ />\r
+ <xsl:if test="$sr-count > 0 or $rr-count > 0">\r
+ <a>\r
+ <xsl:attribute name="href">\r
+ <xsl:value-of select="concat('#state_', @number)"/>\r
+ </xsl:attribute>\r
+ <xsl:value-of select="concat('State ', @number)"/>\r
+ </a>\r
+ <xsl:text> conflicts:</xsl:text>\r
+ <xsl:if test="$sr-count > 0">\r
+ <xsl:value-of select="concat(' ', $sr-count, ' shift/reduce')"/>\r
+ <xsl:if test="$rr-count > 0">\r
+ <xsl:value-of select="(',')"/>\r
+ </xsl:if>\r
+ </xsl:if>\r
+ <xsl:if test="$rr-count > 0">\r
+ <xsl:value-of select="concat(' ', $rr-count, ' reduce/reduce')"/>\r
+ </xsl:if>\r
+ <xsl:value-of select="' '"/>\r
+ </xsl:if>\r
+</xsl:template>\r
+\r
+<xsl:template match="grammar/terminals">\r
+ <h3>\r
+ <a name="terminals"/>\r
+ <xsl:text> Terminals, with rules where they appear</xsl:text>\r
+ </h3>\r
+ <xsl:text> </xsl:text>\r
+ <p class="pre">\r
+ <xsl:apply-templates select="terminal"/>\r
+ </p>\r
+ <xsl:text> </xsl:text>\r
+</xsl:template>\r
+\r
+<xsl:template match="grammar/nonterminals">\r
+ <h3>\r
+ <a name="nonterminals"/>\r
+ <xsl:text> Nonterminals, with rules where they appear</xsl:text>\r
+ </h3>\r
+ <xsl:text> </xsl:text>\r
+ <p class="pre">\r
+ <xsl:apply-templates\r
+ select="nonterminal[@usefulness!='useless-in-grammar']"\r
+ />\r
+ </p>\r
+</xsl:template>\r
+\r
+<xsl:template match="terminal">\r
+ <b><xsl:value-of select="@name"/></b>\r
+ <xsl:value-of select="concat(' (', @token-number, ')')"/>\r
+ <xsl:for-each select="key('bison:ruleByRhs', @name)">\r
+ <xsl:apply-templates select="." mode="number-link"/>\r
+ </xsl:for-each>\r
+ <xsl:text> </xsl:text>\r
+</xsl:template>\r
+\r
+<xsl:template match="nonterminal">\r
+ <b><xsl:value-of select="@name"/></b>\r
+ <xsl:value-of select="concat(' (', @symbol-number, ')')"/>\r
+ <xsl:text> </xsl:text>\r
+ <xsl:if test="key('bison:ruleByLhs', @name)">\r
+ <xsl:text>on left:</xsl:text>\r
+ <xsl:for-each select="key('bison:ruleByLhs', @name)">\r
+ <xsl:apply-templates select="." mode="number-link"/>\r
+ </xsl:for-each>\r
+ </xsl:if>\r
+ <xsl:if test="key('bison:ruleByRhs', @name)">\r
+ <xsl:if test="key('bison:ruleByLhs', @name)">\r
+ <xsl:text> </xsl:text>\r
+ </xsl:if>\r
+ <xsl:text>on right:</xsl:text>\r
+ <xsl:for-each select="key('bison:ruleByRhs', @name)">\r
+ <xsl:apply-templates select="." mode="number-link"/>\r
+ </xsl:for-each>\r
+ </xsl:if>\r
+ <xsl:text> </xsl:text>\r
+</xsl:template>\r
+\r
+<xsl:template match="rule" mode="number-link">\r
+ <xsl:text> </xsl:text>\r
+ <a>\r
+ <xsl:attribute name="href">\r
+ <xsl:value-of select="concat('#rule_', @number)"/>\r
+ </xsl:attribute>\r
+ <xsl:value-of select="@number"/>\r
+ </a>\r
+</xsl:template>\r
+\r
+<xsl:template match="automaton">\r
+ <h2>\r
+ <a name="automaton"/>\r
+ <xsl:text> Automaton</xsl:text>\r
+ </h2>\r
+ <xsl:apply-templates select="state">\r
+ <xsl:with-param name="pad" select="'3'"/>\r
+ </xsl:apply-templates>\r
+</xsl:template>\r
+\r
+<xsl:template match="automaton/state">\r
+ <xsl:param name="pad"/>\r
+ <xsl:text> </xsl:text>\r
+ <h3>\r
+ <a>\r
+ <xsl:attribute name="name">\r
+ <xsl:value-of select="concat('state_', @number)"/>\r
+ </xsl:attribute>\r
+ </a>\r
+ <xsl:text>state </xsl:text>\r
+ <xsl:value-of select="@number"/>\r
+ </h3>\r
+ <xsl:text> </xsl:text>\r
+ <p class="pre">\r
+ <xsl:apply-templates select="itemset/item">\r
+ <xsl:with-param name="pad" select="$pad"/>\r
+ </xsl:apply-templates>\r
+ <xsl:apply-templates select="actions/transitions">\r
+ <xsl:with-param name="type" select="'shift'"/>\r
+ </xsl:apply-templates>\r
+ <xsl:apply-templates select="actions/errors"/>\r
+ <xsl:apply-templates select="actions/reductions"/>\r
+ <xsl:apply-templates select="actions/transitions">\r
+ <xsl:with-param name="type" select="'goto'"/>\r
+ </xsl:apply-templates>\r
+ <xsl:apply-templates select="solved-conflicts"/>\r
+ </p>\r
+</xsl:template>\r
+\r
+<xsl:template match="actions/transitions">\r
+ <xsl:param name="type"/>\r
+ <xsl:if test="transition[@type = $type]">\r
+ <xsl:text> </xsl:text>\r
+ <xsl:apply-templates select="transition[@type = $type]">\r
+ <xsl:with-param name="pad">\r
+ <xsl:call-template name="max-width-symbol">\r
+ <xsl:with-param name="node" select="transition[@type = $type]"/>\r
+ </xsl:call-template>\r
+ </xsl:with-param>\r
+ </xsl:apply-templates>\r
+ </xsl:if>\r
+</xsl:template>\r
+\r
+<xsl:template match="actions/errors">\r
+ <xsl:if test="error">\r
+ <xsl:text> </xsl:text>\r
+ <xsl:apply-templates select="error">\r
+ <xsl:with-param name="pad">\r
+ <xsl:call-template name="max-width-symbol">\r
+ <xsl:with-param name="node" select="error"/>\r
+ </xsl:call-template>\r
+ </xsl:with-param>\r
+ </xsl:apply-templates>\r
+ </xsl:if>\r
+</xsl:template>\r
+\r
+<xsl:template match="actions/reductions">\r
+ <xsl:if test="reduction">\r
+ <xsl:text> </xsl:text>\r
+ <xsl:apply-templates select="reduction">\r
+ <xsl:with-param name="pad">\r
+ <xsl:call-template name="max-width-symbol">\r
+ <xsl:with-param name="node" select="reduction"/>\r
+ </xsl:call-template>\r
+ </xsl:with-param>\r
+ </xsl:apply-templates>\r
+ </xsl:if>\r
+</xsl:template>\r
+\r
+<xsl:template match="item">\r
+ <xsl:param name="pad"/>\r
+ <xsl:param name="prev-rule-number"\r
+ select="preceding-sibling::item[1]/@rule-number"/>\r
+ <xsl:apply-templates\r
+ select="key('bison:ruleByNumber', current()/@rule-number)"\r
+ >\r
+ <xsl:with-param name="itemset" select="'true'"/>\r
+ <xsl:with-param name="pad" select="$pad"/>\r
+ <xsl:with-param name="prev-lhs"\r
+ select="key('bison:ruleByNumber', $prev-rule-number)/lhs[text()]"\r
+ />\r
+ <xsl:with-param name="point" select="@point"/>\r
+ <xsl:with-param name="lookaheads">\r
+ <xsl:apply-templates select="lookaheads"/>\r
+ </xsl:with-param>\r
+ </xsl:apply-templates>\r
+</xsl:template>\r
+\r
+<xsl:template match="rule">\r
+ <xsl:param name="itemset"/>\r
+ <xsl:param name="pad"/>\r
+ <xsl:param name="prev-lhs"/>\r
+ <xsl:param name="point"/>\r
+ <xsl:param name="lookaheads"/>\r
+\r
+ <xsl:if test="$itemset != 'true' and not($prev-lhs = lhs[text()])">\r
+ <xsl:text> </xsl:text>\r
+ </xsl:if>\r
+\r
+ <xsl:if test="$itemset != 'true'">\r
+ <a>\r
+ <xsl:attribute name="name">\r
+ <xsl:value-of select="concat('rule_', @number)"/>\r
+ </xsl:attribute>\r
+ </a>\r
+ </xsl:if>\r
+ <xsl:text> </xsl:text>\r
+\r
+ <xsl:choose>\r
+ <xsl:when test="$itemset = 'true'">\r
+ <a>\r
+ <xsl:attribute name="href">\r
+ <xsl:value-of select="concat('#rule_', @number)"/>\r
+ </xsl:attribute>\r
+ <xsl:call-template name="lpad">\r
+ <xsl:with-param name="str" select="string(@number)"/>\r
+ <xsl:with-param name="pad" select="number($pad)"/>\r
+ </xsl:call-template>\r
+ </a>\r
+ </xsl:when>\r
+ <xsl:otherwise>\r
+ <xsl:call-template name="lpad">\r
+ <xsl:with-param name="str" select="string(@number)"/>\r
+ <xsl:with-param name="pad" select="number($pad)"/>\r
+ </xsl:call-template>\r
+ </xsl:otherwise>\r
+ </xsl:choose>\r
+ <xsl:text> </xsl:text>\r
+\r
+ <!-- LHS -->\r
+ <xsl:choose>\r
+ <xsl:when test="$itemset != 'true' and $prev-lhs = lhs[text()]">\r
+ <xsl:call-template name="lpad">\r
+ <xsl:with-param name="str" select="'|'"/>\r
+ <xsl:with-param name="pad" select="number(string-length(lhs[text()])) + 2"/>\r
+ </xsl:call-template>\r
+ </xsl:when>\r
+ <xsl:when test="$itemset = 'true' and $prev-lhs = lhs[text()]">\r
+ <xsl:call-template name="lpad">\r
+ <xsl:with-param name="str" select="'|'"/>\r
+ <xsl:with-param name="pad" select="number(string-length(lhs[text()])) + 2"/>\r
+ </xsl:call-template>\r
+ </xsl:when>\r
+ <xsl:otherwise>\r
+ <span class="i">\r
+ <xsl:value-of select="lhs"/>\r
+ </span>\r
+ <xsl:text> →</xsl:text>\r
+ </xsl:otherwise>\r
+ </xsl:choose>\r
+\r
+ <!-- RHS -->\r
+ <xsl:for-each select="rhs/*">\r
+ <xsl:if test="position() = $point + 1">\r
+ <xsl:text> </xsl:text>\r
+ <span class="point">.</span>\r
+ </xsl:if>\r
+ <xsl:if test="$itemset = 'true' and name(.) != 'empty'">\r
+ <xsl:apply-templates select="."/>\r
+ </xsl:if>\r
+ <xsl:if test="$itemset != 'true'">\r
+ <xsl:apply-templates select="."/>\r
+ </xsl:if>\r
+ <xsl:if test="position() = last() and position() = $point">\r
+ <xsl:text> </xsl:text>\r
+ <span class="point">.</span>\r
+ </xsl:if>\r
+ </xsl:for-each>\r
+ <xsl:if test="$lookaheads">\r
+ <xsl:value-of select="$lookaheads"/>\r
+ </xsl:if>\r
+\r
+ <xsl:text> </xsl:text>\r
+</xsl:template>\r
+\r
+<xsl:template match="symbol">\r
+ <xsl:text> </xsl:text>\r
+ <xsl:choose>\r
+ <xsl:when test="name(key('bison:symbolByName', .)) = 'nonterminal'">\r
+ <span class="i"><xsl:value-of select="."/></span>\r
+ </xsl:when>\r
+ <xsl:otherwise>\r
+ <b><xsl:value-of select="."/></b>\r
+ </xsl:otherwise>\r
+ </xsl:choose>\r
+</xsl:template>\r
+\r
+<xsl:template match="empty">\r
+ <xsl:text> ε</xsl:text>\r
+</xsl:template>\r
+\r
+<xsl:template match="lookaheads">\r
+ <xsl:text> [</xsl:text>\r
+ <xsl:apply-templates select="symbol"/>\r
+ <xsl:text>]</xsl:text>\r
+</xsl:template>\r
+\r
+<xsl:template match="lookaheads/symbol">\r
+ <xsl:value-of select="."/>\r
+ <xsl:if test="position() != last()">\r
+ <xsl:text>, </xsl:text>\r
+ </xsl:if>\r
+</xsl:template>\r
+\r
+<xsl:template match="transition">\r
+ <xsl:param name="pad"/>\r
+ <xsl:text> </xsl:text>\r
+ <xsl:call-template name="rpad">\r
+ <xsl:with-param name="str" select="string(@symbol)"/>\r
+ <xsl:with-param name="pad" select="number($pad) + 2"/>\r
+ </xsl:call-template>\r
+ <xsl:choose>\r
+ <xsl:when test="@type = 'shift'">\r
+ <a>\r
+ <xsl:attribute name="href">\r
+ <xsl:value-of select="concat('#state_', @state)"/>\r
+ </xsl:attribute>\r
+ <xsl:value-of select="concat('shift, and go to state ', @state)"/>\r
+ </a>\r
+ </xsl:when>\r
+ <xsl:when test="@type = 'goto'">\r
+ <a>\r
+ <xsl:attribute name="href">\r
+ <xsl:value-of select="concat('#state_', @state)"/>\r
+ </xsl:attribute>\r
+ <xsl:value-of select="concat('go to state ', @state)"/>\r
+ </a>\r
+ </xsl:when>\r
+ </xsl:choose>\r
+ <xsl:text> </xsl:text>\r
+</xsl:template>\r
+\r
+<xsl:template match="error">\r
+ <xsl:param name="pad"/>\r
+ <xsl:text> </xsl:text>\r
+ <xsl:call-template name="rpad">\r
+ <xsl:with-param name="str" select="string(@symbol)"/>\r
+ <xsl:with-param name="pad" select="number($pad) + 2"/>\r
+ </xsl:call-template>\r
+ <xsl:text>error</xsl:text>\r
+ <xsl:text> (</xsl:text>\r
+ <xsl:value-of select="text()"/>\r
+ <xsl:text>)</xsl:text>\r
+ <xsl:text> </xsl:text>\r
+</xsl:template>\r
+\r
+<xsl:template match="reduction">\r
+ <xsl:param name="pad"/>\r
+ <xsl:text> </xsl:text>\r
+ <xsl:call-template name="rpad">\r
+ <xsl:with-param name="str" select="string(@symbol)"/>\r
+ <xsl:with-param name="pad" select="number($pad) + 2"/>\r
+ </xsl:call-template>\r
+ <xsl:if test="@enabled = 'false'">\r
+ <xsl:text>[</xsl:text>\r
+ </xsl:if>\r
+ <xsl:choose>\r
+ <xsl:when test="@rule = 'accept'">\r
+ <xsl:text>accept</xsl:text>\r
+ </xsl:when>\r
+ <xsl:otherwise>\r
+ <a>\r
+ <xsl:attribute name="href">\r
+ <xsl:value-of select="concat('#rule_', @rule)"/>\r
+ </xsl:attribute>\r
+ <xsl:value-of select="concat('reduce using rule ', @rule)"/>\r
+ </a>\r
+ <xsl:text> (</xsl:text>\r
+ <xsl:value-of\r
+ select="key('bison:ruleByNumber', current()/@rule)/lhs[text()]"\r
+ />\r
+ <xsl:text>)</xsl:text>\r
+ </xsl:otherwise>\r
+ </xsl:choose>\r
+ <xsl:if test="@enabled = 'false'">\r
+ <xsl:text>]</xsl:text>\r
+ </xsl:if>\r
+ <xsl:text> </xsl:text>\r
+</xsl:template>\r
+\r
+<xsl:template match="solved-conflicts">\r
+ <xsl:if test="resolution">\r
+ <xsl:text> </xsl:text>\r
+ <xsl:apply-templates select="resolution"/>\r
+ </xsl:if>\r
+</xsl:template>\r
+\r
+<xsl:template match="resolution">\r
+ <xsl:text> Conflict between </xsl:text>\r
+ <a>\r
+ <xsl:attribute name="href">\r
+ <xsl:value-of select="concat('#rule_', @rule)"/>\r
+ </xsl:attribute>\r
+ <xsl:value-of select="concat('rule ',@rule)"/>\r
+ </a>\r
+ <xsl:text> and token </xsl:text>\r
+ <xsl:value-of select="@symbol"/>\r
+ <xsl:text> resolved as </xsl:text>\r
+ <xsl:if test="@type = 'error'">\r
+ <xsl:text>an </xsl:text>\r
+ </xsl:if>\r
+ <xsl:value-of select="@type"/>\r
+ <xsl:text> (</xsl:text>\r
+ <xsl:value-of select="."/>\r
+ <xsl:text>). </xsl:text>\r
+</xsl:template>\r
+\r
+<xsl:template name="max-width-symbol">\r
+ <xsl:param name="node"/>\r
+ <xsl:variable name="longest">\r
+ <xsl:for-each select="$node">\r
+ <xsl:sort data-type="number" select="string-length(@symbol)"\r
+ order="descending"/>\r
+ <xsl:if test="position() = 1">\r
+ <xsl:value-of select="string-length(@symbol)"/>\r
+ </xsl:if>\r
+ </xsl:for-each>\r
+ </xsl:variable>\r
+ <xsl:value-of select="$longest"/>\r
+</xsl:template>\r
+\r
+<xsl:template name="lpad">\r
+ <xsl:param name="str" select="''"/>\r
+ <xsl:param name="pad" select="0"/>\r
+ <xsl:variable name="diff" select="$pad - string-length($str)" />\r
+ <xsl:choose>\r
+ <xsl:when test="$diff < 0">\r
+ <xsl:value-of select="$str"/>\r
+ </xsl:when>\r
+ <xsl:otherwise>\r
+ <xsl:call-template name="space">\r
+ <xsl:with-param name="repeat" select="$diff"/>\r
+ </xsl:call-template>\r
+ <xsl:value-of select="$str"/>\r
+ </xsl:otherwise>\r
+ </xsl:choose>\r
+</xsl:template>\r
+\r
+<xsl:template name="rpad">\r
+ <xsl:param name="str" select="''"/>\r
+ <xsl:param name="pad" select="0"/>\r
+ <xsl:variable name="diff" select="$pad - string-length($str)"/>\r
+ <xsl:choose>\r
+ <xsl:when test="$diff < 0">\r
+ <xsl:value-of select="$str"/>\r
+ </xsl:when>\r
+ <xsl:otherwise>\r
+ <xsl:value-of select="$str"/>\r
+ <xsl:call-template name="space">\r
+ <xsl:with-param name="repeat" select="$diff"/>\r
+ </xsl:call-template>\r
+ </xsl:otherwise>\r
+ </xsl:choose>\r
+</xsl:template>\r
+\r
+<xsl:template name="space">\r
+ <xsl:param name="repeat">0</xsl:param>\r
+ <xsl:param name="fill" select="' '"/>\r
+ <xsl:if test="number($repeat) >= 1">\r
+ <xsl:call-template name="space">\r
+ <xsl:with-param name="repeat" select="$repeat - 1"/>\r
+ <xsl:with-param name="fill" select="$fill"/>\r
+ </xsl:call-template>\r
+ <xsl:value-of select="$fill"/>\r
+ </xsl:if>\r
+</xsl:template>\r
+\r
+</xsl:stylesheet>\r
--- /dev/null
+ -*- C -*-
+
+# Yacc compatible skeleton for Bison
+
+# Copyright (C) 1984, 1989-1990, 2000-2012 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 3 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, see <http://www.gnu.org/licenses/>.
+
+# Check the value of %define api.push-pull.
+b4_percent_define_default([[api.push-pull]], [[pull]])
+b4_percent_define_check_values([[[[api.push-pull]],
+ [[pull]], [[push]], [[both]]]])
+b4_define_flag_if([pull]) m4_define([b4_pull_flag], [[1]])
+b4_define_flag_if([push]) m4_define([b4_push_flag], [[1]])
+m4_case(b4_percent_define_get([[api.push-pull]]),
+ [pull], [m4_define([b4_push_flag], [[0]])],
+ [push], [m4_define([b4_pull_flag], [[0]])])
+
+# Handle BISON_USE_PUSH_FOR_PULL for the test suite. So that push parsing
+# tests function as written, do not let BISON_USE_PUSH_FOR_PULL modify the
+# behavior of Bison at all when push parsing is already requested.
+b4_define_flag_if([use_push_for_pull])
+b4_use_push_for_pull_if([
+ b4_push_if([m4_define([b4_use_push_for_pull_flag], [[0]])],
+ [m4_define([b4_push_flag], [[1]])])])
+
+# Check the value of %define parse.lac and friends, where LAC stands for
+# lookahead correction.
+b4_percent_define_default([[parse.lac]], [[none]])
+b4_percent_define_default([[parse.lac.es-capacity-initial]], [[20]])
+b4_percent_define_default([[parse.lac.memory-trace]], [[failures]])
+b4_percent_define_check_values([[[[parse.lac]], [[full]], [[none]]]],
+ [[[[parse.lac.memory-trace]],
+ [[failures]], [[full]]]])
+b4_define_flag_if([lac])
+m4_define([b4_lac_flag],
+ [m4_if(b4_percent_define_get([[parse.lac]]),
+ [none], [[0]], [[1]])])
+
+m4_include(b4_pkgdatadir/[c.m4])
+
+## ---------------- ##
+## Default values. ##
+## ---------------- ##
+
+# Stack parameters.
+m4_define_default([b4_stack_depth_max], [10000])
+m4_define_default([b4_stack_depth_init], [200])
+
+
+## ------------------------ ##
+## Pure/impure interfaces. ##
+## ------------------------ ##
+
+b4_percent_define_default([[api.pure]], [[false]])
+b4_percent_define_check_values([[[[api.pure]],
+ [[false]], [[true]], [[]], [[full]]]])
+
+m4_define([b4_pure_flag], [[0]])
+m4_case(b4_percent_define_get([[api.pure]]),
+ [false], [m4_define([b4_pure_flag], [[0]])],
+ [true], [m4_define([b4_pure_flag], [[1]])],
+ [], [m4_define([b4_pure_flag], [[1]])],
+ [full], [m4_define([b4_pure_flag], [[2]])])
+
+m4_define([b4_pure_if],
+[m4_case(b4_pure_flag,
+ [0], [$2],
+ [1], [$1],
+ [2], [$1])])
+ [m4_fatal([invalid api.pure value: ]$1)])])
+
+# b4_yyerror_arg_loc_if(ARG)
+# --------------------------
+# Expand ARG iff yyerror is to be given a location as argument.
+m4_define([b4_yyerror_arg_loc_if],
+[b4_locations_if([m4_case(b4_pure_flag,
+ [1], [m4_ifset([b4_parse_param], [$1])],
+ [2], [$1])])])
+
+# b4_yyerror_args
+# ---------------
+# Arguments passed to yyerror: user args plus yylloc.
+m4_define([b4_yyerror_args],
+[b4_yyerror_arg_loc_if([&yylloc, ])dnl
+m4_ifset([b4_parse_param], [b4_c_args(b4_parse_param), ])])
+
+
+# b4_lex_param
+# ------------
+# Accumulate in b4_lex_param all the yylex arguments.
+# b4_lex_param arrives quoted twice, but we want to keep only one level.
+m4_define([b4_lex_param],
+m4_dquote(b4_pure_if([[[[YYSTYPE *]], [[&yylval]]][]dnl
+b4_locations_if([, [[YYLTYPE *], [&yylloc]]])m4_ifdef([b4_lex_param], [, ])])dnl
+m4_ifdef([b4_lex_param], b4_lex_param)))
+
+
+## ------------ ##
+## Data Types. ##
+## ------------ ##
+
+# b4_int_type(MIN, MAX)
+# ---------------------
+# Return the smallest int type able to handle numbers ranging from
+# MIN to MAX (included). Overwrite the version from c.m4, which
+# uses only C89 types, so that the user can override the shorter
+# types, and so that pre-C89 compilers are handled correctly.
+m4_define([b4_int_type],
+[m4_if(b4_ints_in($@, [0], [255]), [1], [yytype_uint8],
+ b4_ints_in($@, [-128], [127]), [1], [yytype_int8],
+
+ b4_ints_in($@, [0], [65535]), [1], [yytype_uint16],
+ b4_ints_in($@, [-32768], [32767]), [1], [yytype_int16],
+
+ m4_eval([0 <= $1]), [1], [unsigned int],
+
+ [int])])
+
+
+## ----------------- ##
+## Semantic Values. ##
+## ----------------- ##
+
+
+# b4_lhs_value([TYPE])
+# --------------------
+# Expansion of $<TYPE>$.
+m4_define([b4_lhs_value],
+[(yyval[]m4_ifval([$1], [.$1]))])
+
+
+# b4_rhs_value(RULE-LENGTH, NUM, [TYPE])
+# --------------------------------------
+# Expansion of $<TYPE>NUM, where the current rule has RULE-LENGTH
+# symbols on RHS.
+m4_define([b4_rhs_value],
+[(yyvsp@{($2) - ($1)@}m4_ifval([$3], [.$3]))])
+
+
+
+## ----------- ##
+## Locations. ##
+## ----------- ##
+
+# b4_lhs_location()
+# -----------------
+# Expansion of @$.
+m4_define([b4_lhs_location],
+[(yyloc)])
+
+
+# b4_rhs_location(RULE-LENGTH, NUM)
+# ---------------------------------
+# Expansion of @NUM, where the current rule has RULE-LENGTH symbols
+# on RHS.
+m4_define([b4_rhs_location],
+[(yylsp@{($2) - ($1)@})])
+
+
+## -------------- ##
+## Declarations. ##
+## -------------- ##
+
+# b4_declare_scanner_communication_variables
+# ------------------------------------------
+# Declare the variables that are global, or local to YYPARSE if
+# pure-parser.
+m4_define([b4_declare_scanner_communication_variables], [[
+/* The lookahead symbol. */
+int yychar;
+
+]b4_pure_if([[
+#if defined __GNUC__ && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
+/* Suppress an incorrect diagnostic about yylval being uninitialized. */
+# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
+ _Pragma ("GCC diagnostic push") \
+ _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")\
+ _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
+# define YY_IGNORE_MAYBE_UNINITIALIZED_END \
+ _Pragma ("GCC diagnostic pop")
+#else
+/* Default value used for initialization, for pacifying older GCCs
+ or non-GCC compilers. */
+static YYSTYPE yyval_default;
+# define YY_INITIAL_VALUE(Value) = Value
+#endif]b4_locations_if([[
+static YYLTYPE yyloc_default][]b4_yyloc_default[;]])])[
+#ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
+# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
+# define YY_IGNORE_MAYBE_UNINITIALIZED_END
+#endif
+#ifndef YY_INITIAL_VALUE
+# define YY_INITIAL_VALUE(Value) /* Nothing. */
+#endif
+
+/* The semantic value of the lookahead symbol. */
+YYSTYPE yylval YY_INITIAL_VALUE(yyval_default);]b4_locations_if([[
+
+/* Location data for the lookahead symbol. */
+YYLTYPE yylloc]b4_pure_if([ = yyloc_default], [b4_yyloc_default])[;
+]])b4_pure_if([], [[
+
+/* Number of syntax errors so far. */
+int yynerrs;]])])
+
+
+# b4_declare_parser_state_variables
+# ---------------------------------
+# Declare all the variables that are needed to maintain the parser state
+# between calls to yypush_parse.
+m4_define([b4_declare_parser_state_variables], [b4_pure_if([[
+ /* Number of syntax errors so far. */
+ int yynerrs;
+]])[
+ int yystate;
+ /* Number of tokens to shift before error messages enabled. */
+ int yyerrstatus;
+
+ /* The stacks and their tools:
+ `yyss': related to states.
+ `yyvs': related to semantic values.]b4_locations_if([[
+ `yyls': related to locations.]])[
+
+ Refer to the stacks through separate pointers, to allow yyoverflow
+ to reallocate them elsewhere. */
+
+ /* The state stack. */
+ yytype_int16 yyssa[YYINITDEPTH];
+ yytype_int16 *yyss;
+ yytype_int16 *yyssp;
+
+ /* The semantic value stack. */
+ YYSTYPE yyvsa[YYINITDEPTH];
+ YYSTYPE *yyvs;
+ YYSTYPE *yyvsp;]b4_locations_if([[
+
+ /* The location stack. */
+ YYLTYPE yylsa[YYINITDEPTH];
+ YYLTYPE *yyls;
+ YYLTYPE *yylsp;
+
+ /* The locations where the error started and ended. */
+ YYLTYPE yyerror_range[3];]])[
+
+ YYSIZE_T yystacksize;]b4_lac_if([[
+
+ yytype_int16 yyesa@{]b4_percent_define_get([[parse.lac.es-capacity-initial]])[@};
+ yytype_int16 *yyes;
+ YYSIZE_T yyes_capacity;]])])
+
+
+# b4_declare_yyparse_push_
+# ------------------------
+# Declaration of yyparse (and dependencies) when using the push parser
+# (including in pull mode).
+m4_define([b4_declare_yyparse_push_],
+[[#ifndef YYPUSH_MORE_DEFINED
+# define YYPUSH_MORE_DEFINED
+enum { YYPUSH_MORE = 4 };
+#endif
+
+typedef struct ]b4_prefix[pstate ]b4_prefix[pstate;
+
+]b4_pull_if([b4_c_function_decl([b4_prefix[parse]], [[int]], b4_parse_param)
+])b4_c_function_decl([b4_prefix[push_parse]], [[int]],
+ [[b4_prefix[pstate *ps]], [[ps]]]b4_pure_if([,
+ [[[int pushed_char]], [[pushed_char]]],
+ [[b4_api_PREFIX[STYPE const *pushed_val]], [[pushed_val]]]b4_locations_if([,
+ [[b4_api_PREFIX[LTYPE *pushed_loc]], [[pushed_loc]]]])])m4_ifset([b4_parse_param], [,
+ b4_parse_param]))
+b4_pull_if([b4_c_function_decl([b4_prefix[pull_parse]], [[int]],
+ [[b4_prefix[pstate *ps]], [[ps]]]m4_ifset([b4_parse_param], [,
+ b4_parse_param]))])
+b4_c_function_decl([b4_prefix[pstate_new]], [b4_prefix[pstate *]],
+ [[[void]], []])
+b4_c_function_decl([b4_prefix[pstate_delete]], [[void]],
+ [[b4_prefix[pstate *ps]], [[ps]]])dnl
+])
+
+# b4_declare_yyparse_
+# -------------------
+# When not the push parser.
+m4_define([b4_declare_yyparse_],
+[[#ifdef YYPARSE_PARAM
+]b4_c_function_decl(b4_prefix[parse], [int],
+ [[void *YYPARSE_PARAM], [YYPARSE_PARAM]])[
+#else /* ! YYPARSE_PARAM */
+]b4_c_function_decl(b4_prefix[parse], [int], b4_parse_param)[
+#endif /* ! YYPARSE_PARAM */]dnl
+])
+
+
+# b4_declare_yyparse
+# ------------------
+m4_define([b4_declare_yyparse],
+[b4_push_if([b4_declare_yyparse_push_],
+ [b4_declare_yyparse_])[]dnl
+])
+
+
+# b4_shared_declarations
+# ----------------------
+# Declaration that might either go into the header (if --defines)
+# or open coded in the parser body.
+m4_define([b4_shared_declarations],
+[b4_cpp_guard_open([b4_spec_defines_file])[
+]b4_declare_yydebug[
+]b4_percent_code_get([[requires]])[
+]b4_token_enums_defines(b4_tokens)[
+]b4_declare_yylstype[
+]b4_declare_yyparse[
+]b4_percent_code_get([[provides]])[
+]b4_cpp_guard_close([b4_spec_defines_file])[]dnl
+])
+
+
+## -------------- ##
+## Output files. ##
+## -------------- ##
+
+b4_output_begin([b4_parser_file_name])
+b4_copyright([Bison implementation for Yacc-like parsers in C],
+ [1984, 1989-1990, 2000-2012])[
+
+/* C LALR(1) parser skeleton written by Richard Stallman, by
+ simplifying the original so-called "semantic" parser. */
+
+/* All symbols defined below should begin with yy or YY, to avoid
+ infringing on user name space. This should be done even for local
+ variables, as they might otherwise be expanded by user macros.
+ There are some unavoidable exceptions within include files to
+ define necessary library symbols; they are noted "INFRINGES ON
+ USER NAME SPACE" below. */
+
+]b4_identification
+b4_percent_code_get([[top]])[]dnl
+m4_if(b4_api_prefix, [yy], [],
+[[/* Substitute the type names. */
+#define YYSTYPE ]b4_api_PREFIX[STYPE]b4_locations_if([[
+#define YYLTYPE ]b4_api_PREFIX[LTYPE]])])[
+]m4_if(b4_prefix, [yy], [],
+[[/* Substitute the variable and function names. */]b4_pull_if([[
+#define yyparse ]b4_prefix[parse]])b4_push_if([[
+#define yypush_parse ]b4_prefix[push_parse]b4_pull_if([[
+#define yypull_parse ]b4_prefix[pull_parse]])[
+#define yypstate_new ]b4_prefix[pstate_new
+#define yypstate_delete ]b4_prefix[pstate_delete
+#define yypstate ]b4_prefix[pstate]])[
+#define yylex ]b4_prefix[lex
+#define yyerror ]b4_prefix[error
+#define yylval ]b4_prefix[lval
+#define yychar ]b4_prefix[char
+#define yydebug ]b4_prefix[debug
+#define yynerrs ]b4_prefix[nerrs]b4_locations_if([[
+#define yylloc ]b4_prefix[lloc]])])[
+
+/* Copy the first part of user declarations. */
+]b4_user_pre_prologue[
+
+]b4_null_define[
+
+/* Enabling verbose error messages. */
+#ifdef YYERROR_VERBOSE
+# undef YYERROR_VERBOSE
+# define YYERROR_VERBOSE 1
+#else
+# define YYERROR_VERBOSE ]b4_error_verbose_flag[
+#endif
+
+]m4_ifval(m4_quote(b4_spec_defines_file),
+[[/* In a future release of Bison, this section will be replaced
+ by #include "@basename(]b4_spec_defines_file[@)". */
+]])dnl
+b4_shared_declarations[
+
+/* Copy the second part of user declarations. */
+]b4_user_post_prologue
+b4_percent_code_get[]dnl
+
+[#ifdef short
+# undef short
+#endif
+
+#ifdef YYTYPE_UINT8
+typedef YYTYPE_UINT8 yytype_uint8;
+#else
+typedef unsigned char yytype_uint8;
+#endif
+
+#ifdef YYTYPE_INT8
+typedef YYTYPE_INT8 yytype_int8;
+#elif ]b4_c_modern[
+typedef signed char yytype_int8;
+#else
+typedef short int yytype_int8;
+#endif
+
+#ifdef YYTYPE_UINT16
+typedef YYTYPE_UINT16 yytype_uint16;
+#else
+typedef unsigned short int yytype_uint16;
+#endif
+
+#ifdef YYTYPE_INT16
+typedef YYTYPE_INT16 yytype_int16;
+#else
+typedef short int yytype_int16;
+#endif
+
+#ifndef YYSIZE_T
+# ifdef __SIZE_TYPE__
+# define YYSIZE_T __SIZE_TYPE__
+# elif defined size_t
+# define YYSIZE_T size_t
+# elif ! defined YYSIZE_T && ]b4_c_modern[
+# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
+# define YYSIZE_T size_t
+# else
+# define YYSIZE_T unsigned int
+# endif
+#endif
+
+#define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
+
+#ifndef YY_
+# if defined YYENABLE_NLS && YYENABLE_NLS
+# if ENABLE_NLS
+# include <libintl.h> /* INFRINGES ON USER NAME SPACE */
+# define YY_(Msgid) dgettext ("bison-runtime", Msgid)
+# endif
+# endif
+# ifndef YY_
+# define YY_(Msgid) Msgid
+# endif
+#endif
+
+/* Suppress unused-variable warnings by "using" E. */
+#if ! defined lint || defined __GNUC__
+# define YYUSE(E) ((void) (E))
+#else
+# define YYUSE(E) /* empty */
+#endif
+
+/* Identity function, used to suppress warnings about constant conditions. */
+#ifndef lint
+# define YYID(N) (N)
+#else
+]b4_c_function_def([YYID], [static int], [[int yyi], [yyi]])[
+{
+ return yyi;
+}
+#endif
+
+#if ]b4_lac_if([[1]], [[! defined yyoverflow || YYERROR_VERBOSE]])[
+
+/* The parser invokes alloca or malloc; define the necessary symbols. */]dnl
+b4_push_if([], [b4_lac_if([], [[
+
+# ifdef YYSTACK_USE_ALLOCA
+# if YYSTACK_USE_ALLOCA
+# ifdef __GNUC__
+# define YYSTACK_ALLOC __builtin_alloca
+# elif defined __BUILTIN_VA_ARG_INCR
+# include <alloca.h> /* INFRINGES ON USER NAME SPACE */
+# elif defined _AIX
+# define YYSTACK_ALLOC __alloca
+# elif defined _MSC_VER
+# include <malloc.h> /* INFRINGES ON USER NAME SPACE */
+# define alloca _alloca
+# else
+# define YYSTACK_ALLOC alloca
+# if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS && ]b4_c_modern[
+# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
+ /* Use EXIT_SUCCESS as a witness for stdlib.h. */
+# ifndef EXIT_SUCCESS
+# define EXIT_SUCCESS 0
+# endif
+# endif
+# endif
+# endif
+# endif]])])[
+
+# ifdef YYSTACK_ALLOC
+ /* Pacify GCC's `empty if-body' warning. */
+# define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
+# ifndef YYSTACK_ALLOC_MAXIMUM
+ /* The OS might guarantee only one guard page at the bottom of the stack,
+ and a page size can be as small as 4096 bytes. So we cannot safely
+ invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
+ to allow for a few compiler-allocated temporary stack slots. */
+# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
+# endif
+# else
+# define YYSTACK_ALLOC YYMALLOC
+# define YYSTACK_FREE YYFREE
+# ifndef YYSTACK_ALLOC_MAXIMUM
+# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
+# endif
+# if (defined __cplusplus && ! defined EXIT_SUCCESS \
+ && ! ((defined YYMALLOC || defined malloc) \
+ && (defined YYFREE || defined free)))
+# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
+# ifndef EXIT_SUCCESS
+# define EXIT_SUCCESS 0
+# endif
+# endif
+# ifndef YYMALLOC
+# define YYMALLOC malloc
+# if ! defined malloc && ! defined EXIT_SUCCESS && ]b4_c_modern[
+void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
+# endif
+# endif
+# ifndef YYFREE
+# define YYFREE free
+# if ! defined free && ! defined EXIT_SUCCESS && ]b4_c_modern[
+void free (void *); /* INFRINGES ON USER NAME SPACE */
+# endif
+# endif
+# endif]b4_lac_if([[
+# define YYCOPY_NEEDED 1]])[
+#endif]b4_lac_if([], [[ /* ! defined yyoverflow || YYERROR_VERBOSE */]])[
+
+
+#if (! defined yyoverflow \
+ && (! defined __cplusplus \
+ || (]b4_locations_if([[defined ]b4_api_PREFIX[LTYPE_IS_TRIVIAL && ]b4_api_PREFIX[LTYPE_IS_TRIVIAL \
+ && ]])[defined ]b4_api_PREFIX[STYPE_IS_TRIVIAL && ]b4_api_PREFIX[STYPE_IS_TRIVIAL)))
+
+/* A type that is properly aligned for any stack member. */
+union yyalloc
+{
+ yytype_int16 yyss_alloc;
+ YYSTYPE yyvs_alloc;]b4_locations_if([
+ YYLTYPE yyls_alloc;])[
+};
+
+/* The size of the maximum gap between one aligned stack and the next. */
+# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
+
+/* The size of an array large to enough to hold all stacks, each with
+ N elements. */
+]b4_locations_if(
+[# define YYSTACK_BYTES(N) \
+ ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE) + sizeof (YYLTYPE)) \
+ + 2 * YYSTACK_GAP_MAXIMUM)],
+[# define YYSTACK_BYTES(N) \
+ ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
+ + YYSTACK_GAP_MAXIMUM)])[
+
+# define YYCOPY_NEEDED 1
+
+/* Relocate STACK from its old location to the new one. The
+ local variables YYSIZE and YYSTACKSIZE give the old and new number of
+ elements in the stack, and YYPTR gives the new location of the
+ stack. Advance YYPTR to a properly aligned location for the next
+ stack. */
+# define YYSTACK_RELOCATE(Stack_alloc, Stack) \
+ do \
+ { \
+ YYSIZE_T yynewbytes; \
+ YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
+ Stack = &yyptr->Stack_alloc; \
+ yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
+ yyptr += yynewbytes / sizeof (*yyptr); \
+ } \
+ while (YYID (0))
+
+#endif
+
+#if defined YYCOPY_NEEDED && YYCOPY_NEEDED
+/* Copy COUNT objects from SRC to DST. The source and destination do
+ not overlap. */
+# ifndef YYCOPY
+# if defined __GNUC__ && 1 < __GNUC__
+# define YYCOPY(Dst, Src, Count) \
+ __builtin_memcpy (Dst, Src, (Count) * sizeof (*(Src)))
+# else
+# define YYCOPY(Dst, Src, Count) \
+ do \
+ { \
+ YYSIZE_T yyi; \
+ for (yyi = 0; yyi < (Count); yyi++) \
+ (Dst)[yyi] = (Src)[yyi]; \
+ } \
+ while (YYID (0))
+# endif
+# endif
+#endif /* !YYCOPY_NEEDED */
+
+/* YYFINAL -- State number of the termination state. */
+#define YYFINAL ]b4_final_state_number[
+/* YYLAST -- Last index in YYTABLE. */
+#define YYLAST ]b4_last[
+
+/* YYNTOKENS -- Number of terminals. */
+#define YYNTOKENS ]b4_tokens_number[
+/* YYNNTS -- Number of nonterminals. */
+#define YYNNTS ]b4_nterms_number[
+/* YYNRULES -- Number of rules. */
+#define YYNRULES ]b4_rules_number[
+/* YYNRULES -- Number of states. */
+#define YYNSTATES ]b4_states_number[
+
+/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
+#define YYUNDEFTOK ]b4_undef_token_number[
+#define YYMAXUTOK ]b4_user_token_number_max[
+
+#define YYTRANSLATE(YYX) \
+ ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
+
+/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
+static const ]b4_int_type_for([b4_translate])[ yytranslate[] =
+{
+ ]b4_translate[
+};
+
+#if ]b4_api_PREFIX[DEBUG
+/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
+ YYRHS. */
+static const ]b4_int_type_for([b4_prhs])[ yyprhs[] =
+{
+ ]b4_prhs[
+};
+
+/* YYRHS -- A `-1'-separated list of the rules' RHS. */
+static const ]b4_int_type_for([b4_rhs])[ yyrhs[] =
+{
+ ]b4_rhs[
+};
+
+/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
+static const ]b4_int_type_for([b4_rline])[ yyrline[] =
+{
+ ]b4_rline[
+};
+#endif
+
+#if ]b4_api_PREFIX[DEBUG || YYERROR_VERBOSE || ]b4_token_table_flag[
+/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
+ First, the terminals, then, starting at YYNTOKENS, nonterminals. */
+static const char *const yytname[] =
+{
+ ]b4_tname[
+};
+#endif
+
+# ifdef YYPRINT
+/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
+ token YYLEX-NUM. */
+static const ]b4_int_type_for([b4_toknum])[ yytoknum[] =
+{
+ ]b4_toknum[
+};
+# endif
+
+/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
+static const ]b4_int_type_for([b4_r1])[ yyr1[] =
+{
+ ]b4_r1[
+};
+
+/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
+static const ]b4_int_type_for([b4_r2])[ yyr2[] =
+{
+ ]b4_r2[
+};
+
+/* YYDEFACT[STATE-NAME] -- Default reduction number in state STATE-NUM.
+ Performed when YYTABLE doesn't specify something else to do. Zero
+ means the default is an error. */
+static const ]b4_int_type_for([b4_defact])[ yydefact[] =
+{
+ ]b4_defact[
+};
+
+/* YYDEFGOTO[NTERM-NUM]. */
+static const ]b4_int_type_for([b4_defgoto])[ yydefgoto[] =
+{
+ ]b4_defgoto[
+};
+
+/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
+ STATE-NUM. */
+#define YYPACT_NINF ]b4_pact_ninf[
+static const ]b4_int_type_for([b4_pact])[ yypact[] =
+{
+ ]b4_pact[
+};
+
+/* YYPGOTO[NTERM-NUM]. */
+static const ]b4_int_type_for([b4_pgoto])[ yypgoto[] =
+{
+ ]b4_pgoto[
+};
+
+/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
+ positive, shift that token. If negative, reduce the rule which
+ number is the opposite. If YYTABLE_NINF, syntax error. */
+#define YYTABLE_NINF ]b4_table_ninf[
+static const ]b4_int_type_for([b4_table])[ yytable[] =
+{
+ ]b4_table[
+};
+
+#define yypact_value_is_default(Yystate) \
+ ]b4_table_value_equals([[pact]], [[Yystate]], [b4_pact_ninf])[
+
+#define yytable_value_is_error(Yytable_value) \
+ ]b4_table_value_equals([[table]], [[Yytable_value]], [b4_table_ninf])[
+
+static const ]b4_int_type_for([b4_check])[ yycheck[] =
+{
+ ]b4_check[
+};
+
+/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
+ symbol of state STATE-NUM. */
+static const ]b4_int_type_for([b4_stos])[ yystos[] =
+{
+ ]b4_stos[
+};
+
+#define yyerrok (yyerrstatus = 0)
+#define yyclearin (yychar = YYEMPTY)
+#define YYEMPTY (-2)
+#define YYEOF 0
+
+#define YYACCEPT goto yyacceptlab
+#define YYABORT goto yyabortlab
+#define YYERROR goto yyerrorlab
+
+
+/* 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. However,
+ YYFAIL appears to be in use. Nevertheless, it is formally deprecated
+ in Bison 2.4.2's NEWS entry, where a plan to phase it out is
+ discussed. */
+
+#define YYFAIL goto yyerrlab
+#if defined YYFAIL
+ /* This is here to suppress warnings from the GCC cpp's
+ -Wunused-macros. Normally we don't worry about that warning, but
+ some users do, and we want to make it easy for users to remove
+ YYFAIL uses, which will produce warnings from Bison 2.5. */
+#endif
+
+#define YYRECOVERING() (!!yyerrstatus)
+
+#define YYBACKUP(Token, Value) \
+do \
+ if (yychar == YYEMPTY) \
+ { \
+ yychar = (Token); \
+ yylval = (Value); \
+ YYPOPSTACK (yylen); \
+ yystate = *yyssp; \]b4_lac_if([[
+ YY_LAC_DISCARD ("YYBACKUP"); \]])[
+ goto yybackup; \
+ } \
+ else \
+ { \
+ yyerror (]b4_yyerror_args[YY_("syntax error: cannot back up")); \
+ YYERROR; \
+ } \
+while (YYID (0))
+
+/* Error token number */
+#define YYTERROR 1
+#define YYERRCODE 256
+
+]b4_locations_if([[
+]b4_yylloc_default_define[
+#define YYRHSLOC(Rhs, K) ((Rhs)[K])
+]])[
+]b4_yy_location_print_define[
+
+/* YYLEX -- calling `yylex' with the right arguments. */
+#ifdef YYLEX_PARAM
+# define YYLEX yylex (]b4_pure_if([&yylval[]b4_locations_if([, &yylloc]), ])[YYLEX_PARAM)
+#else
+# define YYLEX ]b4_c_function_call([yylex], [int], b4_lex_param)[
+#endif
+
+/* Enable debugging if requested. */
+#if ]b4_api_PREFIX[DEBUG
+
+# ifndef YYFPRINTF
+# include <stdio.h> /* INFRINGES ON USER NAME SPACE */
+# define YYFPRINTF fprintf
+# endif
+
+# define YYDPRINTF(Args) \
+do { \
+ if (yydebug) \
+ YYFPRINTF Args; \
+} while (YYID (0))
+
+# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
+do { \
+ if (yydebug) \
+ { \
+ YYFPRINTF (stderr, "%s ", Title); \
+ yy_symbol_print (stderr, \
+ Type, Value]b4_locations_if([, Location])[]b4_user_args[); \
+ YYFPRINTF (stderr, "\n"); \
+ } \
+} while (YYID (0))
+
+]b4_yy_symbol_print_generate([b4_c_function_def])[
+
+/*------------------------------------------------------------------.
+| yy_stack_print -- Print the state stack from its BOTTOM up to its |
+| TOP (included). |
+`------------------------------------------------------------------*/
+
+]b4_c_function_def([yy_stack_print], [static void],
+ [[yytype_int16 *yybottom], [yybottom]],
+ [[yytype_int16 *yytop], [yytop]])[
+{
+ YYFPRINTF (stderr, "Stack now");
+ for (; yybottom <= yytop; yybottom++)
+ {
+ int yybot = *yybottom;
+ YYFPRINTF (stderr, " %d", yybot);
+ }
+ YYFPRINTF (stderr, "\n");
+}
+
+# define YY_STACK_PRINT(Bottom, Top) \
+do { \
+ if (yydebug) \
+ yy_stack_print ((Bottom), (Top)); \
+} while (YYID (0))
+
+
+/*------------------------------------------------.
+| Report that the YYRULE is going to be reduced. |
+`------------------------------------------------*/
+
+]b4_c_function_def([yy_reduce_print], [static void],
+ [[YYSTYPE *yyvsp], [yyvsp]],
+ b4_locations_if([[[YYLTYPE *yylsp], [yylsp]],
+ ])[[int yyrule], [yyrule]]m4_ifset([b4_parse_param], [,
+ b4_parse_param]))[
+{
+ int yynrhs = yyr2[yyrule];
+ int yyi;
+ unsigned long int yylno = yyrline[yyrule];
+ YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
+ yyrule - 1, yylno);
+ /* The symbols being reduced. */
+ for (yyi = 0; yyi < yynrhs; yyi++)
+ {
+ YYFPRINTF (stderr, " $%d = ", yyi + 1);
+ yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
+ &]b4_rhs_value(yynrhs, yyi + 1)[
+ ]b4_locations_if([, &]b4_rhs_location(yynrhs, yyi + 1))[]dnl
+ b4_user_args[);
+ YYFPRINTF (stderr, "\n");
+ }
+}
+
+# define YY_REDUCE_PRINT(Rule) \
+do { \
+ if (yydebug) \
+ yy_reduce_print (yyvsp, ]b4_locations_if([yylsp, ])[Rule]b4_user_args[); \
+} while (YYID (0))
+
+/* Nonzero means print parse trace. It is left uninitialized so that
+ multiple parsers can coexist. */
+int yydebug;
+#else /* !]b4_api_PREFIX[DEBUG */
+# define YYDPRINTF(Args)
+# define YY_SYMBOL_PRINT(Title, Type, Value, Location)
+# define YY_STACK_PRINT(Bottom, Top)
+# define YY_REDUCE_PRINT(Rule)
+#endif /* !]b4_api_PREFIX[DEBUG */
+
+
+/* YYINITDEPTH -- initial size of the parser's stacks. */
+#ifndef YYINITDEPTH
+# define YYINITDEPTH ]b4_stack_depth_init[
+#endif
+
+/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
+ if the built-in stack extension method is used).
+
+ Do not make this value too large; the results are undefined if
+ YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
+ evaluated with infinite-precision integer arithmetic. */
+
+#ifndef YYMAXDEPTH
+# define YYMAXDEPTH ]b4_stack_depth_max[
+#endif]b4_lac_if([[
+
+/* Given a state stack such that *YYBOTTOM is its bottom, such that
+ *YYTOP is either its top or is YYTOP_EMPTY to indicate an empty
+ stack, and such that *YYCAPACITY is the maximum number of elements it
+ can hold without a reallocation, make sure there is enough room to
+ store YYADD more elements. If not, allocate a new stack using
+ YYSTACK_ALLOC, copy the existing elements, and adjust *YYBOTTOM,
+ *YYTOP, and *YYCAPACITY to reflect the new capacity and memory
+ location. If *YYBOTTOM != YYBOTTOM_NO_FREE, then free the old stack
+ using YYSTACK_FREE. Return 0 if successful or if no reallocation is
+ required. Return 1 if memory is exhausted. */
+static int
+yy_lac_stack_realloc (YYSIZE_T *yycapacity, YYSIZE_T yyadd,
+#if ]b4_api_PREFIX[DEBUG
+ char const *yydebug_prefix,
+ char const *yydebug_suffix,
+#endif
+ yytype_int16 **yybottom,
+ yytype_int16 *yybottom_no_free,
+ yytype_int16 **yytop, yytype_int16 *yytop_empty)
+{
+ YYSIZE_T yysize_old =
+ *yytop == yytop_empty ? 0 : *yytop - *yybottom + 1;
+ YYSIZE_T yysize_new = yysize_old + yyadd;
+ if (*yycapacity < yysize_new)
+ {
+ YYSIZE_T yyalloc = 2 * yysize_new;
+ yytype_int16 *yybottom_new;
+ /* Use YYMAXDEPTH for maximum stack size given that the stack
+ should never need to grow larger than the main state stack
+ needs to grow without LAC. */
+ if (YYMAXDEPTH < yysize_new)
+ {
+ YYDPRINTF ((stderr, "%smax size exceeded%s", yydebug_prefix,
+ yydebug_suffix));
+ return 1;
+ }
+ if (YYMAXDEPTH < yyalloc)
+ yyalloc = YYMAXDEPTH;
+ yybottom_new =
+ (yytype_int16*) YYSTACK_ALLOC (yyalloc * sizeof *yybottom_new);
+ if (!yybottom_new)
+ {
+ YYDPRINTF ((stderr, "%srealloc failed%s", yydebug_prefix,
+ yydebug_suffix));
+ return 1;
+ }
+ if (*yytop != yytop_empty)
+ {
+ YYCOPY (yybottom_new, *yybottom, yysize_old);
+ *yytop = yybottom_new + (yysize_old - 1);
+ }
+ if (*yybottom != yybottom_no_free)
+ YYSTACK_FREE (*yybottom);
+ *yybottom = yybottom_new;
+ *yycapacity = yyalloc;]m4_if(b4_percent_define_get([[parse.lac.memory-trace]]),
+ [full], [[
+ YYDPRINTF ((stderr, "%srealloc to %lu%s", yydebug_prefix,
+ (unsigned long int) yyalloc, yydebug_suffix));]])[
+ }
+ return 0;
+}
+
+/* Establish the initial context for the current lookahead if no initial
+ context is currently established.
+
+ We define a context as a snapshot of the parser stacks. We define
+ the initial context for a lookahead as the context in which the
+ parser initially examines that lookahead in order to select a
+ syntactic action. Thus, if the lookahead eventually proves
+ syntactically unacceptable (possibly in a later context reached via a
+ series of reductions), the initial context can be used to determine
+ the exact set of tokens that would be syntactically acceptable in the
+ lookahead's place. Moreover, it is the context after which any
+ further semantic actions would be erroneous because they would be
+ determined by a syntactically unacceptable token.
+
+ YY_LAC_ESTABLISH should be invoked when a reduction is about to be
+ performed in an inconsistent state (which, for the purposes of LAC,
+ includes consistent states that don't know they're consistent because
+ their default reductions have been disabled). Iff there is a
+ lookahead token, it should also be invoked before reporting a syntax
+ error. This latter case is for the sake of the debugging output.
+
+ For parse.lac=full, the implementation of YY_LAC_ESTABLISH is as
+ follows. If no initial context is currently established for the
+ current lookahead, then check if that lookahead can eventually be
+ shifted if syntactic actions continue from the current context.
+ Report a syntax error if it cannot. */
+#define YY_LAC_ESTABLISH \
+do { \
+ if (!yy_lac_established) \
+ { \
+ YYDPRINTF ((stderr, \
+ "LAC: initial context established for %s\n", \
+ yytname[yytoken])); \
+ yy_lac_established = 1; \
+ { \
+ int yy_lac_status = \
+ yy_lac (yyesa, &yyes, &yyes_capacity, yyssp, yytoken); \
+ if (yy_lac_status == 2) \
+ goto yyexhaustedlab; \
+ if (yy_lac_status == 1) \
+ goto yyerrlab; \
+ } \
+ } \
+} while (YYID (0))
+
+/* Discard any previous initial lookahead context because of Event,
+ which may be a lookahead change or an invalidation of the currently
+ established initial context for the current lookahead.
+
+ The most common example of a lookahead change is a shift. An example
+ of both cases is syntax error recovery. That is, a syntax error
+ occurs when the lookahead is syntactically erroneous for the
+ currently established initial context, so error recovery manipulates
+ the parser stacks to try to find a new initial context in which the
+ current lookahead is syntactically acceptable. If it fails to find
+ such a context, it discards the lookahead. */
+#if ]b4_api_PREFIX[DEBUG
+# define YY_LAC_DISCARD(Event) \
+do { \
+ if (yy_lac_established) \
+ { \
+ if (yydebug) \
+ YYFPRINTF (stderr, "LAC: initial context discarded due to " \
+ Event "\n"); \
+ yy_lac_established = 0; \
+ } \
+} while (YYID (0))
+#else
+# define YY_LAC_DISCARD(Event) yy_lac_established = 0
+#endif
+
+/* Given the stack whose top is *YYSSP, return 0 iff YYTOKEN can
+ eventually (after perhaps some reductions) be shifted, return 1 if
+ not, or return 2 if memory is exhausted. As preconditions and
+ postconditions: *YYES_CAPACITY is the allocated size of the array to
+ which *YYES points, and either *YYES = YYESA or *YYES points to an
+ array allocated with YYSTACK_ALLOC. yy_lac may overwrite the
+ contents of either array, alter *YYES and *YYES_CAPACITY, and free
+ any old *YYES other than YYESA. */
+static int
+yy_lac (yytype_int16 *yyesa, yytype_int16 **yyes,
+ YYSIZE_T *yyes_capacity, yytype_int16 *yyssp, int yytoken)
+{
+ yytype_int16 *yyes_prev = yyssp;
+ yytype_int16 *yyesp = yyes_prev;
+ YYDPRINTF ((stderr, "LAC: checking lookahead %s:", yytname[yytoken]));
+ if (yytoken == YYUNDEFTOK)
+ {
+ YYDPRINTF ((stderr, " Always Err\n"));
+ return 1;
+ }
+ while (1)
+ {
+ int yyrule = yypact[*yyesp];
+ if (yypact_value_is_default (yyrule)
+ || (yyrule += yytoken) < 0 || YYLAST < yyrule
+ || yycheck[yyrule] != yytoken)
+ {
+ yyrule = yydefact[*yyesp];
+ if (yyrule == 0)
+ {
+ YYDPRINTF ((stderr, " Err\n"));
+ return 1;
+ }
+ }
+ else
+ {
+ yyrule = yytable[yyrule];
+ if (yytable_value_is_error (yyrule))
+ {
+ YYDPRINTF ((stderr, " Err\n"));
+ return 1;
+ }
+ if (0 < yyrule)
+ {
+ YYDPRINTF ((stderr, " S%d\n", yyrule));
+ return 0;
+ }
+ yyrule = -yyrule;
+ }
+ {
+ YYSIZE_T yylen = yyr2[yyrule];
+ YYDPRINTF ((stderr, " R%d", yyrule - 1));
+ if (yyesp != yyes_prev)
+ {
+ YYSIZE_T yysize = yyesp - *yyes + 1;
+ if (yylen < yysize)
+ {
+ yyesp -= yylen;
+ yylen = 0;
+ }
+ else
+ {
+ yylen -= yysize;
+ yyesp = yyes_prev;
+ }
+ }
+ if (yylen)
+ yyesp = yyes_prev -= yylen;
+ }
+ {
+ int yystate;
+ {
+ int yylhs = yyr1[yyrule] - YYNTOKENS;
+ yystate = yypgoto[yylhs] + *yyesp;
+ if (yystate < 0 || YYLAST < yystate
+ || yycheck[yystate] != *yyesp)
+ yystate = yydefgoto[yylhs];
+ else
+ yystate = yytable[yystate];
+ }
+ if (yyesp == yyes_prev)
+ {
+ yyesp = *yyes;
+ *yyesp = yystate;
+ }
+ else
+ {
+ if (yy_lac_stack_realloc (yyes_capacity, 1,
+#if ]b4_api_PREFIX[DEBUG
+ " (", ")",
+#endif
+ yyes, yyesa, &yyesp, yyes_prev))
+ {
+ YYDPRINTF ((stderr, "\n"));
+ return 2;
+ }
+ *++yyesp = yystate;
+ }
+ YYDPRINTF ((stderr, " G%d", yystate));
+ }
+ }
+}]])[
+
+
+#if YYERROR_VERBOSE
+
+# ifndef yystrlen
+# if defined __GLIBC__ && defined _STRING_H
+# define yystrlen strlen
+# else
+/* Return the length of YYSTR. */
+]b4_c_function_def([yystrlen], [static YYSIZE_T],
+ [[const char *yystr], [yystr]])[
+{
+ YYSIZE_T yylen;
+ for (yylen = 0; yystr[yylen]; yylen++)
+ continue;
+ return yylen;
+}
+# endif
+# endif
+
+# ifndef yystpcpy
+# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
+# define yystpcpy stpcpy
+# else
+/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
+ YYDEST. */
+]b4_c_function_def([yystpcpy], [static char *],
+ [[char *yydest], [yydest]], [[const char *yysrc], [yysrc]])[
+{
+ char *yyd = yydest;
+ const char *yys = yysrc;
+
+ while ((*yyd++ = *yys++) != '\0')
+ continue;
+
+ return yyd - 1;
+}
+# endif
+# endif
+
+# ifndef yytnamerr
+/* Copy to YYRES the contents of YYSTR after stripping away unnecessary
+ quotes and backslashes, so that it's suitable for yyerror. The
+ heuristic is that double-quoting is unnecessary unless the string
+ contains an apostrophe, a comma, or backslash (other than
+ backslash-backslash). YYSTR is taken from yytname. If YYRES is
+ null, do not copy; instead, return the length of what the result
+ would have been. */
+static YYSIZE_T
+yytnamerr (char *yyres, const char *yystr)
+{
+ if (*yystr == '"')
+ {
+ YYSIZE_T yyn = 0;
+ char const *yyp = yystr;
+
+ for (;;)
+ switch (*++yyp)
+ {
+ case '\'':
+ case ',':
+ goto do_not_strip_quotes;
+
+ case '\\':
+ if (*++yyp != '\\')
+ goto do_not_strip_quotes;
+ /* Fall through. */
+ default:
+ if (yyres)
+ yyres[yyn] = *yyp;
+ yyn++;
+ break;
+
+ case '"':
+ if (yyres)
+ yyres[yyn] = '\0';
+ return yyn;
+ }
+ do_not_strip_quotes: ;
+ }
+
+ if (! yyres)
+ return yystrlen (yystr);
+
+ return yystpcpy (yyres, yystr) - yyres;
+}
+# endif
+
+/* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message
+ about the unexpected token YYTOKEN for the state stack whose top is
+ YYSSP.]b4_lac_if([[ In order to see if a particular token T is a
+ valid looakhead, invoke yy_lac (YYESA, YYES, YYES_CAPACITY, YYSSP, T).]])[
+
+ Return 0 if *YYMSG was successfully written. Return 1 if *YYMSG is
+ not large enough to hold the message. In that case, also set
+ *YYMSG_ALLOC to the required number of bytes. Return 2 if the
+ required number of bytes is too large to store]b4_lac_if([[ or if
+ yy_lac returned 2]])[. */
+static int
+yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
+ ]b4_lac_if([[yytype_int16 *yyesa, yytype_int16 **yyes,
+ YYSIZE_T *yyes_capacity, ]])[yytype_int16 *yyssp, int yytoken)
+{
+ YYSIZE_T yysize0 = yytnamerr (YY_NULL, yytname[yytoken]);
+ YYSIZE_T yysize = yysize0;
+ enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
+ /* Internationalized format string. */
+ const char *yyformat = YY_NULL;
+ /* Arguments of yyformat. */
+ char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
+ /* Number of reported tokens (one for the "unexpected", one per
+ "expected"). */
+ int yycount = 0;
+
+ /* There are many possibilities here to consider:
+ - Assume YYFAIL is not used. It's too flawed to consider. See
+ <http://lists.gnu.org/archive/html/bison-patches/2009-12/msg00024.html>
+ for details. YYERROR is fine as it does not invoke this
+ function.
+ - If this state is a consistent state with a default action, then
+ the only way this function was invoked is if the default action
+ is an error action. In that case, don't check for expected
+ tokens because there are none.
+ - The only way there can be no lookahead present (in yychar) is if
+ this state is a consistent state with a default action. Thus,
+ detecting the absence of a lookahead is sufficient to determine
+ that there is no unexpected or expected token to report. In that
+ case, just report a simple "syntax error".
+ - Don't assume there isn't a lookahead just because this state is a
+ consistent state with a default action. There might have been a
+ previous inconsistent state, consistent state with a non-default
+ action, or user semantic action that manipulated yychar.]b4_lac_if([[
+ In the first two cases, it might appear that the current syntax
+ error should have been detected in the previous state when yy_lac
+ was invoked. However, at that time, there might have been a
+ different syntax error that discarded a different initial context
+ during error recovery, leaving behind the current lookahead.]], [[
+ - Of course, the expected token list depends on states to have
+ correct lookahead information, and it depends on the parser not
+ to perform extra reductions after fetching a lookahead from the
+ scanner and before detecting a syntax error. Thus, state merging
+ (from LALR or IELR) and default reductions corrupt the expected
+ token list. However, the list is correct for canonical LR with
+ one exception: it will still contain any token that will not be
+ accepted due to an error action in a later state.]])[
+ */
+ if (yytoken != YYEMPTY)
+ {
+ int yyn = yypact[*yyssp];]b4_lac_if([[
+ YYDPRINTF ((stderr, "Constructing syntax error message\n"));]])[
+ yyarg[yycount++] = yytname[yytoken];
+ if (!yypact_value_is_default (yyn))
+ {]b4_lac_if([], [[
+ /* Start YYX at -YYN if negative to avoid negative indexes in
+ YYCHECK. In other words, skip the first -YYN actions for
+ this state because they are default actions. */
+ int yyxbegin = yyn < 0 ? -yyn : 0;
+ /* Stay within bounds of both yycheck and yytname. */
+ int yychecklim = YYLAST - yyn + 1;
+ int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;]])[
+ int yyx;]b4_lac_if([[
+
+ for (yyx = 0; yyx < YYNTOKENS; ++yyx)
+ if (yyx != YYTERROR && yyx != YYUNDEFTOK)
+ {
+ {
+ int yy_lac_status = yy_lac (yyesa, yyes, yyes_capacity,
+ yyssp, yyx);
+ if (yy_lac_status == 2)
+ return 2;
+ if (yy_lac_status == 1)
+ continue;
+ }]], [[
+
+ for (yyx = yyxbegin; yyx < yyxend; ++yyx)
+ if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR
+ && !yytable_value_is_error (yytable[yyx + yyn]))
+ {]])[
+ if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
+ {
+ yycount = 1;
+ yysize = yysize0;
+ break;
+ }
+ yyarg[yycount++] = yytname[yyx];
+ {
+ YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULL, yytname[yyx]);
+ if (! (yysize <= yysize1
+ && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
+ return 2;
+ yysize = yysize1;
+ }
+ }
+ }]b4_lac_if([[
+# if ]b4_api_PREFIX[DEBUG
+ else if (yydebug)
+ YYFPRINTF (stderr, "No expected tokens.\n");
+# endif]])[
+ }
+
+ switch (yycount)
+ {
+# define YYCASE_(N, S) \
+ case N: \
+ yyformat = S; \
+ break
+ YYCASE_(0, YY_("syntax error"));
+ YYCASE_(1, YY_("syntax error, unexpected %s"));
+ YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
+ YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s"));
+ YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
+ YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
+# undef YYCASE_
+ }
+
+ {
+ YYSIZE_T yysize1 = yysize + yystrlen (yyformat);
+ if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
+ return 2;
+ yysize = yysize1;
+ }
+
+ if (*yymsg_alloc < yysize)
+ {
+ *yymsg_alloc = 2 * yysize;
+ if (! (yysize <= *yymsg_alloc
+ && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM))
+ *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM;
+ return 1;
+ }
+
+ /* Avoid sprintf, as that infringes on the user's name space.
+ Don't have undefined behavior even if the translation
+ produced a string with the wrong number of "%s"s. */
+ {
+ char *yyp = *yymsg;
+ int yyi = 0;
+ while ((*yyp = *yyformat) != '\0')
+ if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount)
+ {
+ yyp += yytnamerr (yyp, yyarg[yyi++]);
+ yyformat += 2;
+ }
+ else
+ {
+ yyp++;
+ yyformat++;
+ }
+ }
+ return 0;
+}
+#endif /* YYERROR_VERBOSE */
+
+]b4_yydestruct_generate([b4_c_function_def])[
+
+]b4_pure_if([], [
+
+b4_declare_scanner_communication_variables])[]b4_push_if([[
+
+struct yypstate
+ {]b4_declare_parser_state_variables[
+ /* Used to determine if this is the first time this instance has
+ been used. */
+ int yynew;
+ };]b4_pure_if([], [[
+
+static char yypstate_allocated = 0;]])b4_pull_if([
+
+b4_c_function_def([[yyparse]], [[int]], b4_parse_param)[
+{
+ return yypull_parse (YY_NULL]m4_ifset([b4_parse_param],
+ [[, ]b4_c_args(b4_parse_param)])[);
+}
+
+]b4_c_function_def([[yypull_parse]], [[int]],
+ [[[yypstate *yyps]], [[yyps]]]m4_ifset([b4_parse_param], [,
+ b4_parse_param]))[
+{
+ int yystatus;
+ yypstate *yyps_local;]b4_pure_if([[
+ int yychar;
+ YYSTYPE yylval;]b4_locations_if([[
+ static YYLTYPE yyloc_default][]b4_yyloc_default[;
+ YYLTYPE yylloc = yyloc_default;]])])[
+ if (yyps)
+ yyps_local = yyps;
+ else
+ {
+ yyps_local = yypstate_new ();
+ if (!yyps_local)
+ {]b4_pure_if([[
+ yyerror (]b4_yyerror_args[YY_("memory exhausted"));]], [[
+ if (!yypstate_allocated)
+ yyerror (]b4_yyerror_args[YY_("memory exhausted"));]])[
+ return 2;
+ }
+ }
+ do {
+ yychar = YYLEX;
+ yystatus =
+ yypush_parse (yyps_local]b4_pure_if([[, yychar, &yylval]b4_locations_if([[, &yylloc]])])m4_ifset([b4_parse_param], [, b4_c_args(b4_parse_param)])[);
+ } while (yystatus == YYPUSH_MORE);
+ if (!yyps)
+ yypstate_delete (yyps_local);
+ return yystatus;
+}]])[
+
+/* Initialize the parser data structure. */
+]b4_c_function_def([[yypstate_new]], [[yypstate *]])[
+{
+ yypstate *yyps;]b4_pure_if([], [[
+ if (yypstate_allocated)
+ return YY_NULL;]])[
+ yyps = (yypstate *) malloc (sizeof *yyps);
+ if (!yyps)
+ return YY_NULL;
+ yyps->yynew = 1;]b4_pure_if([], [[
+ yypstate_allocated = 1;]])[
+ return yyps;
+}
+
+]b4_c_function_def([[yypstate_delete]], [[void]],
+ [[[yypstate *yyps]], [[yyps]]])[
+{
+#ifndef yyoverflow
+ /* If the stack was reallocated but the parse did not complete, then the
+ stack still needs to be freed. */
+ if (!yyps->yynew && yyps->yyss != yyps->yyssa)
+ YYSTACK_FREE (yyps->yyss);
+#endif]b4_lac_if([[
+ if (!yyps->yynew && yyps->yyes != yyps->yyesa)
+ YYSTACK_FREE (yyps->yyes);]])[
+ free (yyps);]b4_pure_if([], [[
+ yypstate_allocated = 0;]])[
+}
+]b4_pure_if([[
+#define ]b4_prefix[nerrs yyps->]b4_prefix[nerrs]])[
+#define yystate yyps->yystate
+#define yyerrstatus yyps->yyerrstatus
+#define yyssa yyps->yyssa
+#define yyss yyps->yyss
+#define yyssp yyps->yyssp
+#define yyvsa yyps->yyvsa
+#define yyvs yyps->yyvs
+#define yyvsp yyps->yyvsp]b4_locations_if([[
+#define yylsa yyps->yylsa
+#define yyls yyps->yyls
+#define yylsp yyps->yylsp
+#define yyerror_range yyps->yyerror_range]])[
+#define yystacksize yyps->yystacksize]b4_lac_if([[
+#define yyesa yyps->yyesa
+#define yyes yyps->yyes
+#define yyes_capacity yyps->yyes_capacity]])[
+
+
+/*---------------.
+| yypush_parse. |
+`---------------*/
+
+]b4_c_function_def([[yypush_parse]], [[int]],
+ [[[yypstate *yyps]], [[yyps]]]b4_pure_if([,
+ [[[int yypushed_char]], [[yypushed_char]]],
+ [[[YYSTYPE const *yypushed_val]], [[yypushed_val]]]b4_locations_if([,
+ [[[YYLTYPE *yypushed_loc]], [[yypushed_loc]]]])])m4_ifset([b4_parse_param], [,
+ b4_parse_param]))], [[
+
+
+/*----------.
+| yyparse. |
+`----------*/
+
+#ifdef YYPARSE_PARAM
+]b4_c_function_def([yyparse], [int],
+ [[void *YYPARSE_PARAM], [YYPARSE_PARAM]])[
+#else /* ! YYPARSE_PARAM */
+]b4_c_function_def([yyparse], [int], b4_parse_param)[
+#endif]])[
+{]b4_pure_if([b4_declare_scanner_communication_variables
+])b4_push_if([b4_pure_if([], [[
+ int yypushed_char = yychar;
+ YYSTYPE yypushed_val = yylval;]b4_locations_if([[
+ YYLTYPE yypushed_loc = yylloc;]])
+])],
+ [b4_declare_parser_state_variables
+])b4_lac_if([[
+ int yy_lac_established = 0;]])[
+ int yyn;
+ int yyresult;
+ /* Lookahead token as an internal (translated) token number. */
+ int yytoken = 0;
+ /* The variables used to return semantic value and location from the
+ action routines. */
+ YYSTYPE yyval;]b4_locations_if([[
+ YYLTYPE yyloc;]])[
+
+#if YYERROR_VERBOSE
+ /* Buffer for error messages, and its allocated size. */
+ char yymsgbuf[128];
+ char *yymsg = yymsgbuf;
+ YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
+#endif
+
+#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)]b4_locations_if([, yylsp -= (N)])[)
+
+ /* The number of symbols on the RHS of the reduced rule.
+ Keep to zero when no symbol should be popped. */
+ int yylen = 0;]b4_push_if([[
+
+ if (!yyps->yynew)
+ {
+ yyn = yypact[yystate];
+ goto yyread_pushed_token;
+ }]])[
+
+ yyssp = yyss = yyssa;
+ yyvsp = yyvs = yyvsa;]b4_locations_if([[
+ yylsp = yyls = yylsa;]])[
+ yystacksize = YYINITDEPTH;]b4_lac_if([[
+
+ yyes = yyesa;
+ yyes_capacity = sizeof yyesa / sizeof *yyes;
+ if (YYMAXDEPTH < yyes_capacity)
+ yyes_capacity = YYMAXDEPTH;]])[
+
+ YYDPRINTF ((stderr, "Starting parse\n"));
+
+ yystate = 0;
+ yyerrstatus = 0;
+ yynerrs = 0;
+ yychar = YYEMPTY; /* Cause a token to be read. */
+]m4_ifdef([b4_initial_action], [
+b4_dollar_pushdef([m4_define([b4_dollar_dollar_used])yylval], [],
+ [b4_push_if([b4_pure_if([*])yypushed_loc], [yylloc])])dnl
+/* User initialization code. */
+b4_user_initial_action
+b4_dollar_popdef[]dnl
+m4_ifdef([b4_dollar_dollar_used],[[ yyvsp[0] = yylval;
+]])])dnl
+b4_locations_if([[ yylsp[0] = ]b4_push_if([b4_pure_if([*])yypushed_loc], [yylloc])[;
+]])dnl
+[ goto yysetstate;
+
+/*------------------------------------------------------------.
+| yynewstate -- Push a new state, which is found in yystate. |
+`------------------------------------------------------------*/
+ yynewstate:
+ /* In all cases, when you get here, the value and location stacks
+ have just been pushed. So pushing a state here evens the stacks. */
+ yyssp++;
+
+ yysetstate:
+ *yyssp = yystate;
+
+ if (yyss + yystacksize - 1 <= yyssp)
+ {
+ /* Get the current used size of the three stacks, in elements. */
+ YYSIZE_T yysize = yyssp - yyss + 1;
+
+#ifdef yyoverflow
+ {
+ /* 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;
+ yytype_int16 *yyss1 = yyss;]b4_locations_if([
+ YYLTYPE *yyls1 = yyls;])[
+
+ /* Each stack pointer address is followed by the size of the
+ data in use in that stack, in bytes. This used to be a
+ conditional around just the two extra args, but that might
+ be undefined if yyoverflow is a macro. */
+ yyoverflow (YY_("memory exhausted"),
+ &yyss1, yysize * sizeof (*yyssp),
+ &yyvs1, yysize * sizeof (*yyvsp),]b4_locations_if([
+ &yyls1, yysize * sizeof (*yylsp),])[
+ &yystacksize);
+]b4_locations_if([
+ yyls = yyls1;])[
+ yyss = yyss1;
+ yyvs = yyvs1;
+ }
+#else /* no yyoverflow */
+# ifndef YYSTACK_RELOCATE
+ goto yyexhaustedlab;
+# else
+ /* Extend the stack our own way. */
+ if (YYMAXDEPTH <= yystacksize)
+ goto yyexhaustedlab;
+ yystacksize *= 2;
+ if (YYMAXDEPTH < yystacksize)
+ yystacksize = YYMAXDEPTH;
+
+ {
+ yytype_int16 *yyss1 = yyss;
+ union yyalloc *yyptr =
+ (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
+ if (! yyptr)
+ goto yyexhaustedlab;
+ YYSTACK_RELOCATE (yyss_alloc, yyss);
+ YYSTACK_RELOCATE (yyvs_alloc, yyvs);]b4_locations_if([
+ YYSTACK_RELOCATE (yyls_alloc, yyls);])[
+# undef YYSTACK_RELOCATE
+ if (yyss1 != yyssa)
+ YYSTACK_FREE (yyss1);
+ }
+# endif
+#endif /* no yyoverflow */
+
+ yyssp = yyss + yysize - 1;
+ yyvsp = yyvs + yysize - 1;]b4_locations_if([
+ yylsp = yyls + yysize - 1;])[
+
+ YYDPRINTF ((stderr, "Stack size increased to %lu\n",
+ (unsigned long int) yystacksize));
+
+ if (yyss + yystacksize - 1 <= yyssp)
+ YYABORT;
+ }
+
+ YYDPRINTF ((stderr, "Entering state %d\n", yystate));
+
+ if (yystate == YYFINAL)
+ YYACCEPT;
+
+ goto yybackup;
+
+/*-----------.
+| yybackup. |
+`-----------*/
+yybackup:
+
+ /* Do appropriate processing given the current state. Read a
+ lookahead token if we need one and don't already have one. */
+
+ /* First try to decide what to do without reference to lookahead token. */
+ yyn = yypact[yystate];
+ if (yypact_value_is_default (yyn))
+ goto yydefault;
+
+ /* Not known => get a lookahead token if don't already have one. */
+
+ /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
+ if (yychar == YYEMPTY)
+ {]b4_push_if([[
+ if (!yyps->yynew)
+ {]b4_use_push_for_pull_if([], [[
+ YYDPRINTF ((stderr, "Return for a new token:\n"));]])[
+ yyresult = YYPUSH_MORE;
+ goto yypushreturn;
+ }
+ yyps->yynew = 0;]b4_pure_if([], [[
+ /* Restoring the pushed token is only necessary for the first
+ yypush_parse invocation since subsequent invocations don't overwrite
+ it before jumping to yyread_pushed_token. */
+ yychar = yypushed_char;
+ yylval = yypushed_val;]b4_locations_if([[
+ yylloc = yypushed_loc;]])])[
+yyread_pushed_token:]])[
+ YYDPRINTF ((stderr, "Reading a token: "));]b4_push_if([b4_pure_if([[
+ yychar = yypushed_char;
+ if (yypushed_val)
+ yylval = *yypushed_val;]b4_locations_if([[
+ if (yypushed_loc)
+ yylloc = *yypushed_loc;]])])], [[
+ yychar = YYLEX;]])[
+ }
+
+ if (yychar <= YYEOF)
+ {
+ yychar = yytoken = YYEOF;
+ YYDPRINTF ((stderr, "Now at end of input.\n"));
+ }
+ else
+ {
+ yytoken = YYTRANSLATE (yychar);
+ YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
+ }
+
+ /* If the proper action on seeing token YYTOKEN is to reduce or to
+ detect an error, take that action. */
+ yyn += yytoken;
+ if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)]b4_lac_if([[
+ {
+ YY_LAC_ESTABLISH;
+ goto yydefault;
+ }]], [[
+ goto yydefault;]])[
+ yyn = yytable[yyn];
+ if (yyn <= 0)
+ {
+ if (yytable_value_is_error (yyn))
+ goto yyerrlab;]b4_lac_if([[
+ YY_LAC_ESTABLISH;]])[
+ yyn = -yyn;
+ goto yyreduce;
+ }
+
+ /* Count tokens shifted since error; after three, turn off error
+ status. */
+ if (yyerrstatus)
+ yyerrstatus--;
+
+ /* Shift the lookahead token. */
+ YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
+
+ /* Discard the shifted token. */
+ yychar = YYEMPTY;]b4_lac_if([[
+ YY_LAC_DISCARD ("shift");]])[
+
+ yystate = yyn;
+ YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
+ *++yyvsp = yylval;
+ YY_IGNORE_MAYBE_UNINITIALIZED_END
+]b4_locations_if([ *++yylsp = yylloc;])[
+ goto yynewstate;
+
+
+/*-----------------------------------------------------------.
+| yydefault -- do the default action for the current state. |
+`-----------------------------------------------------------*/
+yydefault:
+ yyn = yydefact[yystate];
+ if (yyn == 0)
+ goto yyerrlab;
+ goto yyreduce;
+
+
+/*-----------------------------.
+| yyreduce -- Do a reduction. |
+`-----------------------------*/
+yyreduce:
+ /* yyn is the number of a rule to reduce with. */
+ yylen = yyr2[yyn];
+
+ /* If YYLEN is nonzero, implement the default value of the action:
+ `$$ = $1'.
+
+ Otherwise, the following line sets YYVAL to garbage.
+ This behavior is undocumented and Bison
+ users should not rely upon it. Assigning to YYVAL
+ unconditionally makes the parser a bit smaller, and it avoids a
+ GCC warning that YYVAL may be used uninitialized. */
+ yyval = yyvsp[1-yylen];
+
+]b4_locations_if(
+[[ /* Default location. */
+ YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen);]])[
+ YY_REDUCE_PRINT (yyn);]b4_lac_if([[
+ {
+ int yychar_backup = yychar;
+ switch (yyn)
+ {
+ ]b4_user_actions[
+ default: break;
+ }
+ if (yychar_backup != yychar)
+ YY_LAC_DISCARD ("yychar change");
+ }]], [[
+ switch (yyn)
+ {
+ ]b4_user_actions[
+ default: break;
+ }]])[
+ /* User semantic actions sometimes alter yychar, and that requires
+ that yytoken be updated with the new translation. We take the
+ approach of translating immediately before every use of yytoken.
+ One alternative is translating here after every semantic action,
+ but that translation would be missed if the semantic action invokes
+ YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or
+ if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an
+ incorrect destructor might then be invoked immediately. In the
+ case of YYERROR or YYBACKUP, subsequent parser actions might lead
+ to an incorrect destructor call or verbose syntax error message
+ before the lookahead is translated. */
+ YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
+
+ YYPOPSTACK (yylen);
+ yylen = 0;
+ YY_STACK_PRINT (yyss, yyssp);
+
+ *++yyvsp = yyval;]b4_locations_if([
+ *++yylsp = yyloc;])[
+
+ /* 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 - YYNTOKENS] + *yyssp;
+ if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
+ yystate = yytable[yystate];
+ else
+ yystate = yydefgoto[yyn - YYNTOKENS];
+
+ goto yynewstate;
+
+
+/*------------------------------------.
+| yyerrlab -- here on detecting error |
+`------------------------------------*/
+yyerrlab:
+ /* Make sure we have latest lookahead translation. See comments at
+ user semantic actions for why this is necessary. */
+ yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar);
+
+ /* If not already recovering from an error, report this error. */
+ if (!yyerrstatus)
+ {
+ ++yynerrs;
+#if ! YYERROR_VERBOSE
+ yyerror (]b4_yyerror_args[YY_("syntax error"));
+#else
+# define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \]b4_lac_if([[
+ yyesa, &yyes, &yyes_capacity, \]])[
+ yyssp, yytoken)
+ {
+ char const *yymsgp = YY_("syntax error");
+ int yysyntax_error_status;]b4_lac_if([[
+ if (yychar != YYEMPTY)
+ YY_LAC_ESTABLISH;]])[
+ yysyntax_error_status = YYSYNTAX_ERROR;
+ if (yysyntax_error_status == 0)
+ yymsgp = yymsg;
+ else if (yysyntax_error_status == 1)
+ {
+ if (yymsg != yymsgbuf)
+ YYSTACK_FREE (yymsg);
+ yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc);
+ if (!yymsg)
+ {
+ yymsg = yymsgbuf;
+ yymsg_alloc = sizeof yymsgbuf;
+ yysyntax_error_status = 2;
+ }
+ else
+ {
+ yysyntax_error_status = YYSYNTAX_ERROR;
+ yymsgp = yymsg;
+ }
+ }
+ yyerror (]b4_yyerror_args[yymsgp);
+ if (yysyntax_error_status == 2)
+ goto yyexhaustedlab;
+ }
+# undef YYSYNTAX_ERROR
+#endif
+ }
+
+]b4_locations_if([[ yyerror_range[1] = yylloc;]])[
+
+ if (yyerrstatus == 3)
+ {
+ /* If just tried and failed to reuse lookahead token after an
+ error, discard it. */
+
+ if (yychar <= YYEOF)
+ {
+ /* Return failure if at end of input. */
+ if (yychar == YYEOF)
+ YYABORT;
+ }
+ else
+ {
+ yydestruct ("Error: discarding",
+ yytoken, &yylval]b4_locations_if([, &yylloc])[]b4_user_args[);
+ yychar = YYEMPTY;
+ }
+ }
+
+ /* Else will try to reuse lookahead token after shifting the error
+ token. */
+ goto yyerrlab1;
+
+
+/*---------------------------------------------------.
+| yyerrorlab -- error raised explicitly by YYERROR. |
+`---------------------------------------------------*/
+yyerrorlab:
+
+ /* Pacify compilers like GCC when the user code never invokes
+ YYERROR and the label yyerrorlab therefore never appears in user
+ code. */
+ if (/*CONSTCOND*/ 0)
+ goto yyerrorlab;
+
+]b4_locations_if([[ yyerror_range[1] = yylsp[1-yylen];
+]])[ /* Do not reclaim the symbols of the rule which action triggered
+ this YYERROR. */
+ YYPOPSTACK (yylen);
+ yylen = 0;
+ YY_STACK_PRINT (yyss, yyssp);
+ yystate = *yyssp;
+ goto yyerrlab1;
+
+
+/*-------------------------------------------------------------.
+| yyerrlab1 -- common code for both syntax error and YYERROR. |
+`-------------------------------------------------------------*/
+yyerrlab1:
+ yyerrstatus = 3; /* Each real token shifted decrements this. */
+
+ for (;;)
+ {
+ yyn = yypact[yystate];
+ if (!yypact_value_is_default (yyn))
+ {
+ yyn += YYTERROR;
+ if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
+ {
+ yyn = yytable[yyn];
+ if (0 < yyn)
+ break;
+ }
+ }
+
+ /* Pop the current state because it cannot handle the error token. */
+ if (yyssp == yyss)
+ YYABORT;
+
+]b4_locations_if([[ yyerror_range[1] = *yylsp;]])[
+ yydestruct ("Error: popping",
+ yystos[yystate], yyvsp]b4_locations_if([, yylsp])[]b4_user_args[);
+ YYPOPSTACK (1);
+ yystate = *yyssp;
+ YY_STACK_PRINT (yyss, yyssp);
+ }]b4_lac_if([[
+
+ /* If the stack popping above didn't lose the initial context for the
+ current lookahead token, the shift below will for sure. */
+ YY_LAC_DISCARD ("error recovery");]])[
+
+ YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
+ *++yyvsp = yylval;
+ YY_IGNORE_MAYBE_UNINITIALIZED_END
+]b4_locations_if([[
+ yyerror_range[2] = yylloc;
+ /* Using YYLLOC is tempting, but would change the location of
+ the lookahead. YYLOC is available though. */
+ YYLLOC_DEFAULT (yyloc, yyerror_range, 2);
+ *++yylsp = yyloc;]])[
+
+ /* Shift the error token. */
+ YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
+
+ yystate = yyn;
+ goto yynewstate;
+
+
+/*-------------------------------------.
+| yyacceptlab -- YYACCEPT comes here. |
+`-------------------------------------*/
+yyacceptlab:
+ yyresult = 0;
+ goto yyreturn;
+
+/*-----------------------------------.
+| yyabortlab -- YYABORT comes here. |
+`-----------------------------------*/
+yyabortlab:
+ yyresult = 1;
+ goto yyreturn;
+
+#if ]b4_lac_if([[1]], [[!defined yyoverflow || YYERROR_VERBOSE]])[
+/*-------------------------------------------------.
+| yyexhaustedlab -- memory exhaustion comes here. |
+`-------------------------------------------------*/
+yyexhaustedlab:
+ yyerror (]b4_yyerror_args[YY_("memory exhausted"));
+ yyresult = 2;
+ /* Fall through. */
+#endif
+
+yyreturn:
+ if (yychar != YYEMPTY)
+ {
+ /* Make sure we have latest lookahead translation. See comments at
+ user semantic actions for why this is necessary. */
+ yytoken = YYTRANSLATE (yychar);
+ yydestruct ("Cleanup: discarding lookahead",
+ yytoken, &yylval]b4_locations_if([, &yylloc])[]b4_user_args[);
+ }
+ /* Do not reclaim the symbols of the rule which action triggered
+ this YYABORT or YYACCEPT. */
+ YYPOPSTACK (yylen);
+ YY_STACK_PRINT (yyss, yyssp);
+ while (yyssp != yyss)
+ {
+ yydestruct ("Cleanup: popping",
+ yystos[*yyssp], yyvsp]b4_locations_if([, yylsp])[]b4_user_args[);
+ YYPOPSTACK (1);
+ }
+#ifndef yyoverflow
+ if (yyss != yyssa)
+ YYSTACK_FREE (yyss);
+#endif]b4_lac_if([[
+ if (yyes != yyesa)
+ YYSTACK_FREE (yyes);]])b4_push_if([[
+ yyps->yynew = 1;
+
+yypushreturn:]])[
+#if YYERROR_VERBOSE
+ if (yymsg != yymsgbuf)
+ YYSTACK_FREE (yymsg);
+#endif
+ /* Make sure YYID is used. */
+ return YYID (yyresult);
+}
+
+
+]b4_epilogue[]dnl
+b4_output_end()
+
+b4_defines_if(
+[b4_output_begin([b4_spec_defines_file])[
+]b4_copyright([Bison interface for Yacc-like parsers in C],
+ [1984, 1989-1990, 2000-2012])[
+
+]b4_shared_declarations[
+]b4_output_end()
+])