aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2010-10-30 18:34:27 +0000
committermarha <marha@users.sourceforge.net>2010-10-30 18:34:27 +0000
commit75ef19188d021a5e965198bde774c1c33bedc1f3 (patch)
treef20be1d1e684a5388c0e386ea302c1b3e98359d0
parentd9ddf066b898491827ffd6f1d115534c54c82f6b (diff)
downloadvcxsrv-75ef19188d021a5e965198bde774c1c33bedc1f3.tar.gz
vcxsrv-75ef19188d021a5e965198bde774c1c33bedc1f3.tar.bz2
vcxsrv-75ef19188d021a5e965198bde774c1c33bedc1f3.zip
Increased gnu make compatibility.
-rw-r--r--tools/mhmake/CMakeLists.txt16
-rw-r--r--tools/mhmake/addstdafxh.py33
-rw-r--r--tools/mhmake/flex++.exebin131072 -> 485280 bytes
-rw-r--r--tools/mhmake/makebison.bat16
-rw-r--r--tools/mhmake/makelex.bat11
-rw-r--r--tools/mhmake/mhmake.vcproj94
-rw-r--r--tools/mhmake/mhmake.vcxproj68
-rw-r--r--tools/mhmake/mhmake.vcxproj.filters9
-rw-r--r--tools/mhmake/src/build.cpp30
-rw-r--r--tools/mhmake/src/commandqueue.cpp8
-rw-r--r--tools/mhmake/src/fileinfo.h6
-rw-r--r--tools/mhmake/src/flex.skl3426
-rw-r--r--tools/mhmake/src/flexint.h63
-rw-r--r--tools/mhmake/src/flexlexer.h260
-rw-r--r--tools/mhmake/src/flexskel.cc1053
-rw-r--r--tools/mhmake/src/flexskel.h395
-rw-r--r--tools/mhmake/src/functions.cpp2
-rw-r--r--tools/mhmake/src/mhmakefileparser.cpp86
-rw-r--r--tools/mhmake/src/mhmakefileparser.h13
-rw-r--r--tools/mhmake/src/mhmakelexer.l485
-rw-r--r--tools/mhmake/src/mhmakeparser.y9
-rw-r--r--tools/mhmake/src/rule.cpp22
-rw-r--r--tools/mhmake/src/rule.h28
-rw-r--r--tools/mhmake/src/stdafx.h1
-rw-r--r--tools/mhmake/src/util.cpp4
-rw-r--r--tools/mhmake/src/util.h4
26 files changed, 4276 insertions, 1866 deletions
diff --git a/tools/mhmake/CMakeLists.txt b/tools/mhmake/CMakeLists.txt
index 7fb5c6c6f..8af73f6db 100644
--- a/tools/mhmake/CMakeLists.txt
+++ b/tools/mhmake/CMakeLists.txt
@@ -11,13 +11,15 @@ PROJECT(${PROGRAM_NAME})
SET( CMAKE_CXX_FLAGS_DEBUG "-D _DEBUG")
ADD_CUSTOM_COMMAND(
- OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/mhmakelexer.cpp ${CMAKE_CURRENT_BINARY_DIR}/mhmakelexer.h
- COMMAND flex++ -8 -S${CMAKE_CURRENT_SOURCE_DIR}/src/flexskel.cc -H${CMAKE_CURRENT_SOURCE_DIR}/src/flexskel.h -h${CMAKE_CURRENT_BINARY_DIR}/mhmakelexer.h -otemp1234.456 ${CMAKE_CURRENT_SOURCE_DIR}/src/mhmakelexer.l
+ OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/mhmakelexer.cpp
+ COMMAND flex++ -S${CMAKE_CURRENT_SOURCE_DIR}/src/flex.skl -o${CMAKE_CURRENT_BINARY_DIR}/mhmakelexer.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/mhmakelexer.l
+ COMMAND mv ${CMAKE_CURRENT_BINARY_DIR}/mhmakelexer.cpp ${CMAKE_CURRENT_BINARY_DIR}/temp1234.456
COMMAND echo '\#include \"stdafx.h\"' > ${CMAKE_CURRENT_BINARY_DIR}/mhmakelexer.cpp
- COMMAND cat temp1234.456 >> ${CMAKE_CURRENT_BINARY_DIR}/mhmakelexer.cpp
- COMMAND rm temp1234.456
+ COMMAND cat ${CMAKE_CURRENT_BINARY_DIR}/temp1234.456 >> ${CMAKE_CURRENT_BINARY_DIR}/mhmakelexer.cpp
+ COMMAND rm ${CMAKE_CURRENT_BINARY_DIR}/temp1234.456
+ COMMAND cp ${CMAKE_CURRENT_SOURCE_DIR}/src/flexlexer.h ${CMAKE_CURRENT_BINARY_DIR}/FlexLexer.h
- DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/src/mhmakelexer.l ${CMAKE_CURRENT_BINARY_DIR}/mhmakeparser.h
+ DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/src/mhmakelexer.l ${CMAKE_CURRENT_SOURCE_DIR}/src/flex.skl ${CMAKE_CURRENT_BINARY_DIR}/mhmakeparser.h
)
ADD_CUSTOM_COMMAND(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/mhmakeparser.cpp ${CMAKE_CURRENT_BINARY_DIR}/mhmakeparser.h
@@ -32,8 +34,8 @@ INCLUDE_DIRECTORIES(src ${CMAKE_CURRENT_BINARY_DIR})
LINK_LIBRARIES(/usr/lib/libpopt.a)
ADD_EXECUTABLE(${PROGRAM_NAME}
- mhmakeparser.cpp
- mhmakelexer.cpp
+ ${CMAKE_CURRENT_BINARY_DIR}/mhmakeparser.cpp
+ ${CMAKE_CURRENT_BINARY_DIR}/mhmakelexer.cpp
src/mhmake.cpp
src/mhmakefileparser.cpp
src/util.cpp
diff --git a/tools/mhmake/addstdafxh.py b/tools/mhmake/addstdafxh.py
new file mode 100644
index 000000000..45413a474
--- /dev/null
+++ b/tools/mhmake/addstdafxh.py
@@ -0,0 +1,33 @@
+import sys,re,os
+
+try:
+ InputFile=sys.argv[1]
+except:
+ print "No input file specified"
+ sys.exit(1)
+
+try:
+ InputFile=sys.argv[1]
+ pIN=open(InputFile,"r")
+ data=pIN.read()
+ pIN.close()
+except:
+ print "Error reading input file",InputFile
+ sys.exit(1)
+
+try:
+ pOUT=open(InputFile,"w")
+except:
+ print "Error opening",InputFile,"for writing"
+ sys.exit(1)
+
+pOUT.write("""#include "stdafx.h"\n""")
+#since we are going to add one line we need to update all line statements
+def IncrementLine(matchobj):
+ return "#line %d%s"%(int(matchobj.group(1))+1,matchobj.group(2))
+
+data=re.sub(r"#\s*line\s+(\d+)(.*%s)"%os.path.split(InputFile)[1],IncrementLine,data)
+
+pOUT.write(data)
+pOUT.close()
+
diff --git a/tools/mhmake/flex++.exe b/tools/mhmake/flex++.exe
index 3d915b466..14da34eb0 100644
--- a/tools/mhmake/flex++.exe
+++ b/tools/mhmake/flex++.exe
Binary files differ
diff --git a/tools/mhmake/makebison.bat b/tools/mhmake/makebison.bat
index ccbe58f54..9d46f535a 100644
--- a/tools/mhmake/makebison.bat
+++ b/tools/mhmake/makebison.bat
@@ -1,16 +1,4 @@
@echo off
-setlocal
-
-cd %1
-"..\bison++" -d -S%3 -H%4 -h%5 -o%6 %2
-
-set file=%6
-set tempfile=%RANDOM%bison.tmp
-
-move %file% %tempfile%
-echo #include "stdafx.h" > %file%
-type %tempfile% >> %file%
-del /q %tempfile%
-
-endlocal
+"bison++" -d -Ssrc/bison.cc -Hsrc/bison.h -h%1/mhmakeparser.h -o%1/mhmakeparser.cpp src\mhmakeParser.y
+python addstdafxh.py %1\mhmakeparser.cpp
diff --git a/tools/mhmake/makelex.bat b/tools/mhmake/makelex.bat
index 0705f4bb1..66d9255fa 100644
--- a/tools/mhmake/makelex.bat
+++ b/tools/mhmake/makelex.bat
@@ -1,16 +1,11 @@
@echo off
setlocal
-cd %1
-"..\flex++" -8 -S%3 -H%4 -h%5 -o%6 %2
+set M4=.\m4.exe
-set file=%6
-set tempfile=%RANDOM%lex.tmp
+"flex++" --nounistd -Ssrc/flex.skl -o%1/mhmakelexer.cpp src/mhmakelexer.l
-move %file% %tempfile%
-echo #include "stdafx.h" > %file%
-type %tempfile% >> %file%
-del /q %tempfile%
+python addstdafxh.py %1\mhmakelexer.cpp
endlocal
diff --git a/tools/mhmake/mhmake.vcproj b/tools/mhmake/mhmake.vcproj
index b8ea6a674..9d8ad1db2 100644
--- a/tools/mhmake/mhmake.vcproj
+++ b/tools/mhmake/mhmake.vcproj
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
- Version="9,00"
+ Version="9.00"
Name="mhmake"
ProjectGUID="{7F1669C8-7974-45DF-9B71-0E2A8DC44C06}"
RootNamespace="mhmake"
@@ -268,7 +268,7 @@
/>
<Tool
Name="VCLinkerTool"
- OutputFile="$(OutDir)\mhmake_dbg.exe"
+ OutputFile="$(ConfigurationName)/mhmake_dbg.exe"
LinkIncremental="1"
SuppressStartupBanner="true"
GenerateDebugInformation="true"
@@ -358,7 +358,7 @@
/>
<Tool
Name="VCLinkerTool"
- OutputFile="$(OutDir)\mhmake_dbg.exe"
+ OutputFile="$(ConfigurationName)/mhmake_dbg.exe"
LinkIncremental="1"
SuppressStartupBanner="true"
GenerateDebugInformation="true"
@@ -493,8 +493,8 @@
</Configuration>
<Configuration
Name="Profile|x64"
- OutputDirectory="$(PlatformName)\$(ConfigurationName)"
- IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
+ OutputDirectory="Profile64"
+ IntermediateDirectory="Profile64"
ConfigurationType="1"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
UseOfMFC="0"
@@ -779,9 +779,9 @@
>
<Tool
Name="VCCustomBuildTool"
- CommandLine="cmd.exe /c makelex.bat $(OutDir) &quot;$(InputPath)&quot; ..\src\flexskel.cc ..\src\flexskel.h $(InputName).h $(InputName).cpp&#x0D;&#x0A;"
- AdditionalDependencies=".\src\flexskel.cc;.\src\flexskel.h;"
- Outputs="$(OutDir)\$(InputName).cpp;$(OutDir)\$(InputName).h"
+ CommandLine="cmd.exe /c makelex.bat Release&#x0D;&#x0A;"
+ AdditionalDependencies=".\src\flexint.h;.\src\flex.skl;.\src\flexlexer.h;"
+ Outputs="$(OutDir)\$(InputName).cpp"
/>
</FileConfiguration>
<FileConfiguration
@@ -789,9 +789,9 @@
>
<Tool
Name="VCCustomBuildTool"
- CommandLine="cmd.exe /c makelex.bat $(OutDir) &quot;$(InputPath)&quot; ..\src\flexskel.cc ..\src\flexskel.h $(InputName).h $(InputName).cpp&#x0D;&#x0A;"
- AdditionalDependencies=".\src\flexskel.cc;.\src\flexskel.h;"
- Outputs="$(OutDir)\$(InputName).cpp;$(OutDir)\$(InputName).h"
+ CommandLine="cmd.exe /c makelex.bat Release64&#x0D;&#x0A;"
+ AdditionalDependencies=".\src\flexint.h;.\src\flex.skl;.\src\flexlexer.h;"
+ Outputs="$(OutDir)\$(InputName).cpp"
/>
</FileConfiguration>
<FileConfiguration
@@ -799,9 +799,9 @@
>
<Tool
Name="VCCustomBuildTool"
- CommandLine="cmd.exe /c makelex.bat $(OutDir) &quot;$(InputPath)&quot; ..\src\flexskel.cc ..\src\flexskel.h $(InputName).h $(InputName).cpp&#x0D;&#x0A;"
- AdditionalDependencies=".\src\flexskel.cc;.\src\flexskel.h;"
- Outputs="$(OutDir)\$(InputName).cpp;$(OutDir)\$(InputName).h"
+ CommandLine="cmd.exe /c makelex.bat Debug&#x0D;&#x0A;"
+ AdditionalDependencies=".\src\flexint.h;.\src\flex.skl;.\src\flexlexer.h;"
+ Outputs="$(OutDir)\$(InputName).cpp"
/>
</FileConfiguration>
<FileConfiguration
@@ -809,9 +809,9 @@
>
<Tool
Name="VCCustomBuildTool"
- CommandLine="cmd.exe /c makelex.bat $(OutDir) &quot;$(InputPath)&quot; ..\src\flexskel.cc ..\src\flexskel.h $(InputName).h $(InputName).cpp&#x0D;&#x0A;"
- AdditionalDependencies=".\src\flexskel.cc;.\src\flexskel.h;"
- Outputs="$(OutDir)\$(InputName).cpp;$(OutDir)\$(InputName).h"
+ CommandLine="cmd.exe /c makelex.bat Debug64&#x0D;&#x0A;"
+ AdditionalDependencies=".\src\flexint.h;.\src\flex.skl;.\src\flexlexer.h;"
+ Outputs="$(OutDir)\$(InputName).cpp"
/>
</FileConfiguration>
<FileConfiguration
@@ -819,9 +819,9 @@
>
<Tool
Name="VCCustomBuildTool"
- CommandLine="cmd.exe /c makelex.bat $(OutDir) &quot;$(InputPath)&quot; ..\src\flexskel.cc ..\src\flexskel.h $(InputName).h $(InputName).cpp&#x0D;&#x0A;"
- AdditionalDependencies=".\src\flexskel.cc;.\src\flexskel.h;"
- Outputs="$(OutDir)\$(InputName).cpp;$(OutDir)\$(InputName).h"
+ CommandLine="cmd.exe /c makelex.bat Profile&#x0D;&#x0A;"
+ AdditionalDependencies=".\src\flexint.h;.\src\flex.skl;.\src\flexlexer.h;"
+ Outputs="$(OutDir)\$(InputName).cpp"
/>
</FileConfiguration>
<FileConfiguration
@@ -829,9 +829,9 @@
>
<Tool
Name="VCCustomBuildTool"
- CommandLine="cmd.exe /c makelex.bat $(OutDir) &quot;$(InputPath)&quot; ..\src\flexskel.cc ..\src\flexskel.h $(InputName).h $(InputName).cpp&#x0D;&#x0A;"
- AdditionalDependencies=".\src\flexskel.cc;.\src\flexskel.h;"
- Outputs="$(OutDir)\$(InputName).cpp;$(OutDir)\$(InputName).h"
+ CommandLine="cmd.exe /c makelex.bat Profile64&#x0D;&#x0A;"
+ AdditionalDependencies=".\src\flexint.h;.\src\flex.skl;.\src\flexlexer.h;"
+ Outputs="$(OutDir)\$(InputName).cpp"
/>
</FileConfiguration>
<FileConfiguration
@@ -839,9 +839,9 @@
>
<Tool
Name="VCCustomBuildTool"
- CommandLine="cmd.exe /c makelex.bat $(OutDir) &quot;$(InputPath)&quot; ..\src\flexskel.cc ..\src\flexskel.h $(InputName).h $(InputName).cpp&#x0D;&#x0A;"
- AdditionalDependencies=".\src\flexskel.cc;.\src\flexskel.h;"
- Outputs="$(OutDir)\$(InputName).cpp;$(OutDir)\$(InputName).h"
+ CommandLine="cmd.exe /c makelex.bat Debug64&#x0D;&#x0A;"
+ AdditionalDependencies=".\src\flexint.h;.\src\flex.skl;.\src\flexlexer.h;"
+ Outputs="$(OutDir)\$(InputName).cpp"
/>
</FileConfiguration>
<FileConfiguration
@@ -849,9 +849,9 @@
>
<Tool
Name="VCCustomBuildTool"
- CommandLine="cmd.exe /c makelex.bat $(OutDir) &quot;$(InputPath)&quot; ..\src\flexskel.cc ..\src\flexskel.h $(InputName).h $(InputName).cpp&#x0D;&#x0A;"
- AdditionalDependencies=".\src\flexskel.cc;.\src\flexskel.h;"
- Outputs="$(OutDir)\$(InputName).cpp;$(OutDir)\$(InputName).h"
+ CommandLine="cmd.exe /c makelex.bat Debug64&#x0D;&#x0A;"
+ AdditionalDependencies=".\src\flexint.h;.\src\flex.skl;.\src\flexlexer.h;"
+ Outputs="$(OutDir)\$(InputName).cpp"
/>
</FileConfiguration>
<FileConfiguration
@@ -859,9 +859,9 @@
>
<Tool
Name="VCCustomBuildTool"
- CommandLine="cmd.exe /c makelex.bat $(OutDir) &quot;$(InputPath)&quot; ..\src\flexskel.cc ..\src\flexskel.h $(InputName).h $(InputName).cpp&#x0D;&#x0A;"
- AdditionalDependencies=".\src\flexskel.cc;.\src\flexskel.h;"
- Outputs="$(OutDir)\$(InputName).cpp;$(OutDir)\$(InputName).h"
+ CommandLine="cmd.exe /c makelex.bat Release64&#x0D;&#x0A;"
+ AdditionalDependencies=".\src\flexint.h;.\src\flex.skl;.\src\flexlexer.h;"
+ Outputs="$(OutDir)\$(InputName).cpp"
/>
</FileConfiguration>
<FileConfiguration
@@ -869,9 +869,9 @@
>
<Tool
Name="VCCustomBuildTool"
- CommandLine="cmd.exe /c makelex.bat $(OutDir) &quot;$(InputPath)&quot; ..\src\flexskel.cc ..\src\flexskel.h $(InputName).h $(InputName).cpp&#x0D;&#x0A;"
- AdditionalDependencies=".\src\flexskel.cc;.\src\flexskel.h;"
- Outputs="$(OutDir)\$(InputName).cpp;$(OutDir)\$(InputName).h"
+ CommandLine="cmd.exe /c makelex.bat Release64&#x0D;&#x0A;"
+ AdditionalDependencies=".\src\flexint.h;.\src\flex.skl;.\src\flexlexer.h;"
+ Outputs="$(OutDir)\$(InputName).cpp"
/>
</FileConfiguration>
</File>
@@ -883,7 +883,7 @@
>
<Tool
Name="VCCustomBuildTool"
- CommandLine="cmd.exe /c makebison.bat $(OutDir) &quot;$(InputPath)&quot; ..\src\bison.cc ..\src\bison.h $(InputName).h $(InputName).cpp&#x0D;&#x0A;"
+ CommandLine="cmd.exe /c makebison.bat Release&#x0D;&#x0A;"
AdditionalDependencies=".\src\bison.cc;.\src\bison.h;"
Outputs="$(OutDir)\$(InputName).cpp;$(OutDir)\$(InputName).h"
/>
@@ -893,7 +893,7 @@
>
<Tool
Name="VCCustomBuildTool"
- CommandLine="cmd.exe /c makebison.bat $(OutDir) &quot;$(InputPath)&quot; ..\src\bison.cc ..\src\bison.h $(InputName).h $(InputName).cpp&#x0D;&#x0A;"
+ CommandLine="cmd.exe /c makebison.bat Release64&#x0D;&#x0A;"
AdditionalDependencies=".\src\bison.cc;.\src\bison.h;"
Outputs="$(OutDir)\$(InputName).cpp;$(OutDir)\$(InputName).h"
/>
@@ -903,7 +903,7 @@
>
<Tool
Name="VCCustomBuildTool"
- CommandLine="cmd.exe /c makebison.bat $(OutDir) &quot;$(InputPath)&quot; ..\src\bison.cc ..\src\bison.h $(InputName).h $(InputName).cpp&#x0D;&#x0A;"
+ CommandLine="cmd.exe /c makebison.bat Debug&#x0D;&#x0A;"
AdditionalDependencies=".\src\bison.cc;.\src\bison.h;"
Outputs="$(OutDir)\$(InputName).cpp;$(OutDir)\$(InputName).h"
/>
@@ -913,7 +913,7 @@
>
<Tool
Name="VCCustomBuildTool"
- CommandLine="cmd.exe /c makebison.bat $(OutDir) &quot;$(InputPath)&quot; ..\src\bison.cc ..\src\bison.h $(InputName).h $(InputName).cpp&#x0D;&#x0A;"
+ CommandLine="cmd.exe /c makebison.bat Debug64&#x0D;&#x0A;"
AdditionalDependencies=".\src\bison.cc;.\src\bison.h;"
Outputs="$(OutDir)\$(InputName).cpp;$(OutDir)\$(InputName).h"
/>
@@ -923,7 +923,7 @@
>
<Tool
Name="VCCustomBuildTool"
- CommandLine="cmd.exe /c makebison.bat $(OutDir) &quot;$(InputPath)&quot; ..\src\bison.cc ..\src\bison.h $(InputName).h $(InputName).cpp&#x0D;&#x0A;"
+ CommandLine="cmd.exe /c makebison.bat Profile&#x0D;&#x0A;"
AdditionalDependencies=".\src\bison.cc;.\src\bison.h;"
Outputs="$(OutDir)\$(InputName).cpp;$(OutDir)\$(InputName).h"
/>
@@ -933,7 +933,7 @@
>
<Tool
Name="VCCustomBuildTool"
- CommandLine="cmd.exe /c makebison.bat $(OutDir) &quot;$(InputPath)&quot; ..\src\bison.cc ..\src\bison.h $(InputName).h $(InputName).cpp&#x0D;&#x0A;"
+ CommandLine="cmd.exe /c makebison.bat Profile64&#x0D;&#x0A;"
AdditionalDependencies=".\src\bison.cc;.\src\bison.h;"
Outputs="$(OutDir)\$(InputName).cpp;$(OutDir)\$(InputName).h"
/>
@@ -943,7 +943,7 @@
>
<Tool
Name="VCCustomBuildTool"
- CommandLine="cmd.exe /c makebison.bat $(OutDir) &quot;$(InputPath)&quot; ..\src\bison.cc ..\src\bison.h $(InputName).h $(InputName).cpp&#x0D;&#x0A;"
+ CommandLine="cmd.exe /c makebison.bat Debug64&#x0D;&#x0A;"
AdditionalDependencies=".\src\bison.cc;.\src\bison.h;"
Outputs="$(OutDir)\$(InputName).cpp;$(OutDir)\$(InputName).h"
/>
@@ -953,7 +953,7 @@
>
<Tool
Name="VCCustomBuildTool"
- CommandLine="cmd.exe /c makebison.bat $(OutDir) &quot;$(InputPath)&quot; ..\src\bison.cc ..\src\bison.h $(InputName).h $(InputName).cpp&#x0D;&#x0A;"
+ CommandLine="cmd.exe /c makebison.bat Debug64&#x0D;&#x0A;"
AdditionalDependencies=".\src\bison.cc;.\src\bison.h;"
Outputs="$(OutDir)\$(InputName).cpp;$(OutDir)\$(InputName).h"
/>
@@ -963,7 +963,7 @@
>
<Tool
Name="VCCustomBuildTool"
- CommandLine="cmd.exe /c makebison.bat $(OutDir) &quot;$(InputPath)&quot; ..\src\bison.cc ..\src\bison.h $(InputName).h $(InputName).cpp&#x0D;&#x0A;"
+ CommandLine="cmd.exe /c makebison.bat Release64&#x0D;&#x0A;"
AdditionalDependencies=".\src\bison.cc;.\src\bison.h;"
Outputs="$(OutDir)\$(InputName).cpp;$(OutDir)\$(InputName).h"
/>
@@ -973,7 +973,7 @@
>
<Tool
Name="VCCustomBuildTool"
- CommandLine="cmd.exe /c makebison.bat $(OutDir) &quot;$(InputPath)&quot; ..\src\bison.cc ..\src\bison.h $(InputName).h $(InputName).cpp&#x0D;&#x0A;"
+ CommandLine="cmd.exe /c makebison.bat Release64&#x0D;&#x0A;"
AdditionalDependencies=".\src\bison.cc;.\src\bison.h;"
Outputs="$(OutDir)\$(InputName).cpp;$(OutDir)\$(InputName).h"
/>
@@ -988,10 +988,6 @@
>
</File>
<File
- RelativePath="$(OutDir)\mhmakelexer.h"
- >
- </File>
- <File
RelativePath="$(OutDir)\mhmakeparser.cpp"
>
</File>
diff --git a/tools/mhmake/mhmake.vcxproj b/tools/mhmake/mhmake.vcxproj
index 8b7faed2c..c5c548c77 100644
--- a/tools/mhmake/mhmake.vcxproj
+++ b/tools/mhmake/mhmake.vcxproj
@@ -110,8 +110,8 @@
<OutDir Condition="'$(Configuration)|$(Platform)'=='Profile|Win32'">$(Configuration)\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Profile|Win32'">$(Configuration)\</IntDir>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Profile|Win32'">false</LinkIncremental>
- <OutDir Condition="'$(Configuration)|$(Platform)'=='Profile|x64'">$(Platform)\$(Configuration)\</OutDir>
- <IntDir Condition="'$(Configuration)|$(Platform)'=='Profile|x64'">$(Platform)\$(Configuration)\</IntDir>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Profile|x64'">Profile64\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Profile|x64'">Profile64\</IntDir>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Profile|x64'">false</LinkIncremental>
<TargetName Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">mhmake_dbg</TargetName>
<TargetName Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">mhmake_dbg</TargetName>
@@ -274,7 +274,7 @@
<Culture>0x0409</Culture>
</ResourceCompile>
<Link>
- <OutputFile>$(OutDir)mhmake_dbg.exe</OutputFile>
+ <OutputFile>$(OutDir)\mhmake_dbg.exe</OutputFile>
<SuppressStartupBanner>true</SuppressStartupBanner>
<GenerateDebugInformation>true</GenerateDebugInformation>
<ProgramDatabaseFile>.\Debug/mhmake.pdb</ProgramDatabaseFile>
@@ -322,7 +322,7 @@
<Link>
<SuppressStartupBanner>true</SuppressStartupBanner>
<GenerateDebugInformation>true</GenerateDebugInformation>
- <ProgramDatabaseFile>$(OutDir)$(ProjectName).pdb</ProgramDatabaseFile>
+ <ProgramDatabaseFile>$(OutDir)\$(ProjectName).pdb</ProgramDatabaseFile>
<GenerateMapFile>true</GenerateMapFile>
<MapExports>true</MapExports>
<SubSystem>Console</SubSystem>
@@ -375,7 +375,7 @@
<OutputFile>$(Configuration)/mhmake.exe</OutputFile>
<SuppressStartupBanner>true</SuppressStartupBanner>
<GenerateDebugInformation>true</GenerateDebugInformation>
- <ProgramDatabaseFile>$(OutDir)$(ProjectName).pdb</ProgramDatabaseFile>
+ <ProgramDatabaseFile>$(OutDir)\$(ProjectName).pdb</ProgramDatabaseFile>
<GenerateMapFile>true</GenerateMapFile>
<MapExports>true</MapExports>
<SubSystem>Console</SubSystem>
@@ -405,8 +405,8 @@
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
</ClCompile>
<ClCompile Include="src\util.cpp" />
- <ClCompile Include="$(OutDir)mhmakelexer.cpp" />
- <ClCompile Include="$(OutDir)mhmakeparser.cpp" />
+ <ClCompile Include="$(OutDir)\mhmakelexer.cpp" />
+ <ClCompile Include="$(OutDir)\mhmakeparser.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="src\commandqueue.h" />
@@ -418,60 +418,56 @@
<ClInclude Include="src\rule.h" />
<ClInclude Include="src\stdafx.h" />
<ClInclude Include="src\util.h" />
- <ClInclude Include="$(OutDir)mhmakelexer.h" />
- <ClInclude Include="$(OutDir)mhmakeparser.h" />
+ <ClInclude Include="$(OutDir)\mhmakeparser.h" />
<ClInclude Include="src\bison.h" />
</ItemGroup>
<ItemGroup>
<CustomBuild Include="src\mhmakeLexer.l">
- <Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">cmd.exe /c makelex.bat $(OutDir) "%(FullPath)" ..\src\flexskel.cc ..\src\flexskel.h %(Filename).h %(Filename).cpp
+ <Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">cmd.exe /c makelex.bat Debug
</Command>
- <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">.\src\flexskel.cc;.\src\flexskel.h;%(AdditionalInputs)</AdditionalInputs>
- <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(OutDir)%(Filename).cpp;$(OutDir)%(Filename).h;%(Outputs)</Outputs>
- <Command Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">cmd.exe /c makelex.bat $(OutDir) "%(FullPath)" ..\src\flexskel.cc ..\src\flexskel.h %(Filename).h %(Filename).cpp
+ <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">.\src\flexint.h;.\src\flex.skl;.\src\flexlexer.h;%(AdditionalInputs)</AdditionalInputs>
+ <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(OutDir)%(Filename).cpp;%(Outputs)</Outputs>
+ <Command Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">cmd.exe /c makelex.bat Debug64
</Command>
- <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">.\src\flexskel.cc;.\src\flexskel.h;%(AdditionalInputs)</AdditionalInputs>
- <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(OutDir)%(Filename).cpp;$(OutDir)%(Filename).h;%(Outputs)</Outputs>
- <Command Condition="'$(Configuration)|$(Platform)'=='Profile|Win32'">cmd.exe /c makelex.bat $(OutDir) "%(FullPath)" ..\src\flexskel.cc ..\src\flexskel.h %(Filename).h %(Filename).cpp
+ <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">.\src\flexint.h;.\src\flex.skl;.\src\flexlexer.h;%(AdditionalInputs)</AdditionalInputs>
+ <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(OutDir)%(Filename).cpp;%(Outputs)</Outputs>
+ <Command Condition="'$(Configuration)|$(Platform)'=='Profile|Win32'">cmd.exe /c makelex.bat Profile
</Command>
- <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Profile|Win32'">.\src\flexskel.cc;.\src\flexskel.h;%(AdditionalInputs)</AdditionalInputs>
- <Outputs Condition="'$(Configuration)|$(Platform)'=='Profile|Win32'">$(OutDir)%(Filename).cpp;$(OutDir)%(Filename).h;%(Outputs)</Outputs>
- <Command Condition="'$(Configuration)|$(Platform)'=='Profile|x64'">cmd.exe /c makelex.bat $(OutDir) "%(FullPath)" ..\src\flexskel.cc ..\src\flexskel.h %(Filename).h %(Filename).cpp
+ <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Profile|Win32'">.\src\flexint.h;.\src\flex.skl;.\src\flexlexer.h;%(AdditionalInputs)</AdditionalInputs>
+ <Outputs Condition="'$(Configuration)|$(Platform)'=='Profile|Win32'">$(OutDir)%(Filename).cpp;%(Outputs)</Outputs>
+ <Command Condition="'$(Configuration)|$(Platform)'=='Profile|x64'">cmd.exe /c makelex.bat Profile64
</Command>
- <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Profile|x64'">.\src\flexskel.cc;.\src\flexskel.h;%(AdditionalInputs)</AdditionalInputs>
- <Outputs Condition="'$(Configuration)|$(Platform)'=='Profile|x64'">$(OutDir)%(Filename).cpp;$(OutDir)%(Filename).h;%(Outputs)</Outputs>
- <Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">cmd.exe /c makelex.bat $(OutDir) "%(FullPath)" ..\src\flexskel.cc ..\src\flexskel.h %(Filename).h %(Filename).cpp
+ <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Profile|x64'">.\src\flexint.h;.\src\flex.skl;.\src\flexlexer.h;%(AdditionalInputs)</AdditionalInputs>
+ <Outputs Condition="'$(Configuration)|$(Platform)'=='Profile|x64'">$(OutDir)%(Filename).cpp;%(Outputs)</Outputs>
+ <Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">cmd.exe /c makelex.bat Release
</Command>
- <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">.\src\flexskel.cc;.\src\flexskel.h;%(AdditionalInputs)</AdditionalInputs>
- <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(OutDir)%(Filename).cpp;$(OutDir)%(Filename).h;%(Outputs)</Outputs>
- <Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">cmd.exe /c makelex.bat $(OutDir) "%(FullPath)" ..\src\flexskel.cc ..\src\flexskel.h %(Filename).h %(Filename).cpp
-</Command>
- <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">.\src\flexskel.cc;.\src\flexskel.h;%(AdditionalInputs)</AdditionalInputs>
- <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(OutDir)%(Filename).cpp;$(OutDir)%(Filename).h;%(Outputs)</Outputs>
+ <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">.\src\flexint.h;.\src\flex.skl;.\src\flexlexer.h;%(AdditionalInputs)</AdditionalInputs>
+ <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(OutDir)%(Filename).cpp;%(Outputs)</Outputs>
+ <Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">cmd.exe /c makelex.bat Release64</Command>
+ <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">.\src\flexint.h;.\src\flex.skl;.\src\flexlexer.h;%(AdditionalInputs)</AdditionalInputs>
+ <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(OutDir)%(Filename).cpp;%(Outputs)</Outputs>
</CustomBuild>
<CustomBuild Include="src\mhmakeParser.y">
- <Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">cmd.exe /c makebison.bat $(OutDir) "%(FullPath)" ..\src\bison.cc ..\src\bison.h %(Filename).h %(Filename).cpp
+ <Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">cmd.exe /c makebison.bat Debug
</Command>
<AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">.\src\bison.cc;.\src\bison.h;%(AdditionalInputs)</AdditionalInputs>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(OutDir)%(Filename).cpp;$(OutDir)%(Filename).h;%(Outputs)</Outputs>
- <Command Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">cmd.exe /c makebison.bat $(OutDir) "%(FullPath)" ..\src\bison.cc ..\src\bison.h %(Filename).h %(Filename).cpp
+ <Command Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">cmd.exe /c makebison.bat Debug64
</Command>
<AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">.\src\bison.cc;.\src\bison.h;%(AdditionalInputs)</AdditionalInputs>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(OutDir)%(Filename).cpp;$(OutDir)%(Filename).h;%(Outputs)</Outputs>
- <Command Condition="'$(Configuration)|$(Platform)'=='Profile|Win32'">cmd.exe /c makebison.bat $(OutDir) "%(FullPath)" ..\src\bison.cc ..\src\bison.h %(Filename).h %(Filename).cpp
+ <Command Condition="'$(Configuration)|$(Platform)'=='Profile|Win32'">cmd.exe /c makebison.bat Profile
</Command>
<AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Profile|Win32'">.\src\bison.cc;.\src\bison.h;%(AdditionalInputs)</AdditionalInputs>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Profile|Win32'">$(OutDir)%(Filename).cpp;$(OutDir)%(Filename).h;%(Outputs)</Outputs>
- <Command Condition="'$(Configuration)|$(Platform)'=='Profile|x64'">cmd.exe /c makebison.bat $(OutDir) "%(FullPath)" ..\src\bison.cc ..\src\bison.h %(Filename).h %(Filename).cpp
-</Command>
+ <Command Condition="'$(Configuration)|$(Platform)'=='Profile|x64'">cmd.exe /c makebison.bat Profile64</Command>
<AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Profile|x64'">.\src\bison.cc;.\src\bison.h;%(AdditionalInputs)</AdditionalInputs>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Profile|x64'">$(OutDir)%(Filename).cpp;$(OutDir)%(Filename).h;%(Outputs)</Outputs>
- <Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">cmd.exe /c makebison.bat $(OutDir) "%(FullPath)" ..\src\bison.cc ..\src\bison.h %(Filename).h %(Filename).cpp
+ <Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">cmd.exe /c makebison.bat Release
</Command>
<AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">.\src\bison.cc;.\src\bison.h;%(AdditionalInputs)</AdditionalInputs>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(OutDir)%(Filename).cpp;$(OutDir)%(Filename).h;%(Outputs)</Outputs>
- <Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">cmd.exe /c makebison.bat $(OutDir) "%(FullPath)" ..\src\bison.cc ..\src\bison.h %(Filename).h %(Filename).cpp
-</Command>
+ <Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">cmd.exe /c makebison.bat Release64</Command>
<AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">.\src\bison.cc;.\src\bison.h;%(AdditionalInputs)</AdditionalInputs>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(OutDir)%(Filename).cpp;$(OutDir)%(Filename).h;%(Outputs)</Outputs>
</CustomBuild>
diff --git a/tools/mhmake/mhmake.vcxproj.filters b/tools/mhmake/mhmake.vcxproj.filters
index e56db173b..72f6cf675 100644
--- a/tools/mhmake/mhmake.vcxproj.filters
+++ b/tools/mhmake/mhmake.vcxproj.filters
@@ -91,15 +91,12 @@
<ClInclude Include="src\util.h">
<Filter>Header Files</Filter>
</ClInclude>
- <ClInclude Include="$(OutDir)mhmakelexer.h">
- <Filter>Parser Files\Auto</Filter>
- </ClInclude>
- <ClInclude Include="$(OutDir)mhmakeparser.h">
- <Filter>Parser Files\Auto</Filter>
- </ClInclude>
<ClInclude Include="src\bison.h">
<Filter>Header Files</Filter>
</ClInclude>
+ <ClInclude Include="$(OutDir)\mhmakeparser.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
</ItemGroup>
<ItemGroup>
<CustomBuild Include="src\mhmakeLexer.l">
diff --git a/tools/mhmake/src/build.cpp b/tools/mhmake/src/build.cpp
index 525ff8c05..3a6af155c 100644
--- a/tools/mhmake/src/build.cpp
+++ b/tools/mhmake/src/build.cpp
@@ -440,7 +440,7 @@ mh_pid_t mhmakefileparser::DeleteFiles(const string &Params) const
if (DeleteDir(FileName,DirSearch,bRemoveDir) && !IgnoreError)
{
cerr << "Error deleting "<<FileName<<endl;
- return false;
+ return (mh_pid_t)-1;
}
}
else
@@ -866,7 +866,7 @@ string mhmakefileparser::GetFullCommand(string Command)
const char *pBeg=Command.c_str();
const char *pEnd=pBeg+Command.length()-1;
bool HasExt=false;
- while (pEnd>pBeg && *pEnd!=OSPATHSEP)
+ while (pEnd>pBeg && *pEnd!='\\' && *pEnd!='/')
{
if (*pEnd=='.')
{
@@ -1315,7 +1315,7 @@ mh_pid_t mhmakefileparser::ExecuteCommand(string Command, bool &IgnoreError, str
{
bool Echo=true;
IgnoreError=false;
- while (1)
+ while (Command.length())
{
if (Command[0]=='@')
{
@@ -1331,6 +1331,8 @@ mh_pid_t mhmakefileparser::ExecuteCommand(string Command, bool &IgnoreError, str
}
break;
}
+ if (!Command.length())
+ (mh_pid_t)0;
string InCommand=Command;
if (g_Quiet)
Echo=false;
@@ -1378,7 +1380,7 @@ mh_pid_t mhmakefileparser::ExecuteCommand(string Command, bool &IgnoreError, str
}
else
{
- if (Command!="echo")
+ if (Command!="echo" || strchr(Params.c_str(),'|')) // the EchoCommand(Params) does not implement piping, only redirecting (>)
{
string FullCommand=GetFullCommand(Command);
string ComSpec=GetComspec();
@@ -1449,6 +1451,15 @@ void mhmakefileparser::BuildDependencies(const refptr<rule> &pRule, fileinfo* pT
while (pDepIt!=Deps.end())
{
mh_time_t DepDate=WaitBuildTarget(*pDepIt);
+ #ifdef _DEBUG
+ if (!DepDate.DoesExist()&&!(*pDepIt)->IsPhony())
+ {
+ if (!(*pDepIt)->GetDir()->GetDate().DoesExist())
+ cout << "Building of "<<(*pDepIt)->GetFullFileName()<<" failed because directory does not exist (rule defined to create it?)\n";
+ else
+ cout << "Does not known how to create "<<(*pDepIt)->GetFullFileName()<<".\n";
+ }
+ #endif
if (DepDate.IsNewer(YoungestDate))
YoungestDate=DepDate;
if (DepDate.IsNewer(TargetDate))
@@ -1572,7 +1583,7 @@ mh_time_t mhmakefileparser::StartBuildTarget(fileinfo* pTarget,bool bCheckTarget
#endif
break;
}
- else
+ else if (!IMPLICITRULE::PushRule(ResultIt->second))
{
#ifdef _DEBUG
m_ImplicitSearch++;
@@ -1585,6 +1596,7 @@ mh_time_t mhmakefileparser::StartBuildTarget(fileinfo* pTarget,bool bCheckTarget
if (pNewTarget!=NULL)
DepDate=pNewTarget->GetDate();
}
+ IMPLICITRULE::PopRule(ResultIt->second);
#ifdef _DEBUG
m_ImplicitSearch--;
#endif
@@ -1613,6 +1625,12 @@ mh_time_t mhmakefileparser::StartBuildTarget(fileinfo* pTarget,bool bCheckTarget
break;
}
}
+ #ifdef _DEBUG
+ else if (g_PrintAdditionalInfo)
+ {
+ cout << "Stopping implicit search of "<<pTarget->GetFullFileName()<<" because of implicit rule recursion detected.\n";
+ }
+ #endif
ResultIt++;
}
if (pRule)
@@ -1627,7 +1645,7 @@ mh_time_t mhmakefileparser::StartBuildTarget(fileinfo* pTarget,bool bCheckTarget
}
}
- mhmakeparser *pMakefile=NULL;
+ mhmakefileparser *pMakefile=NULL;
if (pRule)
{
pMakefile=pRule->GetMakefile();
diff --git a/tools/mhmake/src/commandqueue.cpp b/tools/mhmake/src/commandqueue.cpp
index fca26f997..6f3fd4d1a 100644
--- a/tools/mhmake/src/commandqueue.cpp
+++ b/tools/mhmake/src/commandqueue.cpp
@@ -116,7 +116,7 @@ void commandqueue::ThrowCommandExecutionError(refptr<activeentry> pActiveEntry)
{
fileinfo* pTarget=pActiveEntry->pTarget;
const string &Command=pActiveEntry->Command;
- mhmakeparser *pMakefile=pTarget->GetRule()->GetMakefile();
+ mhmakefileparser *pMakefile=pTarget->GetRule()->GetMakefile();
string ErrorMessage = string("Error running command: ")+ Command +"\n";
ErrorMessage += "Command defined in makefile: " + pMakefile->GetMakeDir()->GetQuotedFullFileName();
@@ -167,7 +167,7 @@ void commandqueue::RemoveActiveEntry(unsigned Entry)
bool commandqueue::StartExecuteNextCommand(refptr<activeentry> pActiveEntry, mh_pid_t *pActiveProcess)
{
fileinfo* pTarget=pActiveEntry->pTarget;
- mhmakeparser *pMakefile=pTarget->GetRule()->GetMakefile();
+ mhmakefileparser *pMakefile=pTarget->GetRule()->GetMakefile();
pMakefile->SetRuleThatIsBuild(pTarget); // Make sure that the command expension is correct
string Command=pMakefile->ExpandExpression(*pActiveEntry->CurrentCommandIt);
@@ -222,7 +222,7 @@ void commandqueue::TargetBuildFinished(refptr<activeentry> pActiveEntry)
pTarget->SetCommandsMd5_32(Md5_32); /* If the rule of the target was added with an implicit rule the targets in the rule is empty */
refptr<rule> pRule=pTarget->GetRule();
- mhmakeparser *pMakefile=pRule->GetMakefile();
+ mhmakefileparser *pMakefile=pRule->GetMakefile();
pMakefile->AddTarget(pTarget);
pMakefile->SetAutoDepsDirty();
@@ -251,7 +251,7 @@ bool commandqueue::StartExecuteCommands(fileinfo* pTarget)
cout << "Building " << pTarget->GetQuotedFullFileName()<<endl;
// We do not have to put it in the queue, we can start executing directly
refptr<rule> pRule=pTarget->GetRule();
- mhmakeparser *pMakefile=pRule->GetMakefile();
+ mhmakefileparser *pMakefile=pRule->GetMakefile();
vector<string>::iterator CommandIt=pRule->GetCommands().begin();
refptr<activeentry> pActiveEntry=CreateActiveEntry();
diff --git a/tools/mhmake/src/fileinfo.h b/tools/mhmake/src/fileinfo.h
index 8d58a1efa..bb5e0ce71 100644
--- a/tools/mhmake/src/fileinfo.h
+++ b/tools/mhmake/src/fileinfo.h
@@ -136,7 +136,7 @@ class fileinfo
bool m_IsPhony;
int m_BuildStatus; /* Bit 0 means the target built is started, Bit 1 means the target is still building */
refptr<rule> m_pRule;
- mhmakeparser *m_pAutoDepsMakefile;
+ mhmakefileparser *m_pAutoDepsMakefile;
vector<fileinfo*> m_Deps;
mh_time_t m_Date;
uint32 m_CommandsMd5_32; // 32-bit Md5 checksum of commands to build this target
@@ -291,7 +291,7 @@ public:
return m_Deps;
}
string GetPrerequisits(void) const;
- void SetAutoDepsScan(mhmakeparser *pMakefile)
+ void SetAutoDepsScan(mhmakefileparser *pMakefile)
{
#ifdef _DEBUG
if (m_pAutoDepsMakefile)
@@ -299,7 +299,7 @@ public:
#endif
m_pAutoDepsMakefile=pMakefile;
}
- mhmakeparser *GetAutoDepsMakefile(void) const
+ mhmakefileparser *GetAutoDepsMakefile(void) const
{
return m_pAutoDepsMakefile;
}
diff --git a/tools/mhmake/src/flex.skl b/tools/mhmake/src/flex.skl
new file mode 100644
index 000000000..4d57bac46
--- /dev/null
+++ b/tools/mhmake/src/flex.skl
@@ -0,0 +1,3426 @@
+%# -*-C-*- vi: set ft=c:
+%# This file is processed in several stages.
+%# Here are the stages, as best as I can describe:
+%#
+%# 1. flex.skl is processed through GNU m4 during the
+%# pre-compilation stage of flex. Only macros starting
+%# with `m4preproc_' are processed, and quoting is normal.
+%#
+%# 2. The preprocessed skeleton is translated verbatim into a
+%# C array, saved as "skel.c" and compiled into the flex binary.
+%#
+%# 3. At runtime, the skeleton is generated and filtered (again)
+%# through m4. Macros beginning with `m4_' will be processed.
+%# The quoting is "[[" and "]]" so we don't interfere with
+%# user code.
+%#
+%# All generate macros for the m4 stage contain the text "m4" or "M4"
+%# in them. This is to distinguish them from CPP macros.
+%# The exception to this rule is YY_G, which is an m4 macro,
+%# but it needs to be remain short because it is used everywhere.
+%#
+/* A lexical scanner generated by flex */
+
+%# Macros for preproc stage.
+
+%# Macros for runtime processing stage.
+m4_changecom
+m4_changequote
+m4_changequote([[, ]])
+
+%#
+%# Lines in this skeleton starting with a "%" character are "control lines"
+%# and affect the generation of the scanner. The possible control codes are
+%# listed and processed in misc.c.
+%#
+%# %# - A comment. The current line is omitted from the generated scanner.
+%# %if-c++-only - The following lines are printed for C++ scanners ONLY.
+%# %if-c-only - The following lines are NOT printed for C++ scanners.
+%# %if-c-or-c++ - The following lines are printed in BOTH C and C++ scanners.
+%# %if-reentrant - Print for reentrant scanners.(push)
+%# %if-not-reentrant - Print for non-reentrant scanners. (push)
+%# %if-bison-bridge - Print for bison-bridge. (push)
+%# %if-not-bison-bridge - Print for non-bison-bridge. (push)
+%# %endif - pop from the previous if code.
+%# %% - A stop-point, where code is inserted by flex.
+%# Each stop-point is numbered here and also in the code generator.
+%# (See gen.c, etc. for details.)
+%# %not-for-header - Begin code that should NOT appear in a ".h" file.
+%# %ok-for-header - %c and %e are used for building a header file.
+%# %if-tables-serialization
+%#
+%# All control-lines EXCEPT comment lines ("%#") will be inserted into
+%# the generated scanner as a C-style comment. This is to aid those who
+%# edit the skeleton.
+%#
+
+%not-for-header
+%if-c-only
+%if-not-reentrant
+m4_ifelse(M4_YY_PREFIX,yy,,
+#define yy_create_buffer M4_YY_PREFIX[[_create_buffer]]
+#define yy_delete_buffer M4_YY_PREFIX[[_delete_buffer]]
+#define yy_flex_debug M4_YY_PREFIX[[_flex_debug]]
+#define yy_init_buffer M4_YY_PREFIX[[_init_buffer]]
+#define yy_flush_buffer M4_YY_PREFIX[[_flush_buffer]]
+#define yy_load_buffer_state M4_YY_PREFIX[[_load_buffer_state]]
+#define yy_switch_to_buffer M4_YY_PREFIX[[_switch_to_buffer]]
+#define yyin M4_YY_PREFIX[[in]]
+#define yyleng M4_YY_PREFIX[[leng]]
+#define yylex M4_YY_PREFIX[[lex]]
+#define yylineno M4_YY_PREFIX[[lineno]]
+#define yyout M4_YY_PREFIX[[out]]
+#define yyrestart M4_YY_PREFIX[[restart]]
+#define yytext M4_YY_PREFIX[[text]]
+#define yywrap M4_YY_PREFIX[[wrap]]
+#define yyalloc M4_YY_PREFIX[[alloc]]
+#define yyrealloc M4_YY_PREFIX[[realloc]]
+#define yyfree M4_YY_PREFIX[[free]]
+)
+%endif
+%endif
+%ok-for-header
+
+#define FLEX_SCANNER
+#define YY_FLEX_MAJOR_VERSION FLEX_MAJOR_VERSION
+#define YY_FLEX_MINOR_VERSION FLEX_MINOR_VERSION
+#define YY_FLEX_SUBMINOR_VERSION FLEX_SUBMINOR_VERSION
+#if YY_FLEX_SUBMINOR_VERSION > 0
+#define FLEX_BETA
+#endif
+
+%# Some negated symbols
+m4_ifdef( [[M4_YY_IN_HEADER]], , [[m4_define([[M4_YY_NOT_IN_HEADER]], [[]])]])
+m4_ifdef( [[M4_YY_REENTRANT]], , [[m4_define([[M4_YY_NOT_REENTRANT]], [[]])]])
+
+%# This is the m4 way to say "(stack_used || is_reentrant)
+m4_ifdef( [[M4_YY_STACK_USED]], [[m4_define([[M4_YY_HAS_START_STACK_VARS]])]])
+m4_ifdef( [[M4_YY_REENTRANT]], [[m4_define([[M4_YY_HAS_START_STACK_VARS]])]])
+
+%# Prefixes.
+%# The complexity here is necessary so that m4 preserves
+%# the argument lists to each C function.
+
+
+m4_ifdef( [[M4_YY_PREFIX]],, [[m4_define([[M4_YY_PREFIX]], [[yy]])]])
+
+%if-c++-only
+ /* The c++ scanner is a mess. The FlexLexer.h header file relies on the
+ * following macro. This is required in order to pass the c++-multiple-scanners
+ * test in the regression suite. We get reports that it breaks inheritance.
+ * We will address this in a future release of flex, or omit the C++ scanner
+ * altogether.
+ */
+ #define yyFlexLexer M4_YY_PREFIX[[FlexLexer]]
+%endif
+
+%if-c-only
+ M4_GEN_PREFIX(`_create_buffer')
+ M4_GEN_PREFIX(`_delete_buffer')
+ M4_GEN_PREFIX(`_scan_buffer')
+ M4_GEN_PREFIX(`_scan_string')
+ M4_GEN_PREFIX(`_scan_bytes')
+ M4_GEN_PREFIX(`_init_buffer')
+ M4_GEN_PREFIX(`_flush_buffer')
+ M4_GEN_PREFIX(`_load_buffer_state')
+ M4_GEN_PREFIX(`_switch_to_buffer')
+ M4_GEN_PREFIX(`push_buffer_state')
+ M4_GEN_PREFIX(`pop_buffer_state')
+ M4_GEN_PREFIX(`ensure_buffer_stack')
+ M4_GEN_PREFIX(`lex')
+ M4_GEN_PREFIX(`restart')
+ M4_GEN_PREFIX(`lex_init')
+ M4_GEN_PREFIX(`lex_init_extra')
+ M4_GEN_PREFIX(`lex_destroy')
+ M4_GEN_PREFIX(`get_debug')
+ M4_GEN_PREFIX(`set_debug')
+ M4_GEN_PREFIX(`get_extra')
+ M4_GEN_PREFIX(`set_extra')
+ M4_GEN_PREFIX(`get_in')
+ M4_GEN_PREFIX(`set_in')
+ M4_GEN_PREFIX(`get_out')
+ M4_GEN_PREFIX(`set_out')
+ M4_GEN_PREFIX(`get_leng')
+ M4_GEN_PREFIX(`get_text')
+ M4_GEN_PREFIX(`get_lineno')
+ M4_GEN_PREFIX(`set_lineno')
+ m4_ifdef( [[M4_YY_REENTRANT]],
+ [[
+ M4_GEN_PREFIX(`get_column')
+ M4_GEN_PREFIX(`set_column')
+ ]])
+ M4_GEN_PREFIX(`wrap')
+%endif
+
+m4_ifdef( [[M4_YY_BISON_LVAL]],
+[[
+ M4_GEN_PREFIX(`get_lval')
+ M4_GEN_PREFIX(`set_lval')
+]])
+
+m4_ifdef( [[<M4_YY_BISON_LLOC>]],
+[[
+ M4_GEN_PREFIX(`get_lloc')
+ M4_GEN_PREFIX(`set_lloc')
+]])
+
+%if-c-only
+m4_ifdef( [[M4_YY_NOT_REENTRANT]],
+[[
+ M4_GEN_PREFIX(`text')
+ M4_GEN_PREFIX(`leng')
+ M4_GEN_PREFIX(`in')
+ M4_GEN_PREFIX(`out')
+ M4_GEN_PREFIX(`_flex_debug')
+ M4_GEN_PREFIX(`lineno')
+]])
+%endif
+
+
+m4_ifdef( [[M4_YY_TABLES_EXTERNAL]],
+[[
+ M4_GEN_PREFIX(`tables_fload')
+ M4_GEN_PREFIX(`tables_destroy')
+ M4_GEN_PREFIX(`TABLES_NAME')
+]])
+
+/* First, we deal with platform-specific or compiler-specific issues. */
+
+/* begin standard C headers. */
+%if-c-only
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+#include <stdlib.h>
+%endif
+
+%if-tables-serialization
+#include <sys/types.h>
+#include <netinet/in.h>
+%endif
+/* end standard C headers. */
+
+%if-c-or-c++
+#include <flexint.h>
+%endif
+
+%if-c++-only
+/* begin standard C++ headers. */
+#include <iostream>
+#include <errno.h>
+#include <cstdlib>
+#include <cstring>
+/* end standard C++ headers. */
+%endif
+
+#ifdef __cplusplus
+
+/* The "const" storage-class-modifier is valid. */
+#define YY_USE_CONST
+
+#else /* ! __cplusplus */
+
+/* C99 requires __STDC__ to be defined as 1. */
+#if defined (__STDC__)
+
+#define YY_USE_CONST
+
+#endif /* defined (__STDC__) */
+#endif /* ! __cplusplus */
+
+#ifdef YY_USE_CONST
+#define yyconst const
+#else
+#define yyconst
+#endif
+
+%# For compilers that can not handle prototypes.
+%# e.g.,
+%# The function prototype
+%# int foo(int x, char* y);
+%#
+%# ...should be written as
+%# int foo M4_YY_PARAMS(int x, char* y);
+%#
+%# ...which could possibly generate
+%# int foo ();
+%#
+m4_ifdef( [[M4_YY_NO_ANSI_FUNC_PROTOS]],
+[[
+ m4_define( [[M4_YY_PARAMS]], [[()]])
+]],
+[[
+ m4_define( [[M4_YY_PARAMS]], [[($*)]])
+]])
+
+%not-for-header
+/* Returned upon end-of-file. */
+#define YY_NULL 0
+%ok-for-header
+
+%not-for-header
+/* Promotes a possibly negative, possibly signed char to an unsigned
+ * integer for use as an array index. If the signed char is negative,
+ * we want to instead treat it as an 8-bit unsigned char, hence the
+ * double cast.
+ */
+#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c)
+%ok-for-header
+
+
+
+%if-reentrant
+
+/* An opaque pointer. */
+#ifndef YY_TYPEDEF_YY_SCANNER_T
+#define YY_TYPEDEF_YY_SCANNER_T
+typedef void* yyscan_t;
+#endif
+
+%# Declare yyguts variable
+m4_define( [[M4_YY_DECL_GUTS_VAR]], [[struct yyguts_t * yyg = (struct yyguts_t*)yyscanner]])
+%# For use wherever a Global is accessed or assigned.
+m4_define( [[YY_G]], [[yyg->$1]])
+
+%# For use in function prototypes to append the additional argument.
+m4_define( [[M4_YY_PROTO_LAST_ARG]], [[, yyscan_t yyscanner]])
+m4_define( [[M4_YY_PROTO_ONLY_ARG]], [[yyscan_t yyscanner]])
+
+%# For use in function definitions to append the additional argument.
+m4_ifdef( [[M4_YY_NO_ANSI_FUNC_DEFS]],
+[[
+ m4_define( [[M4_YY_DEF_LAST_ARG]], [[, yyscanner]])
+ m4_define( [[M4_YY_DEF_ONLY_ARG]], [[yyscanner]])
+]],
+[[
+ m4_define( [[M4_YY_DEF_LAST_ARG]], [[, yyscan_t yyscanner]])
+ m4_define( [[M4_YY_DEF_ONLY_ARG]], [[yyscan_t yyscanner]])
+]])
+m4_define( [[M4_YY_DECL_LAST_ARG]], [[yyscan_t yyscanner;]])
+
+%# For use in function calls to pass the additional argument.
+m4_define( [[M4_YY_CALL_LAST_ARG]], [[, yyscanner]])
+m4_define( [[M4_YY_CALL_ONLY_ARG]], [[yyscanner]])
+
+%# For use in function documentation to adjust for additional argument.
+m4_define( [[M4_YY_DOC_PARAM]], [[@param yyscanner The scanner object.]])
+
+/* For convenience, these vars (plus the bison vars far below)
+ are macros in the reentrant scanner. */
+#define yyin YY_G(yyin_r)
+#define yyout YY_G(yyout_r)
+#define yyextra YY_G(yyextra_r)
+#define yyleng YY_G(yyleng_r)
+#define yytext YY_G(yytext_r)
+#define yylineno (YY_CURRENT_BUFFER_LVALUE->yy_bs_lineno)
+#define yycolumn (YY_CURRENT_BUFFER_LVALUE->yy_bs_column)
+#define yy_flex_debug YY_G(yy_flex_debug_r)
+
+m4_define( [[M4_YY_INCR_LINENO]],
+[[
+ do{ yylineno++;
+ yycolumn=0;
+ }while(0)
+]])
+
+%endif
+
+
+
+%if-not-reentrant
+
+m4_define( [[M4_YY_INCR_LINENO]],
+[[
+ yylineno++;
+]])
+
+%# Define these macros to be no-ops.
+m4_define( [[M4_YY_DECL_GUTS_VAR]], [[m4_dnl]])
+m4_define( [[YY_G]], [[($1)]])
+m4_define( [[M4_YY_PROTO_LAST_ARG]])
+m4_define( [[M4_YY_PROTO_ONLY_ARG]], [[void]])
+m4_define( [[M4_YY_DEF_LAST_ARG]])
+
+m4_ifdef( [[M4_YY_NO_ANSI_FUNC_DEFS]],
+[[
+ m4_define( [[M4_YY_DEF_ONLY_ARG]])
+]],
+[[
+ m4_define( [[M4_YY_DEF_ONLY_ARG]], [[void]])
+]])
+m4_define([[M4_YY_DECL_LAST_ARG]])
+m4_define([[M4_YY_CALL_LAST_ARG]])
+m4_define([[M4_YY_CALL_ONLY_ARG]])
+m4_define( [[M4_YY_DOC_PARAM]], [[]])
+
+%endif
+
+
+m4_ifdef( [[M4_YY_NO_ANSI_FUNC_DEFS]],
+[[
+%# For compilers that need traditional function definitions.
+%# e.g.,
+%# The function prototype taking 2 arguments
+%# int foo (int x, char* y)
+%#
+%# ...should be written as
+%# int foo YYFARGS2(int,x, char*,y)
+%#
+%# ...which could possibly generate
+%# int foo (x,y,yyscanner)
+%# int x;
+%# char * y;
+%# yyscan_t yyscanner;
+%#
+%# Generate traditional function defs
+ m4_define( [[YYFARGS0]], [[(M4_YY_DEF_ONLY_ARG) [[\]]
+ M4_YY_DECL_LAST_ARG]])
+ m4_define( [[YYFARGS1]], [[($2 M4_YY_DEF_LAST_ARG) [[\]]
+ $1 $2; [[\]]
+ M4_YY_DECL_LAST_ARG]])
+ m4_define( [[YYFARGS2]], [[($2,$4 M4_YY_DEF_LAST_ARG) [[\]]
+ $1 $2; [[\]]
+ $3 $4; [[\]]
+ M4_YY_DECL_LAST_ARG]])
+ m4_define( [[YYFARGS3]], [[($2,$4,$6 M4_YY_DEF_LAST_ARG) [[\]]
+ $1 $2; [[\]]
+ $3 $4; [[\]]
+ $5 $6; [[\]]
+ M4_YY_DECL_LAST_ARG]])
+]],
+[[
+%# Generate C99 function defs.
+ m4_define( [[YYFARGS0]], [[(M4_YY_DEF_ONLY_ARG)]])
+ m4_define( [[YYFARGS1]], [[($1 $2 M4_YY_DEF_LAST_ARG)]])
+ m4_define( [[YYFARGS2]], [[($1 $2, $3 $4 M4_YY_DEF_LAST_ARG)]])
+ m4_define( [[YYFARGS3]], [[($1 $2, $3 $4, $5 $6 M4_YY_DEF_LAST_ARG)]])
+]])
+
+m4_ifdef( [[M4_YY_NOT_IN_HEADER]],
+[[
+/* Enter a start condition. This macro really ought to take a parameter,
+ * but we do it the disgusting crufty way forced on us by the ()-less
+ * definition of BEGIN.
+ */
+#define BEGIN YY_G(yy_start) = 1 + 2 *
+]])
+
+m4_ifdef( [[M4_YY_NOT_IN_HEADER]],
+[[
+/* Translate the current start state into a value that can be later handed
+ * to BEGIN to return to the state. The YYSTATE alias is for lex
+ * compatibility.
+ */
+#define YY_START ((YY_G(yy_start) - 1) / 2)
+#define YYSTATE YY_START
+]])
+
+m4_ifdef( [[M4_YY_NOT_IN_HEADER]],
+[[
+/* Action number for EOF rule of a given start state. */
+#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
+]])
+
+m4_ifdef( [[M4_YY_NOT_IN_HEADER]],
+[[
+/* Special action meaning "start processing a new file". */
+#define YY_NEW_FILE yyrestart( yyin M4_YY_CALL_LAST_ARG )
+]])
+
+m4_ifdef( [[M4_YY_NOT_IN_HEADER]],
+[[
+#define YY_END_OF_BUFFER_CHAR 0
+]])
+
+/* Size of default input buffer. */
+#ifndef YY_BUF_SIZE
+#define YY_BUF_SIZE 16384
+#endif
+
+m4_ifdef( [[M4_YY_NOT_IN_HEADER]],
+[[
+/* The state buf must be large enough to hold one state per character in the main buffer.
+ */
+#define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type))
+]])
+
+
+#ifndef YY_TYPEDEF_YY_BUFFER_STATE
+#define YY_TYPEDEF_YY_BUFFER_STATE
+typedef struct yy_buffer_state *YY_BUFFER_STATE;
+#endif
+
+%if-not-reentrant
+extern int yyleng;
+%endif
+
+%if-c-only
+%if-not-reentrant
+extern FILE *yyin, *yyout;
+%endif
+%endif
+
+m4_ifdef( [[M4_YY_NOT_IN_HEADER]],
+[[
+#define EOB_ACT_CONTINUE_SCAN 0
+#define EOB_ACT_END_OF_FILE 1
+#define EOB_ACT_LAST_MATCH 2
+]])
+
+m4_ifdef( [[M4_YY_NOT_IN_HEADER]],
+[[
+ m4_ifdef( [[M4_YY_USE_LINENO]],
+ [[
+ /* Note: We specifically omit the test for yy_rule_can_match_eol because it requires
+ * access to the local variable yy_act. Since yyless() is a macro, it would break
+ * existing scanners that call yyless() from OUTSIDE yylex.
+ * One obvious solution it to make yy_act a global. I tried that, and saw
+ * a 5% performance hit in a non-yylineno scanner, because yy_act is
+ * normally declared as a register variable-- so it is not worth it.
+ */
+ #define YY_LESS_LINENO(n) \
+ do { \
+ int yyl;\
+ for ( yyl = n; yyl < yyleng; ++yyl )\
+ if ( yytext[yyl] == '\n' )\
+ --yylineno;\
+ }while(0)
+ ]],
+ [[
+ #define YY_LESS_LINENO(n)
+ ]])
+]])
+
+m4_ifdef( [[M4_YY_NOT_IN_HEADER]],
+[[
+/* Return all but the first "n" matched characters back to the input stream. */
+#define yyless(n) \
+ do \
+ { \
+ /* Undo effects of setting up yytext. */ \
+ int yyless_macro_arg = (n); \
+ YY_LESS_LINENO(yyless_macro_arg);\
+ *yy_cp = YY_G(yy_hold_char); \
+ YY_RESTORE_YY_MORE_OFFSET \
+ YY_G(yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \
+ YY_DO_BEFORE_ACTION; /* set up yytext again */ \
+ } \
+ while ( 0 )
+]])
+
+m4_ifdef( [[M4_YY_NOT_IN_HEADER]],
+[[
+#define unput(c) yyunput( c, YY_G(yytext_ptr) M4_YY_CALL_LAST_ARG )
+]])
+
+#ifndef YY_TYPEDEF_YY_SIZE_T
+#define YY_TYPEDEF_YY_SIZE_T
+typedef size_t yy_size_t;
+#endif
+
+#ifndef YY_STRUCT_YY_BUFFER_STATE
+#define YY_STRUCT_YY_BUFFER_STATE
+struct yy_buffer_state
+ {
+%if-c-only
+ FILE *yy_input_file;
+%endif
+
+%if-c++-only
+ std::istream* yy_input_file;
+%endif
+
+
+ char *yy_ch_buf; /* input buffer */
+ char *yy_buf_pos; /* current position in input buffer */
+
+ /* Size of input buffer in bytes, not including room for EOB
+ * characters.
+ */
+ yy_size_t yy_buf_size;
+
+ /* Number of characters read into yy_ch_buf, not including EOB
+ * characters.
+ */
+ int yy_n_chars;
+
+ /* Whether we "own" the buffer - i.e., we know we created it,
+ * and can realloc() it to grow it, and should free() it to
+ * delete it.
+ */
+ int yy_is_our_buffer;
+
+ /* Whether this is an "interactive" input source; if so, and
+ * if we're using stdio for input, then we want to use getc()
+ * instead of fread(), to make sure we stop fetching input after
+ * each newline.
+ */
+ int yy_is_interactive;
+
+ /* Whether we're considered to be at the beginning of a line.
+ * If so, '^' rules will be active on the next match, otherwise
+ * not.
+ */
+ int yy_at_bol;
+
+ int yy_bs_lineno; /**< The line count. */
+ int yy_bs_column; /**< The column count. */
+
+
+ /* Whether to try to fill the input buffer when we reach the
+ * end of it.
+ */
+ int yy_fill_buffer;
+
+ int yy_buffer_status;
+m4_ifdef( [[M4_YY_NOT_IN_HEADER]],
+[[
+#define YY_BUFFER_NEW 0
+#define YY_BUFFER_NORMAL 1
+ /* When an EOF's been seen but there's still some text to process
+ * then we mark the buffer as YY_EOF_PENDING, to indicate that we
+ * shouldn't try reading from the input source any more. We might
+ * still have a bunch of tokens to match, though, because of
+ * possible backing-up.
+ *
+ * When we actually see the EOF, we change the status to "new"
+ * (via yyrestart()), so that the user can continue scanning by
+ * just pointing yyin at a new input file.
+ */
+#define YY_BUFFER_EOF_PENDING 2
+]])
+ };
+#endif /* !YY_STRUCT_YY_BUFFER_STATE */
+
+%if-c-only Standard (non-C++) definition
+%not-for-header
+%if-not-reentrant
+
+/* Stack of input buffers. */
+static size_t yy_buffer_stack_top = 0; /**< index of top of stack. */
+static size_t yy_buffer_stack_max = 0; /**< capacity of stack. */
+static YY_BUFFER_STATE * yy_buffer_stack = 0; /**< Stack as an array. */
+%endif
+%ok-for-header
+%endif
+
+m4_ifdef( [[M4_YY_NOT_IN_HEADER]],
+[[
+/* We provide macros for accessing buffer states in case in the
+ * future we want to put the buffer states in a more general
+ * "scanner state".
+ *
+ * Returns the top of the stack, or NULL.
+ */
+#define YY_CURRENT_BUFFER ( YY_G(yy_buffer_stack) \
+ ? YY_G(yy_buffer_stack)[YY_G(yy_buffer_stack_top)] \
+ : NULL)
+]])
+
+m4_ifdef( [[M4_YY_NOT_IN_HEADER]],
+[[
+/* Same as previous macro, but useful when we know that the buffer stack is not
+ * NULL or when we need an lvalue. For internal use only.
+ */
+#define YY_CURRENT_BUFFER_LVALUE YY_G(yy_buffer_stack)[YY_G(yy_buffer_stack_top)]
+]])
+
+%if-c-only Standard (non-C++) definition
+
+%if-not-reentrant
+%not-for-header
+/* yy_hold_char holds the character lost when yytext is formed. */
+static char yy_hold_char;
+static int yy_n_chars; /* number of characters read into yy_ch_buf */
+int yyleng;
+
+/* Points to current character in buffer. */
+static char *yy_c_buf_p = (char *) 0;
+static int yy_init = 0; /* whether we need to initialize */
+static int yy_start = 0; /* start state number */
+
+/* Flag which is used to allow yywrap()'s to do buffer switches
+ * instead of setting up a fresh yyin. A bit of a hack ...
+ */
+static int yy_did_buffer_switch_on_eof;
+%ok-for-header
+%endif
+
+void yyrestart M4_YY_PARAMS( FILE *input_file M4_YY_PROTO_LAST_ARG );
+void yy_switch_to_buffer M4_YY_PARAMS( YY_BUFFER_STATE new_buffer M4_YY_PROTO_LAST_ARG );
+YY_BUFFER_STATE yy_create_buffer M4_YY_PARAMS( FILE *file, int size M4_YY_PROTO_LAST_ARG );
+void yy_delete_buffer M4_YY_PARAMS( YY_BUFFER_STATE b M4_YY_PROTO_LAST_ARG );
+void yy_flush_buffer M4_YY_PARAMS( YY_BUFFER_STATE b M4_YY_PROTO_LAST_ARG );
+void yypush_buffer_state M4_YY_PARAMS( YY_BUFFER_STATE new_buffer M4_YY_PROTO_LAST_ARG );
+void yypop_buffer_state M4_YY_PARAMS( M4_YY_PROTO_ONLY_ARG );
+
+m4_ifdef( [[M4_YY_NOT_IN_HEADER]],
+[[
+static void yyensure_buffer_stack M4_YY_PARAMS( M4_YY_PROTO_ONLY_ARG );
+static void yy_load_buffer_state M4_YY_PARAMS( M4_YY_PROTO_ONLY_ARG );
+static void yy_init_buffer M4_YY_PARAMS( YY_BUFFER_STATE b, FILE *file M4_YY_PROTO_LAST_ARG );
+]])
+
+m4_ifdef( [[M4_YY_NOT_IN_HEADER]],
+[[
+#define YY_FLUSH_BUFFER yy_flush_buffer( YY_CURRENT_BUFFER M4_YY_CALL_LAST_ARG)
+]])
+
+YY_BUFFER_STATE yy_scan_buffer M4_YY_PARAMS( char *base, yy_size_t size M4_YY_PROTO_LAST_ARG );
+YY_BUFFER_STATE yy_scan_string M4_YY_PARAMS( yyconst char *yy_str M4_YY_PROTO_LAST_ARG );
+YY_BUFFER_STATE yy_scan_bytes M4_YY_PARAMS( yyconst char *bytes, int len M4_YY_PROTO_LAST_ARG );
+
+%endif
+
+void *yyalloc M4_YY_PARAMS( yy_size_t M4_YY_PROTO_LAST_ARG );
+void *yyrealloc M4_YY_PARAMS( void *, yy_size_t M4_YY_PROTO_LAST_ARG );
+void yyfree M4_YY_PARAMS( void * M4_YY_PROTO_LAST_ARG );
+
+m4_ifdef( [[M4_YY_NOT_IN_HEADER]],
+[[
+#define yy_new_buffer yy_create_buffer
+]])
+
+m4_ifdef( [[M4_YY_NOT_IN_HEADER]],
+[[
+#define yy_set_interactive(is_interactive) \
+ { \
+ if ( ! YY_CURRENT_BUFFER ){ \
+ yyensure_buffer_stack (M4_YY_CALL_ONLY_ARG); \
+ YY_CURRENT_BUFFER_LVALUE = \
+ yy_create_buffer( yyin, YY_BUF_SIZE M4_YY_CALL_LAST_ARG); \
+ } \
+ YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \
+ }
+]])
+
+m4_ifdef( [[M4_YY_NOT_IN_HEADER]],
+[[
+#define yy_set_bol(at_bol) \
+ { \
+ if ( ! YY_CURRENT_BUFFER ){\
+ yyensure_buffer_stack (M4_YY_CALL_ONLY_ARG); \
+ YY_CURRENT_BUFFER_LVALUE = \
+ yy_create_buffer( yyin, YY_BUF_SIZE M4_YY_CALL_LAST_ARG); \
+ } \
+ YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \
+ }
+]])
+
+m4_ifdef( [[M4_YY_NOT_IN_HEADER]],
+[[
+#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol)
+]])
+
+%% [1.0] yytext/yyin/yyout/yy_state_type/yylineno etc. def's & init go here
+
+%if-c-only Standard (non-C++) definition
+
+m4_ifdef( [[M4_YY_NOT_IN_HEADER]],
+[[
+static yy_state_type yy_get_previous_state M4_YY_PARAMS( M4_YY_PROTO_ONLY_ARG );
+static yy_state_type yy_try_NUL_trans M4_YY_PARAMS( yy_state_type current_state M4_YY_PROTO_LAST_ARG);
+static int yy_get_next_buffer M4_YY_PARAMS( M4_YY_PROTO_ONLY_ARG );
+static void yy_fatal_error M4_YY_PARAMS( yyconst char msg[] M4_YY_PROTO_LAST_ARG );
+]])
+
+%endif
+
+m4_ifdef( [[M4_YY_NOT_IN_HEADER]],
+[[
+/* Done after the current pattern has been matched and before the
+ * corresponding action - sets up yytext.
+ */
+#define YY_DO_BEFORE_ACTION \
+ YY_G(yytext_ptr) = yy_bp; \
+%% [2.0] code to fiddle yytext and yyleng for yymore() goes here \
+ YY_G(yy_hold_char) = *yy_cp; \
+ *yy_cp = '\0'; \
+%% [3.0] code to copy yytext_ptr to yytext[] goes here, if %array \
+ YY_G(yy_c_buf_p) = yy_cp;
+]])
+
+m4_ifdef( [[M4_YY_NOT_IN_HEADER]],
+[[
+%% [4.0] data tables for the DFA and the user's section 1 definitions go here
+]])
+
+m4_ifdef( [[M4_YY_IN_HEADER]], [[#ifdef YY_HEADER_EXPORT_START_CONDITIONS]])
+M4_YY_SC_DEFS
+m4_ifdef( [[M4_YY_IN_HEADER]], [[#endif]])
+
+m4_ifdef( [[M4_YY_NO_UNISTD_H]],,
+[[
+#ifndef YY_NO_UNISTD_H
+/* Special case for "unistd.h", since it is non-ANSI. We include it way
+ * down here because we want the user's section 1 to have been scanned first.
+ * The user has a chance to override it with an option.
+ */
+%if-c-only
+#include <unistd.h>
+%endif
+%if-c++-only
+#include <unistd.h>
+%endif
+#endif
+]])
+
+m4_ifdef( [[M4_EXTRA_TYPE_DEFS]],
+[[
+#define YY_EXTRA_TYPE M4_EXTRA_TYPE_DEFS
+]],
+[[
+#ifndef YY_EXTRA_TYPE
+#define YY_EXTRA_TYPE void *
+#endif
+]]
+)
+
+%if-c-only Reentrant structure and macros (non-C++).
+%if-reentrant
+
+m4_ifdef( [[M4_YY_NOT_IN_HEADER]],
+[[
+/* Holds the entire state of the reentrant scanner. */
+struct yyguts_t
+ {
+
+ /* User-defined. Not touched by flex. */
+ YY_EXTRA_TYPE yyextra_r;
+
+ /* The rest are the same as the globals declared in the non-reentrant scanner. */
+ FILE *yyin_r, *yyout_r;
+ size_t yy_buffer_stack_top; /**< index of top of stack. */
+ size_t yy_buffer_stack_max; /**< capacity of stack. */
+ YY_BUFFER_STATE * yy_buffer_stack; /**< Stack as an array. */
+ char yy_hold_char;
+ int yy_n_chars;
+ int yyleng_r;
+ char *yy_c_buf_p;
+ int yy_init;
+ int yy_start;
+ int yy_did_buffer_switch_on_eof;
+ int yy_start_stack_ptr;
+ int yy_start_stack_depth;
+ int *yy_start_stack;
+ yy_state_type yy_last_accepting_state;
+ char* yy_last_accepting_cpos;
+
+ int yylineno_r;
+ int yy_flex_debug_r;
+
+m4_ifdef( [[M4_YY_USES_REJECT]],
+[[
+ yy_state_type *yy_state_buf;
+ yy_state_type *yy_state_ptr;
+ char *yy_full_match;
+ int yy_lp;
+
+ /* These are only needed for trailing context rules,
+ * but there's no conditional variable for that yet. */
+ int yy_looking_for_trail_begin;
+ int yy_full_lp;
+ int *yy_full_state;
+]])
+
+m4_ifdef( [[M4_YY_TEXT_IS_ARRAY]],
+[[
+ char yytext_r[YYLMAX];
+ char *yytext_ptr;
+ int yy_more_offset;
+ int yy_prev_more_offset;
+]],
+[[
+ char *yytext_r;
+ int yy_more_flag;
+ int yy_more_len;
+]])
+
+m4_ifdef( [[M4_YY_BISON_LVAL]],
+[[
+ YYSTYPE * yylval_r;
+]])
+
+m4_ifdef( [[<M4_YY_BISON_LLOC>]],
+[[
+ YYLTYPE * yylloc_r;
+]])
+
+ }; /* end struct yyguts_t */
+]])
+
+
+%if-c-only
+m4_ifdef( [[M4_YY_NOT_IN_HEADER]],
+[[
+static int yy_init_globals M4_YY_PARAMS( M4_YY_PROTO_ONLY_ARG );
+]])
+%endif
+
+%if-reentrant
+
+m4_ifdef( [[M4_YY_NOT_IN_HEADER]],
+[[
+ m4_ifdef( [[M4_YY_BISON_LVAL]],
+ [[
+ /* This must go here because YYSTYPE and YYLTYPE are included
+ * from bison output in section 1.*/
+ # define yylval YY_G(yylval_r)
+ ]])
+
+ m4_ifdef( [[<M4_YY_BISON_LLOC>]],
+ [[
+ # define yylloc YY_G(yylloc_r)
+ ]])
+]])
+
+int yylex_init M4_YY_PARAMS(yyscan_t* scanner);
+
+int yylex_init_extra M4_YY_PARAMS( YY_EXTRA_TYPE user_defined, yyscan_t* scanner);
+
+%endif
+
+%endif End reentrant structures and macros.
+
+/* Accessor methods to globals.
+ These are made visible to non-reentrant scanners for convenience. */
+
+m4_ifdef( [[M4_YY_NO_DESTROY]],,
+[[
+int yylex_destroy M4_YY_PARAMS( M4_YY_PROTO_ONLY_ARG );
+]])
+
+m4_ifdef( [[M4_YY_NO_GET_DEBUG]],,
+[[
+int yyget_debug M4_YY_PARAMS( M4_YY_PROTO_ONLY_ARG );
+]])
+
+m4_ifdef( [[M4_YY_NO_SET_DEBUG]],,
+[[
+void yyset_debug M4_YY_PARAMS( int debug_flag M4_YY_PROTO_LAST_ARG );
+]])
+
+m4_ifdef( [[M4_YY_NO_GET_EXTRA]],,
+[[
+YY_EXTRA_TYPE yyget_extra M4_YY_PARAMS( M4_YY_PROTO_ONLY_ARG );
+]])
+
+m4_ifdef( [[M4_YY_NO_SET_EXTRA]],,
+[[
+void yyset_extra M4_YY_PARAMS( YY_EXTRA_TYPE user_defined M4_YY_PROTO_LAST_ARG );
+]])
+
+m4_ifdef( [[M4_YY_NO_GET_IN]],,
+[[
+FILE *yyget_in M4_YY_PARAMS( M4_YY_PROTO_ONLY_ARG );
+]])
+
+m4_ifdef( [[M4_YY_NO_SET_IN]],,
+[[
+void yyset_in M4_YY_PARAMS( FILE * in_str M4_YY_PROTO_LAST_ARG );
+]])
+
+m4_ifdef( [[M4_YY_NO_GET_OUT]],,
+[[
+FILE *yyget_out M4_YY_PARAMS( M4_YY_PROTO_ONLY_ARG );
+]])
+
+m4_ifdef( [[M4_YY_NO_SET_OUT]],,
+[[
+void yyset_out M4_YY_PARAMS( FILE * out_str M4_YY_PROTO_LAST_ARG );
+]])
+
+m4_ifdef( [[M4_YY_NO_GET_LENG]],,
+[[
+int yyget_leng M4_YY_PARAMS( M4_YY_PROTO_ONLY_ARG );
+]])
+
+m4_ifdef( [[M4_YY_NO_GET_TEXT]],,
+[[
+char *yyget_text M4_YY_PARAMS( M4_YY_PROTO_ONLY_ARG );
+]])
+
+m4_ifdef( [[M4_YY_NO_GET_LINENO]],,
+[[
+int yyget_lineno M4_YY_PARAMS( M4_YY_PROTO_ONLY_ARG );
+]])
+
+m4_ifdef( [[M4_YY_NO_SET_LINENO]],,
+[[
+void yyset_lineno M4_YY_PARAMS( int line_number M4_YY_PROTO_LAST_ARG );
+]])
+
+%if-bison-bridge
+m4_ifdef( [[M4_YY_NO_GET_LVAL]],,
+[[
+YYSTYPE * yyget_lval M4_YY_PARAMS( M4_YY_PROTO_ONLY_ARG );
+]])
+
+void yyset_lval M4_YY_PARAMS( YYSTYPE * yylval_param M4_YY_PROTO_LAST_ARG );
+
+m4_ifdef( [[<M4_YY_BISON_LLOC>]],
+[[
+ m4_ifdef( [[M4_YY_NO_GET_LLOC]],,
+ [[
+ YYLTYPE *yyget_lloc M4_YY_PARAMS( M4_YY_PROTO_ONLY_ARG );
+ ]])
+
+ m4_ifdef( [[M4_YY_NO_SET_LLOC]],,
+ [[
+ void yyset_lloc M4_YY_PARAMS( YYLTYPE * yylloc_param M4_YY_PROTO_LAST_ARG );
+ ]])
+]])
+%endif
+
+/* Macros after this point can all be overridden by user definitions in
+ * section 1.
+ */
+
+#ifndef YY_SKIP_YYWRAP
+#ifdef __cplusplus
+extern "C" int yywrap M4_YY_PARAMS( M4_YY_PROTO_ONLY_ARG );
+#else
+extern int yywrap M4_YY_PARAMS( M4_YY_PROTO_ONLY_ARG );
+#endif
+#endif
+
+%not-for-header
+ m4_ifdef( [[M4_YY_NO_UNPUT]],,
+ [[
+ static void yyunput M4_YY_PARAMS( int c, char *buf_ptr M4_YY_PROTO_LAST_ARG);
+ ]])
+%ok-for-header
+%endif
+
+#ifndef yytext_ptr
+static void yy_flex_strncpy M4_YY_PARAMS( char *, yyconst char *, int M4_YY_PROTO_LAST_ARG);
+#endif
+
+#ifdef YY_NEED_STRLEN
+static int yy_flex_strlen M4_YY_PARAMS( yyconst char * M4_YY_PROTO_LAST_ARG);
+#endif
+
+#ifndef YY_NO_INPUT
+%if-c-only Standard (non-C++) definition
+%not-for-header
+#ifdef __cplusplus
+static int yyinput M4_YY_PARAMS( M4_YY_PROTO_ONLY_ARG );
+#else
+static int input M4_YY_PARAMS( M4_YY_PROTO_ONLY_ARG );
+#endif
+%ok-for-header
+%endif
+#endif
+
+
+%if-c-only
+%# TODO: This is messy.
+m4_ifdef( [[M4_YY_STACK_USED]],
+[[
+
+m4_ifdef( [[M4_YY_NOT_REENTRANT]],
+[[
+ m4_ifdef( [[M4_YY_NOT_IN_HEADER]],
+ [[
+ static int yy_start_stack_ptr = 0;
+ static int yy_start_stack_depth = 0;
+ static int *yy_start_stack = NULL;
+ ]])
+]])
+
+m4_ifdef( [[M4_YY_NOT_IN_HEADER]],
+[[
+ m4_ifdef( [[M4_YY_NO_PUSH_STATE]],,
+ [[
+ static void yy_push_state M4_YY_PARAMS( int new_state M4_YY_PROTO_LAST_ARG);
+ ]])
+ m4_ifdef( [[M4_YY_NO_POP_STATE]],,
+ [[
+ static void yy_pop_state M4_YY_PARAMS( M4_YY_PROTO_ONLY_ARG );
+ ]])
+ m4_ifdef( [[M4_YY_NO_TOP_STATE]],,
+ [[
+ static int yy_top_state M4_YY_PARAMS( M4_YY_PROTO_ONLY_ARG );
+ ]])
+]])
+
+]],
+[[
+m4_define( [[M4_YY_NO_PUSH_STATE]])
+m4_define( [[M4_YY_NO_POP_STATE]])
+m4_define( [[M4_YY_NO_TOP_STATE]])
+]])
+%endif
+
+/* Amount of stuff to slurp up with each read. */
+#ifndef YY_READ_BUF_SIZE
+#define YY_READ_BUF_SIZE 8192
+#endif
+
+m4_ifdef( [[M4_YY_NOT_IN_HEADER]],
+[[
+/* Copy whatever the last rule matched to the standard output. */
+#ifndef ECHO
+%if-c-only Standard (non-C++) definition
+/* This used to be an fputs(), but since the string might contain NUL's,
+ * we now use fwrite().
+ */
+#define ECHO fwrite( yytext, yyleng, 1, yyout )
+%endif
+%if-c++-only C++ definition
+#define ECHO LexerOutput( yytext, yyleng )
+%endif
+#endif
+]])
+
+m4_ifdef( [[M4_YY_NOT_IN_HEADER]],
+[[
+/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
+ * is returned in "result".
+ */
+#ifndef YY_INPUT
+#define YY_INPUT(buf,result,max_size) \
+%% [5.0] fread()/read() definition of YY_INPUT goes here unless we're doing C++ \
+\
+%if-c++-only C++ definition \
+ if ( (result = LexerInput( (char *) buf, max_size )) < 0 ) \
+ YY_FATAL_ERROR( "input in flex scanner failed" );
+%endif
+
+#endif
+]])
+
+m4_ifdef( [[M4_YY_NOT_IN_HEADER]],
+[[
+/* No semi-colon after return; correct usage is to write "yyterminate();" -
+ * we don't want an extra ';' after the "return" because that will cause
+ * some compilers to complain about unreachable statements.
+ */
+#ifndef yyterminate
+#define yyterminate() return YY_NULL
+#endif
+]])
+
+/* Number of entries by which start-condition stack grows. */
+#ifndef YY_START_STACK_INCR
+#define YY_START_STACK_INCR 25
+#endif
+
+m4_ifdef( [[M4_YY_NOT_IN_HEADER]],
+[[
+/* Report a fatal error. */
+#ifndef YY_FATAL_ERROR
+%if-c-only
+#define YY_FATAL_ERROR(msg) yy_fatal_error( msg M4_YY_CALL_LAST_ARG)
+%endif
+%if-c++-only
+#define YY_FATAL_ERROR(msg) LexerError( msg )
+%endif
+#endif
+]])
+
+%if-tables-serialization structures and prototypes
+m4preproc_include(`tables_shared.h')
+
+/* Load the DFA tables from the given stream. */
+int yytables_fload M4_YY_PARAMS(FILE * fp M4_YY_PROTO_LAST_ARG);
+
+/* Unload the tables from memory. */
+int yytables_destroy M4_YY_PARAMS(M4_YY_PROTO_ONLY_ARG);
+%not-for-header
+
+/** Describes a mapping from a serialized table id to its deserialized state in
+ * this scanner. This is the bridge between our "generic" deserialization code
+ * and the specifics of this scanner.
+ */
+struct yytbl_dmap {
+ enum yytbl_id dm_id;/**< table identifier */
+ void **dm_arr; /**< address of pointer to store the deserialized table. */
+ size_t dm_sz; /**< local sizeof() each element in table. */
+};
+
+/** A {0,0,0}-terminated list of structs, forming the map */
+static struct yytbl_dmap yydmap[] =
+{
+%tables-yydmap generated elements
+ {0,0,0}
+};
+
+/** A tables-reader object to maintain some state in the read. */
+struct yytbl_reader {
+ FILE * fp; /**< input stream */
+ flex_uint32_t bread; /**< bytes read since beginning of current tableset */
+};
+
+%endif
+/* end tables serialization structures and prototypes */
+
+%ok-for-header
+
+/* Default declaration of generated scanner - a define so the user can
+ * easily add parameters.
+ */
+#ifndef YY_DECL
+#define YY_DECL_IS_OURS 1
+%if-c-only Standard (non-C++) definition
+
+
+m4_define( [[M4_YY_LEX_PROTO]], [[M4_YY_PARAMS(M4_YY_PROTO_ONLY_ARG)]])
+m4_define( [[M4_YY_LEX_DECLARATION]], [[YYFARGS0(void)]])
+
+m4_ifdef( [[M4_YY_BISON_LVAL]],
+[[
+ m4_dnl The bison pure parser is used. Redefine yylex to
+ m4_dnl accept the lval parameter.
+
+ m4_define( [[M4_YY_LEX_PROTO]], [[\]]
+ [[M4_YY_PARAMS(YYSTYPE * yylval_param M4_YY_PROTO_LAST_ARG)]])
+ m4_define( [[M4_YY_LEX_DECLARATION]], [[\]]
+ [[YYFARGS1(YYSTYPE *,yylval_param)]])
+]])
+
+m4_ifdef( [[<M4_YY_BISON_LLOC>]],
+[[
+ m4_dnl Locations are used. yylex should also accept the ylloc parameter.
+
+ m4_define( [[M4_YY_LEX_PROTO]], [[\]]
+ [[M4_YY_PARAMS(YYSTYPE * yylval_param, YYLTYPE * yylloc_param M4_YY_PROTO_LAST_ARG)]])
+ m4_define( [[M4_YY_LEX_DECLARATION]], [[\]]
+ [[YYFARGS2(YYSTYPE *,yylval_param, YYLTYPE *,yylloc_param)]])
+]])
+
+extern int yylex M4_YY_LEX_PROTO;
+
+#define YY_DECL int yylex M4_YY_LEX_DECLARATION
+%endif
+%if-c++-only C++ definition
+#define YY_DECL int yyFlexLexer::yylex()
+%endif
+#endif /* !YY_DECL */
+
+m4_ifdef( [[M4_YY_NOT_IN_HEADER]],
+[[
+/* Code executed at the beginning of each rule, after yytext and yyleng
+ * have been set up.
+ */
+#ifndef YY_USER_ACTION
+#define YY_USER_ACTION
+#endif
+]])
+
+m4_ifdef( [[M4_YY_NOT_IN_HEADER]],
+[[
+/* Code executed at the end of each rule. */
+#ifndef YY_BREAK
+#define YY_BREAK break;
+#endif
+]])
+
+m4_ifdef( [[M4_YY_NOT_IN_HEADER]],
+[[
+%% [6.0] YY_RULE_SETUP definition goes here
+]])
+
+%not-for-header
+/** The main scanner function which does all the work.
+ */
+YY_DECL
+{
+ register yy_state_type yy_current_state;
+ register char *yy_cp, *yy_bp;
+ register int yy_act;
+ M4_YY_DECL_GUTS_VAR();
+
+m4_ifdef( [[M4_YY_NOT_REENTRANT]],
+[[
+ m4_ifdef( [[M4_YY_BISON_LVAL]],
+ [[
+ YYSTYPE * yylval;
+ ]])
+ m4_ifdef( [[<M4_YY_BISON_LLOC>]],
+ [[
+ YYLTYPE * yylloc;
+ ]])
+]])
+
+%% [7.0] user's declarations go here
+
+m4_ifdef( [[M4_YY_BISON_LVAL]],
+[[
+ yylval = yylval_param;
+]])
+
+m4_ifdef( [[<M4_YY_BISON_LLOC>]],
+[[
+ yylloc = yylloc_param;
+]])
+
+ if ( !YY_G(yy_init) )
+ {
+ YY_G(yy_init) = 1;
+
+#ifdef YY_USER_INIT
+ YY_USER_INIT;
+#endif
+
+m4_ifdef( [[M4_YY_USES_REJECT]],
+[[
+ /* Create the reject buffer large enough to save one state per allowed character. */
+ if ( ! YY_G(yy_state_buf) )
+ YY_G(yy_state_buf) = (yy_state_type *)yyalloc(YY_STATE_BUF_SIZE M4_YY_CALL_LAST_ARG);
+ if ( ! YY_G(yy_state_buf) )
+ YY_FATAL_ERROR( "out of dynamic memory in yylex()" );
+]])
+
+ if ( ! YY_G(yy_start) )
+ YY_G(yy_start) = 1; /* first start state */
+
+ if ( ! yyin )
+%if-c-only
+ yyin = stdin;
+%endif
+%if-c++-only
+ yyin = & std::cin;
+%endif
+
+ if ( ! yyout )
+%if-c-only
+ yyout = stdout;
+%endif
+%if-c++-only
+ yyout = & std::cout;
+%endif
+
+ if ( ! YY_CURRENT_BUFFER ) {
+ yyensure_buffer_stack (M4_YY_CALL_ONLY_ARG);
+ YY_CURRENT_BUFFER_LVALUE =
+ yy_create_buffer( yyin, YY_BUF_SIZE M4_YY_CALL_LAST_ARG);
+ }
+
+ yy_load_buffer_state( M4_YY_CALL_ONLY_ARG );
+ }
+
+ while ( 1 ) /* loops until end-of-file is reached */
+ {
+%% [8.0] yymore()-related code goes here
+ yy_cp = YY_G(yy_c_buf_p);
+
+ /* Support of yytext. */
+ *yy_cp = YY_G(yy_hold_char);
+
+ /* yy_bp points to the position in yy_ch_buf of the start of
+ * the current run.
+ */
+ yy_bp = yy_cp;
+
+%% [9.0] code to set up and find next match goes here
+
+yy_find_action:
+%% [10.0] code to find the action number goes here
+
+ YY_DO_BEFORE_ACTION;
+
+%% [11.0] code for yylineno update goes here
+
+do_action: /* This label is used only to access EOF actions. */
+
+%% [12.0] debug code goes here
+
+ switch ( yy_act )
+ { /* beginning of action switch */
+%% [13.0] actions go here
+
+ case YY_END_OF_BUFFER:
+ {
+ /* Amount of text matched not including the EOB char. */
+ int yy_amount_of_matched_text = (int) (yy_cp - YY_G(yytext_ptr)) - 1;
+
+ /* Undo the effects of YY_DO_BEFORE_ACTION. */
+ *yy_cp = YY_G(yy_hold_char);
+ YY_RESTORE_YY_MORE_OFFSET
+
+ if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW )
+ {
+ /* We're scanning a new file or input source. It's
+ * possible that this happened because the user
+ * just pointed yyin at a new source and called
+ * yylex(). If so, then we have to assure
+ * consistency between YY_CURRENT_BUFFER and our
+ * globals. Here is the right place to do so, because
+ * this is the first action (other than possibly a
+ * back-up) that will match for the new input source.
+ */
+ YY_G(yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
+ YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin;
+ YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL;
+ }
+
+ /* Note that here we test for yy_c_buf_p "<=" to the position
+ * of the first EOB in the buffer, since yy_c_buf_p will
+ * already have been incremented past the NUL character
+ * (since all states make transitions on EOB to the
+ * end-of-buffer state). Contrast this with the test
+ * in input().
+ */
+ if ( YY_G(yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[YY_G(yy_n_chars)] )
+ { /* This was really a NUL. */
+ yy_state_type yy_next_state;
+
+ YY_G(yy_c_buf_p) = YY_G(yytext_ptr) + yy_amount_of_matched_text;
+
+ yy_current_state = yy_get_previous_state( M4_YY_CALL_ONLY_ARG );
+
+ /* Okay, we're now positioned to make the NUL
+ * transition. We couldn't have
+ * yy_get_previous_state() go ahead and do it
+ * for us because it doesn't know how to deal
+ * with the possibility of jamming (and we don't
+ * want to build jamming into it because then it
+ * will run more slowly).
+ */
+
+ yy_next_state = yy_try_NUL_trans( yy_current_state M4_YY_CALL_LAST_ARG);
+
+ yy_bp = YY_G(yytext_ptr) + YY_MORE_ADJ;
+
+ if ( yy_next_state )
+ {
+ /* Consume the NUL. */
+ yy_cp = ++YY_G(yy_c_buf_p);
+ yy_current_state = yy_next_state;
+ goto yy_match;
+ }
+
+ else
+ {
+%% [14.0] code to do back-up for compressed tables and set up yy_cp goes here
+ goto yy_find_action;
+ }
+ }
+
+ else switch ( yy_get_next_buffer( M4_YY_CALL_ONLY_ARG ) )
+ {
+ case EOB_ACT_END_OF_FILE:
+ {
+ YY_G(yy_did_buffer_switch_on_eof) = 0;
+
+ if ( yywrap( M4_YY_CALL_ONLY_ARG ) )
+ {
+ /* Note: because we've taken care in
+ * yy_get_next_buffer() to have set up
+ * yytext, we can now set up
+ * yy_c_buf_p so that if some total
+ * hoser (like flex itself) wants to
+ * call the scanner after we return the
+ * YY_NULL, it'll still work - another
+ * YY_NULL will get returned.
+ */
+ YY_G(yy_c_buf_p) = YY_G(yytext_ptr) + YY_MORE_ADJ;
+
+ yy_act = YY_STATE_EOF(YY_START);
+ goto do_action;
+ }
+
+ else
+ {
+ if ( ! YY_G(yy_did_buffer_switch_on_eof) )
+ YY_NEW_FILE;
+ }
+ break;
+ }
+
+ case EOB_ACT_CONTINUE_SCAN:
+ YY_G(yy_c_buf_p) =
+ YY_G(yytext_ptr) + yy_amount_of_matched_text;
+
+ yy_current_state = yy_get_previous_state( M4_YY_CALL_ONLY_ARG );
+
+ yy_cp = YY_G(yy_c_buf_p);
+ yy_bp = YY_G(yytext_ptr) + YY_MORE_ADJ;
+ goto yy_match;
+
+ case EOB_ACT_LAST_MATCH:
+ YY_G(yy_c_buf_p) =
+ &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[YY_G(yy_n_chars)];
+
+ yy_current_state = yy_get_previous_state( M4_YY_CALL_ONLY_ARG );
+
+ yy_cp = YY_G(yy_c_buf_p);
+ yy_bp = YY_G(yytext_ptr) + YY_MORE_ADJ;
+ goto yy_find_action;
+ }
+ break;
+ }
+
+ default:
+ YY_FATAL_ERROR(
+ "fatal flex scanner internal error--no action found" );
+ } /* end of action switch */
+ } /* end of scanning one token */
+} /* end of yylex */
+%ok-for-header
+
+%if-c++-only
+%not-for-header
+/* The contents of this function are C++ specific, so the YY_G macro is not used.
+ */
+yyFlexLexer::yyFlexLexer( std::istream* arg_yyin, std::ostream* arg_yyout )
+{
+ yyin = arg_yyin;
+ yyout = arg_yyout;
+ yy_c_buf_p = 0;
+ yy_init = 0;
+ yy_start = 0;
+ yy_flex_debug = 0;
+ yylineno = 1; // this will only get updated if %option yylineno
+
+ yy_did_buffer_switch_on_eof = 0;
+
+ yy_looking_for_trail_begin = 0;
+ yy_more_flag = 0;
+ yy_more_len = 0;
+ yy_more_offset = yy_prev_more_offset = 0;
+
+ yy_start_stack_ptr = yy_start_stack_depth = 0;
+ yy_start_stack = NULL;
+
+ yy_buffer_stack = 0;
+ yy_buffer_stack_top = 0;
+ yy_buffer_stack_max = 0;
+
+
+m4_ifdef( [[M4_YY_USES_REJECT]],
+[[
+ yy_state_buf = new yy_state_type[YY_STATE_BUF_SIZE];
+]],
+[[
+ yy_state_buf = 0;
+]])
+}
+
+/* The contents of this function are C++ specific, so the YY_G macro is not used.
+ */
+yyFlexLexer::~yyFlexLexer()
+{
+ mystack::iterator It=m_IncludeStack.begin();
+ while (It!=m_IncludeStack.end())
+ {
+ yy_delete_buffer((*It)->m_BufferState); /* When the stack is deleted, the lexer is not run anymore, so we have to clean up the buffers ourself */
+ It++;
+ }
+ delete [] yy_state_buf;
+ yyfree( yy_start_stack M4_YY_CALL_LAST_ARG );
+ yy_delete_buffer( YY_CURRENT_BUFFER M4_YY_CALL_LAST_ARG);
+ yyfree( yy_buffer_stack M4_YY_CALL_LAST_ARG );
+}
+
+/* The contents of this function are C++ specific, so the YY_G macro is not used.
+ */
+void yyFlexLexer::switch_streams( std::istream* new_in, std::ostream* new_out )
+{
+ if ( new_in )
+ {
+ yy_delete_buffer( YY_CURRENT_BUFFER M4_YY_CALL_LAST_ARG);
+ yy_switch_to_buffer( yy_create_buffer( new_in, YY_BUF_SIZE M4_YY_CALL_LAST_ARG) M4_YY_CALL_LAST_ARG);
+ }
+
+ if ( new_out )
+ yyout = new_out;
+}
+
+#ifdef YY_INTERACTIVE
+int yyFlexLexer::LexerInput( char* buf, int /* max_size */ )
+#else
+int yyFlexLexer::LexerInput( char* buf, int max_size )
+#endif
+{
+ if ( yyin->eof() || yyin->fail() )
+ return 0;
+
+#ifdef YY_INTERACTIVE
+ yyin->get( buf[0] );
+
+ if ( yyin->eof() )
+ return 0;
+
+ if ( yyin->bad() )
+ return -1;
+
+ return 1;
+
+#else
+ (void) yyin->read( buf, max_size );
+
+ if ( yyin->bad() )
+ return -1;
+ else
+ return (int)yyin->gcount();
+#endif
+}
+
+void yyFlexLexer::LexerOutput( const char* buf, int size )
+{
+ (void) yyout->write( buf, size );
+}
+%ok-for-header
+%endif
+
+m4_ifdef( [[M4_YY_NOT_IN_HEADER]],
+[[
+/* yy_get_next_buffer - try to read in a new buffer
+ *
+ * Returns a code representing an action:
+ * EOB_ACT_LAST_MATCH -
+ * EOB_ACT_CONTINUE_SCAN - continue scanning from current position
+ * EOB_ACT_END_OF_FILE - end of file
+ */
+%if-c-only
+static int yy_get_next_buffer YYFARGS0(void)
+%endif
+%if-c++-only
+int yyFlexLexer::yy_get_next_buffer()
+%endif
+{
+ M4_YY_DECL_GUTS_VAR();
+ register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf;
+ register char *source = YY_G(yytext_ptr);
+ register int number_to_move, i;
+ int ret_val;
+
+ if ( YY_G(yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[YY_G(yy_n_chars) + 1] )
+ YY_FATAL_ERROR(
+ "fatal flex scanner internal error--end of buffer missed" );
+
+ if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 )
+ { /* Don't try to fill the buffer, so this is an EOF. */
+ if ( YY_G(yy_c_buf_p) - YY_G(yytext_ptr) - YY_MORE_ADJ == 1 )
+ {
+ /* We matched a single character, the EOB, so
+ * treat this as a final EOF.
+ */
+ return EOB_ACT_END_OF_FILE;
+ }
+
+ else
+ {
+ /* We matched some text prior to the EOB, first
+ * process it.
+ */
+ return EOB_ACT_LAST_MATCH;
+ }
+ }
+
+ /* Try to read more data. */
+
+ /* First move last chars to start of buffer. */
+ number_to_move = (int) (YY_G(yy_c_buf_p) - YY_G(yytext_ptr)) - 1;
+
+ for ( i = 0; i < number_to_move; ++i )
+ *(dest++) = *(source++);
+
+ if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING )
+ /* don't do the read, it's not guaranteed to return an EOF,
+ * just force an EOF
+ */
+ YY_CURRENT_BUFFER_LVALUE->yy_n_chars = YY_G(yy_n_chars) = 0;
+
+ else
+ {
+ int num_to_read =
+ YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;
+
+ while ( num_to_read <= 0 )
+ { /* Not enough room in the buffer - grow it. */
+m4_ifdef( [[M4_YY_USES_REJECT]],
+[[
+ YY_FATAL_ERROR(
+"input buffer overflow, can't enlarge buffer because scanner uses REJECT" );
+]],
+[[
+ /* just a shorter name for the current buffer */
+ YY_BUFFER_STATE b = YY_CURRENT_BUFFER;
+
+ int yy_c_buf_p_offset =
+ (int) (YY_G(yy_c_buf_p) - b->yy_ch_buf);
+
+ if ( b->yy_is_our_buffer )
+ {
+ int new_size = b->yy_buf_size * 2;
+
+ if ( new_size <= 0 )
+ b->yy_buf_size += b->yy_buf_size / 8;
+ else
+ b->yy_buf_size *= 2;
+
+ b->yy_ch_buf = (char *)
+ /* Include room in for 2 EOB chars. */
+ yyrealloc( (void *) b->yy_ch_buf,
+ b->yy_buf_size + 2 M4_YY_CALL_LAST_ARG );
+ }
+ else
+ /* Can't grow it, we don't own it. */
+ b->yy_ch_buf = 0;
+
+ if ( ! b->yy_ch_buf )
+ YY_FATAL_ERROR(
+ "fatal error - scanner input buffer overflow" );
+
+ YY_G(yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset];
+
+ num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size -
+ number_to_move - 1;
+]])
+ }
+
+ if ( num_to_read > YY_READ_BUF_SIZE )
+ num_to_read = YY_READ_BUF_SIZE;
+
+ /* Read in more data. */
+ YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]),
+ YY_G(yy_n_chars), (size_t) num_to_read );
+
+ YY_CURRENT_BUFFER_LVALUE->yy_n_chars = YY_G(yy_n_chars);
+ }
+
+ if ( YY_G(yy_n_chars) == 0 )
+ {
+ if ( number_to_move == YY_MORE_ADJ )
+ {
+ ret_val = EOB_ACT_END_OF_FILE;
+ yyrestart( yyin M4_YY_CALL_LAST_ARG);
+ }
+
+ else
+ {
+ ret_val = EOB_ACT_LAST_MATCH;
+ YY_CURRENT_BUFFER_LVALUE->yy_buffer_status =
+ YY_BUFFER_EOF_PENDING;
+ }
+ }
+
+ else
+ ret_val = EOB_ACT_CONTINUE_SCAN;
+
+ if ((yy_size_t) (YY_G(yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) {
+ /* Extend the array by 50%, plus the number we really need. */
+ yy_size_t new_size = YY_G(yy_n_chars) + number_to_move + (YY_G(yy_n_chars) >> 1);
+ YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc(
+ (void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf, new_size M4_YY_CALL_LAST_ARG );
+ if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
+ YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" );
+ }
+
+ YY_G(yy_n_chars) += number_to_move;
+ YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[YY_G(yy_n_chars)] = YY_END_OF_BUFFER_CHAR;
+ YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[YY_G(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR;
+
+ YY_G(yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0];
+
+ return ret_val;
+}
+]])
+
+/* yy_get_previous_state - get the state just before the EOB char was reached */
+
+%if-c-only
+%not-for-header
+ static yy_state_type yy_get_previous_state YYFARGS0(void)
+%endif
+%if-c++-only
+ yy_state_type yyFlexLexer::yy_get_previous_state()
+%endif
+{
+ register yy_state_type yy_current_state;
+ register char *yy_cp;
+ M4_YY_DECL_GUTS_VAR();
+
+%% [15.0] code to get the start state into yy_current_state goes here
+
+ for ( yy_cp = YY_G(yytext_ptr) + YY_MORE_ADJ; yy_cp < YY_G(yy_c_buf_p); ++yy_cp )
+ {
+%% [16.0] code to find the next state goes here
+ }
+
+ return yy_current_state;
+}
+
+
+/* yy_try_NUL_trans - try to make a transition on the NUL character
+ *
+ * synopsis
+ * next_state = yy_try_NUL_trans( current_state );
+ */
+%if-c-only
+ static yy_state_type yy_try_NUL_trans YYFARGS1( yy_state_type, yy_current_state)
+%endif
+%if-c++-only
+ yy_state_type yyFlexLexer::yy_try_NUL_trans( yy_state_type yy_current_state )
+%endif
+{
+ register int yy_is_jam;
+ M4_YY_DECL_GUTS_VAR(); /* This var may be unused depending upon options. */
+%% [17.0] code to find the next state, and perhaps do backing up, goes here
+
+ return yy_is_jam ? 0 : yy_current_state;
+}
+
+
+%if-c-only
+m4_ifdef( [[M4_YY_NO_UNPUT]],,
+[[
+ static void yyunput YYFARGS2( int,c, register char *,yy_bp)
+%endif
+%if-c++-only
+ void yyFlexLexer::yyunput( int c, register char* yy_bp)
+%endif
+{
+ register char *yy_cp;
+ M4_YY_DECL_GUTS_VAR();
+
+ yy_cp = YY_G(yy_c_buf_p);
+
+ /* undo effects of setting up yytext */
+ *yy_cp = YY_G(yy_hold_char);
+
+ if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 )
+ { /* need to shift things up to make room */
+ /* +2 for EOB chars. */
+ register int number_to_move = YY_G(yy_n_chars) + 2;
+ register char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[
+ YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2];
+ register char *source =
+ &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move];
+
+ while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
+ *--dest = *--source;
+
+ yy_cp += (int) (dest - source);
+ yy_bp += (int) (dest - source);
+ YY_CURRENT_BUFFER_LVALUE->yy_n_chars =
+ YY_G(yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_buf_size;
+
+ if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 )
+ YY_FATAL_ERROR( "flex scanner push-back overflow" );
+ }
+
+ *--yy_cp = (char) c;
+
+%% [18.0] update yylineno here
+m4_ifdef( [[M4_YY_USE_LINENO]],
+[[
+ if ( c == '\n' ){
+ --yylineno;
+ }
+]])
+
+ YY_G(yytext_ptr) = yy_bp;
+ YY_G(yy_hold_char) = *yy_cp;
+ YY_G(yy_c_buf_p) = yy_cp;
+}
+%if-c-only
+]])
+%endif
+
+%if-c-only
+#ifndef YY_NO_INPUT
+#ifdef __cplusplus
+ static int yyinput YYFARGS0(void)
+#else
+ static int input YYFARGS0(void)
+#endif
+
+%endif
+%if-c++-only
+ int yyFlexLexer::yyinput()
+%endif
+{
+ int c;
+ M4_YY_DECL_GUTS_VAR();
+
+ *YY_G(yy_c_buf_p) = YY_G(yy_hold_char);
+
+ if ( *YY_G(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR )
+ {
+ /* yy_c_buf_p now points to the character we want to return.
+ * If this occurs *before* the EOB characters, then it's a
+ * valid NUL; if not, then we've hit the end of the buffer.
+ */
+ if ( YY_G(yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[YY_G(yy_n_chars)] )
+ /* This was really a NUL. */
+ *YY_G(yy_c_buf_p) = '\0';
+
+ else
+ { /* need more input */
+ int offset = YY_G(yy_c_buf_p) - YY_G(yytext_ptr);
+ ++YY_G(yy_c_buf_p);
+
+ switch ( yy_get_next_buffer( M4_YY_CALL_ONLY_ARG ) )
+ {
+ case EOB_ACT_LAST_MATCH:
+ /* This happens because yy_g_n_b()
+ * sees that we've accumulated a
+ * token and flags that we need to
+ * try matching the token before
+ * proceeding. But for input(),
+ * there's no matching to consider.
+ * So convert the EOB_ACT_LAST_MATCH
+ * to EOB_ACT_END_OF_FILE.
+ */
+
+ /* Reset buffer status. */
+ yyrestart( yyin M4_YY_CALL_LAST_ARG);
+
+ /*FALLTHROUGH*/
+
+ case EOB_ACT_END_OF_FILE:
+ {
+ if ( yywrap( M4_YY_CALL_ONLY_ARG ) )
+ return EOF;
+
+ if ( ! YY_G(yy_did_buffer_switch_on_eof) )
+ YY_NEW_FILE;
+#ifdef __cplusplus
+ return yyinput(M4_YY_CALL_ONLY_ARG);
+#else
+ return input(M4_YY_CALL_ONLY_ARG);
+#endif
+ }
+
+ case EOB_ACT_CONTINUE_SCAN:
+ YY_G(yy_c_buf_p) = YY_G(yytext_ptr) + offset;
+ break;
+ }
+ }
+ }
+
+ c = *(unsigned char *) YY_G(yy_c_buf_p); /* cast for 8-bit char's */
+ *YY_G(yy_c_buf_p) = '\0'; /* preserve yytext */
+ YY_G(yy_hold_char) = *++YY_G(yy_c_buf_p);
+
+%% [19.0] update BOL and yylineno
+
+ return c;
+}
+%if-c-only
+#endif /* ifndef YY_NO_INPUT */
+%endif
+
+/** Immediately switch to a different input stream.
+ * @param input_file A readable stream.
+ * M4_YY_DOC_PARAM
+ * @note This function does not reset the start condition to @c INITIAL .
+ */
+%if-c-only
+ void yyrestart YYFARGS1( FILE *,input_file)
+%endif
+%if-c++-only
+ void yyFlexLexer::yyrestart( std::istream* input_file )
+%endif
+{
+ M4_YY_DECL_GUTS_VAR();
+
+ if ( ! YY_CURRENT_BUFFER ){
+ yyensure_buffer_stack (M4_YY_CALL_ONLY_ARG);
+ YY_CURRENT_BUFFER_LVALUE =
+ yy_create_buffer( yyin, YY_BUF_SIZE M4_YY_CALL_LAST_ARG);
+ }
+
+ yy_init_buffer( YY_CURRENT_BUFFER, input_file M4_YY_CALL_LAST_ARG);
+ yy_load_buffer_state( M4_YY_CALL_ONLY_ARG );
+}
+
+/** Switch to a different input buffer.
+ * @param new_buffer The new input buffer.
+ * M4_YY_DOC_PARAM
+ */
+%if-c-only
+ void yy_switch_to_buffer YYFARGS1( YY_BUFFER_STATE ,new_buffer)
+%endif
+%if-c++-only
+ void yyFlexLexer::yy_switch_to_buffer( YY_BUFFER_STATE new_buffer )
+%endif
+{
+ M4_YY_DECL_GUTS_VAR();
+
+ /* TODO. We should be able to replace this entire function body
+ * with
+ * yypop_buffer_state();
+ * yypush_buffer_state(new_buffer);
+ */
+ yyensure_buffer_stack (M4_YY_CALL_ONLY_ARG);
+ if ( YY_CURRENT_BUFFER == new_buffer )
+ return;
+
+ if ( YY_CURRENT_BUFFER )
+ {
+ /* Flush out information for old buffer. */
+ *YY_G(yy_c_buf_p) = YY_G(yy_hold_char);
+ YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = YY_G(yy_c_buf_p);
+ YY_CURRENT_BUFFER_LVALUE->yy_n_chars = YY_G(yy_n_chars);
+ }
+
+ YY_CURRENT_BUFFER_LVALUE = new_buffer;
+ yy_load_buffer_state( M4_YY_CALL_ONLY_ARG );
+
+ /* We don't actually know whether we did this switch during
+ * EOF (yywrap()) processing, but the only time this flag
+ * is looked at is after yywrap() is called, so it's safe
+ * to go ahead and always set it.
+ */
+ YY_G(yy_did_buffer_switch_on_eof) = 1;
+}
+
+
+%if-c-only
+static void yy_load_buffer_state YYFARGS0(void)
+%endif
+%if-c++-only
+ void yyFlexLexer::yy_load_buffer_state()
+%endif
+{
+ M4_YY_DECL_GUTS_VAR();
+ YY_G(yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
+ YY_G(yytext_ptr) = YY_G(yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos;
+ yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file;
+ YY_G(yy_hold_char) = *YY_G(yy_c_buf_p);
+}
+
+/** Allocate and initialize an input buffer state.
+ * @param file A readable stream.
+ * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE.
+ * M4_YY_DOC_PARAM
+ * @return the allocated buffer state.
+ */
+%if-c-only
+ YY_BUFFER_STATE yy_create_buffer YYFARGS2( FILE *,file, int ,size)
+%endif
+%if-c++-only
+ YY_BUFFER_STATE yyFlexLexer::yy_create_buffer( std::istream* file, int size )
+%endif
+{
+ YY_BUFFER_STATE b;
+ m4_dnl M4_YY_DECL_GUTS_VAR();
+
+ b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) M4_YY_CALL_LAST_ARG );
+ if ( ! b )
+ YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
+
+ b->yy_buf_size = size;
+
+ /* yy_ch_buf has to be 2 characters longer than the size given because
+ * we need to put in 2 end-of-buffer characters.
+ */
+ b->yy_ch_buf = (char *) yyalloc( b->yy_buf_size + 2 M4_YY_CALL_LAST_ARG );
+ if ( ! b->yy_ch_buf )
+ YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
+
+ b->yy_is_our_buffer = 1;
+
+ yy_init_buffer( b, file M4_YY_CALL_LAST_ARG);
+
+ return b;
+}
+
+/** Destroy the buffer.
+ * @param b a buffer created with yy_create_buffer()
+ * M4_YY_DOC_PARAM
+ */
+%if-c-only
+ void yy_delete_buffer YYFARGS1( YY_BUFFER_STATE ,b)
+%endif
+%if-c++-only
+ void yyFlexLexer::yy_delete_buffer( YY_BUFFER_STATE b )
+%endif
+{
+ M4_YY_DECL_GUTS_VAR();
+
+ if ( ! b )
+ return;
+
+ if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */
+ YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0;
+
+ if ( b->yy_is_our_buffer )
+ yyfree( (void *) b->yy_ch_buf M4_YY_CALL_LAST_ARG );
+
+ yyfree( (void *) b M4_YY_CALL_LAST_ARG );
+}
+
+
+%if-c-only
+m4_ifdef( [[M4_YY_ALWAYS_INTERACTIVE]],,
+[[
+ m4_ifdef( [[M4_YY_NEVER_INTERACTIVE]],,
+ [[
+#ifndef __cplusplus
+extern int isatty M4_YY_PARAMS( int );
+#endif /* __cplusplus */
+ ]])
+]])
+%endif
+
+%if-c++-only
+m4_ifdef( [[M4_YY_NEVER_INTERACTIVE]],,
+[[
+]])
+%endif
+
+/* Initializes or reinitializes a buffer.
+ * This function is sometimes called more than once on the same buffer,
+ * such as during a yyrestart() or at EOF.
+ */
+%if-c-only
+ static void yy_init_buffer YYFARGS2( YY_BUFFER_STATE ,b, FILE *,file)
+%endif
+%if-c++-only
+ void yyFlexLexer::yy_init_buffer( YY_BUFFER_STATE b, std::istream* file )
+%endif
+
+{
+ int oerrno = errno;
+ M4_YY_DECL_GUTS_VAR();
+
+ yy_flush_buffer( b M4_YY_CALL_LAST_ARG);
+
+ b->yy_input_file = file;
+ b->yy_fill_buffer = 1;
+
+ /* If b is the current buffer, then yy_init_buffer was _probably_
+ * called from yyrestart() or through yy_get_next_buffer.
+ * In that case, we don't want to reset the lineno or column.
+ */
+ if (b != YY_CURRENT_BUFFER){
+ b->yy_bs_lineno = 1;
+ b->yy_bs_column = 0;
+ }
+
+%if-c-only
+m4_ifdef( [[M4_YY_ALWAYS_INTERACTIVE]],
+[[
+ b->yy_is_interactive = 1;
+]],
+[[
+ m4_ifdef( [[M4_YY_NEVER_INTERACTIVE]],
+ [[
+ b->yy_is_interactive = 0;
+ ]],
+ [[
+ b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0;
+ ]])
+]])
+%endif
+%if-c++-only
+ b->yy_is_interactive = 0;
+%endif
+ errno = oerrno;
+}
+
+/** Discard all buffered characters. On the next scan, YY_INPUT will be called.
+ * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER.
+ * M4_YY_DOC_PARAM
+ */
+%if-c-only
+ void yy_flush_buffer YYFARGS1( YY_BUFFER_STATE ,b)
+%endif
+%if-c++-only
+ void yyFlexLexer::yy_flush_buffer( YY_BUFFER_STATE b )
+%endif
+{
+ M4_YY_DECL_GUTS_VAR();
+ if ( ! b )
+ return;
+
+ b->yy_n_chars = 0;
+
+ /* We always need two end-of-buffer characters. The first causes
+ * a transition to the end-of-buffer state. The second causes
+ * a jam in that state.
+ */
+ b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR;
+ b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
+
+ b->yy_buf_pos = &b->yy_ch_buf[0];
+
+ b->yy_at_bol = 1;
+ b->yy_buffer_status = YY_BUFFER_NEW;
+
+ if ( b == YY_CURRENT_BUFFER )
+ yy_load_buffer_state( M4_YY_CALL_ONLY_ARG );
+}
+
+%if-c-or-c++
+/** Pushes the new state onto the stack. The new state becomes
+ * the current state. This function will allocate the stack
+ * if necessary.
+ * @param new_buffer The new state.
+ * M4_YY_DOC_PARAM
+ */
+%if-c-only
+void yypush_buffer_state YYFARGS1(YY_BUFFER_STATE,new_buffer)
+%endif
+%if-c++-only
+void yyFlexLexer::yypush_buffer_state (YY_BUFFER_STATE new_buffer)
+%endif
+{
+ M4_YY_DECL_GUTS_VAR();
+ if (new_buffer == NULL)
+ return;
+
+ yyensure_buffer_stack(M4_YY_CALL_ONLY_ARG);
+
+ /* This block is copied from yy_switch_to_buffer. */
+ if ( YY_CURRENT_BUFFER )
+ {
+ /* Flush out information for old buffer. */
+ *YY_G(yy_c_buf_p) = YY_G(yy_hold_char);
+ YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = YY_G(yy_c_buf_p);
+ YY_CURRENT_BUFFER_LVALUE->yy_n_chars = YY_G(yy_n_chars);
+ }
+
+ /* Only push if top exists. Otherwise, replace top. */
+ if (YY_CURRENT_BUFFER)
+ YY_G(yy_buffer_stack_top)++;
+ YY_CURRENT_BUFFER_LVALUE = new_buffer;
+
+ /* copied from yy_switch_to_buffer. */
+ yy_load_buffer_state( M4_YY_CALL_ONLY_ARG );
+ YY_G(yy_did_buffer_switch_on_eof) = 1;
+}
+%endif
+
+
+%if-c-or-c++
+/** Removes and deletes the top of the stack, if present.
+ * The next element becomes the new top.
+ * M4_YY_DOC_PARAM
+ */
+%if-c-only
+void yypop_buffer_state YYFARGS0(void)
+%endif
+%if-c++-only
+void yyFlexLexer::yypop_buffer_state (void)
+%endif
+{
+ M4_YY_DECL_GUTS_VAR();
+ if (!YY_CURRENT_BUFFER)
+ return;
+
+ yy_delete_buffer(YY_CURRENT_BUFFER M4_YY_CALL_LAST_ARG);
+ YY_CURRENT_BUFFER_LVALUE = NULL;
+ if (YY_G(yy_buffer_stack_top) > 0)
+ --YY_G(yy_buffer_stack_top);
+
+ if (YY_CURRENT_BUFFER) {
+ yy_load_buffer_state( M4_YY_CALL_ONLY_ARG );
+ YY_G(yy_did_buffer_switch_on_eof) = 1;
+ }
+}
+%endif
+
+
+%if-c-or-c++
+/* Allocates the stack if it does not exist.
+ * Guarantees space for at least one push.
+ */
+%if-c-only
+static void yyensure_buffer_stack YYFARGS0(void)
+%endif
+%if-c++-only
+void yyFlexLexer::yyensure_buffer_stack(void)
+%endif
+{
+ int num_to_alloc;
+ M4_YY_DECL_GUTS_VAR();
+
+ if (!YY_G(yy_buffer_stack)) {
+
+ /* First allocation is just for 2 elements, since we don't know if this
+ * scanner will even need a stack. We use 2 instead of 1 to avoid an
+ * immediate realloc on the next call.
+ */
+ num_to_alloc = 1;
+ YY_G(yy_buffer_stack) = (struct yy_buffer_state**)yyalloc
+ (num_to_alloc * sizeof(struct yy_buffer_state*)
+ M4_YY_CALL_LAST_ARG);
+ if ( ! YY_G(yy_buffer_stack) )
+ YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" );
+
+
+ memset(YY_G(yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*));
+
+ YY_G(yy_buffer_stack_max) = num_to_alloc;
+ YY_G(yy_buffer_stack_top) = 0;
+ return;
+ }
+
+ if (YY_G(yy_buffer_stack_top) >= (YY_G(yy_buffer_stack_max)) - 1){
+
+ /* Increase the buffer to prepare for a possible push. */
+ int grow_size = 8 /* arbitrary grow size */;
+
+ num_to_alloc = YY_G(yy_buffer_stack_max) + grow_size;
+ YY_G(yy_buffer_stack) = (struct yy_buffer_state**)yyrealloc
+ (YY_G(yy_buffer_stack),
+ num_to_alloc * sizeof(struct yy_buffer_state*)
+ M4_YY_CALL_LAST_ARG);
+ if ( ! YY_G(yy_buffer_stack) )
+ YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" );
+
+ /* zero only the new slots.*/
+ memset(YY_G(yy_buffer_stack) + YY_G(yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*));
+ YY_G(yy_buffer_stack_max) = num_to_alloc;
+ }
+}
+%endif
+
+
+
+
+m4_ifdef( [[M4_YY_NO_SCAN_BUFFER]],,
+[[
+%if-c-only
+/** Setup the input buffer state to scan directly from a user-specified character buffer.
+ * @param base the character buffer
+ * @param size the size in bytes of the character buffer
+ * M4_YY_DOC_PARAM
+ * @return the newly allocated buffer state object.
+ */
+YY_BUFFER_STATE yy_scan_buffer YYFARGS2( char *,base, yy_size_t ,size)
+{
+ YY_BUFFER_STATE b;
+ m4_dnl M4_YY_DECL_GUTS_VAR();
+
+ if ( size < 2 ||
+ base[size-2] != YY_END_OF_BUFFER_CHAR ||
+ base[size-1] != YY_END_OF_BUFFER_CHAR )
+ /* They forgot to leave room for the EOB's. */
+ return 0;
+
+ b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) M4_YY_CALL_LAST_ARG );
+ if ( ! b )
+ YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" );
+
+ b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */
+ b->yy_buf_pos = b->yy_ch_buf = base;
+ b->yy_is_our_buffer = 0;
+ b->yy_input_file = 0;
+ b->yy_n_chars = b->yy_buf_size;
+ b->yy_is_interactive = 0;
+ b->yy_at_bol = 1;
+ b->yy_fill_buffer = 0;
+ b->yy_buffer_status = YY_BUFFER_NEW;
+
+ yy_switch_to_buffer( b M4_YY_CALL_LAST_ARG );
+
+ return b;
+}
+%endif
+]])
+
+
+m4_ifdef( [[M4_YY_NO_SCAN_STRING]],,
+[[
+%if-c-only
+/** Setup the input buffer state to scan a string. The next call to yylex() will
+ * scan from a @e copy of @a str.
+ * @param yystr a NUL-terminated string to scan
+ * M4_YY_DOC_PARAM
+ * @return the newly allocated buffer state object.
+ * @note If you want to scan bytes that may contain NUL values, then use
+ * yy_scan_bytes() instead.
+ */
+YY_BUFFER_STATE yy_scan_string YYFARGS1( yyconst char *, yystr)
+{
+ m4_dnl M4_YY_DECL_GUTS_VAR();
+
+ return yy_scan_bytes( yystr, strlen(yystr) M4_YY_CALL_LAST_ARG);
+}
+%endif
+]])
+
+
+m4_ifdef( [[M4_YY_NO_SCAN_BYTES]],,
+[[
+%if-c-only
+/** Setup the input buffer state to scan the given bytes. The next call to yylex() will
+ * scan from a @e copy of @a bytes.
+ * @param bytes the byte buffer to scan
+ * @param len the number of bytes in the buffer pointed to by @a bytes.
+ * M4_YY_DOC_PARAM
+ * @return the newly allocated buffer state object.
+ */
+YY_BUFFER_STATE yy_scan_bytes YYFARGS2( yyconst char *,yybytes, int ,_yybytes_len)
+{
+ YY_BUFFER_STATE b;
+ char *buf;
+ yy_size_t n;
+ int i;
+ m4_dnl M4_YY_DECL_GUTS_VAR();
+
+ /* Get memory for full buffer, including space for trailing EOB's. */
+ n = _yybytes_len + 2;
+ buf = (char *) yyalloc( n M4_YY_CALL_LAST_ARG );
+ if ( ! buf )
+ YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" );
+
+ for ( i = 0; i < _yybytes_len; ++i )
+ buf[i] = yybytes[i];
+
+ buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR;
+
+ b = yy_scan_buffer( buf, n M4_YY_CALL_LAST_ARG);
+ if ( ! b )
+ YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" );
+
+ /* It's okay to grow etc. this buffer, and we should throw it
+ * away when we're done.
+ */
+ b->yy_is_our_buffer = 1;
+
+ return b;
+}
+%endif
+]])
+
+
+m4_ifdef( [[M4_YY_NO_PUSH_STATE]],,
+[[
+%if-c-only
+ static void yy_push_state YYFARGS1( int ,new_state)
+%endif
+%if-c++-only
+ void yyFlexLexer::yy_push_state( int new_state )
+%endif
+{
+ M4_YY_DECL_GUTS_VAR();
+ if ( YY_G(yy_start_stack_ptr) >= YY_G(yy_start_stack_depth) )
+ {
+ yy_size_t new_size;
+
+ YY_G(yy_start_stack_depth) += YY_START_STACK_INCR;
+ new_size = YY_G(yy_start_stack_depth) * sizeof( int );
+
+ if ( ! YY_G(yy_start_stack) )
+ YY_G(yy_start_stack) = (int *) yyalloc( new_size M4_YY_CALL_LAST_ARG );
+
+ else
+ YY_G(yy_start_stack) = (int *) yyrealloc(
+ (void *) YY_G(yy_start_stack), new_size M4_YY_CALL_LAST_ARG );
+
+ if ( ! YY_G(yy_start_stack) )
+ YY_FATAL_ERROR( "out of memory expanding start-condition stack" );
+ }
+
+ YY_G(yy_start_stack)[YY_G(yy_start_stack_ptr)++] = YY_START;
+
+ BEGIN(new_state);
+}
+]])
+
+
+m4_ifdef( [[M4_YY_NO_POP_STATE]],,
+[[
+%if-c-only
+ static void yy_pop_state YYFARGS0(void)
+%endif
+%if-c++-only
+ void yyFlexLexer::yy_pop_state()
+%endif
+{
+ M4_YY_DECL_GUTS_VAR();
+ if ( --YY_G(yy_start_stack_ptr) < 0 )
+ YY_FATAL_ERROR( "start-condition stack underflow" );
+
+ BEGIN(YY_G(yy_start_stack)[YY_G(yy_start_stack_ptr)]);
+}
+]])
+
+
+m4_ifdef( [[M4_YY_NO_TOP_STATE]],,
+[[
+%if-c-only
+ static int yy_top_state YYFARGS0(void)
+%endif
+%if-c++-only
+ int yyFlexLexer::yy_top_state()
+%endif
+{
+ M4_YY_DECL_GUTS_VAR();
+ return YY_G(yy_start_stack)[YY_G(yy_start_stack_ptr) - 1];
+}
+]])
+
+#ifndef YY_EXIT_FAILURE
+#define YY_EXIT_FAILURE 2
+#endif
+
+%if-c-only
+static void yy_fatal_error YYFARGS1(yyconst char*, msg)
+{
+ m4_dnl M4_YY_DECL_GUTS_VAR();
+ (void) fprintf( stderr, "%s\n", msg );
+ exit( YY_EXIT_FAILURE );
+}
+%endif
+%if-c++-only
+void yyFlexLexer::LexerError( yyconst char msg[] )
+{
+ M4_YY_DECL_GUTS_VAR();
+ std::cerr << msg << std::endl;
+ exit( YY_EXIT_FAILURE );
+}
+%endif
+
+/* Redefine yyless() so it works in section 3 code. */
+
+#undef yyless
+#define yyless(n) \
+ do \
+ { \
+ /* Undo effects of setting up yytext. */ \
+ int yyless_macro_arg = (n); \
+ YY_LESS_LINENO(yyless_macro_arg);\
+ yytext[yyleng] = YY_G(yy_hold_char); \
+ YY_G(yy_c_buf_p) = yytext + yyless_macro_arg; \
+ YY_G(yy_hold_char) = *YY_G(yy_c_buf_p); \
+ *YY_G(yy_c_buf_p) = '\0'; \
+ yyleng = yyless_macro_arg; \
+ } \
+ while ( 0 )
+
+
+
+/* Accessor methods (get/set functions) to struct members. */
+
+%if-c-only
+%if-reentrant
+m4_ifdef( [[M4_YY_NO_GET_EXTRA]],,
+[[
+/** Get the user-defined data for this scanner.
+ * M4_YY_DOC_PARAM
+ */
+YY_EXTRA_TYPE yyget_extra YYFARGS0(void)
+{
+ M4_YY_DECL_GUTS_VAR();
+ return yyextra;
+}
+]])
+%endif
+
+m4_ifdef( [[M4_YY_NO_GET_LINENO]],,
+[[
+/** Get the current line number.
+ * M4_YY_DOC_PARAM
+ */
+int yyget_lineno YYFARGS0(void)
+{
+ M4_YY_DECL_GUTS_VAR();
+
+ m4_ifdef( [[M4_YY_REENTRANT]],
+ [[
+ if (! YY_CURRENT_BUFFER)
+ return 0;
+ ]])
+ return yylineno;
+}
+]])
+
+m4_ifdef( [[M4_YY_REENTRANT]],
+[[
+m4_ifdef( [[M4_YY_NO_GET_COLUMN]],,
+[[
+/** Get the current column number.
+ * M4_YY_DOC_PARAM
+ */
+int yyget_column YYFARGS0(void)
+{
+ M4_YY_DECL_GUTS_VAR();
+
+ m4_ifdef( [[M4_YY_REENTRANT]],
+ [[
+ if (! YY_CURRENT_BUFFER)
+ return 0;
+ ]])
+ return yycolumn;
+}
+]])
+]])
+
+m4_ifdef( [[M4_YY_NO_GET_IN]],,
+[[
+/** Get the input stream.
+ * M4_YY_DOC_PARAM
+ */
+FILE *yyget_in YYFARGS0(void)
+{
+ M4_YY_DECL_GUTS_VAR();
+ return yyin;
+}
+]])
+
+m4_ifdef( [[M4_YY_NO_GET_OUT]],,
+[[
+/** Get the output stream.
+ * M4_YY_DOC_PARAM
+ */
+FILE *yyget_out YYFARGS0(void)
+{
+ M4_YY_DECL_GUTS_VAR();
+ return yyout;
+}
+]])
+
+m4_ifdef( [[M4_YY_NO_GET_LENG]],,
+[[
+/** Get the length of the current token.
+ * M4_YY_DOC_PARAM
+ */
+int yyget_leng YYFARGS0(void)
+{
+ M4_YY_DECL_GUTS_VAR();
+ return yyleng;
+}
+]])
+
+/** Get the current token.
+ * M4_YY_DOC_PARAM
+ */
+m4_ifdef( [[M4_YY_NO_GET_TEXT]],,
+[[
+char *yyget_text YYFARGS0(void)
+{
+ M4_YY_DECL_GUTS_VAR();
+ return yytext;
+}
+]])
+
+%if-reentrant
+m4_ifdef( [[M4_YY_NO_SET_EXTRA]],,
+[[
+/** Set the user-defined data. This data is never touched by the scanner.
+ * @param user_defined The data to be associated with this scanner.
+ * M4_YY_DOC_PARAM
+ */
+void yyset_extra YYFARGS1( YY_EXTRA_TYPE ,user_defined)
+{
+ M4_YY_DECL_GUTS_VAR();
+ yyextra = user_defined ;
+}
+]])
+%endif
+
+m4_ifdef( [[M4_YY_NO_SET_LINENO]],,
+[[
+/** Set the current line number.
+ * @param line_number
+ * M4_YY_DOC_PARAM
+ */
+void yyset_lineno YYFARGS1( int ,line_number)
+{
+ M4_YY_DECL_GUTS_VAR();
+
+ m4_ifdef( [[M4_YY_REENTRANT]],
+ [[
+ /* lineno is only valid if an input buffer exists. */
+ if (! YY_CURRENT_BUFFER )
+ yy_fatal_error( "yyset_lineno called with no buffer" M4_YY_CALL_LAST_ARG);
+ ]])
+ yylineno = line_number;
+}
+]])
+
+m4_ifdef( [[M4_YY_REENTRANT]],
+[[
+m4_ifdef( [[M4_YY_NO_SET_COLUMN]],,
+[[
+/** Set the current column.
+ * @param line_number
+ * M4_YY_DOC_PARAM
+ */
+void yyset_column YYFARGS1( int , column_no)
+{
+ M4_YY_DECL_GUTS_VAR();
+
+ m4_ifdef( [[M4_YY_REENTRANT]],
+ [[
+ /* column is only valid if an input buffer exists. */
+ if (! YY_CURRENT_BUFFER )
+ yy_fatal_error( "yyset_column called with no buffer" M4_YY_CALL_LAST_ARG);
+ ]])
+ yycolumn = column_no;
+}
+]])
+]])
+
+
+m4_ifdef( [[M4_YY_NO_SET_IN]],,
+[[
+/** Set the input stream. This does not discard the current
+ * input buffer.
+ * @param in_str A readable stream.
+ * M4_YY_DOC_PARAM
+ * @see yy_switch_to_buffer
+ */
+void yyset_in YYFARGS1( FILE * ,in_str)
+{
+ M4_YY_DECL_GUTS_VAR();
+ yyin = in_str ;
+}
+]])
+
+m4_ifdef( [[M4_YY_NO_SET_OUT]],,
+[[
+void yyset_out YYFARGS1( FILE * ,out_str)
+{
+ M4_YY_DECL_GUTS_VAR();
+ yyout = out_str ;
+}
+]])
+
+
+m4_ifdef( [[M4_YY_NO_GET_DEBUG]],,
+[[
+int yyget_debug YYFARGS0(void)
+{
+ M4_YY_DECL_GUTS_VAR();
+ return yy_flex_debug;
+}
+]])
+
+m4_ifdef( [[M4_YY_NO_SET_DEBUG]],,
+[[
+void yyset_debug YYFARGS1( int ,bdebug)
+{
+ M4_YY_DECL_GUTS_VAR();
+ yy_flex_debug = bdebug ;
+}
+]])
+%endif
+
+%if-reentrant
+/* Accessor methods for yylval and yylloc */
+
+%if-bison-bridge
+m4_ifdef( [[M4_YY_NO_GET_LVAL]],,
+[[
+YYSTYPE * yyget_lval YYFARGS0(void)
+{
+ M4_YY_DECL_GUTS_VAR();
+ return yylval;
+}
+]])
+
+m4_ifdef( [[M4_YY_NO_SET_LVAL]],,
+[[
+void yyset_lval YYFARGS1( YYSTYPE * ,yylval_param)
+{
+ M4_YY_DECL_GUTS_VAR();
+ yylval = yylval_param;
+}
+]])
+
+m4_ifdef( [[<M4_YY_BISON_LLOC>]],
+[[
+ m4_ifdef( [[M4_YY_NO_GET_LLOC]],,
+ [[
+YYLTYPE *yyget_lloc YYFARGS0(void)
+{
+ M4_YY_DECL_GUTS_VAR();
+ return yylloc;
+}
+ ]])
+
+ m4_ifdef( [[M4_YY_NO_SET_LLOC]],,
+ [[
+void yyset_lloc YYFARGS1( YYLTYPE * ,yylloc_param)
+{
+ M4_YY_DECL_GUTS_VAR();
+ yylloc = yylloc_param;
+}
+ ]])
+]])
+
+%endif
+
+
+/* User-visible API */
+
+/* yylex_init is special because it creates the scanner itself, so it is
+ * the ONLY reentrant function that doesn't take the scanner as the last argument.
+ * That's why we explicitly handle the declaration, instead of using our macros.
+ */
+m4_ifdef( [[M4_YY_NO_ANSI_FUNC_DEFS]],
+[[
+int yylex_init( ptr_yy_globals )
+ yyscan_t* ptr_yy_globals;
+]],
+[[
+int yylex_init(yyscan_t* ptr_yy_globals)
+]])
+{
+ if (ptr_yy_globals == NULL){
+ errno = EINVAL;
+ return 1;
+ }
+
+ *ptr_yy_globals = (yyscan_t) yyalloc ( sizeof( struct yyguts_t ), NULL );
+
+ if (*ptr_yy_globals == NULL){
+ errno = ENOMEM;
+ return 1;
+ }
+
+ /* By setting to 0xAA, we expose bugs in yy_init_globals. Leave at 0x00 for releases. */
+ memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t));
+
+ return yy_init_globals ( *ptr_yy_globals );
+}
+
+
+/* yylex_init_extra has the same functionality as yylex_init, but follows the
+ * convention of taking the scanner as the last argument. Note however, that
+ * this is a *pointer* to a scanner, as it will be allocated by this call (and
+ * is the reason, too, why this function also must handle its own declaration).
+ * The user defined value in the first argument will be available to yyalloc in
+ * the yyextra field.
+ */
+m4_ifdef( [[M4_YY_NO_ANSI_FUNC_DEFS]],
+[[
+int yylex_init_extra( yy_user_defined, ptr_yy_globals )
+ YY_EXTRA_TYPE yy_user_defined;
+ yyscan_t* ptr_yy_globals;
+]],
+[[
+int yylex_init_extra( YY_EXTRA_TYPE yy_user_defined, yyscan_t* ptr_yy_globals )
+]])
+{
+ struct yyguts_t dummy_yyguts;
+
+ yyset_extra (yy_user_defined, &dummy_yyguts);
+
+ if (ptr_yy_globals == NULL){
+ errno = EINVAL;
+ return 1;
+ }
+
+ *ptr_yy_globals = (yyscan_t) yyalloc ( sizeof( struct yyguts_t ), &dummy_yyguts );
+
+ if (*ptr_yy_globals == NULL){
+ errno = ENOMEM;
+ return 1;
+ }
+
+ /* By setting to 0xAA, we expose bugs in
+ yy_init_globals. Leave at 0x00 for releases. */
+ memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t));
+
+ yyset_extra (yy_user_defined, *ptr_yy_globals);
+
+ return yy_init_globals ( *ptr_yy_globals );
+}
+
+%endif if-c-only
+
+
+%if-c-only
+static int yy_init_globals YYFARGS0(void)
+{
+ M4_YY_DECL_GUTS_VAR();
+ /* Initialization is the same as for the non-reentrant scanner.
+ * This function is called from yylex_destroy(), so don't allocate here.
+ */
+
+m4_ifdef( [[M4_YY_USE_LINENO]],
+[[
+ m4_ifdef( [[M4_YY_NOT_REENTRANT]],
+ [[
+ /* We do not touch yylineno unless the option is enabled. */
+ yylineno = 1;
+ ]])
+]])
+ YY_G(yy_buffer_stack) = 0;
+ YY_G(yy_buffer_stack_top) = 0;
+ YY_G(yy_buffer_stack_max) = 0;
+ YY_G(yy_c_buf_p) = (char *) 0;
+ YY_G(yy_init) = 0;
+ YY_G(yy_start) = 0;
+
+m4_ifdef( [[M4_YY_HAS_START_STACK_VARS]],
+[[
+ YY_G(yy_start_stack_ptr) = 0;
+ YY_G(yy_start_stack_depth) = 0;
+ YY_G(yy_start_stack) = NULL;
+]])
+
+m4_ifdef( [[M4_YY_USES_REJECT]],
+[[
+ YY_G(yy_state_buf) = 0;
+ YY_G(yy_state_ptr) = 0;
+ YY_G(yy_full_match) = 0;
+ YY_G(yy_lp) = 0;
+]])
+
+m4_ifdef( [[M4_YY_TEXT_IS_ARRAY]],
+[[
+ YY_G(yytext_ptr) = 0;
+ YY_G(yy_more_offset) = 0;
+ YY_G(yy_prev_more_offset) = 0;
+]])
+
+/* Defined in main.c */
+#ifdef YY_STDINIT
+ yyin = stdin;
+ yyout = stdout;
+#else
+ yyin = (FILE *) 0;
+ yyout = (FILE *) 0;
+#endif
+
+ /* For future reference: Set errno on error, since we are called by
+ * yylex_init()
+ */
+ return 0;
+}
+%endif
+
+
+%if-c-only SNIP! this currently causes conflicts with the c++ scanner
+/* yylex_destroy is for both reentrant and non-reentrant scanners. */
+int yylex_destroy YYFARGS0(void)
+{
+ M4_YY_DECL_GUTS_VAR();
+
+ /* Pop the buffer stack, destroying each element. */
+ while(YY_CURRENT_BUFFER){
+ yy_delete_buffer( YY_CURRENT_BUFFER M4_YY_CALL_LAST_ARG );
+ YY_CURRENT_BUFFER_LVALUE = NULL;
+ yypop_buffer_state(M4_YY_CALL_ONLY_ARG);
+ }
+
+ /* Destroy the stack itself. */
+ yyfree(YY_G(yy_buffer_stack) M4_YY_CALL_LAST_ARG);
+ YY_G(yy_buffer_stack) = NULL;
+
+m4_ifdef( [[M4_YY_HAS_START_STACK_VARS]],
+[[
+ /* Destroy the start condition stack. */
+ yyfree( YY_G(yy_start_stack) M4_YY_CALL_LAST_ARG );
+ YY_G(yy_start_stack) = NULL;
+]])
+
+m4_ifdef( [[M4_YY_USES_REJECT]],
+[[
+ yyfree ( YY_G(yy_state_buf) M4_YY_CALL_LAST_ARG);
+ YY_G(yy_state_buf) = NULL;
+]])
+
+ /* Reset the globals. This is important in a non-reentrant scanner so the next time
+ * yylex() is called, initialization will occur. */
+ yy_init_globals( M4_YY_CALL_ONLY_ARG);
+
+%if-reentrant
+ /* Destroy the main struct (reentrant only). */
+ yyfree ( yyscanner M4_YY_CALL_LAST_ARG );
+ yyscanner = NULL;
+%endif
+ return 0;
+}
+%endif
+
+
+m4_ifdef( [[M4_YY_NOT_IN_HEADER]],
+[[
+/*
+ * Internal utility routines.
+ */
+]])
+
+m4_ifdef( [[M4_YY_NOT_IN_HEADER]],
+[[
+#ifndef yytext_ptr
+static void yy_flex_strncpy YYFARGS3( char*,s1, yyconst char *,s2, int,n)
+{
+ register int i;
+ for ( i = 0; i < n; ++i )
+ s1[i] = s2[i];
+}
+#endif
+]])
+
+m4_ifdef( [[M4_YY_NOT_IN_HEADER]],
+[[
+#ifdef YY_NEED_STRLEN
+static int yy_flex_strlen YYFARGS1( yyconst char *,s)
+{
+ register int n;
+ for ( n = 0; s[n]; ++n )
+ ;
+
+ return n;
+}
+#endif
+]])
+
+m4_ifdef( [[M4_YY_NO_FLEX_ALLOC]],,
+[[
+void *yyalloc YYFARGS1( yy_size_t ,size)
+{
+ return (void *) malloc( size );
+}
+]])
+
+m4_ifdef( [[M4_YY_NO_FLEX_REALLOC]],,
+[[
+void *yyrealloc YYFARGS2( void *,ptr, yy_size_t ,size)
+{
+ /* The cast to (char *) in the following accommodates both
+ * implementations that use char* generic pointers, and those
+ * that use void* generic pointers. It works with the latter
+ * because both ANSI C and C++ allow castless assignment from
+ * any pointer type to void*, and deal with argument conversions
+ * as though doing an assignment.
+ */
+ return (void *) realloc( (char *) ptr, size );
+}
+]])
+
+m4_ifdef( [[M4_YY_NO_FLEX_FREE]],,
+[[
+void yyfree YYFARGS1( void *,ptr)
+{
+ free( (char *) ptr ); /* see yyrealloc() for (char *) cast */
+}
+]])
+
+%if-tables-serialization definitions
+m4preproc_include(`tables_shared.c')
+
+static int yytbl_read8 (void *v, struct yytbl_reader * rd)
+{
+ errno = 0;
+ if (fread (v, sizeof (flex_uint8_t), 1, rd->fp) != 1){
+ errno = EIO;
+ return -1;
+ }
+ rd->bread += sizeof(flex_uint8_t);
+ return 0;
+}
+
+static int yytbl_read16 (void *v, struct yytbl_reader * rd)
+{
+ errno = 0;
+ if (fread (v, sizeof (flex_uint16_t), 1, rd->fp) != 1){
+ errno = EIO;
+ return -1;
+ }
+ *((flex_uint16_t *) v) = ntohs (*((flex_uint16_t *) v));
+ rd->bread += sizeof(flex_uint16_t);
+ return 0;
+}
+
+static int yytbl_read32 (void *v, struct yytbl_reader * rd)
+{
+ errno = 0;
+ if (fread (v, sizeof (flex_uint32_t), 1, rd->fp) != 1){
+ errno = EIO;
+ return -1;
+ }
+ *((flex_uint32_t *) v) = ntohl (*((flex_uint32_t *) v));
+ rd->bread += sizeof(flex_uint32_t);
+ return 0;
+}
+
+/** Read the header */
+static int yytbl_hdr_read YYFARGS2(struct yytbl_hdr *, th, struct yytbl_reader *, rd)
+{
+ int bytes;
+ memset (th, 0, sizeof (struct yytbl_hdr));
+
+ if (yytbl_read32 (&(th->th_magic), rd) != 0)
+ return -1;
+
+ if (th->th_magic != YYTBL_MAGIC){
+ yy_fatal_error("bad magic number" /*TODO: not fatal.*/ M4_YY_CALL_LAST_ARG);
+ return -1;
+ }
+
+ if (yytbl_read32 (&(th->th_hsize), rd) != 0
+ || yytbl_read32 (&(th->th_ssize), rd) != 0
+ || yytbl_read16 (&(th->th_flags), rd) != 0)
+ return -1;
+
+ /* Sanity check on header size. Greater than 1k suggests some funny business. */
+ if (th->th_hsize < 16 || th->th_hsize > 1024){
+ yy_fatal_error("insane header size detected" /*TODO: not fatal.*/ M4_YY_CALL_LAST_ARG);
+ return -1;
+ }
+
+ /* Allocate enough space for the version and name fields */
+ bytes = th->th_hsize - 14;
+ th->th_version = (char *) yyalloc (bytes M4_YY_CALL_LAST_ARG);
+ if ( ! th->th_version )
+ YY_FATAL_ERROR( "out of dynamic memory in yytbl_hdr_read()" );
+
+ /* we read it all into th_version, and point th_name into that data */
+ if (fread (th->th_version, 1, bytes, rd->fp) != bytes){
+ errno = EIO;
+ yyfree(th->th_version M4_YY_CALL_LAST_ARG);
+ th->th_version = NULL;
+ return -1;
+ }
+ else
+ rd->bread += bytes;
+
+ th->th_name = th->th_version + strlen (th->th_version) + 1;
+ return 0;
+}
+
+/** lookup id in the dmap list.
+ * @param dmap pointer to first element in list
+ * @return NULL if not found.
+ */
+static struct yytbl_dmap *yytbl_dmap_lookup YYFARGS2(struct yytbl_dmap *, dmap,
+ int, id)
+{
+ while (dmap->dm_id)
+ if (dmap->dm_id == id)
+ return dmap;
+ else
+ dmap++;
+ return NULL;
+}
+
+/** Read a table while mapping its contents to the local array.
+ * @param dmap used to performing mapping
+ * @return 0 on success
+ */
+static int yytbl_data_load YYFARGS2(struct yytbl_dmap *, dmap, struct yytbl_reader*, rd)
+{
+ struct yytbl_data td;
+ struct yytbl_dmap *transdmap=0;
+ int len, i, rv, inner_loop_count;
+ void *p=0;
+
+ memset (&td, 0, sizeof (struct yytbl_data));
+
+ if (yytbl_read16 (&td.td_id, rd) != 0
+ || yytbl_read16 (&td.td_flags, rd) != 0
+ || yytbl_read32 (&td.td_hilen, rd) != 0
+ || yytbl_read32 (&td.td_lolen, rd) != 0)
+ return -1;
+
+ /* Lookup the map for the transition table so we have it in case we need it
+ * inside the loop below. This scanner might not even have a transition
+ * table, which is ok.
+ */
+ transdmap = yytbl_dmap_lookup (dmap, YYTD_ID_TRANSITION M4_YY_CALL_LAST_ARG);
+
+ if ((dmap = yytbl_dmap_lookup (dmap, td.td_id M4_YY_CALL_LAST_ARG)) == NULL){
+ yy_fatal_error("table id not found in map." /*TODO: not fatal.*/ M4_YY_CALL_LAST_ARG);
+ return -1;
+ }
+
+ /* Allocate space for table.
+ * The --full yy_transition table is a special case, since we
+ * need the dmap.dm_sz entry to tell us the sizeof the individual
+ * struct members.
+ */
+ {
+ size_t bytes;
+
+ if ((td.td_flags & YYTD_STRUCT))
+ bytes = sizeof(struct yy_trans_info) * td.td_lolen * (td.td_hilen ? td.td_hilen : 1);
+ else
+ bytes = td.td_lolen * (td.td_hilen ? td.td_hilen : 1) * dmap->dm_sz;
+
+ if(M4_YY_TABLES_VERIFY)
+ /* We point to the array itself */
+ p = dmap->dm_arr;
+ else
+ /* We point to the address of a pointer. */
+ *dmap->dm_arr = p = (void *) yyalloc (bytes M4_YY_CALL_LAST_ARG);
+ if ( ! p )
+ YY_FATAL_ERROR( "out of dynamic memory in yytbl_data_load()" );
+ }
+
+ /* If it's a struct, we read 2 integers to get one element */
+ if ((td.td_flags & YYTD_STRUCT) != 0)
+ inner_loop_count = 2;
+ else
+ inner_loop_count = 1;
+
+ /* read and map each element.
+ * This loop iterates once for each element of the td_data array.
+ * Notice that we increment 'i' in the inner loop.
+ */
+ len = yytbl_calc_total_len (&td);
+ for (i = 0; i < len; ){
+ int j;
+
+
+ /* This loop really executes exactly 1 or 2 times.
+ * The second time is to handle the second member of the
+ * YYTD_STRUCT for the yy_transition array.
+ */
+ for (j = 0; j < inner_loop_count; j++, i++) {
+ flex_int32_t t32;
+
+ /* read into t32 no matter what the real size is. */
+ {
+ flex_int16_t t16;
+ flex_int8_t t8;
+
+ switch (YYTDFLAGS2BYTES (td.td_flags)) {
+ case sizeof (flex_int32_t):
+ rv = yytbl_read32 (&t32, rd);
+ break;
+ case sizeof (flex_int16_t):
+ rv = yytbl_read16 (&t16, rd);
+ t32 = t16;
+ break;
+ case sizeof (flex_int8_t):
+ rv = yytbl_read8 (&t8, rd);
+ t32 = t8;
+ break;
+ default:
+ yy_fatal_error("invalid td_flags" /*TODO: not fatal.*/ M4_YY_CALL_LAST_ARG);
+ return -1;
+ }
+ }
+ if (rv != 0)
+ return -1;
+
+ /* copy into the deserialized array... */
+
+ if ((td.td_flags & YYTD_STRUCT)) {
+ /* t32 is the j'th member of a two-element struct. */
+ void *v;
+
+ v = j == 0 ? &(((struct yy_trans_info *) p)->yy_verify)
+ : &(((struct yy_trans_info *) p)->yy_nxt);
+
+ switch (dmap->dm_sz) {
+ case sizeof (flex_int32_t):
+ if (M4_YY_TABLES_VERIFY){
+ if( ((flex_int32_t *) v)[0] != (flex_int32_t) t32)
+ yy_fatal_error("tables verification failed at YYTD_STRUCT flex_int32_t" M4_YY_CALL_LAST_ARG);
+ }else
+ ((flex_int32_t *) v)[0] = (flex_int32_t) t32;
+ break;
+ case sizeof (flex_int16_t):
+ if (M4_YY_TABLES_VERIFY ){
+ if(((flex_int16_t *) v)[0] != (flex_int16_t) t32)
+ yy_fatal_error("tables verification failed at YYTD_STRUCT flex_int16_t" M4_YY_CALL_LAST_ARG);
+ }else
+ ((flex_int16_t *) v)[0] = (flex_int16_t) t32;
+ break;
+ case sizeof(flex_int8_t):
+ if (M4_YY_TABLES_VERIFY ){
+ if( ((flex_int8_t *) v)[0] != (flex_int8_t) t32)
+ yy_fatal_error("tables verification failed at YYTD_STRUCT flex_int8_t" M4_YY_CALL_LAST_ARG);
+ }else
+ ((flex_int8_t *) v)[0] = (flex_int8_t) t32;
+ break;
+ default:
+ yy_fatal_error("invalid dmap->dm_sz for struct" /*TODO: not fatal.*/ M4_YY_CALL_LAST_ARG);
+ return -1;
+ }
+
+ /* if we're done with j, increment p */
+ if (j == 1)
+ p = (struct yy_trans_info *) p + 1;
+ }
+ else if ((td.td_flags & YYTD_PTRANS)) {
+ /* t32 is an index into the transition array. */
+ struct yy_trans_info *v;
+
+
+ if (!transdmap){
+ yy_fatal_error("transition table not found" /*TODO: not fatal.*/ M4_YY_CALL_LAST_ARG);
+ return -1;
+ }
+
+ if( M4_YY_TABLES_VERIFY)
+ v = &(((struct yy_trans_info *) (transdmap->dm_arr))[t32]);
+ else
+ v = &((*((struct yy_trans_info **) (transdmap->dm_arr)))[t32]);
+
+ if(M4_YY_TABLES_VERIFY ){
+ if( ((struct yy_trans_info **) p)[0] != v)
+ yy_fatal_error("tables verification failed at YYTD_PTRANS" M4_YY_CALL_LAST_ARG);
+ }else
+ ((struct yy_trans_info **) p)[0] = v;
+
+ /* increment p */
+ p = (struct yy_trans_info **) p + 1;
+ }
+ else {
+ /* t32 is a plain int. copy data, then incrememnt p. */
+ switch (dmap->dm_sz) {
+ case sizeof (flex_int32_t):
+ if(M4_YY_TABLES_VERIFY ){
+ if( ((flex_int32_t *) p)[0] != (flex_int32_t) t32)
+ yy_fatal_error("tables verification failed at flex_int32_t" M4_YY_CALL_LAST_ARG);
+ }else
+ ((flex_int32_t *) p)[0] = (flex_int32_t) t32;
+ p = ((flex_int32_t *) p) + 1;
+ break;
+ case sizeof (flex_int16_t):
+ if(M4_YY_TABLES_VERIFY ){
+ if( ((flex_int16_t *) p)[0] != (flex_int16_t) t32)
+ yy_fatal_error("tables verification failed at flex_int16_t" M4_YY_CALL_LAST_ARG);
+ }else
+ ((flex_int16_t *) p)[0] = (flex_int16_t) t32;
+ p = ((flex_int16_t *) p) + 1;
+ break;
+ case sizeof (flex_int8_t):
+ if(M4_YY_TABLES_VERIFY ){
+ if( ((flex_int8_t *) p)[0] != (flex_int8_t) t32)
+ yy_fatal_error("tables verification failed at flex_int8_t" M4_YY_CALL_LAST_ARG);
+ }else
+ ((flex_int8_t *) p)[0] = (flex_int8_t) t32;
+ p = ((flex_int8_t *) p) + 1;
+ break;
+ default:
+ yy_fatal_error("invalid dmap->dm_sz for plain int" /*TODO: not fatal.*/ M4_YY_CALL_LAST_ARG);
+ return -1;
+ }
+ }
+ }
+
+ }
+
+ /* Now eat padding. */
+ {
+ int pad;
+ pad = yypad64(rd->bread);
+ while(--pad >= 0){
+ flex_int8_t t8;
+ if(yytbl_read8(&t8,rd) != 0)
+ return -1;
+ }
+ }
+
+ return 0;
+}
+
+%define-yytables The name for this specific scanner's tables.
+
+/* Find the key and load the DFA tables from the given stream. */
+static int yytbl_fload YYFARGS2(FILE *, fp, const char *, key)
+{
+ int rv=0;
+ struct yytbl_hdr th;
+ struct yytbl_reader rd;
+
+ rd.fp = fp;
+ th.th_version = NULL;
+
+ /* Keep trying until we find the right set of tables or end of file. */
+ while (!feof(rd.fp)) {
+ rd.bread = 0;
+ if (yytbl_hdr_read (&th, &rd M4_YY_CALL_LAST_ARG) != 0){
+ rv = -1;
+ goto return_rv;
+ }
+
+ /* A NULL key means choose the first set of tables. */
+ if (key == NULL)
+ break;
+
+ if (strcmp(th.th_name,key) != 0){
+ /* Skip ahead to next set */
+ fseek(rd.fp, th.th_ssize - th.th_hsize, SEEK_CUR);
+ yyfree(th.th_version M4_YY_CALL_LAST_ARG);
+ th.th_version = NULL;
+ }
+ else
+ break;
+ }
+
+ while (rd.bread < th.th_ssize){
+ /* Load the data tables */
+ if(yytbl_data_load (yydmap,&rd M4_YY_CALL_LAST_ARG) != 0){
+ rv = -1;
+ goto return_rv;
+ }
+ }
+
+return_rv:
+ if(th.th_version){
+ yyfree(th.th_version M4_YY_CALL_LAST_ARG);
+ th.th_version = NULL;
+ }
+
+ return rv;
+}
+
+/** Load the DFA tables for this scanner from the given stream. */
+int yytables_fload YYFARGS1(FILE *, fp)
+{
+
+ if( yytbl_fload(fp, YYTABLES_NAME M4_YY_CALL_LAST_ARG) != 0)
+ return -1;
+ return 0;
+}
+
+/** Destroy the loaded tables, freeing memory, etc.. */
+int yytables_destroy YYFARGS0(void)
+{
+ struct yytbl_dmap *dmap=0;
+
+ if(!M4_YY_TABLES_VERIFY){
+ /* Walk the dmap, freeing the pointers */
+ for(dmap=yydmap; dmap->dm_id; dmap++) {
+ void * v;
+ v = dmap->dm_arr;
+ if(v && *(char**)v){
+ yyfree(*(char**)v M4_YY_CALL_LAST_ARG);
+ *(char**)v = NULL;
+ }
+ }
+ }
+
+ return 0;
+}
+
+/* end table serialization code definitions */
+%endif
+
+
+m4_ifdef([[M4_YY_MAIN]], [[
+int main M4_YY_PARAMS(void);
+
+int main ()
+{
+
+%if-reentrant
+ yyscan_t lexer;
+ yylex_init(&lexer);
+ yylex( lexer );
+ yylex_destroy( lexer);
+
+%endif
+%if-not-reentrant
+ yylex();
+%endif
+
+ return 0;
+}
+]])
+
+%ok-for-header
+m4_ifdef( [[M4_YY_IN_HEADER]],
+[[
+#undef YY_NEW_FILE
+#undef YY_FLUSH_BUFFER
+#undef yy_set_bol
+#undef yy_new_buffer
+#undef yy_set_interactive
+#undef YY_DO_BEFORE_ACTION
+
+#ifdef YY_DECL_IS_OURS
+#undef YY_DECL_IS_OURS
+#undef YY_DECL
+#endif
+]])
diff --git a/tools/mhmake/src/flexint.h b/tools/mhmake/src/flexint.h
new file mode 100644
index 000000000..673aa1757
--- /dev/null
+++ b/tools/mhmake/src/flexint.h
@@ -0,0 +1,63 @@
+/* flex integer type definitions */
+
+#ifndef FLEXINT_H
+#define FLEXINT_H
+
+/* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */
+
+#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
+
+/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h,
+ * if you want the limit (max/min) macros for int types.
+ */
+#ifndef __STDC_LIMIT_MACROS
+#define __STDC_LIMIT_MACROS 1
+#endif
+
+#include <inttypes.h>
+typedef int8_t flex_int8_t;
+typedef uint8_t flex_uint8_t;
+typedef int16_t flex_int16_t;
+typedef uint16_t flex_uint16_t;
+typedef int32_t flex_int32_t;
+typedef uint32_t flex_uint32_t;
+#else
+typedef signed char flex_int8_t;
+typedef short int flex_int16_t;
+typedef int flex_int32_t;
+typedef unsigned char flex_uint8_t;
+typedef unsigned short int flex_uint16_t;
+typedef unsigned int flex_uint32_t;
+#endif /* ! C99 */
+
+/* Limits of integral types. */
+#ifndef INT8_MIN
+#define INT8_MIN (-128)
+#endif
+#ifndef INT16_MIN
+#define INT16_MIN (-32767-1)
+#endif
+#ifndef INT32_MIN
+#define INT32_MIN (-2147483647-1)
+#endif
+#ifndef INT8_MAX
+#define INT8_MAX (127)
+#endif
+#ifndef INT16_MAX
+#define INT16_MAX (32767)
+#endif
+#ifndef INT32_MAX
+#define INT32_MAX (2147483647)
+#endif
+#ifndef UINT8_MAX
+#define UINT8_MAX (255U)
+#endif
+#ifndef UINT16_MAX
+#define UINT16_MAX (65535U)
+#endif
+#ifndef UINT32_MAX
+#define UINT32_MAX (4294967295U)
+#endif
+
+
+#endif /* ! FLEXINT_H */
diff --git a/tools/mhmake/src/flexlexer.h b/tools/mhmake/src/flexlexer.h
new file mode 100644
index 000000000..48dab04ae
--- /dev/null
+++ b/tools/mhmake/src/flexlexer.h
@@ -0,0 +1,260 @@
+// -*-C++-*-
+// FlexLexer.h -- define interfaces for lexical analyzer classes generated
+// by flex
+
+// Copyright (c) 1993 The Regents of the University of California.
+// All rights reserved.
+//
+// This code is derived from software contributed to Berkeley by
+// Kent Williams and Tom Epperly.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+
+// 1. Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// 2. 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 the University nor the names of its contributors
+// may be used to endorse or promote products derived from this software
+// without specific prior written permission.
+
+// THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+// IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+// PURPOSE.
+
+// This file defines FlexLexer, an abstract class which specifies the
+// external interface provided to flex C++ lexer objects, and yyFlexLexer,
+// which defines a particular lexer class.
+//
+// If you want to create multiple lexer classes, you use the -P flag
+// to rename each yyFlexLexer to some other xxFlexLexer. You then
+// include <FlexLexer.h> in your other sources once per lexer class:
+//
+// #undef yyFlexLexer
+// #define yyFlexLexer xxFlexLexer
+// #include <FlexLexer.h>
+//
+// #undef yyFlexLexer
+// #define yyFlexLexer zzFlexLexer
+// #include <FlexLexer.h>
+// ...
+
+#ifndef __FLEX_LEXER_H
+// Never included before - need to define base class.
+#define __FLEX_LEXER_H
+#include "mhmakeparser.h"
+
+#include <iostream>
+# ifndef FLEX_STD
+# define FLEX_STD std::
+# endif
+
+extern "C++" {
+
+struct yy_buffer_state;
+typedef struct yy_buffer_state *YY_BUFFER_STATE;
+typedef int yy_state_type;
+
+class FlexLexer {
+public:
+ FlexLexer() : yylineno(1), m_BraceIndent(0) {}
+ virtual ~FlexLexer() { }
+
+ const char* YYText() const { return yytext; }
+ int YYLeng() const { return yyleng; }
+
+ virtual void
+ yy_switch_to_buffer( struct yy_buffer_state* new_buffer ) = 0;
+ virtual struct yy_buffer_state*
+ yy_create_buffer( FLEX_STD istream* s, int size ) = 0;
+ virtual void yy_delete_buffer( struct yy_buffer_state* b ) = 0;
+ virtual void yyrestart( FLEX_STD istream* s ) = 0;
+
+ virtual int yylex(TOKENVALUE &theValue) = 0;
+
+
+ // Switch to new input/output streams. A nil stream pointer
+ // indicates "keep the current one".
+ virtual void switch_streams( FLEX_STD istream* new_in = 0,
+ FLEX_STD ostream* new_out = 0 ) = 0;
+
+ int lineno() const { return yylineno; }
+
+ int debug() const { return yy_flex_debug; }
+ void set_debug( int flag ) { yy_flex_debug = flag; }
+
+protected:
+ char* yytext;
+ int yyleng;
+ int yylineno; // only maintained if you use %option yylineno
+ int yy_flex_debug; // only has effect with -d or "%option debug"
+
+public:
+
+ struct INSTACK
+ {
+ YY_BUFFER_STATE m_BufferState;
+ ifstream m_Stream;
+ string m_FileName;
+ int yylineno;
+ INSTACK(YY_BUFFER_STATE BufferState, const string &FileToOpen, const string &PrevFileName, int Line) :
+ m_BufferState(BufferState),
+ m_FileName(PrevFileName),
+ yylineno(Line),
+ m_Stream(FileToOpen.c_str(), ios_base::in)
+ {
+ }
+ bool fail() const
+ {
+ return m_Stream.fail();
+ }
+ ifstream *GetStream()
+ {
+ return &m_Stream;
+ }
+ };
+ class mystack: public iterstack<INSTACK*>
+ {
+ public:
+ ~mystack()
+ {
+ iterator It=begin();
+ while (It!=end())
+ {
+ delete *It;
+ It++;
+ }
+ }
+ void pop()
+ {
+ INSTACK *pToRemove=top();
+ iterstack<INSTACK*>::pop();
+ delete pToRemove; /* Buffer does not need to be deleted because the lexer does this when it calls the pop */
+ }
+ };
+ int m_BraceIndent;
+ size_t m_IndentSkip;
+ iterstack<int> m_IndentStack;
+ bool m_IgnoreIncludeError;
+ string m_InputFileName;
+ string m_curtoken;
+ mystack m_IncludeStack;
+ mhmakeparser *m_pParser;
+ mhmakeparser *GetParser()
+ {
+ return m_pParser;
+ }
+
+};
+
+}
+#endif // FLEXLEXER_H
+
+#if defined(yyFlexLexer) || ! defined(yyFlexLexerOnce)
+// Either this is the first time through (yyFlexLexerOnce not defined),
+// or this is a repeated include to define a different flavor of
+// yyFlexLexer, as discussed in the flex manual.
+#define yyFlexLexerOnce
+
+extern "C++" {
+
+class mhmakeFlexLexer : public FlexLexer {
+public:
+ // arg_yyin and arg_yyout default to the cin and cout, but we
+ // only make that assignment when initializing in yylex().
+ mhmakeFlexLexer( FLEX_STD istream* arg_yyin = 0, FLEX_STD ostream* arg_yyout = 0 );
+
+ virtual ~mhmakeFlexLexer();
+
+ void yy_switch_to_buffer( struct yy_buffer_state* new_buffer );
+ struct yy_buffer_state* yy_create_buffer( FLEX_STD istream* s, int size );
+ void yy_delete_buffer( struct yy_buffer_state* b );
+ void yyrestart( FLEX_STD istream* s );
+
+ void yypush_buffer_state( struct yy_buffer_state* new_buffer );
+ void yypop_buffer_state();
+
+ virtual int yylex(TOKENVALUE &theValue);
+ virtual void switch_streams( FLEX_STD istream* new_in, FLEX_STD ostream* new_out = 0 );
+
+protected:
+ virtual int LexerInput( char* buf, int max_size );
+ virtual void LexerOutput( const char* buf, int size );
+ virtual void LexerError( const char* msg );
+
+ void yyunput( int c, char* buf_ptr );
+ int yyinput();
+ int yywrap();
+
+ void yy_load_buffer_state();
+ void yy_init_buffer( struct yy_buffer_state* b, FLEX_STD istream* s );
+ void yy_flush_buffer( struct yy_buffer_state* b );
+
+ int yy_start_stack_ptr;
+ int yy_start_stack_depth;
+ int* yy_start_stack;
+
+ void yy_push_state( int new_state );
+ void yy_pop_state();
+ int yy_top_state();
+
+ yy_state_type yy_get_previous_state();
+ yy_state_type yy_try_NUL_trans( yy_state_type current_state );
+ int yy_get_next_buffer();
+
+ FLEX_STD istream* yyin; // input source for default LexerInput
+ FLEX_STD ostream* yyout; // output sink for default LexerOutput
+
+ // yy_hold_char holds the character lost when yytext is formed.
+ char yy_hold_char;
+
+ // Number of characters read into yy_ch_buf.
+ int yy_n_chars;
+
+ // Points to current character in buffer.
+ char* yy_c_buf_p;
+
+ int yy_init; // whether we need to initialize
+ int yy_start; // start state number
+
+ // Flag which is used to allow yywrap()'s to do buffer switches
+ // instead of setting up a fresh yyin. A bit of a hack ...
+ int yy_did_buffer_switch_on_eof;
+
+
+ size_t yy_buffer_stack_top; /**< index of top of stack. */
+ size_t yy_buffer_stack_max; /**< capacity of stack. */
+ struct yy_buffer_state ** yy_buffer_stack; /**< Stack as an array. */
+ void yyensure_buffer_stack(void);
+
+ // The following are not always needed, but may be depending
+ // on use of certain flex features (like REJECT or yymore()).
+
+ yy_state_type yy_last_accepting_state;
+ char* yy_last_accepting_cpos;
+
+ yy_state_type* yy_state_buf;
+ yy_state_type* yy_state_ptr;
+
+ char* yy_full_match;
+ int* yy_full_state;
+ int yy_full_lp;
+
+ int yy_lp;
+ int yy_looking_for_trail_begin;
+
+ int yy_more_flag;
+ int yy_more_len;
+ int yy_more_offset;
+ int yy_prev_more_offset;
+};
+
+}
+
+#endif // yyFlexLexer || ! yyFlexLexerOnce
+
diff --git a/tools/mhmake/src/flexskel.cc b/tools/mhmake/src/flexskel.cc
deleted file mode 100644
index e83775372..000000000
--- a/tools/mhmake/src/flexskel.cc
+++ /dev/null
@@ -1,1053 +0,0 @@
-/* This file is part of mhmake.
- *
- * Copyright (C) 2001-2010 marha_at_sourceforge.net
- *
- * Mhmake 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.
- *
- * Mhmake 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 Mhmake. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-/* $Rev$ */
-
-/* A lexical scanner generated by flex */
-/* scanner skeleton version:
- * $Header: c:\\Program\040Files\\Development\\CVS\040Repository/flex++/flexskel.cc,v 1.1.1.1 2002/04/13 06:01:32 Bear Exp $
- */
-/* MODIFIED FOR C++ CLASS BY Alain Coetmeur: coetmeur(at)icdc.fr */
-/* Note that (at) mean the 'at' symbol that I cannot write */
-/* because it is expanded to the class name */
-/* made at Informatique-CDC, Research&development department */
-/* company from the Caisse Des Depots et Consignations */
-/* institutional financial group */
-
-/* theses symbols are added before this file */
-/* #define YY_CHAR 'unsigned char' if 8bit or 'char' if 7bit */
-/* #define FLEX_DEBUG if debug mode */
-#define FLEX_SCANNER
-/* cfront 1.2 defines "c_plusplus" instead of "__cplusplus" */
-#ifdef c_plusplus
-#ifndef __cplusplus
-#define __cplusplus
-#endif
-#endif
-/* Old MSC, before c7 */
-#ifdef MSDOS
-#ifndef _MSDOS
-#define _MSDOS
-#endif
-#endif
-/* turboc */
-#ifdef __MSDOS__
-#ifndef _MSDOS
-#define _MSDOS
-#endif
-#endif
-
-#ifdef __cplusplus
-#include <stdlib.h>
-#define YY_USE_CONST
-#define YY_USE_PROTOS
-#ifndef YY_USE_CLASS
-#define YY_USE_CLASS
-#endif
-#else /* ! __cplusplus */
-#ifdef __STDC__
-#ifdef __GNUC__
-#include <stddef.h>
-void *malloc( size_t );
-void free( void* );
-int read();
-#else
-#include <stdlib.h>
-#endif /* __GNUC__ */
-#define YY_USE_PROTOS
-#define YY_USE_CONST
-#endif /* __STDC__ */
-#endif /* ! __cplusplus */
-#ifdef __TURBOC__
-#define YY_USE_CONST
-#endif
-#include <stdio.h>
-
-
-/*********************************************/
-/* COMPILER DEPENDENT MACROS */
-/*********************************************/
-/* use prototypes in function declarations */
-/* the "const" storage-class-modifier is valid */
-#ifndef YY_USE_CONST
-#define const
-#endif
-/* use prototypes in function declarations */
-#ifndef YY_PROTO
-#ifdef YY_USE_PROTOS
-#define YY_PROTO(proto) proto
-#else
-#define YY_PROTO(proto) ()
-#endif
-#endif
-
-
-/*********************/
-/* parameters */
-
-/* amount of stuff to slurp up with each read */
-#ifndef YY_READ_BUF_SIZE
-#define YY_READ_BUF_SIZE 8192
-#endif
-/* size of default input buffer */
-#ifndef YY_BUF_SIZE
-#define YY_BUF_SIZE (YY_READ_BUF_SIZE * 2)
-#endif
-
-/***********************************/
-/* to be redefined for application */
-
-/* returned upon end-of-file */
-#define YY_END_TOK 0
-/* no semi-colon after return; correct usage is to write "yyterminate();" -
- * we don't want an extra ';' after the "return" because that will cause
- * some compilers to complain about unreachable statements.
- */
-#define yyterminate() return ( YY_NULL )
-
-/* code executed at the end of each rule */
-#define YY_BREAK break;
-
-/* #define YY_USER_ACTION */
-/* #define YY_USER_INIT */
-
-
-#ifndef YY_USE_CLASS
-/* copy whatever the last rule matched to the standard output */
-/* cast to (char *) is because for 8-bit chars, yy___text is (unsigned char *) */
-/* this used to be an fputs(), but since the string might contain NUL's,
- * we now use fwrite()
- */
-#define ECHO (void) fwrite( (char *) yy___text, yy___leng, 1, yy___out )
-
-/* gets input and stuffs it into "buf". number of characters read, or YY_NULL,
- * is returned in "result".
- */
-#ifdef _MSDOS
-#define YY_INPUT(buf,result,max_size) \
- if ( (result = fread(buf,1,max_size,yy___in)) < 0 ) \
- YY_FATAL_ERROR( "fread() in flex scanner failed" );
-#else
-#define YY_INPUT(buf,result,max_size) \
- if ( (result = read( fileno(yy___in), (char *) buf, max_size )) < 0 ) \
- YY_FATAL_ERROR( "read() in flex scanner failed" );
-
-#endif
-/* report a fatal error */
-
-/* The funky do-while is used to turn this macro definition into
- * a single C statement (which needs a semi-colon terminator).
- * This avoids problems with code like:
- *
- * if ( something_happens )
- * YY_FATAL_ERROR( "oops, the something happened" );
- * else
- * everything_okay();
- *
- * Prior to using the do-while the compiler would get upset at the
- * "else" because it interpreted the "if" statement as being all
- * done when it reached the ';' after the YY_FATAL_ERROR() call.
- */
-
-#define YY_FATAL_ERROR(msg) \
- do \
- { \
- (void) fputs( msg, yy___stderr ); \
- (void) putc( '\n', yy___stderr ); \
- exit( 1 ); \
- } \
- while ( 0 )
-
-/* default yywrap function - always treat EOF as an EOF */
-#define yywrap() 1
-
-
-/* default declaration of generated scanner - a define so the user can
- * easily add parameters
- */
-#define YY_DECL int yylex YY_PROTO(( void ))
-#else
-/* c++ */
-#define ECHO yy___echo()
-#define YY_INPUT(buf,result,max_size) \
- if ( yy___input((char *)buf, result,max_size) < 0 ) \
- YY_FATAL_ERROR( "YY_INPUT() in flex scanner failed" );
-
-#define YY_FATAL_ERROR(msg) yy___fatal_error(msg)
-#define yywrap() yy___wrap()
-
-#endif
-/***********************************/
-/* not to be changed */
-#define YY_NULL 0
-#define YY_END_OF_BUFFER_CHAR 0
-/* special action meaning "start processing a new file" */
-#define YY_NEW_FILE yy___newfile
-/* enter a start condition. This macro really ought to take a parameter,
- * but we do it the disgusting crufty way forced on us by the ()-less
- * definition of BEGIN
- */
-#define BEGIN yy_start = 1 + 2 *
-
-/* action number for EOF rule of a given start state */
-#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
-
-
-
-%% section 1 definitions go here
-
-#define yy___stderr YY_@_ERRFILE
-#define yy___text YY_@_TEXT
-#define yy___leng YY_@_LENG
-#define yy___in YY_@_IN
-#define yy___out YY_@_OUT
-#define yy___newfile \
- do \
- { \
- YY_@_INIT_BUFFER( YY_@_CURRENT_BUFFER, yy___in ); \
- YY_@_LOAD_BUFFER_STATE(); \
- } \
- while ( 0 )
-#if YY_@_DEBUG != 0
-#define yy___flex_debug YY_@_DEBUG_FLAG
-#endif
-
-
-#ifdef YY_USE_CLASS
-
-#define yy___echo YY_@_ECHO
-#define yy___input YY_@_INPUT
-#define yy___fatal_error YY_@_FATAL_ERROR
-#define yy___wrap YY_@_WRAP
-
-#endif
-
-/* done after the current pattern has been matched and before the
- * corresponding action - sets up yy___text
- */
-#define YY_DO_BEFORE_ACTION \
- yy___text = yy_bp; \
-%% code to fiddle yy___text and yy___leng for yymore() goes here
- yy_hold_char = *yy_cp; \
- *yy_cp = '\0'; \
- yy_c_buf_p = yy_cp;
-
-#define EOB_ACT_CONTINUE_SCAN 0
-#define EOB_ACT_END_OF_FILE 1
-#define EOB_ACT_LAST_MATCH 2
-
-/* return all but the first 'n' matched characters back to the input stream */
-#define yyless(n) \
- do \
- { \
- /* undo effects of setting up yy___text */ \
- *yy_cp = yy_hold_char; \
- yy_c_buf_p = yy_cp = yy_bp + n; \
- YY_DO_BEFORE_ACTION; /* set up yy___text again */ \
- } \
- while ( 0 )
-
-#define unput(c) yyunput( c, yy___text )
-
-
-
-struct yy_buffer_state
-{
- YY_@_IFILE *yy_input_file;
-
- YY_@_CHAR *yy_ch_buf; /* input buffer */
- YY_@_CHAR *yy_buf_pos; /* current position in input buffer */
-
- /* size of input buffer in bytes, not including room for EOB characters */
- int yy_buf_size;
-
- /* number of characters read into yy_ch_buf, not including EOB characters */
- size_t yy_n_chars;
-
- int yy_eof_status; /* whether we've seen an EOF on this buffer */
-#define EOF_NOT_SEEN 0
- /* "pending" happens when the EOF has been seen but there's still
- * some text process
- */
-#define EOF_PENDING 1
-#define EOF_DONE 2
- };
-
-/* we provide macros for accessing buffer states in case in the
- * future we want to put the buffer states in a more general
- * "scanner state"
- */
-
-#ifndef YY_USE_CLASS
-
-#if YY_@_DEBUG != 0
-int YY_@_DEBUG_FLAG=YY_@_DEBUG_INIT;
-#endif
-#define YY_CURRENT_BUFFER YY_@_CURRENT_BUFFER
-static YY_BUFFER_STATE YY_@_CURRENT_BUFFER;
-/* yy_hold_char holds the character lost when yy___text is formed */
-static YY_@_CHAR yy_hold_char;
-
-static int yy_n_chars; /* number of characters read into yy_ch_buf */
-
-/* GLOBAL */
-YY_@_CHAR *yy___text;
-size_t yy___leng;
-
-YY_@_IFILE *yy___in = (YY_@_IFILE *) 0;
-YY_@_OFILE *yy___out = (YY_@_OFILE *) 0;
-
-#ifdef __cplusplus
-static int yyinput YY_PROTO(( void ));
-#else
-static int input YY_PROTO(( void ));
-#endif
-/* these variables are all declared out here so that section 3 code can
- * manipulate them
- */
-/* points to current character in buffer */
-static YY_@_CHAR *yy_c_buf_p = (YY_@_CHAR *) 0;
-static int yy_init = 1; /* whether we need to initialize */
-static int yy_start = 0; /* start state number */
-
-/* flag which is used to allow yywrap()'s to do buffer switches
- * instead of setting up a fresh yy___in. A bit of a hack ...
- */
-static int yy_did_buffer_switch_on_eof;
-
-static int yy_get_next_buffer YY_PROTO(( void ));
-static void yyunput YY_PROTO(( YY_@_CHAR c, YY_@_CHAR *buf_ptr ));
-
-#else
-/* c++ */
-#ifndef YY_@_ECHO_NOCODE
-void YY_@_CLASS::yy___echo()
-{
- YY_@_ECHO_CODE
-}
-#endif
-#ifndef YY_@_INPUT_NOCODE
-size_t YY_@_CLASS::yy___input(char * buffer,size_t &result,size_t max_size)
-{
- YY_@_INPUT_CODE
-}
-#endif
-#ifndef YY_@_FATAL_ERROR_NOCODE
-void YY_@_CLASS::yy___fatal_error(const char *msg)
-{
- YY_@_FATAL_ERROR_CODE
-}
-#endif
-#ifndef YY_@_WRAP_NOCODE
-int YY_@_CLASS::yy___wrap()
-{
- YY_@_WRAP_CODE
-}
-#endif
-void YY_@_CLASS::yy_initialize()
-{
- yy___in=0;yy___out=0;yy_init = 1;
- yy_start=0;
- yy___text=0;yy___leng=0;
- YY_@_CURRENT_BUFFER=0;
- yy_did_buffer_switch_on_eof=0;
- yy_c_buf_p=0;yy_hold_char=0;yy_n_chars=0;
-#if YY_@_DEBUG != 0
- YY_@_DEBUG_FLAG=YY_@_DEBUG_INIT;
-#endif
-}
-
-YY_@_CLASS::YY_@_CLASS(YY_@_CONSTRUCTOR_PARAM) YY_@_CONSTRUCTOR_INIT
-{
- yy_initialize();
- YY_@_CONSTRUCTOR_CODE;
-}
-YY_@_CLASS::~YY_@_CLASS()
-{
- YY_@_DESTRUCTOR_CODE;
- if (YY_@_CURRENT_BUFFER)
- YY_@_DELETE_BUFFER(YY_@_CURRENT_BUFFER);
-}
-
-#endif
-
-
-#ifndef YY_USER_ACTION
-#define YY_USER_ACTION
-#endif
-
-#ifndef YY_USER_INIT
-#define YY_USER_INIT
-#endif
-
-%% data tables for the DFA go here
-#ifndef YY_USE_CLASS
-static yy_state_type yy_get_previous_state YY_PROTO(( void ));
-static yy_state_type yy_try_NUL_trans YY_PROTO(( yy_state_type current_state ));
-#else
-#define yy_get_previous_state() ((yy_state_type)(yy_get_previous_state_()))
-#define yy_try_NUL_trans(c) ((yy_state_type)(yy_try_NUL_trans_(c)))
-#endif
-
-#ifndef YY_USE_CLASS
-#ifdef YY_@_LEX_DEFINED
-YY_@_LEX_RETURN YY_@_LEX ( YY_@_LEX_PARAM )
-YY_@_LEX_PARAM_DEF
-#else
-YY_DECL
-#endif
-#else
-YY_@_LEX_RETURN YY_@_CLASS::YY_@_LEX ( YY_@_LEX_PARAM)
-
-#endif
-{
- register yy_state_type yy_current_state;
- register YY_@_CHAR *yy_cp, *yy_bp;
- register int yy_act;
-
-%% user's declarations go here
-
- if ( yy_init )
- {
-
- {
- YY_USER_INIT;
- }
- if ( ! yy_start )
- yy_start = 1; /* first start state */
-
- if ( ! yy___in )
- yy___in = YY_@_IFILE_DEFAULT;
-
- if ( ! yy___out )
- yy___out = YY_@_OFILE_DEFAULT;
-
- if ( YY_@_CURRENT_BUFFER )
- YY_@_INIT_BUFFER( YY_@_CURRENT_BUFFER, yy___in );
- else
- YY_@_CURRENT_BUFFER = YY_@_CREATE_BUFFER( yy___in, YY_BUF_SIZE );
-
- YY_@_LOAD_BUFFER_STATE();
- yy_init=0;
- }
-
- while ( 1 ) /* loops until end-of-file is reached */
- {
-%% yymore()-related code goes here
- yy_cp = yy_c_buf_p;
-
- /* support of yy___text */
- *yy_cp = yy_hold_char;
-
- /* yy_bp points to the position in yy_ch_buf of the start of the
- * current run.
- */
- yy_bp = yy_cp;
-
-%% code to set up and find next match goes here
-
-yy_find_action:
-%% code to find the action number goes here
-
- YY_DO_BEFORE_ACTION;
- YY_USER_ACTION;
-
-do_action: /* this label is used only to access EOF actions */
-#if YY_@_DEBUG != 0
- if ( yy___flex_debug )
- {
- if ( yy_act == 0 )
-#ifndef YY_@_IOSTREAM
- fprintf( yy___stderr , "--scanner backtracking\n" );
-#else
- yy___stderr <<"--scanner backtracking"<<endl;
-#endif
- else if ( yy_act < YY_END_OF_BUFFER -1 )
-#ifndef YY_@_IOSTREAM
- fprintf( yy___stderr ,
- "--accepting rule at line %d (\"%s\")\n",
- yy_rule_linenum[yy_act], yy___text );
-#else
- yy___stderr <<"--accepting rule at line "
- <<(int)yy_rule_linenum[yy_act]
- <<" (\""<<(char *)yy___text<<"\")"<<endl;
-#endif
- else if ( yy_act == YY_END_OF_BUFFER -1 )
-#ifndef YY_@_IOSTREAM
- fprintf( yy___stderr , "--accepting default rule (\"%s\")\n", yy___text );
-#else
- yy___stderr <<"--accepting default rule (\""<<(char *)yy___text<<"\")"<<endl;
-#endif
- else if ( yy_act == YY_END_OF_BUFFER )
-#ifndef YY_@_IOSTREAM
- fprintf( yy___stderr , "--(end of buffer or a NUL)\n" );
-#else
- yy___stderr <<"--(end of buffer or a NUL)"<<endl;
-#endif
- else
-#ifndef YY_@_IOSTREAM
- fprintf( yy___stderr , "--EOF\n" );
-#else
- yy___stderr <<"--EOF"<<endl;
-#endif
- }
-#endif
- switch ( yy_act )
- {
-%% actions go here
-
- case YY_END_OF_BUFFER:
- {
- /* amount of text matched not including the EOB char */
- int yy_amount_of_matched_text = (int)(yy_cp - yy___text - 1);
-
- /* undo the effects of YY_DO_BEFORE_ACTION */
- *yy_cp = yy_hold_char;
-
- /* note that here we test for yy_c_buf_p "<=" to the position
- * of the first EOB in the buffer, since yy_c_buf_p will
- * already have been incremented past the NUL character
- * (since all states make transitions on EOB to the end-
- * of-buffer state). Contrast this with the test in yyinput().
- */
- if ( yy_c_buf_p <= &YY_@_CURRENT_BUFFER->yy_ch_buf[yy_n_chars] )
- /* this was really a NUL */
- {
- yy_state_type yy_next_state;
-
- yy_c_buf_p = yy___text + yy_amount_of_matched_text;
-
- yy_current_state = yy_get_previous_state();
-
- /* okay, we're now positioned to make the
- * NUL transition. We couldn't have
- * yy_get_previous_state() go ahead and do it
- * for us because it doesn't know how to deal
- * with the possibility of jamming (and we
- * don't want to build jamming into it because
- * then it will run more slowly)
- */
-
- yy_next_state = yy_try_NUL_trans( yy_current_state );
-
- yy_bp = yy___text + YY_MORE_ADJ;
-
- if ( yy_next_state )
- {
- /* consume the NUL */
- yy_cp = ++yy_c_buf_p;
- yy_current_state = yy_next_state;
- goto yy_match;
- }
- else
- {
-%% code to do backtracking for compressed tables and set up yy_cp goes here
- goto yy_find_action;
- }
- }
- else switch ( yy_get_next_buffer() )
- {
- case EOB_ACT_END_OF_FILE:
- {
- yy_did_buffer_switch_on_eof = 0;
-
- if ( yywrap() )
- {
- /* note: because we've taken care in
- * yy_get_next_buffer() to have set up yy___text,
- * we can now set up yy_c_buf_p so that if some
- * total hoser (like flex itself) wants
- * to call the scanner after we return the
- * YY_NULL, it'll still work - another YY_NULL
- * will get returned.
- */
- yy_c_buf_p = yy___text + YY_MORE_ADJ;
-
- yy_act = YY_STATE_EOF((yy_start - 1) / 2);
- goto do_action;
- }
- else
- {
- if ( ! yy_did_buffer_switch_on_eof )
- YY_NEW_FILE;
- }
- }
- break;
-
- case EOB_ACT_CONTINUE_SCAN:
- yy_c_buf_p = yy___text + yy_amount_of_matched_text;
-
- yy_current_state = yy_get_previous_state();
-
- yy_cp = yy_c_buf_p;
- yy_bp = yy___text + YY_MORE_ADJ;
- goto yy_match;
-
- case EOB_ACT_LAST_MATCH:
- yy_c_buf_p = &YY_@_CURRENT_BUFFER->yy_ch_buf[yy_n_chars];
-
- yy_current_state = yy_get_previous_state();
-
- yy_cp = yy_c_buf_p;
- yy_bp = yy___text + YY_MORE_ADJ;
- goto yy_find_action;
- }
- break;
- }
-
- default:
-#if YY_@_DEBUG != 0
-#ifndef YY_@_IOSTREAM
- fprintf(yy___stderr , "action # %d\n", yy_act );
-#else
- yy___stderr <<"action # "<<(int)yy_act<<endl;
-#endif
-#endif
- YY_FATAL_ERROR("fatal flex scanner internal error--no action found" );
- }
- }
- yyterminate();/* avoid the no return value error message on MS-C7/dos */
-}
-
-
-/* yy_get_next_buffer - try to read in a new buffer
- *
- * synopsis
- * int yy_get_next_buffer();
- *
- * returns a code representing an action
- * EOB_ACT_LAST_MATCH -
- * EOB_ACT_CONTINUE_SCAN - continue scanning from current position
- * EOB_ACT_END_OF_FILE - end of file
- */
-#ifndef YY_USE_CLASS
-static int yy_get_next_buffer()
-#else
-int YY_@_CLASS::yy_get_next_buffer()
-#endif
-{
- register YY_@_CHAR *dest = YY_@_CURRENT_BUFFER->yy_ch_buf;
- register YY_@_CHAR *source = yy___text - 1; /* copy prev. char, too */
- register ptrdiff_t number_to_move, i;
- int ret_val;
-
- if ( yy_c_buf_p > &YY_@_CURRENT_BUFFER->yy_ch_buf[yy_n_chars + 1] )
- YY_FATAL_ERROR("fatal flex scanner internal error--end of buffer missed" );
-
- /* try to read more data */
-
- /* first move last chars to start of buffer */
- number_to_move = yy_c_buf_p - yy___text;
-
- for ( i = 0; i < number_to_move; ++i )
- *(dest++) = *(source++);
-
- if ( YY_@_CURRENT_BUFFER->yy_eof_status != EOF_NOT_SEEN )
- /* don't do the read, it's not guaranteed to return an EOF,
- * just force an EOF
- */
- yy_n_chars = 0;
-
- else
- {
- ptrdiff_t num_to_read = YY_@_CURRENT_BUFFER->yy_buf_size - number_to_move - 1;
-
- if ( num_to_read > YY_READ_BUF_SIZE )
- num_to_read = YY_READ_BUF_SIZE;
-
- else if ( num_to_read <= 0 )
- YY_FATAL_ERROR( "fatal error - scanner input buffer overflow" );
-
- /* read in more data */
- YY_INPUT( (&YY_@_CURRENT_BUFFER->yy_ch_buf[number_to_move]), yy_n_chars, num_to_read );
- }
-
- if ( yy_n_chars == 0 )
- {
- if ( number_to_move - YY_MORE_ADJ == 1 )
- {
- ret_val = EOB_ACT_END_OF_FILE;
- YY_@_CURRENT_BUFFER->yy_eof_status = EOF_DONE;
- }
- else
- {
- ret_val = EOB_ACT_LAST_MATCH;
- YY_@_CURRENT_BUFFER->yy_eof_status = EOF_PENDING;
- }
- }
- else
- ret_val = EOB_ACT_CONTINUE_SCAN;
-
- yy_n_chars += number_to_move;
- YY_@_CURRENT_BUFFER->yy_ch_buf[yy_n_chars] = YY_END_OF_BUFFER_CHAR;
- YY_@_CURRENT_BUFFER->yy_ch_buf[yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR;
-
- /* yy___text begins at the second character in yy_ch_buf; the first
- * character is the one which preceded it before reading in the latest
- * buffer; it needs to be kept around in case it's a newline, so
- * yy_get_previous_state() will have with '^' rules active
- */
-
- yy___text = &YY_@_CURRENT_BUFFER->yy_ch_buf[1];
-
- return ( ret_val );
-}
-
-
-/* yy_get_previous_state - get the state just before the EOB char was reached
- *
- * synopsis
- * yy_state_type yy_get_previous_state();
- */
-
-#ifndef YY_USE_CLASS
-static yy_state_type yy_get_previous_state()
-#else
-long YY_@_CLASS::yy_get_previous_state_()
-#endif
-{
- register yy_state_type yy_current_state;
- register YY_@_CHAR *yy_cp;
-
-%% code to get the start state into yy_current_state goes here
-
- for ( yy_cp = yy___text + YY_MORE_ADJ; yy_cp < yy_c_buf_p; ++yy_cp )
- {
-%% code to find the next state goes here
- }
-
-#ifndef YY_USE_CLASS
- return ( yy_current_state );
-#else
- return (long)( yy_current_state );
-#endif
-}
-
-
-/* yy_try_NUL_trans - try to make a transition on the NUL character
- *
- * synopsis
- * next_state = yy_try_NUL_trans( current_state );
- */
-
-#ifndef YY_USE_CLASS
-#ifdef YY_USE_PROTOS
-static yy_state_type yy_try_NUL_trans( register yy_state_type yy_current_state )
-#else
-static yy_state_type yy_try_NUL_trans( yy_current_state )
-register yy_state_type yy_current_state;
-#endif
-#else
-long YY_@_CLASS::yy_try_NUL_trans_(long yy_current_state_)
-#endif
-
-{
-#ifndef YY_USE_CLASS
-#else
- yy_state_type yy_current_state=(yy_state_type)yy_current_state_;
-#endif
- register int yy_is_jam;
-%% code to find the next state, and perhaps do backtracking, goes here
-
-#ifndef YY_USE_CLASS
- return ( yy_is_jam ? 0 : yy_current_state );
-#else
- return (long)( yy_is_jam ? 0 : yy_current_state );
-#endif
-}
-
-#ifndef YY_USE_CLASS
-#ifdef YY_USE_PROTOS
-static void yyunput( YY_@_CHAR c, register YY_@_CHAR *yy_bp )
-#else
-static void yyunput( c, yy_bp )
-YY_@_CHAR c;
-register YY_@_CHAR *yy_bp;
-#endif
-#else
-void YY_@_CLASS::yyunput( YY_@_CHAR c, YY_@_CHAR *yy_bp )
-#endif
-
-{
- register YY_@_CHAR *yy_cp = yy_c_buf_p;
-
- /* undo effects of setting up yy___text */
- *yy_cp = yy_hold_char;
-
- if ( yy_cp < YY_@_CURRENT_BUFFER->yy_ch_buf + 2 )
- { /* need to shift things up to make room */
- register ptrdiff_t number_to_move = yy_n_chars + 2; /* +2 for EOB chars */
- register YY_@_CHAR *dest = &YY_@_CURRENT_BUFFER->yy_ch_buf[YY_@_CURRENT_BUFFER->yy_buf_size + 2];
- register YY_@_CHAR *source = &YY_@_CURRENT_BUFFER->yy_ch_buf[number_to_move];
-
- while ( source > YY_@_CURRENT_BUFFER->yy_ch_buf )
- *--dest = *--source;
-
- yy_cp += dest - source;
- yy_bp += dest - source;
- yy_n_chars = YY_@_CURRENT_BUFFER->yy_buf_size;
-
- if ( yy_cp < YY_@_CURRENT_BUFFER->yy_ch_buf + 2 )
- YY_FATAL_ERROR( "flex scanner push-back overflow" );
- }
-
- *--yy_cp = c;
-
- /* note: the formal parameter *must* be called "yy_bp" for this
- * macro to now work correctly
- */
- YY_DO_BEFORE_ACTION; /* set up yy___text again */
-}
-
-#ifndef YY_USE_CLASS
-#ifdef __cplusplus
-static int yyinput()
-#else
-static int input()
-#endif
-#else
-int YY_@_CLASS::input()
-#endif
-{
- int c;
- YY_@_CHAR *yy_cp = yy_c_buf_p;
-
- *yy_cp = yy_hold_char;
-
- if ( *yy_c_buf_p == YY_END_OF_BUFFER_CHAR )
- {
- /* yy_c_buf_p now points to the character we want to return.
- * If this occurs *before* the EOB characters, then it's a
- * valid NUL; if not, then we've hit the end of the buffer.
- */
- if ( yy_c_buf_p < &YY_@_CURRENT_BUFFER->yy_ch_buf[yy_n_chars] )
- /* this was really a NUL */
- *yy_c_buf_p = '\0';
- else
- { /* need more input */
- yy___text = yy_c_buf_p;
- ++yy_c_buf_p;
-
- switch ( yy_get_next_buffer() )
- {
- case EOB_ACT_END_OF_FILE:
- {
- if ( yywrap() )
- {
- yy_c_buf_p = yy___text + YY_MORE_ADJ;
- return ( EOF );
- }
-
- YY_NEW_FILE;
-#ifndef YY_USE_CLASS
-#ifdef __cplusplus
- return ( yyinput() );
-#else
- return ( input() );
-#endif
-#else
- return ( input() );
-#endif
- }
- break;
-
- case EOB_ACT_CONTINUE_SCAN:
- yy_c_buf_p = yy___text + YY_MORE_ADJ;
- break;
-
- case EOB_ACT_LAST_MATCH:
-#ifndef YY_USE_CLASS
-#ifdef __cplusplus
- YY_FATAL_ERROR( "unexpected last match in yyinput()" );
-#else
- YY_FATAL_ERROR( "unexpected last match in input()" );
-#endif
-#else
- YY_FATAL_ERROR( "unexpected last match in YY_@_CLASS::input()" );
-#endif
- }
- }
- }
-
- c = *yy_c_buf_p;
- yy_hold_char = *++yy_c_buf_p;
-
- return ( c );
-}
-
-
-#ifndef YY_USE_CLASS
-#ifdef YY_USE_PROTOS
-void YY_@_RESTART( YY_@_IFILE *input_file )
-#else
-void YY_@_RESTART( input_file )
-YY_@_IFILE *input_file;
-#endif
-#else
-void YY_@_CLASS::YY_@_RESTART ( YY_@_IFILE *input_file )
-#endif
-
-{
- YY_@_INIT_BUFFER( YY_@_CURRENT_BUFFER, input_file );
- YY_@_LOAD_BUFFER_STATE();
-}
-
-
-#ifndef YY_USE_CLASS
-#ifdef YY_USE_PROTOS
-void YY_@_SWITCH_TO_BUFFER( YY_BUFFER_STATE new_buffer )
-#else
-void YY_@_SWITCH_TO_BUFFER( new_buffer )
-YY_BUFFER_STATE new_buffer;
-#endif
-#else
-void YY_@_CLASS::YY_@_SWITCH_TO_BUFFER( YY_BUFFER_STATE new_buffer )
-#endif
-
-{
- if ( YY_@_CURRENT_BUFFER == new_buffer )
- return;
-
- if ( YY_@_CURRENT_BUFFER )
- {
- /* flush out information for old buffer */
- *yy_c_buf_p = yy_hold_char;
- YY_@_CURRENT_BUFFER->yy_buf_pos = yy_c_buf_p;
- YY_@_CURRENT_BUFFER->yy_n_chars = yy_n_chars;
- }
-
- YY_@_CURRENT_BUFFER = new_buffer;
- YY_@_LOAD_BUFFER_STATE();
-
- /* we don't actually know whether we did this switch during
- * EOF (yywrap()) processing, but the only time this flag
- * is looked at is after yywrap() is called, so it's safe
- * to go ahead and always set it.
- */
- yy_did_buffer_switch_on_eof = 1;
-}
-
-
-#ifndef YY_USE_CLASS
-#ifdef YY_USE_PROTOS
-void YY_@_LOAD_BUFFER_STATE( void )
-#else
-void YY_@_LOAD_BUFFER_STATE()
-#endif
-#else
-void YY_@_CLASS::YY_@_LOAD_BUFFER_STATE( )
-#endif
-
-{
- yy_n_chars = YY_@_CURRENT_BUFFER->yy_n_chars;
- yy___text = yy_c_buf_p = YY_@_CURRENT_BUFFER->yy_buf_pos;
- yy___in = YY_@_CURRENT_BUFFER->yy_input_file;
- yy_hold_char = *yy_c_buf_p;
-}
-
-
-#ifndef YY_USE_CLASS
-#ifdef YY_USE_PROTOS
-YY_BUFFER_STATE YY_@_CREATE_BUFFER( YY_@_IFILE *file, int size )
-#else
-YY_BUFFER_STATE YY_@_CREATE_BUFFER( file, size )
-YY_@_IFILE *file;
-int size;
-#endif
-#else
-YY_BUFFER_STATE YY_@_CLASS::YY_@_CREATE_BUFFER( YY_@_IFILE *file, int size )
-#endif
-
-{
- YY_BUFFER_STATE b;
-
- b = (YY_BUFFER_STATE) malloc( sizeof( struct yy_buffer_state ) );
-
- if ( ! b )
- YY_FATAL_ERROR( "out of dynamic memory in YY_@_CREATE_BUFFER()" );
-
- b->yy_buf_size = size;
-
- /* yy_ch_buf has to be 2 characters longer than the size given because
- * we need to put in 2 end-of-buffer characters.
- */
- b->yy_ch_buf = (YY_@_CHAR *) malloc( (unsigned) (b->yy_buf_size + 2) );
-
- if ( ! b->yy_ch_buf )
- YY_FATAL_ERROR( "out of dynamic memory in YY_@_CREATE_BUFFER()" );
-
- YY_@_INIT_BUFFER( b, file );
-
- return ( b );
-}
-
-
-#ifndef YY_USE_CLASS
-#ifdef YY_USE_PROTOS
-void YY_@_DELETE_BUFFER( YY_BUFFER_STATE b )
-#else
-void YY_@_DELETE_BUFFER( b )
-YY_BUFFER_STATE b;
-#endif
-#else
-void YY_@_CLASS::YY_@_DELETE_BUFFER( YY_BUFFER_STATE b )
-#endif
-
-{
- if ( b == YY_@_CURRENT_BUFFER )
- YY_@_CURRENT_BUFFER = (YY_BUFFER_STATE) 0;
-
- free( (char *) b->yy_ch_buf );
- free( (char *) b );
-}
-
-
-#ifndef YY_USE_CLASS
-#ifdef YY_USE_PROTOS
-void YY_@_INIT_BUFFER( YY_BUFFER_STATE b, YY_@_IFILE *file )
-#else
-void YY_@_INIT_BUFFER( b, file )
-YY_BUFFER_STATE b;
-YY_@_IFILE *file;
-#endif
-#else
-void YY_@_CLASS::YY_@_INIT_BUFFER( YY_BUFFER_STATE b, YY_@_IFILE *file)
-#endif
-
-{
- b->yy_input_file = file;
-
- /* we put in the '\n' and start reading from [1] so that an
- * initial match-at-newline will be true.
- */
-
- b->yy_ch_buf[0] = '\n';
- b->yy_n_chars = 1;
-
- /* we always need two end-of-buffer characters. The first causes
- * a transition to the end-of-buffer state. The second causes
- * a jam in that state.
- */
- b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
- b->yy_ch_buf[2] = YY_END_OF_BUFFER_CHAR;
-
- b->yy_buf_pos = &b->yy_ch_buf[1];
-
- b->yy_eof_status = EOF_NOT_SEEN;
-}
-
diff --git a/tools/mhmake/src/flexskel.h b/tools/mhmake/src/flexskel.h
deleted file mode 100644
index 69d0eeeb4..000000000
--- a/tools/mhmake/src/flexskel.h
+++ /dev/null
@@ -1,395 +0,0 @@
-/* This file is part of mhmake.
- *
- * Copyright (C) 2001-2010 marha@sourceforge.net
- *
- * Mhmake 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.
- *
- * Mhmake 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 Mhmake. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-/* $Rev$ */
-
-/* A lexical scanner header generated by flex */
-/* MODIFIED FOR C++ CLASS BY Alain Coetmeur: coetmeur(at)icdc.fr */
-/* Note that (at) mean the 'at' symbol that I cannot write */
-/* because it is expanded to the class name */
-/* made at Informatique-CDC, Research&development department */
-/* company from the Caisse Des Depots et Consignations */
-
-
-/*********************************************/
-/* SYSTEM dependent declaration, includes... */
-/*********************************************/
-/* cfront 1.2 defines "c_plusplus" instead of "__cplusplus" */
-#ifdef c_plusplus
-#ifndef __cplusplus
-#define __cplusplus
-#endif
-#endif
-#ifdef __cplusplus
-#ifndef YY_USE_PROTOS
-#define YY_USE_PROTOS
-#endif
-#ifndef YY_USE_CLASS
-#define YY_USE_CLASS
-#endif
-#else /* ! __cplusplus */
-#ifdef __STDC__
-#ifdef __GNUC__
-#else
-#endif /* __GNUC__ */
-#ifndef YY_USE_PROTOS
-#define YY_USE_PROTOS
-#endif
-#endif /* __STDC__ */
-#endif /* ! __cplusplus */
-/*********************************************/
-/* COMPILER DEPENDENT MACROS */
-/*********************************************/
-/* use prototypes in function declarations */
-#ifndef YY_PROTO
-#ifdef YY_USE_PROTOS
-#define YY_PROTO(proto) proto
-#else
-#define YY_PROTO(proto) ()
-#endif
-#endif
-#include <stdio.h>
-
-
-
-
-%% here is the declaration from section1 %header{
-
-#ifdef YY_USE_CLASS
-#ifdef YY_@_IOSTREAM
-#include <iostream.h>
-#define YY_@_IFILE istream
-#define YY_@_OFILE ostream
-#define YY_@_ERRFILE cerr
-
-#ifndef YY_@_IFILE_DEFAULT
-#define YY_@_IFILE_DEFAULT &cin
-#endif
-
-#ifndef YY_@_OFILE_DEFAULT
-#define YY_@_OFILE_DEFAULT &cout
-#endif
-
-#endif
-#endif
-
-#ifndef YY_@_IFILE
-#define YY_@_IFILE FILE
-#endif
-
-#ifndef YY_@_OFILE
-#define YY_@_OFILE FILE
-#endif
-
-#ifndef YY_@_ERRFILE
-#define YY_@_ERRFILE stderr
-#endif
-
-#ifndef YY_@_IFILE_DEFAULT
-#define YY_@_IFILE_DEFAULT stdin
-#endif
-
-#ifndef YY_@_OFILE_DEFAULT
-#define YY_@_OFILE_DEFAULT stdout
-#endif
-
-
-
-
-#ifndef YY_@_TEXT
-#define YY_@_TEXT yytext
-#endif
-#ifndef YY_@_LENG
-#define YY_@_LENG yyleng
-#endif
-#ifndef YY_@_IN
-#define YY_@_IN yyin
-#endif
-#ifndef YY_@_OUT
-#define YY_@_OUT yyout
-#endif
-
-#ifndef YY_@_LEX_RETURN
-#define YY_@_LEX_RETURN int
-#else
-#ifndef YY_@_LEX_DEFINED
-#define YY_@_LEX_DEFINED
-#endif
-#endif
-
-#ifndef YY_@_LEX
-#define YY_@_LEX yylex
-#else
-#ifndef YY_@_LEX_DEFINED
-#define YY_@_LEX_DEFINED
-#endif
-#endif
-
-#ifndef YY_@_LEX_PARAM
-#ifndef YY_USE_PROTOS
-#define YY_@_LEX_PARAM
-#else
-#define YY_@_LEX_PARAM void
-#endif
-#else
-#ifndef YY_@_LEX_DEFINED
-#define YY_@_LEX_DEFINED
-#endif
-#endif
-
-#ifndef YY_@_LEX_PARAM_DEF
-#define YY_@_LEX_PARAM_DEF
-#else
-#ifndef YY_@_LEX_DEFINED
-#define YY_@_LEX_DEFINED
-#endif
-#endif
-
-#ifndef YY_@_RESTART
-#define YY_@_RESTART yyrestart
-#endif
-#ifndef YY_@_SWITCH_TO_BUFFER
-#define YY_@_SWITCH_TO_BUFFER yy_switch_to_buffer
-#endif
-#ifndef YY_@_LOAD_BUFFER_STATE
-#define YY_@_LOAD_BUFFER_STATE yy_load_buffer_state
-#endif
-
-#ifndef YY_@_CREATE_BUFFER
-#define YY_@_CREATE_BUFFER yy_create_buffer
-#ifndef YY_USE_CLASS
-#ifndef yy_new_buffer
-#define yy_new_buffer yy_create_buffer
-#endif
-#endif
-#endif
-#ifndef YY_@_DELETE_BUFFER
-#define YY_@_DELETE_BUFFER yy_delete_buffer
-#endif
-#ifndef YY_@_INIT_BUFFER
-#define YY_@_INIT_BUFFER yy_init_buffer
-#endif
-
-
-
-#ifdef YY_@_FLEX_DEBUG
-#ifndef YY_@_DEBUG
-#define YY_@_DEBUG 1
-#endif
-#else
-#ifndef YY_@_DEBUG
-#define YY_@_DEBUG 0
-#endif
-#endif
-
-#if YY_@_DEBUG != 0
-#ifndef YY_@_DEBUG_FLAG
-#define YY_@_DEBUG_FLAG yy_flex_debug
-#endif
-#ifndef YY_@_DEBUG_INIT
-#define YY_@_DEBUG_INIT 1
-#endif
-#endif
-
-
-
-
-#ifndef YY_USE_CLASS
-#ifndef YY_@_CURRENT_BUFFER
-#define YY_@_CURRENT_BUFFER yy_current_buffer
-#endif
-typedef struct yy_buffer_state *YY_BUFFER_STATE;
-
-extern void YY_@_RESTART YY_PROTO(( YY_@_IFILE *input_file ));
-extern void YY_@_SWITCH_TO_BUFFER YY_PROTO(( YY_BUFFER_STATE new_buffer ));
-extern void YY_@_LOAD_BUFFER_STATE YY_PROTO(( void ));
-extern YY_BUFFER_STATE YY_@_CREATE_BUFFER YY_PROTO(( YY_@_IFILE *file, int size ));
-extern void YY_@_DELETE_BUFFER YY_PROTO(( YY_BUFFER_STATE b ));
-extern void YY_@_INIT_BUFFER YY_PROTO(( YY_BUFFER_STATE b, YY_@_IFILE *file ));
-
-#if YY_@_DEBUG != 0
-extern int YY_@_DEBUG_FLAG ;
-#endif
-extern YY_@_CHAR *YY_@_TEXT;
-extern int YY_@_LENG;
-extern YY_@_IFILE *YY_@_IN;
-extern YY_@_OFILE *YY_@_OUT;
-#ifdef YY_@_LEX_DEFINED
-extern YY_@_LEX_RETURN YY_@_LEX ( YY_@_LEX_PARAM )
-YY_@_LEX_PARAM_DEF
-#else
-#ifndef YY_DECL
-extern YY_@_LEX_RETURN YY_@_LEX ( YY_@_LEX_PARAM )
-YY_@_LEX_PARAM_DEF
-#else
-/* no declaration if oldstyle flex */
-#endif
-#endif
-#else
-
-#ifndef YY_@_CURRENT_BUFFER
-#define YY_@_CURRENT_BUFFER YY_CURRENT_BUFFER
-#endif
-#ifndef YY_@_CLASS
-#define YY_@_CLASS @
-#endif
-#ifndef YY_@_ECHO
-#define YY_@_ECHO yy_echo
-#endif
-#ifdef YY_@_ECHO_PURE
-#define YY_@_ECHO_NOCODE
-#endif
-
-#ifndef YY_@_ECHO_CODE
-#ifndef YY_@_IOSTREAM
-#define YY_@_ECHO_CODE fwrite( (char *) YY_@_TEXT, YY_@_LENG, 1, YY_@_OUT );
-#else
-#define YY_@_ECHO_CODE (YY_@_OUT->write( (char *) YY_@_TEXT, YY_@_LENG));
-#endif
-#endif
-
-#ifndef YY_@_INPUT
-#define YY_@_INPUT yy_input
-#endif
-#ifdef YY_@_INPUT_PURE
-#define YY_@_INPUT_NOCODE
-#endif
-
-#ifndef YY_@_INPUT_CODE
-#ifndef YY_@_IOSTREAM
-#define YY_@_INPUT_CODE return result= ::fread( buffer, 1,max_size,YY_@_IN );
-#else
-#define YY_@_INPUT_CODE if(YY_@_IN->eof()) result=0;else {YY_@_IN->read(buffer,max_size);result=YY_@_IN->gcount();YY_@_IN->clear(YY_@_IN->rdstate()&(~ios::failbit));if(YY_@_IN->bad()) result= -1;} return result;
-#endif
-#endif
-
-#ifdef YY_@_FATAL_ERROR_PURE
-#define YY_@_FATAL_ERRO_NOCODE
-#endif
-#ifndef YY_@_FATAL_ERROR
-#define YY_@_FATAL_ERROR yy_fatal_error
-#endif
-
-#ifndef YY_@_FATAL_ERROR_CODE
-#ifndef YY_@_IOSTREAM
-#define YY_@_FATAL_ERROR_CODE fputs( msg, YY_@_ERRFILE );putc( '\n', YY_@_ERRFILE );exit( 1 );
-#else
-#define YY_@_FATAL_ERROR_CODE YY_@_ERRFILE<< msg <<endl;exit( 1 );
-#endif
-#endif
-
-#ifndef YY_@_WRAP
-#define YY_@_WRAP yy_wrap
-#endif
-#ifdef YY_@_WRAP_PURE
-#define YY_@_WRAP_NOCODE
-#endif
-#ifndef YY_@_WRAP_CODE
-#define YY_@_WRAP_CODE return 1;
-#endif
-
-
-#ifndef YY_@_INHERIT
-#define YY_@_INHERIT
-#endif
-#ifndef YY_@_MEMBERS
-#define YY_@_MEMBERS
-#endif
-#ifndef YY_@_CONSTRUCTOR_PARAM
-#define YY_@_CONSTRUCTOR_PARAM
-#endif
-#ifndef YY_@_CONSTRUCTOR_CODE
-#define YY_@_CONSTRUCTOR_CODE
-#endif
-#ifndef YY_@_CONSTRUCTOR_INIT
-#define YY_@_CONSTRUCTOR_INIT
-#endif
-#ifndef YY_@_DESTRUCTOR_CODE
-#define YY_@_DESTRUCTOR_CODE
-#endif
-typedef struct yy_buffer_state *YY_BUFFER_STATE;
-
-class YY_@_CLASS YY_@_INHERIT
-{
-private:/* data */
- YY_@_CHAR *yy_c_buf_p;
- YY_@_CHAR yy_hold_char;
- size_t yy_n_chars;
- int yy_init;
- int yy_start;
- int yy_did_buffer_switch_on_eof;
-private: /* functions */
- void yy_initialize();
- int input();
- int yyinput() {return input();};
- int yy_get_next_buffer();
- void yyunput( YY_@_CHAR c, YY_@_CHAR *buf_ptr );
- /* use long instead of yy_state_type because it is undef */
- long yy_get_previous_state_ ( void );
- long yy_try_NUL_trans_ ( long current_state_ );
-protected:/* non virtual */
- YY_BUFFER_STATE YY_@_CURRENT_BUFFER;
- void YY_@_RESTART ( YY_@_IFILE *input_file );
- void YY_@_SWITCH_TO_BUFFER( YY_BUFFER_STATE new_buffer );
- void YY_@_LOAD_BUFFER_STATE( void );
- YY_BUFFER_STATE YY_@_CREATE_BUFFER( YY_@_IFILE *file, int size );
- void YY_@_DELETE_BUFFER( YY_BUFFER_STATE b );
- void YY_@_INIT_BUFFER( YY_BUFFER_STATE b, YY_@_IFILE *file );
- protected: /* virtual */
- virtual void YY_@_ECHO()
-#ifdef YY_@_ECHO_PURE
- =0
-#endif
- ;
- virtual size_t YY_@_INPUT(char *buf,size_t &result,size_t max_size)
-#ifdef YY_@_INPUT_PURE
- =0
-#endif
- ;
- virtual void YY_@_FATAL_ERROR(const char *msg)
-#ifdef YY_@_FATAL_ERROR_PURE
- =0
-#endif
- ;
- virtual int YY_@_WRAP()
-#ifdef YY_@_WRAP_PURE
- =0
-#endif
- ;
-public:
- YY_@_CHAR *YY_@_TEXT;
- size_t YY_@_LENG;
- YY_@_IFILE *YY_@_IN;
- YY_@_OFILE *YY_@_OUT;
- YY_@_LEX_RETURN YY_@_LEX ( YY_@_LEX_PARAM);
- YY_@_CLASS(YY_@_CONSTRUCTOR_PARAM) ;
- virtual ~YY_@_CLASS() ;
-#if YY_@_DEBUG != 0
- int YY_@_DEBUG_FLAG;
-#endif
-public: /* added members */
- YY_@_MEMBERS
-};
-#endif
-
-/* declaration of externs for public use of yylex scanner */
-
-%% here is the declaration from section2 %header{
-
-/* end of generated header */
-
diff --git a/tools/mhmake/src/functions.cpp b/tools/mhmake/src/functions.cpp
index 97dc99c01..1602112c3 100644
--- a/tools/mhmake/src/functions.cpp
+++ b/tools/mhmake/src/functions.cpp
@@ -525,7 +525,7 @@ string mhmakefileparser::f_addprefix(const string & Arg) const
string PreFix;
pTmp=NextCharItem(pTmp,PreFix,',');
#ifdef _DEBUG
- if (!*pTmp) {
+ if (PreFix.empty()) {
throw ("Wrong number of arguments in function addprefix");
}
#endif
diff --git a/tools/mhmake/src/mhmakefileparser.cpp b/tools/mhmake/src/mhmakefileparser.cpp
index 3d074e801..a2d4537a0 100644
--- a/tools/mhmake/src/mhmakefileparser.cpp
+++ b/tools/mhmake/src/mhmakefileparser.cpp
@@ -24,14 +24,14 @@
#include "mhmakefileparser.h"
#include "rule.h"
-#include "mhmakelexer.h"
+#include "flexlexer.h"
commandqueue mhmakefileparser::sm_CommandQueue;
///////////////////////////////////////////////////////////////////////////////
int mhmakefileparser::yylex(void)
{
- m_yyloc=m_ptheLexer->m_Line;
+ m_yyloc=m_ptheLexer->lineno();
return m_ptheLexer->yylex(m_theTokenValue);
}
@@ -44,23 +44,24 @@ void mhmakefileparser::yyerror(const char *m)
///////////////////////////////////////////////////////////////////////////////
int mhmakefileparser::ParseFile(const fileinfo *pFileInfo, const fileinfo *pMakeDir)
{
- mhmakelexer theLexer;
- m_ptheLexer=&theLexer;
if (pMakeDir)
{
m_MakeDir=pMakeDir;
m_Variables[CURDIR]=m_MakeDir->GetQuotedFullFileName();
}
- theLexer.m_InputFileName=pFileInfo->GetFullFileName();
- theLexer.m_pParser=(mhmakeparser*)this;
- theLexer.yyin=::fopen(pFileInfo->GetFullFileName().c_str(),"r");
- if (!theLexer.yyin)
+
+ ifstream yyin(pFileInfo->GetFullFileName().c_str(),ios_base::in);
+ if (yyin.fail())
{
cerr << "Error opening makefile: "<<pFileInfo->GetQuotedFullFileName()<<endl;
return 1;
}
+
+ mhmakeFlexLexer theLexer(&yyin);
+ m_ptheLexer=&theLexer;
+ theLexer.m_InputFileName=pFileInfo->GetFullFileName();
+ theLexer.m_pParser=(mhmakeparser*)this;
int Ret=yyparse();
- ::fclose(theLexer.yyin);
return Ret;
}
@@ -169,7 +170,21 @@ bool mhmakefileparser::IsEqual(const string &EqualExpr) const
///////////////////////////////////////////////////////////////////////////////
string mhmakefileparser::ExpandExpression(const string &Expr) const
{
- ((mhmakefileparser*)this)->m_InExpandExpression++;
+ bool Recurse;
+ string Ret(Expr);
+ do
+ {
+ Recurse=false;
+ Ret=ExpandExpressionRecurse(Ret,Recurse);
+ }
+ while (Recurse);
+ return Ret;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+string mhmakefileparser::ExpandExpressionRecurse(const string &Expr, bool &Recurse) const
+{
+ //((mhmakefileparser*)this)->m_InExpandExpression++;
size_t i=0;
size_t Length=Expr.size();
string Ret;
@@ -182,7 +197,7 @@ string mhmakefileparser::ExpandExpression(const string &Expr) const
char CharNext=Expr[i];
if (CharNext=='$')
{
- ToAdd="$$";
+ ToAdd="$";
i++;
}
else
@@ -191,13 +206,13 @@ string mhmakefileparser::ExpandExpression(const string &Expr) const
i++;
if (inew>i)
{
- ToAdd=ExpandMacro(Expr.substr(i,inew-i-1));
+ ToAdd=ExpandMacro(Expr.substr(i,inew-i-1),Recurse);
i=inew;
}
else
{
// This is a single character expression
- ToAdd=ExpandMacro(string(1,Expr[i-1]));
+ ToAdd=ExpandMacro(string(1,Expr[i-1]),Recurse);
}
}
Ret+=ToAdd;
@@ -207,28 +222,14 @@ string mhmakefileparser::ExpandExpression(const string &Expr) const
Ret+=Char;
}
}
- if (m_InExpandExpression==1)
- {
- // Here we do a special case in case we still have a $ within a %
- if (Ret.find('$')!=string::npos)
- Ret=ExpandExpression(Ret);
- size_t Pos;
- while ((Pos=Ret.find("$$"))!=string::npos)
- {
- Ret=Ret.replace(Pos,2,"$");
- }
- }
- ((mhmakefileparser*)this)->m_InExpandExpression--;
return Ret;
}
///////////////////////////////////////////////////////////////////////////////
-string mhmakefileparser::ExpandMacro(const string &Expr) const
+string mhmakefileparser::ExpandMacro(const string &Expr, bool &Recurse) const
{
- if (Expr.find('%')!=string::npos && Expr.find('$')==string::npos && Expr.find(':')==string::npos)
- return string("$(")+Expr+")";
- string ExpandedExpr=ExpandExpression(Expr);
+ string ExpandedExpr=ExpandExpressionRecurse(Expr,Recurse);
const char *pTmp=ExpandedExpr.c_str();
/* First remove leading spaces */
@@ -272,8 +273,17 @@ string mhmakefileparser::ExpandMacro(const string &Expr) const
{
string Func(pVar,pVarEnd);
string Arg(pTmp);
- if (Arg.find('%')!=string::npos && Arg.find('$')!=string::npos)
- return string("$(")+ExpandedExpr+")";
+ if (Recurse)
+ {
+ #ifdef _DEBUG
+ if (!(Arg.find('%')!=string::npos && Arg.find('$')!=string::npos))
+ throw(string("Bug in mhmake: expected a % and $ sign: ")+Arg);
+ #endif
+ return string("$(")+ExpandedExpr+")"; // we cannot call the function yet since there is still a $(*%*) macro to resolve. so
+ // return it a a macro again so it can be resolved when the % is resolved
+ // remark that the current test is not completely safe because the % could be out of
+ // the $ macro
+ }
function_f pFunc=m_Functions[Func];
#ifdef _DEBUG
if (pFunc)
@@ -299,9 +309,23 @@ string mhmakefileparser::ExpandMacro(const string &Expr) const
}
else
{
+ if (ExpandedExpr.find('%')!=string::npos)
+ {
+ // we have encountered a *%* macro. This means a previous subst is not yet finished. so return
+ // it back as a macro so it can be expanded again later when the % is replaced
+ Recurse=true;
+ return string("$(")+ExpandedExpr+")";
+ }
+ #ifdef _DEBUG
+ else if (ExpandedExpr.find('$')!=string::npos)
+ throw(string("Bug in mhmake: wasn't expecting a $ sign in: ")+ExpandedExpr);
+ #endif
+ else
+ {
return ExpandExpression(ExpandVar(ExpandedExpr));
}
}
+}
///////////////////////////////////////////////////////////////////////////////
string mhmakefileparser::ExpandVar(const string &Var) const
diff --git a/tools/mhmake/src/mhmakefileparser.h b/tools/mhmake/src/mhmakefileparser.h
index 8bc0adbe9..6bdaa911d 100644
--- a/tools/mhmake/src/mhmakefileparser.h
+++ b/tools/mhmake/src/mhmakefileparser.h
@@ -27,7 +27,7 @@
class rule;
-class mhmakelexer;
+class mhmakeFlexLexer;
struct TOKENVALUE
{
@@ -58,13 +58,12 @@ class mhmakefileparser : public refbase
private:
static commandqueue sm_CommandQueue;
- mhmakelexer *m_ptheLexer;
+ mhmakeFlexLexer *m_ptheLexer;
int m_yyloc;
fileinfo *m_RuleThatIsBuild;
vector<string> m_ToBeIncludeAfterBuild;
vector<string> m_MakefilesToLoad;
fileinfo* m_AutoDepFileLoaded;
- int m_InExpandExpression;
mh_time_t m_Date;
uint32 m_EnvMd5_32; /* Cached Md5_32 value of the userd environment variables */
#ifdef _DEBUG
@@ -118,7 +117,6 @@ public:
mhmakefileparser(const map<string,string> &CommandLineVars)
: m_CommandLineVars(CommandLineVars)
- ,m_InExpandExpression(0)
,m_AutoDepsDirty(false)
,m_ForceAutoDepRescan(false)
,m_SkipHeadersInitialized(false)
@@ -126,6 +124,8 @@ public:
,m_EnvMd5_32(0)
,m_pEnv(NULL)
,m_FirstTarget(NULL)
+ ,m_RuleThatIsBuild(NULL)
+ ,m_AutoDepFileLoaded(NULL)
#ifdef _DEBUG
,m_ImplicitSearch(0)
#endif
@@ -216,7 +216,7 @@ public:
bool SkipHeaderFile(const string &FileName);
void InitEnv() const;
- virtual ~mhmakefileparser()
+ virtual ~mhmakefileparser() /* virtual to be sure the correct destructor is called when we delete with a pointer to this class which in reality is a pointer to a derived class */
{
SaveAutoDepsFile();
#ifndef WIN32
@@ -240,7 +240,8 @@ public:
bool IsEqual(const string &EqualExpr) const;
bool IsExprTrue(const string &EqualExpr) const;
string ExpandExpression(const string &Expr) const;
- string ExpandMacro(const string &Expr) const;
+ string ExpandExpressionRecurse(const string &Expr, bool &Recurse) const;
+ string ExpandMacro(const string &Expr, bool &Recurse) const;
string ExpandVar(const string &Var) const;
void PrintVariables(bool Expand=false) const;
diff --git a/tools/mhmake/src/mhmakelexer.l b/tools/mhmake/src/mhmakelexer.l
index 62df687e1..8cf0f1680 100644
--- a/tools/mhmake/src/mhmakelexer.l
+++ b/tools/mhmake/src/mhmakelexer.l
@@ -19,9 +19,8 @@
/* $Rev$ */
/* -------------- declaration section -------------- */
-%name mhmakelexer
-%header{
-#include "mhmakeparser.h"
+%{
+
#include "fileinfo.h"
#include "rule.h"
#include "util.h"
@@ -53,51 +52,59 @@ static void SaveMakMd5(fileinfo *pTarget)
fclose(pFile);
}
-%}
-
-%define LEX_PARAM TOKENVALUE &theValue
-%define MEMBERS public: \
- struct INSTACK\
- {\
- YY_BUFFER_STATE m_BufferState;\
- string m_FileName;\
- int m_Line;\
- INSTACK(YY_BUFFER_STATE BufferState,string FileName,int Line) :\
- m_BufferState(BufferState),m_FileName(FileName),m_Line(Line) {}\
- };\
- int m_Line;\
- int m_BraceIndent;\
- size_t m_IndentSkip;\
- iterstack<int> m_IndentStack;\
- bool m_IgnoreIncludeError;\
- string m_InputFileName; \
- string m_curtoken; \
- iterstack<INSTACK> m_IncludeStack; \
- mhmakeparser *m_pParser;\
- mhmakeparser *GetParser()\
- {\
- return m_pParser;\
+static void ReplaceCurlyBraces(string &String)
+{
+ int Pos=String.find_first_of('{',0);
+ if (Pos!=string::npos)
+ {
+ /* if not { found, } will not be there eather (or it is a valid syntax, so it may generate an error) */
+ do
+ {
+ String.replace(Pos,1,1,'(');
+ Pos=String.find_first_of('{',Pos);
+ }
+ while (Pos!=string::npos);
+ Pos=0;
+ while ((Pos=String.find_first_of('}',Pos))!=string::npos)
+ String.replace(Pos,1,1,')');
}
+}
-%define CONSTRUCTOR_INIT : m_Line(1), m_BraceIndent(0)
+#define YY_DECL int mhmakeFlexLexer::yylex(TOKENVALUE &theValue)
+
+%}
+
+%option prefix="mhmake"
+%option never-interactive
+%option 8bit
+%option c++
+%option full
+%option noyywrap
+%option warn
/* -------------- rules section -------------- */
%x INCLUDE IFDEF IF IFNDEF SKIPUNTILELSEORENDIF QUOTE MAKEEXPRES SINGLEQUOTE COMMANDPARSE
-%x IFEQ IFNEQ ERRORMACRO MESSAGEMACRO MESSAGEINFO MESSAGEERROR REPARSEMACRO LOAD_MAKEFILE
+%x IFEQ IFNEQ ERRORMACRO MESSAGEMACRO REPARSEMACRO LOAD_MAKEFILE
+%x DEFINE
%%
/*---------------------------------------------------------------------------*/
-[ \t\r]*\n/[ ][ \t]* |
+[ \t\r]*\n[ ][ \t]* {
+ yy_set_bol(1); // Make sure the next rule also matches the ^
+ yylineno++;
+ return mhmakeparser::NEWLINE;
+}
+
[ \t\r]*\n {
- PRINTF(("%s %d: NEWLINE:\n",m_InputFileName.c_str(),m_Line));
- m_Line++;
+ PRINTF(("%s %d: NEWLINE:\n",m_InputFileName.c_str(),yylineno));
+ yylineno++;
return mhmakeparser::NEWLINE;
}
/*---------------------------------------------------------------------------*/
-^[ \t]*[s\-]?include {
- PRINTF(("%s %d: INCLUDE: ",m_InputFileName.c_str(),m_Line));
+^[s\-]?include {
+ PRINTF(("%s %d: INCLUDE: ",m_InputFileName.c_str(),yylineno));
BEGIN(INCLUDE);
unsigned i=0;
while (strchr(" \t",yytext[i])) i++;
@@ -114,7 +121,10 @@ static void SaveMakMd5(fileinfo *pTarget)
<INCLUDE>[^\r\n]+ { /* got the include file name */
mhmakeparser *pParser=GetParser();
- string IncludeFileNames=pParser->ExpandExpression((const char*)yytext);
+ /* replace the {} by () before expanding */
+ string IncludeFileNames(yytext);
+ ReplaceCurlyBraces(IncludeFileNames);
+ IncludeFileNames=pParser->ExpandExpression(IncludeFileNames);
PRINTF(("%s -> %s\n",yytext,IncludeFileNames.c_str()));
const char *pTmp=IncludeFileNames.c_str();
@@ -138,31 +148,34 @@ static void SaveMakMd5(fileinfo *pTarget)
pParser->AddIncludedMakefile(pInclude);
string strToInclude=pInclude->GetFullFileName();
- FILE *pTmp = ::fopen(strToInclude.c_str(), "r" );
- if ( ! pTmp )
+ INSTACK *pStackElem=new INSTACK(YY_CURRENT_BUFFER, strToInclude, m_InputFileName, yylineno);
+ if ( pStackElem->fail() )
{
+ delete pStackElem;
if (!m_IgnoreIncludeError)
{
- iterstack<INSTACK>::reverse_iterator StackIt=m_IncludeStack.rbegin();
+ mystack::reverse_iterator StackIt=m_IncludeStack.rbegin();
while (StackIt!=m_IncludeStack.rend())
{
- cout<<" in "<<StackIt->m_FileName<<" ("<<StackIt->m_Line<<")";
+ cout<<" in "<<(*StackIt)->m_FileName<<" ("<<(*StackIt)->yylineno<<")";
StackIt++;
}
cout<<endl;
- cout<<"Warning error opening file "<<strToInclude<<" in "<<m_InputFileName<<" ("<<m_Line<<")\n";
+ cout<<"Warning error opening file "<<strToInclude<<" in "<<m_InputFileName<<" ("<<yylineno<<")\n";
pParser->IncludeAfterBuild(strToInclude);
}
+ else
+ pInclude->SetPhony(); /* To be sure that no message is printed when mhmake is trying to build the file later */
}
else
{
- m_IncludeStack.push(INSTACK(YY_mhmakelexer_CURRENT_BUFFER,m_InputFileName,m_Line));
- m_Line=1;
+ m_IncludeStack.push(pStackElem);
+ yylineno=1;
- yyin=pTmp;
m_InputFileName=strToInclude;
- YY_mhmakelexer_SWITCH_TO_BUFFER(YY_mhmakelexer_CREATE_BUFFER( yyin, YY_BUF_SIZE ) );
+ yypush_buffer_state(yy_create_buffer( pStackElem->GetStream(), YY_BUF_SIZE ));
+ yyrestart(pStackElem->GetStream());
}
}
@@ -173,15 +186,17 @@ static void SaveMakMd5(fileinfo *pTarget)
/*---------------------------------------------------------------------------*/
load_makefile {
- PRINTF(("%s %d: LOAD_MAKEFILE:\n",m_InputFileName.c_str(),m_Line));
+ PRINTF(("%s %d: LOAD_MAKEFILE:\n",m_InputFileName.c_str(),yylineno));
BEGIN(LOAD_MAKEFILE);
return mhmakeparser::NEWLINE; // Return a newline to be sure that the previous line is completely parse by yacc (in case it is a variable definition)
}
/*****************************************************************************/
<LOAD_MAKEFILE>[^\r\n]+ {
- string ListOfMakefiles=GetParser()->ExpandExpression((const char*)yytext);
- PRINTF(("%s %d: LOAD_MAKEFILE: '%s'\n",m_InputFileName.c_str(),m_Line,ListOfMakefiles.c_str()));
+ string ListOfMakefiles((const char*)yytext);
+ ReplaceCurlyBraces(ListOfMakefiles);
+ ListOfMakefiles=GetParser()->ExpandExpression(ListOfMakefiles);
+ PRINTF(("%s %d: LOAD_MAKEFILE: '%s'\n",m_InputFileName.c_str(),yylineno,ListOfMakefiles.c_str()));
const char *pTmp=ListOfMakefiles.c_str();
while (*pTmp)
@@ -190,7 +205,7 @@ load_makefile {
pTmp=NextCharItem(pTmp,Item,';');
if (Item.empty())
{
- throw m_InputFileName + "(" + stringify(m_Line) + "): Error in load_makefile statement";
+ throw m_InputFileName + "(" + stringify(yylineno) + "): Error in load_makefile statement";
}
GetParser()->AddMakefileToMakefilesToLoad(Item);
}
@@ -198,78 +213,78 @@ load_makefile {
}
/*---------------------------------------------------------------------------*/
<LOAD_MAKEFILE>\r?\n {
- m_Line++;
+ yylineno++;
BEGIN(INITIAL);
return mhmakeparser::NEWLINE;
}
/*---------------------------------------------------------------------------*/
[ \t]+ {
- PRINTF(("%s %d: SPACE:\n",m_InputFileName.c_str(),m_Line));
+ PRINTF(("%s %d: SPACE:\n",m_InputFileName.c_str(),yylineno));
return mhmakeparser::SPACE;
}
/*---------------------------------------------------------------------------*/
[ \t]*=[ \t]*\\[ \t\r]*\n[ \t]* {
- PRINTF(("%s %d: EQUAL: %s\n",m_InputFileName.c_str(),m_Line,yytext));
- m_Line++;
+ PRINTF(("%s %d: EQUAL: %s\n",m_InputFileName.c_str(),yylineno,yytext));
+ yylineno++;
theValue.theString=(const char *)yytext;
return mhmakeparser::EQUAL;
}
[ \t]*=[ \t]* {
- PRINTF(("%s %d: EQUAL: %s\n",m_InputFileName.c_str(),m_Line,yytext));
+ PRINTF(("%s %d: EQUAL: %s\n",m_InputFileName.c_str(),yylineno,yytext));
theValue.theString=(const char *)yytext;
return mhmakeparser::EQUAL;
}
/*---------------------------------------------------------------------------*/
[ \t]*:=[ \t]*\\[ \t\r]*\n[ \t]* {
- m_Line++;
- PRINTF(("%s %d: IMEQUAL: %s\n",m_InputFileName.c_str(),m_Line,yytext));
+ yylineno++;
+ PRINTF(("%s %d: IMEQUAL: %s\n",m_InputFileName.c_str(),yylineno,yytext));
return mhmakeparser::IMEQUAL;
}
[ \t]*:=[ \t]* {
- PRINTF(("%s %d: IMEQUAL: %s\n",m_InputFileName.c_str(),m_Line,yytext));
+ PRINTF(("%s %d: IMEQUAL: %s\n",m_InputFileName.c_str(),yylineno,yytext));
return mhmakeparser::IMEQUAL;
}
/*---------------------------------------------------------------------------*/
[ \t]*\?=[ \t]*\\[ \t\r]*\n[ \t]* {
- m_Line++;
- PRINTF(("%s %d: IMEQUAL: %s\n",m_InputFileName.c_str(),m_Line,yytext));
+ yylineno++;
+ PRINTF(("%s %d: OPTEQUAL: %s\n",m_InputFileName.c_str(),yylineno,yytext));
return mhmakeparser::OPTEQUAL;
}
[ \t]*\?=[ \t]* {
- PRINTF(("%s %d: IMEQUAL: %s\n",m_InputFileName.c_str(),m_Line,yytext));
+ PRINTF(("%s %d: OPTEQUAL: %s\n",m_InputFileName.c_str(),yylineno,yytext));
return mhmakeparser::OPTEQUAL;
}
/*---------------------------------------------------------------------------*/
[ \t]*\+=[ \t]*\\[ \t\r]*\n[ \t]* {
- PRINTF(("%s %d: PEQUAL: %s\n",m_InputFileName.c_str(),m_Line,yytext));
- m_Line++;
+ PRINTF(("%s %d: PEQUAL: %s\n",m_InputFileName.c_str(),yylineno,yytext));
+ yylineno++;
return mhmakeparser::PEQUAL;
}
[ \t]*\+=[ \t]* {
- PRINTF(("%s %d: PEQUAL: %s\n",m_InputFileName.c_str(),m_Line,yytext));
+ PRINTF(("%s %d: PEQUAL: %s\n",m_InputFileName.c_str(),yylineno,yytext));
return mhmakeparser::PEQUAL;
}
/*---------------------------------------------------------------------------*/
[ \t]*;[ \t]*\\[ \t\r]*\n[ \t]* {
- PRINTF(("%s %d: -SEMICOLON (NEWLINE): %s\n",m_InputFileName.c_str(),m_Line,yytext));
+ PRINTF(("%s %d: -SEMICOLON (NEWLINE): %s\n",m_InputFileName.c_str(),yylineno,yytext));
m_curtoken=g_EmptyString;
- m_Line++;
+ yylineno++;
BEGIN(COMMANDPARSE);
return mhmakeparser::NEWLINE;
}
[ \t]*;[ \t]* {
- PRINTF(("%s %d: -SEMICOLON (NEWLINE): %s\n",m_InputFileName.c_str(),m_Line,yytext));
+ PRINTF(("%s %d: -SEMICOLON (NEWLINE): %s\n",m_InputFileName.c_str(),yylineno,yytext));
m_curtoken=g_EmptyString;
BEGIN(COMMANDPARSE);
return mhmakeparser::NEWLINE;
@@ -277,169 +292,170 @@ load_makefile {
/*---------------------------------------------------------------------------*/
[ \t]*::[ \t]*\\[ \t\r]*\n[ \t]* {
- PRINTF(("%s %d: DOUBLECOLON: %s\n",m_InputFileName.c_str(),m_Line,yytext));
- m_Line++;
+ PRINTF(("%s %d: DOUBLECOLON: %s\n",m_InputFileName.c_str(),yylineno,yytext));
+ yylineno++;
theValue.theString=(const char *)yytext;
return mhmakeparser::DOUBLECOLON;
}
[ \t]*::[ \t]* {
- PRINTF(("%s %d: DOUBLECOLON: %s\n",m_InputFileName.c_str(),m_Line,yytext));
+ PRINTF(("%s %d: DOUBLECOLON: %s\n",m_InputFileName.c_str(),yylineno,yytext));
theValue.theString=(const char *)yytext;
return mhmakeparser::DOUBLECOLON;
}
/*---------------------------------------------------------------------------*/
[ \t]*:[ \t]*\\[ \t\r]*\n[ \t]* {
- PRINTF(("%s %d: COLON: %s\n",m_InputFileName.c_str(),m_Line,yytext));
- m_Line++;
+ PRINTF(("%s %d: COLON: %s\n",m_InputFileName.c_str(),yylineno,yytext));
+ yylineno++;
theValue.theString=(const char *)yytext;
return mhmakeparser::COLON;
}
[ \t]*:[ \t]* {
- PRINTF(("%s %d: COLON: %s\n",m_InputFileName.c_str(),m_Line,yytext));
+ PRINTF(("%s %d: COLON: %s\n",m_InputFileName.c_str(),yylineno,yytext));
theValue.theString=(const char *)yytext;
return mhmakeparser::COLON;
}
/*---------------------------------------------------------------------------*/
, {
- PRINTF(("%s %d: COMMA: %s\n",m_InputFileName.c_str(),m_Line,yytext));
+ PRINTF(("%s %d: COMMA: %s\n",m_InputFileName.c_str(),yylineno,yytext));
theValue.theString=(const char *)yytext;
return mhmakeparser::COMMA;
}
/*---------------------------------------------------------------------------*/
-^[ \t]*endif {
+^endif {
if (m_IndentStack.size())
{
m_IndentStack.pop();
- PRINTF(("%s %d: %s: depth %d\n",m_InputFileName.c_str(),m_Line,yytext,m_IndentStack.size()));
+ PRINTF(("%s %d: %s: depth %d\n",m_InputFileName.c_str(),yylineno,yytext,m_IndentStack.size()));
}
else
{
- throw string("Unexpected endif at line ") + stringify(m_Line) + " of " + m_InputFileName;
+ throw string("Unexpected endif at line ") + stringify(yylineno) + " of " + m_InputFileName;
}
}
/*---------------------------------------------------------------------------*/
-^[ \t]*ifdef[ \t]*\\[ \t\r]*\n[ \t]* {
+^ifdef[ \t]*\\[ \t\r]*\n[ \t]* {
BEGIN(IFDEF);
- m_Line++;
+ yylineno++;
return mhmakeparser::NEWLINE;
}
-^[ \t]*ifdef[ \t]+ {
+^ifdef[ \t]+ {
BEGIN(IFDEF);
return mhmakeparser::NEWLINE;
}
/*---------------------------------------------------------------------------*/
-^[ \t]*if[ \t]*\\[ \t\r]*\n[ \t]* {
+^if[ \t]*\\[ \t\r]*\n[ \t]* {
BEGIN(IF);
- m_Line++;
+ yylineno++;
m_curtoken=g_EmptyString;
return mhmakeparser::NEWLINE;
}
-^[ \t]*if[ \t]+ {
+^if[ \t]+ {
BEGIN(IF);
m_curtoken=g_EmptyString;
return mhmakeparser::NEWLINE;
}
/*---------------------------------------------------------------------------*/
-^[ \t]*ifndef[ \t]*\\[ \t\r]*\n[ \t]* {
+^ifndef[ \t]*\\[ \t\r]*\n[ \t]* {
BEGIN(IFNDEF);
- m_Line++;
+ yylineno++;
return mhmakeparser::NEWLINE;
}
-^[ \t]*ifndef[ \t]+ {
+^ifndef[ \t]+ {
BEGIN(IFNDEF);
return mhmakeparser::NEWLINE;
}
/*---------------------------------------------------------------------------*/
-^[ \t]*ifeq[ \t]*\\[ \t\r]*\n[ \t]* {
+^ifeq[ \t]*\\[ \t\r]*\n[ \t]* {
BEGIN(IFEQ);
m_curtoken=g_EmptyString;
- m_Line++;
+ yylineno++;
return mhmakeparser::NEWLINE;
}
-^[ \t]*ifeq[ \t]+ {
+^ifeq[ \t]+ {
BEGIN(IFEQ);
m_curtoken=g_EmptyString;
return mhmakeparser::NEWLINE;
}
/*---------------------------------------------------------------------------*/
-^[ \t]*ifneq[ \t]*\\[ \t\r]*\n[ \t]* {
+^ifneq[ \t]*\\[ \t\r]*\n[ \t]* {
BEGIN(IFNEQ);
m_curtoken=g_EmptyString;
- m_Line++;
+ yylineno++;
return mhmakeparser::NEWLINE;
}
-^[ \t]*ifneq[ \t]+ {
+^ifneq[ \t]+ {
BEGIN(IFNEQ);
m_curtoken=g_EmptyString;
return mhmakeparser::NEWLINE;
}
/*---------------------------------------------------------------------------*/
-^[ \t]*else[ \t]* {
+^else[ \t]* {
if (m_IndentStack.size() && (!m_IndentStack.top()))
{
- PRINTF(("%s %d: skipping else: depth %d\n",m_InputFileName.c_str(),m_Line,m_IndentStack.size()));
+ PRINTF(("%s %d: skipping else: depth %d\n",m_InputFileName.c_str(),yylineno,m_IndentStack.size()));
m_IndentSkip=m_IndentStack.size();
m_IndentStack.top()=1;
BEGIN(SKIPUNTILELSEORENDIF);
}
else
{
- throw string("Unexpected else at line ") + stringify(m_Line) + " of file " + m_InputFileName;
+ throw string("Unexpected else at line ") + stringify(yylineno) + " of file " + m_InputFileName;
}
}
/*****************************************************************************/
<IFEQ>\n {
- unput( yytext[0] );
+ yyless(0);
m_IndentStack.push(0);
if (GetParser()->IsEqual(m_curtoken))
{
- PRINTF(("%s %d: Not Skipping ifeq %s: depth %d\n",m_InputFileName.c_str(),m_Line,m_curtoken.c_str(),m_IndentStack.size()));
+ PRINTF(("%s %d: Not Skipping ifeq %s: depth %d\n",m_InputFileName.c_str(),yylineno,m_curtoken.c_str(),m_IndentStack.size()));
BEGIN(INITIAL);
}
else
{
- PRINTF(("%s %d: Skipping ifeq %s: depth %d\n",m_InputFileName.c_str(),m_Line,m_curtoken.c_str(),m_IndentStack.size()));
+ PRINTF(("%s %d: Skipping ifeq %s: depth %d\n",m_InputFileName.c_str(),yylineno,m_curtoken.c_str(),m_IndentStack.size()));
m_IndentSkip=m_IndentStack.size();
BEGIN(SKIPUNTILELSEORENDIF);
}
}
-<IF,IFEQ,IFNEQ>[ \t]*\\[ \t\r]*\n[ \t]* { m_Line++; m_curtoken += g_SpaceString;}
+<IF,IFEQ,IFNEQ>[ \t]*\\[ \t\r]*\n[ \t]* { yylineno++; m_curtoken += g_SpaceString;}
<IF,IFEQ,IFNEQ>\r /* skip */
-<IF,IFEQ,IFNEQ>[^\\\r\n]+ |
+<IF,IFEQ,IFNEQ>[^\\\r\n{}\$]+ |
+<IF,IFEQ,IFNEQ>\$ |
<IF,IFEQ,IFNEQ>\\ { m_curtoken += (const char *)yytext; }
/*****************************************************************************/
<IFNEQ>\n {
- unput( yytext[0] );
+ yyless(0);
m_IndentStack.push(0);
if (!GetParser()->IsEqual(m_curtoken))
{
- PRINTF(("%s %d: Not Skipping ifneq %s: depth %d\n",m_InputFileName.c_str(),m_Line,m_curtoken.c_str(),m_IndentStack.size()));
+ PRINTF(("%s %d: Not Skipping ifneq %s: depth %d\n",m_InputFileName.c_str(),yylineno,m_curtoken.c_str(),m_IndentStack.size()));
BEGIN(INITIAL);
}
else
{
- PRINTF(("%s %d: Skipping ifneq %s: depth %d\n",m_InputFileName.c_str(),m_Line,m_curtoken.c_str(),m_IndentStack.size()));
+ PRINTF(("%s %d: Skipping ifneq %s: depth %d\n",m_InputFileName.c_str(),yylineno,m_curtoken.c_str(),m_IndentStack.size()));
m_IndentSkip=m_IndentStack.size();
BEGIN(SKIPUNTILELSEORENDIF);
}
@@ -447,39 +463,39 @@ load_makefile {
/*****************************************************************************/
<IF>[ \t\r]*[a-zA-Z0-9_]+[ \t\r]*\n {
- unput( '\n' );
+ yyless(yyleng-1);
m_IndentStack.push(0);
#ifndef WIN32
- int lastidx=strlen((const char *)yytext)-1;
+ int lastidx=yyleng-1;
if (yytext[lastidx]=='\r')
yytext[lastidx]='\0';
#endif
string Val=GetParser()->ExpandVar((const char *)yytext);
if (Val.empty() || Val=="0")
{
- PRINTF(("%s %d: Skipping if %s: depth %d\n",m_InputFileName.c_str(),m_Line,yytext,m_IndentStack.size()));
+ PRINTF(("%s %d: Skipping if %s: depth %d\n",m_InputFileName.c_str(),yylineno,yytext,m_IndentStack.size()));
m_IndentSkip=m_IndentStack.size();
BEGIN(SKIPUNTILELSEORENDIF);
}
else
{
- PRINTF(("%s %d: Not Skipping if %s: depth %d\n",m_InputFileName.c_str(),m_Line,yytext,m_IndentStack.size()));
+ PRINTF(("%s %d: Not Skipping if %s: depth %d\n",m_InputFileName.c_str(),yylineno,yytext,m_IndentStack.size()));
BEGIN(INITIAL);
}
}
/*---------------------------------------------------------------------------*/
<IF>\n {
- unput( yytext[0] );
+ yyless(0);
m_IndentStack.push(0);
if (GetParser()->IsExprTrue(m_curtoken))
{
- PRINTF(("%s %d: Not Skipping ifeq %s: depth %d\n",m_InputFileName.c_str(),m_Line,m_curtoken.c_str(),m_IndentStack.size()));
+ PRINTF(("%s %d: Not Skipping ifeq %s: depth %d\n",m_InputFileName.c_str(),yylineno,m_curtoken.c_str(),m_IndentStack.size()));
BEGIN(INITIAL);
}
else
{
- PRINTF(("%s %d: Skipping ifeq %s: depth %d\n",m_InputFileName.c_str(),m_Line,m_curtoken.c_str(),m_IndentStack.size()));
+ PRINTF(("%s %d: Skipping ifeq %s: depth %d\n",m_InputFileName.c_str(),yylineno,m_curtoken.c_str(),m_IndentStack.size()));
m_IndentSkip=m_IndentStack.size();
BEGIN(SKIPUNTILELSEORENDIF);
}
@@ -493,12 +509,12 @@ load_makefile {
m_IndentStack.push(0);
if (GetParser()->IsDefined((const char *)yytext))
{
- PRINTF(("%s %d: Not Skipping ifdef %s: depth %d\n",m_InputFileName.c_str(),m_Line,yytext,m_IndentStack.size()));
+ PRINTF(("%s %d: Not Skipping ifdef %s: depth %d\n",m_InputFileName.c_str(),yylineno,yytext,m_IndentStack.size()));
BEGIN(INITIAL);
}
else
{
- PRINTF(("%s %d: Skipping ifdef %s: depth %d\n",m_InputFileName.c_str(),m_Line,yytext,m_IndentStack.size()));
+ PRINTF(("%s %d: Skipping ifdef %s: depth %d\n",m_InputFileName.c_str(),yylineno,yytext,m_IndentStack.size()));
m_IndentSkip=m_IndentStack.size();
BEGIN(SKIPUNTILELSEORENDIF);
}
@@ -508,12 +524,12 @@ load_makefile {
<IFNDEF>[a-zA-Z0-9_]+ {
m_IndentStack.push(0);
if (!GetParser()->IsDefined((const char *)yytext)) {
- PRINTF(("%s %d: Not Skipping ifndef %s: depth %d\n",m_InputFileName.c_str(),m_Line,yytext,m_IndentStack.size()));
+ PRINTF(("%s %d: Not Skipping ifndef %s: depth %d\n",m_InputFileName.c_str(),yylineno,yytext,m_IndentStack.size()));
BEGIN(INITIAL);
}
else
{
- PRINTF(("%s %d: Skipping ifndef %s: depth %d\n",m_InputFileName.c_str(),m_Line,yytext,m_IndentStack.size()));
+ PRINTF(("%s %d: Skipping ifndef %s: depth %d\n",m_InputFileName.c_str(),yylineno,yytext,m_IndentStack.size()));
m_IndentSkip=m_IndentStack.size();
BEGIN(SKIPUNTILELSEORENDIF);
}
@@ -521,26 +537,26 @@ load_makefile {
/*****************************************************************************/
<SKIPUNTILELSEORENDIF>\n[ ]*endif {
- m_Line++;
+ yylineno++;
if (!m_IndentStack.size())
{
- throw string("Unexpected endif at line ") + stringify(m_Line) + " of " + m_InputFileName;
+ throw string("Unexpected endif at line ") + stringify(yylineno) + " of " + m_InputFileName;
}
else
{
m_IndentStack.pop();
- PRINTF(("%s %d: endif: depth %d\n",m_InputFileName.c_str(),m_Line,m_IndentStack.size()));
+ PRINTF(("%s %d: endif: depth %d\n",m_InputFileName.c_str(),yylineno,m_IndentStack.size()));
if (m_IndentStack.size()==m_IndentSkip-1) BEGIN(INITIAL);
}
}
/*---------------------------------------------------------------------------*/
<SKIPUNTILELSEORENDIF>\n[ ]*else {
- m_Line++;
- PRINTF(("%s %d: else: depth %d\n",m_InputFileName.c_str(),m_Line,m_IndentStack.size()));
+ yylineno++;
+ PRINTF(("%s %d: else: depth %d\n",m_InputFileName.c_str(),yylineno,m_IndentStack.size()));
if (m_IndentStack.top())
{
- throw string("Unexpected else at line ") + stringify(m_Line) + " of file " + m_InputFileName;
+ throw string("Unexpected else at line ") + stringify(yylineno) + " of file " + m_InputFileName;
}
m_IndentStack.top()=1;
if (m_IndentStack.size()==m_IndentSkip)
@@ -551,9 +567,9 @@ load_makefile {
/*---------------------------------------------------------------------------*/
<SKIPUNTILELSEORENDIF>\n[ ]*if(def|ndef|eq|neq)? {
- m_Line++;
+ yylineno++;
m_IndentStack.push(0);
- PRINTF(("%s %d: %s: depth %d\n",m_InputFileName.c_str(),m_Line,yytext+1,m_IndentStack.size()));
+ PRINTF(("%s %d: %s: depth %d\n",m_InputFileName.c_str(),yylineno,yytext+1,m_IndentStack.size()));
}
/*---------------------------------------------------------------------------*/
@@ -561,91 +577,118 @@ load_makefile {
/*---------------------------------------------------------------------------*/
<SKIPUNTILELSEORENDIF>[^a-zA-Z\n]+ /* skip */
/*---------------------------------------------------------------------------*/
-<SKIPUNTILELSEORENDIF>\n[ ]*[a-zA-Z]+ m_Line++;
+<SKIPUNTILELSEORENDIF>\n[ ]*[a-zA-Z]+ yylineno++;
/*---------------------------------------------------------------------------*/
<SKIPUNTILELSEORENDIF>\n {
- m_Line++;
+ yylineno++;
}
/*---------------------------------------------------------------------------*/
[ \t]*#[^\n]* {
- PRINTF(("%s %d: -COMMENT: %s\n",m_InputFileName.c_str(),m_Line,yytext));
+ PRINTF(("%s %d: -COMMENT: %s\n",m_InputFileName.c_str(),yylineno,yytext));
}
/*---------------------------------------------------------------------------*/
[ \t]*\\[ \t\r]*\n[ \t]* {
- PRINTF(("%s %d: SPACE:\n",m_InputFileName.c_str(),m_Line));
- m_Line++;
+ PRINTF(("%s %d: SPACE:\n",m_InputFileName.c_str(),yylineno));
+ yylineno++;
return mhmakeparser::SPACE;
}
/*---------------------------------------------------------------------------*/
\.PHONY {
- PRINTF(("%s %d: .PHONY: %s\n",m_InputFileName.c_str(),m_Line,yytext));
+ PRINTF(("%s %d: .PHONY: %s\n",m_InputFileName.c_str(),yylineno,yytext));
return mhmakeparser::PHONY;
}
/*---------------------------------------------------------------------------*/
\.AUTODEPS {
- PRINTF(("%s %d: .AUTODEPS: %s\n",m_InputFileName.c_str(),m_Line,yytext));
+ PRINTF(("%s %d: .AUTODEPS: %s\n",m_InputFileName.c_str(),yylineno,yytext));
return mhmakeparser::AUTODEPS;
}
/*---------------------------------------------------------------------------*/
export {
- PRINTF(("%s %d: export: %s\n",m_InputFileName.c_str(),m_Line,yytext));
+ PRINTF(("%s %d: export: %s\n",m_InputFileName.c_str(),yylineno,yytext));
return mhmakeparser::EXPORT;
}
/*---------------------------------------------------------------------------*/
-^[ \t]*vpath {
- PRINTF(("%s %d: vpath\n",m_InputFileName.c_str(),m_Line));
+^vpath {
+ PRINTF(("%s %d: vpath\n",m_InputFileName.c_str(),yylineno));
return mhmakeparser::VPATH;
}
/*---------------------------------------------------------------------------*/
[a-zA-Z]:[a-zA-Z0-9\\\._\~\-%\@<&/]+\\[ \t\r]*\n {
- size_t EndIndex=::strlen((const char*)yytext);
+ size_t EndIndex=yyleng;
while (strchr(" \t\r\n\\",yytext[--EndIndex]));
yyless(EndIndex+1);
- PRINTF(("%s %d: STRING: %s\n",m_InputFileName.c_str(),m_Line,yytext));
+ PRINTF(("%s %d: STRING: %s\n",m_InputFileName.c_str(),yylineno,yytext));
theValue.theString=(const char *)yytext;
return mhmakeparser::STRING;
}
[a-zA-Z]:[a-zA-Z0-9\\\._\~\-%\@<&/]+ {
- PRINTF(("%s %d: STRING: %s\n",m_InputFileName.c_str(),m_Line,yytext));
+ PRINTF(("%s %d: STRING: %s\n",m_InputFileName.c_str(),yylineno,yytext));
theValue.theString=(const char *)yytext;
return mhmakeparser::STRING;
}
/*---------------------------------------------------------------------------*/
([a-zA-Z0-9\\\._\~\-\+%\@<&;/\*\|]|\\\ |\\#)+\\[ \t\r]*\n {
- size_t EndIndex=::strlen((const char*)yytext);
+ size_t EndIndex=yyleng;
while (strchr(" \t\r\n\\",yytext[--EndIndex]));
yyless(EndIndex+1);
- PRINTF(("%s %d: STRING: %s\n",m_InputFileName.c_str(),m_Line,yytext));
+ PRINTF(("%s %d: STRING: %s\n",m_InputFileName.c_str(),yylineno,yytext));
theValue.theString=(const char *)yytext;
return mhmakeparser::STRING;
}
([a-zA-Z0-9\\\._\~\-\+%\@<&;/\*\|]|\\\ |\\#)+\+= {
- size_t Len;
- PRINTF(("%s %d: STRING: %s\n",m_InputFileName.c_str(),m_Line,yytext));
- Len=strlen((const char *)yytext)-2;
- yyless(Len);
+ PRINTF(("%s %d: STRING: %s\n",m_InputFileName.c_str(),yylineno,yytext));
+ yyless(yyleng-2);
theValue.theString=(const char *)yytext;
return mhmakeparser::STRING;
}
([a-zA-Z0-9\\\._\~\-\+%\@<&;/\*\|]|\\\ |\\#)+ {
- PRINTF(("%s %d: STRING: %s\n",m_InputFileName.c_str(),m_Line,yytext));
+ PRINTF(("%s %d: STRING: %s\n",m_InputFileName.c_str(),yylineno,yytext));
theValue.theString=(const char *)yytext;
return mhmakeparser::STRING;
}
+^define[ \t]+[a-zA-Z0-9_\.]+[ \t]*\n {
+ const char *pVar=(const char *)yytext;
+ while (strchr(" \t",*pVar)) pVar++;
+ pVar+=6;
+ theValue.theString=pVar;
+ BEGIN(DEFINE);
+ m_curtoken=g_EmptyString;
+ PRINTF(("%s %d: VARDEF: %s\n",m_InputFileName.c_str(),yylineno,m_curtoken.c_str()));
+ yylineno++;
+ return mhmakeparser::VARDEF;
+}
+
+<DEFINE>[ \t]*\\[ \t\r]*\n[ \t]* {
+ yylineno++;
+ m_curtoken+=g_SpaceString;
+}
+
+<DEFINE>. {
+ m_curtoken+=(const char *)yytext;
+}
+
+<DEFINE>[ \t]*\n[ \t]*endef {
+ yylineno++;
+ theValue.theString=m_curtoken;
+ PRINTF(("%s %d: VARVAL: %s\n",m_InputFileName.c_str(),yylineno,m_curtoken.c_str()));
+ BEGIN(INITIAL);
+ return mhmakeparser::VARVAL;
+}
+
/*---------------------------------------------------------------------------*/
\" {
BEGIN(QUOTE);
@@ -661,45 +704,33 @@ export {
/*---------------------------------------------------------------------------*/
\$\( {
m_BraceIndent++;
- PRINTF(("%s %d: BEGIN MACRO $(: %d\n",m_InputFileName.c_str(),m_Line,m_BraceIndent));
+ PRINTF(("%s %d: BEGIN MACRO $(: %d\n",m_InputFileName.c_str(),yylineno,m_BraceIndent));
BEGIN(MAKEEXPRES);
- yymore();
+ m_curtoken=(const char *)yytext;
}
/*---------------------------------------------------------------------------*/
\$\([ \t]*error[ \t]+ {
m_BraceIndent++;
- PRINTF(("%s %d: BEGIN ERROR MACRO $(: %d\n",m_InputFileName.c_str(),m_Line,m_BraceIndent));
+ PRINTF(("%s %d: BEGIN ERROR MACRO $(: %d\n",m_InputFileName.c_str(),yylineno,m_BraceIndent));
BEGIN(ERRORMACRO);
m_curtoken=g_EmptyString;
+ return mhmakeparser::NEWLINE; // Make sure that the previous lines are matched by the bison parser (so that all variables until here are defined)
}
/*---------------------------------------------------------------------------*/
-\$\([ \t]*message[ \t]+ {
+\$\([ \t]*(message|info)[ \t]+ {
m_BraceIndent++;
- PRINTF(("%s %d: BEGIN MESSAGE MACRO $(: %d\n",m_InputFileName.c_str(),m_Line,m_BraceIndent));
+ PRINTF(("%s %d: BEGIN MESSAGE MACRO $(: %d\n",m_InputFileName.c_str(),yylineno,m_BraceIndent));
BEGIN(MESSAGEMACRO);
m_curtoken=g_EmptyString;
-}
-
- /*---------------------------------------------------------------------------*/
-[ \t]*\$\{[ \t]*info[ \t]+ {
- PRINTF(("%s %d: BEGIN INFO MESSAGE ${: %d\n",m_InputFileName.c_str(),m_Line,m_BraceIndent));
- BEGIN(MESSAGEINFO);
- m_curtoken=g_EmptyString;
-}
-
- /*---------------------------------------------------------------------------*/
-[ \t]*\$\{[ \t]*error[ \t]+ {
- PRINTF(("%s %d: BEGIN ERROR MESSAGE ${: %d\n",m_InputFileName.c_str(),m_Line,m_BraceIndent));
- BEGIN(MESSAGEERROR);
- m_curtoken=g_EmptyString;
+ return mhmakeparser::NEWLINE; // Make sure that the previous lines are matched by the bison parser (so that all variables until here are defined)
}
/*---------------------------------------------------------------------------*/
\$\([ \t]*reparse[ \t]+ {
m_BraceIndent++;
- PRINTF(("%s %d: BEGIN REPARSE MACRO $(: %d\n",m_InputFileName.c_str(),m_Line,m_BraceIndent));
+ PRINTF(("%s %d: BEGIN REPARSE MACRO $(: %d\n",m_InputFileName.c_str(),yylineno,m_BraceIndent));
BEGIN(REPARSEMACRO);
m_curtoken=g_EmptyString;
return mhmakeparser::NEWLINE;
@@ -707,19 +738,19 @@ export {
/*---------------------------------------------------------------------------*/
\( {
- PRINTF(("%s %d: OPENBRACE: %s\n",m_InputFileName.c_str(),m_Line,yytext));
+ PRINTF(("%s %d: OPENBRACE: %s\n",m_InputFileName.c_str(),yylineno,yytext));
return mhmakeparser::OPENBRACE;
}
/*---------------------------------------------------------------------------*/
\) {
- PRINTF(("%s %d: CLOSEBRACE: %s\n",m_InputFileName.c_str(),m_Line,yytext));
+ PRINTF(("%s %d: CLOSEBRACE: %s\n",m_InputFileName.c_str(),yylineno,yytext));
return mhmakeparser::CLOSEBRACE;
}
/*---------------------------------------------------------------------------*/
\$[<@/$] {
- PRINTF(("%s %d: DOLLAREXPR: %s\n",m_InputFileName.c_str(),m_Line,yytext));
+ PRINTF(("%s %d: DOLLAREXPR: %s\n",m_InputFileName.c_str(),yylineno,yytext));
theValue.theString=(const char *)yytext;
return mhmakeparser::DOLLAREXPR;
}
@@ -727,40 +758,50 @@ export {
/*---------------------------------------------------------------------------*/
[ \t\r]*\n\t[ \t]* {
/* token newline */
- PRINTF(("%s %d: NEWLINE\n",m_InputFileName.c_str(),m_Line));
- m_Line++;
+ PRINTF(("%s %d: NEWLINE\n",m_InputFileName.c_str(),yylineno));
+ yylineno++;
m_curtoken=g_EmptyString;
BEGIN(COMMANDPARSE);
return mhmakeparser::NEWLINE;
}
/*---------------------------------------------------------------------------*/
+<*>\$\{ {
+ unput('(');
+ unput('$');
+}
+ /*---------------------------------------------------------------------------*/
+<*>\} {
+ unput(')');
+}
+
+ /*---------------------------------------------------------------------------*/
[^\n] {
- PRINTF(("%s %d: ANYCHAR: %d: %s\n",m_InputFileName.c_str(),m_Line,m_Line,yytext));
+ PRINTF(("%s %d: ANYCHAR: %d: %s\n",m_InputFileName.c_str(),yylineno,yylineno,yytext));
}
/*****************************************************************************/
<COMMANDPARSE>[ \t\r]*\n {
- PRINTF(("%s %d: COMMAND: %d: %s\n",m_InputFileName.c_str(),m_Line,m_Line,m_curtoken.c_str()));
+ PRINTF(("%s %d: COMMAND: %d: %s\n",m_InputFileName.c_str(),yylineno,yylineno,m_curtoken.c_str()));
theValue.theString=m_curtoken;
- m_Line++;
+ yylineno++;
BEGIN(INITIAL);
return mhmakeparser::COMMAND;
}
/*---------------------------------------------------------------------------*/
<COMMANDPARSE>[ \t\r]*\n\t[ \t]* {
- PRINTF(("%s %d: COMMAND: %s\n",m_InputFileName.c_str(),m_Line,m_curtoken.c_str()));
+ PRINTF(("%s %d: COMMAND: %s\n",m_InputFileName.c_str(),yylineno,m_curtoken.c_str()));
theValue.theString=m_curtoken;
- m_Line++;
+ yylineno++;
m_curtoken=g_EmptyString;
return mhmakeparser::COMMAND;
}
/*---------------------------------------------------------------------------*/
<COMMANDPARSE>[ \t]*\\[ \t\r]*\n[ \t]* {
- m_Line++;
+ yylineno++;
m_curtoken+=g_SpaceString;
}
@@ -770,35 +811,28 @@ export {
}
/*---------------------------------------------------------------------------*/
-<COMMANDPARSE>[^ \r\n#\\]+ |
+<COMMANDPARSE>[^ \r\n#\\{}$]+ |
+<COMMANDPARSE>\$ |
<COMMANDPARSE>\\ {
m_curtoken+=(const char *)yytext;
}
/*---------------------------------------------------------------------------*/
<COMMANDPARSE>[ \t]*\\#[^\n]* {
- char ToAdd[100];
- int i=0;
int nChars=(int)((strchr((const char *)yytext,'#')-(char*)yytext))+1;
- while (strchr(" \t",yytext[i]))
- {
- ToAdd[i]=yytext[i];
- i++;
- }
- ToAdd[i++]='#';
- ToAdd[i++]=0;
- m_curtoken+=ToAdd;
yyless(nChars);
+ m_curtoken+=string(yytext,nChars-2);
+ m_curtoken+='#';
}
/*---------------------------------------------------------------------------*/
<COMMANDPARSE>[ \t]*#[^\n]* {
- PRINTF(("%s %d: -COMMENT: %s\n",m_InputFileName.c_str(),m_Line,yytext));
+ PRINTF(("%s %d: -COMMENT: %s\n",m_InputFileName.c_str(),yylineno,yytext));
}
/*****************************************************************************/
<QUOTE>\" {
- PRINTF(("%s %d: QUOTEDSTRING: %s\n",m_InputFileName.c_str(),m_Line,yytext));
+ PRINTF(("%s %d: QUOTEDSTRING: %s\n",m_InputFileName.c_str(),yylineno,yytext));
BEGIN(INITIAL);
theValue.theString=(const char *)yytext;
return mhmakeparser::STRING;
@@ -807,7 +841,8 @@ export {
/*---------------------------------------------------------------------------*/
<QUOTE>\r /* skip */
-<QUOTE>[^\\\"\r\n]+ |
+<QUOTE>[^\\\"\r\n{}$]+ |
+<QUOTE>\$ |
<QUOTE>\\ |
<QUOTE>\\\" |
<QUOTE>\\# {
@@ -816,7 +851,7 @@ export {
/*****************************************************************************/
<SINGLEQUOTE>\' {
- PRINTF(("%s %d: QUOTEDSTRING: %s\n",m_InputFileName.c_str(),m_Line,yytext));
+ PRINTF(("%s %d: QUOTEDSTRING: %s\n",m_InputFileName.c_str(),yylineno,yytext));
BEGIN(INITIAL);
theValue.theString=(const char *)yytext;
return mhmakeparser::STRING;
@@ -825,7 +860,8 @@ export {
/*---------------------------------------------------------------------------*/
<SINGLEQUOTE>\r /* skip */
-<SINGLEQUOTE>[^\\\'\r\n]+ |
+<SINGLEQUOTE>[^\\\'\r\n{}$]+ |
+<SINGLEQUOTE>\$ |
<SINGLEQUOTE>\\ |
<SINGLEQUOTE>\\\' |
<SINGLEQUOTE>\\# {
@@ -835,57 +871,39 @@ export {
/*****************************************************************************/
<ERRORMACRO>\) {
m_BraceIndent--;
- PRINTF(("%s %d: CLOSE BRACE ERROR MACRO ): %d\n",m_InputFileName.c_str(),m_Line,m_BraceIndent));
+ PRINTF(("%s %d: CLOSE BRACE ERROR MACRO ): %d\n",m_InputFileName.c_str(),yylineno,m_BraceIndent));
if (!m_BraceIndent)
{
- PRINTF(("%s %d: ERRORMACRO: %s\n",m_InputFileName.c_str(),m_Line,yytext));
- yyless(0);
- throw GetParser()->ExpandExpression((const char*)yytext);
+ PRINTF(("%s %d: ERRORMACRO: %s\n",m_InputFileName.c_str(),yylineno,m_curtoken.c_str()));
+ throw string("\n-> ")+m_InputFileName.c_str()+"("+stringify(yylineno)+") : "+GetParser()->ExpandExpression(m_curtoken);
} else {
- yymore();
- }
+ m_curtoken+=(const char *)yytext;
}
-
- /*****************************************************************************/
-<MESSAGEERROR>[^\}]+ {
- throw(GetParser()->ExpandExpression((const char*)yytext));
-}
-
- /*****************************************************************************/
-<MESSAGEINFO>[^\}]+ {
- cerr<<GetParser()->ExpandExpression((const char*)yytext)<<endl;
-}
-
- /*****************************************************************************/
-<MESSAGEINFO>\} {
- PRINTF(("%s %d: MESSAGEINFO: %s\n",m_InputFileName.c_str(),m_Line,yytext));
- BEGIN(INITIAL);
}
/*****************************************************************************/
<MESSAGEMACRO>\) {
m_BraceIndent--;
- PRINTF(("%s %d: CLOSE BRACE MESSAGE MACRO ): %d\n",m_InputFileName.c_str(),m_Line,m_BraceIndent));
+ PRINTF(("%s %d: CLOSE BRACE MESSAGE MACRO ): %d\n",m_InputFileName.c_str(),yylineno,m_BraceIndent));
if (!m_BraceIndent)
{
- PRINTF(("%s %d: MESSAGEMACRO: %s\n",m_InputFileName.c_str(),m_Line,yytext));
- yytext[strlen((const char*)yytext)-1]=0;
- cerr<<GetParser()->ExpandExpression((const char*)yytext)<<endl;
+ PRINTF(("%s %d: MESSAGEMACRO: %s\n",m_InputFileName.c_str(),yylineno,yytext));
+ cerr<<m_InputFileName.c_str()<<"("<<stringify(yylineno)+") : "<<GetParser()->ExpandExpression(m_curtoken)<<endl;
BEGIN(INITIAL);
} else {
- yymore();
+ m_curtoken+=(const char *)yytext;
}
}
/*****************************************************************************/
<REPARSEMACRO>\) {
m_BraceIndent--;
- PRINTF(("%s %d: CLOSE BRACE REPARSE MACRO ): %d\n",m_InputFileName.c_str(),m_Line,m_BraceIndent));
+ PRINTF(("%s %d: CLOSE BRACE REPARSE MACRO ): %d\n",m_InputFileName.c_str(),yylineno,m_BraceIndent));
if (!m_BraceIndent)
{
- PRINTF(("%s %d: REPARSEMACRO: %s\n",m_InputFileName.c_str(),m_Line,yytext));
- string Deps=GetParser()->ExpandExpression((const char*)yytext);
- PRINTF(("%s %d: REPARSEMACRO expanded: %s\n",m_InputFileName.c_str(),m_Line,Deps.c_str()));
+ PRINTF(("%s %d: REPARSEMACRO: %s\n",m_InputFileName.c_str(),yylineno,yytext));
+ string Deps=GetParser()->ExpandExpression(m_curtoken);
+ PRINTF(("%s %d: REPARSEMACRO expanded: %s\n",m_InputFileName.c_str(),yylineno,Deps.c_str()));
string::const_reverse_iterator It=Deps.rbegin()+1; // +1 because we don't want the latest brace
string::const_reverse_iterator ItBeg=Deps.rend();
while (It!= ItBeg)
@@ -898,42 +916,45 @@ export {
}
else
{
- yymore();
+ m_curtoken+=(const char *)yytext;
}
}
/*****************************************************************************/
<MAKEEXPRES>\) {
m_BraceIndent--;
- PRINTF(("%s %d: CLOSE BRACE MAKEEXPRES MACRO ): %d\n",m_InputFileName.c_str(),m_Line,m_BraceIndent));
+ PRINTF(("%s %d: CLOSE BRACE MAKEEXPRES MACRO ): %d\n",m_InputFileName.c_str(),yylineno,m_BraceIndent));
if (!m_BraceIndent)
{
- PRINTF(("%s %d: DOLLAREXPR: %s\n",m_InputFileName.c_str(),m_Line,yytext));
BEGIN(INITIAL);
- theValue.theString=(const char *)yytext;
+ m_curtoken+=(const char *)yytext;
+ theValue.theString=m_curtoken;
+ PRINTF(("%s %d: DOLLAREXPR: %s\n",m_InputFileName.c_str(),yylineno,m_curtoken.c_str()));
return mhmakeparser::DOLLAREXPR;
}
else
{
- yymore();
+ m_curtoken+=(const char *)yytext;
}
}
/*---------------------------------------------------------------------------*/
<MAKEEXPRES,ERRORMACRO,MESSAGEMACRO,REPARSEMACRO>\$\( {
m_BraceIndent++;
- PRINTF(("%s %d: MACRO extra $(: %d\n",m_InputFileName.c_str(),m_Line,m_BraceIndent));
- yymore();
+ PRINTF(("%s %d: MACRO extra $(: %d\n",m_InputFileName.c_str(),yylineno,m_BraceIndent));
+ m_curtoken+=(const char *)yytext;
}
/*---------------------------------------------------------------------------*/
-<MAKEEXPRES,ERRORMACRO,MESSAGEMACRO,REPARSEMACRO>[^$\(\)\r\n]+ |
+<MAKEEXPRES,ERRORMACRO,MESSAGEMACRO,REPARSEMACRO>[^$\(\){}\r\n\\]+ |
<MAKEEXPRES,ERRORMACRO,MESSAGEMACRO,REPARSEMACRO>\$ |
+<MAKEEXPRES,ERRORMACRO,MESSAGEMACRO,REPARSEMACRO>\\ |
<MAKEEXPRES,ERRORMACRO,MESSAGEMACRO,REPARSEMACRO>\( {
- yymore();
+ m_curtoken+=(const char *)yytext;
}
-<MAKEEXPRES,ERRORMACRO,MESSAGEMACRO,REPARSEMACRO>\r?\n {
- m_Line++;
+<MAKEEXPRES,ERRORMACRO,MESSAGEMACRO,REPARSEMACRO>[ \t\r]*\\[ \t\r]*\n[ \t\r]* {
+ yylineno++;
+ m_curtoken+=g_SpaceString;
}
<SKIPUNTILELSEORENDIF><<EOF>> {
@@ -955,12 +976,10 @@ export {
}
else
{
- ::fclose(YY_mhmakelexer_CURRENT_BUFFER->yy_input_file);
- YY_mhmakelexer_DELETE_BUFFER(YY_mhmakelexer_CURRENT_BUFFER);
- INSTACK *pInStack=&m_IncludeStack.top();
- YY_mhmakelexer_SWITCH_TO_BUFFER(pInStack->m_BufferState);
+ INSTACK *pInStack=m_IncludeStack.top();
+ yypop_buffer_state();
m_InputFileName=pInStack->m_FileName;
- m_Line=pInStack->m_Line;
+ yylineno=pInStack->yylineno;
m_IncludeStack.pop();
}
}
diff --git a/tools/mhmake/src/mhmakeparser.y b/tools/mhmake/src/mhmakeparser.y
index e2312b50e..f1ab48606 100644
--- a/tools/mhmake/src/mhmakeparser.y
+++ b/tools/mhmake/src/mhmakeparser.y
@@ -41,7 +41,7 @@
%token <theString> COMMAND
%token <theString> COMMA OPENBRACE CLOSEBRACE
-%token <theString> STRING DOLLAREXPR EQUAL COLON DOUBLECOLON
+%token <theString> STRING DOLLAREXPR EQUAL COLON DOUBLECOLON VARDEF VARVAL
%token IMEQUAL PEQUAL OPTEQUAL PHONY AUTODEPS EXPORT NEWLINE INCLUDEMAK SPACE VPATH
%type <theString> expression nonspaceexpression simpleexpression
@@ -182,7 +182,12 @@ vpathrule: VPATH SPACE nonspaceexpression SPACE expression NEWLINE
}
;
-varassignment: STRING EQUAL maybeemptyexpression
+varassignment: VARDEF VARVAL
+ {
+ m_Variables[f_strip($1)]=$2;
+ PRINTF(("Defining variable %s to %s\n",f_strip($1).c_str(), $2.c_str()));
+ }
+ | STRING EQUAL maybeemptyexpression
{
m_Variables[$1]=$3;
PRINTF(("Setting variable %s to %s\n",$1.c_str(), $3.c_str()));
diff --git a/tools/mhmake/src/rule.cpp b/tools/mhmake/src/rule.cpp
index dc8ab3b00..cee38ddb9 100644
--- a/tools/mhmake/src/rule.cpp
+++ b/tools/mhmake/src/rule.cpp
@@ -27,6 +27,7 @@
refptr<rule> NullRule;
+set<rule*> IMPLICITRULE::m_ImplicitRuleRecurseDetStack;
vector<pair<fileinfo *, vector<pair< fileinfo *,refptr<rule> > > > > IMPLICITRULE::m_ImplicitRules;
makecommand g_MakeCommand; // Order is important since sm_Statics is using g_MakeCommand
@@ -78,8 +79,8 @@ static bool FindDep(fileinfo *pDep, vector<pair<fileinfo*,refptr<rule> > >*pImpl
else
cerr << ErrorMessage << endl;
}
- mhmakeparser *pOldMakefile=SecIt->second->GetMakefile();
- mhmakeparser *pNewMakefile=Rule->GetMakefile();
+ mhmakefileparser *pOldMakefile=SecIt->second->GetMakefile();
+ mhmakefileparser *pNewMakefile=Rule->GetMakefile();
vector<string>::iterator OldIt=OldCommands.begin();
vector<string>::iterator NewIt=NewCommands.begin();
while (OldIt!=OldCommands.end())
@@ -107,6 +108,14 @@ static bool FindDep(fileinfo *pDep, vector<pair<fileinfo*,refptr<rule> > >*pImpl
///////////////////////////////////////////////////////////////////////////////
void IMPLICITRULE::AddImplicitRule(fileinfo *pTarget,const vector<fileinfo*> &Deps,refptr<rule> Rule)
{
+ if (!Rule)
+ {
+ #ifdef _DEBUG
+ if (g_PrintAdditionalInfo)
+ cout << "No commands defined for implicit rule " << pTarget->GetFullFileName()<<endl;
+ #endif
+ return;
+ }
// first search if there is already the same target in the current list of implicit rules
vector<pair<fileinfo*,refptr<rule> > >* pImplicitRule=NULL;
vector<pair<fileinfo *, vector<pair< fileinfo *,refptr<rule> > > > >::iterator RuleIt=m_ImplicitRules.begin();
@@ -164,13 +173,20 @@ void IMPLICITRULE::SearchImplicitRule(const fileinfo *pTarget,vector< pair<filei
#ifdef _DEBUG
if (!ResIt->second)
{
- throw string("No rhs for implicit rule : ") + ImpRegExIt->first->GetFullFileName();
+ throw string("No commands for implicit rule : ") + ImpRegExIt->first->GetFullFileName();
}
#endif
ResIt->second->SetStem(Res.m_Stem);
if (ResIt->first!=NULL)
{
string Dependent=ReplaceWithStem(ResIt->first->GetFullFileName(),Res.m_Stem);
+ #ifdef _DEBUG
+ if (Dependent.length()>MAX_PATH)
+ {
+ /* File name is getting too long, this is most probable an infinit loop */
+ throw(string("Filename too long in implicit rule search: ")+Dependent+"\nProbably some infinit loop in the implicit rules search.\n");
+ }
+ #endif
Result.push_back(pair<fileinfo*,refptr<rule> >(GetFileInfo(Dependent,ResIt->second->GetMakefile()->GetMakeDir()),ResIt->second));
}
else
diff --git a/tools/mhmake/src/rule.h b/tools/mhmake/src/rule.h
index 1ec944f96..3b288e3d2 100644
--- a/tools/mhmake/src/rule.h
+++ b/tools/mhmake/src/rule.h
@@ -23,17 +23,17 @@
#include "refptr.h"
#include "md5.h"
-class mhmakeparser;
+class mhmakefileparser;
class fileinfo;
class rule: public refbase
{
vector<string> m_Commands;
string m_Stem; // Contains the stem in case the rule is part of an implicit rule (filled in in the implicit search)
- mhmakeparser* m_pMakefile;
+ mhmakefileparser* m_pMakefile;
vector< fileinfo* > m_Targets; /* Targets that are build with this rule, do not use refptr here because otherwise we get circular references */
public:
- rule(mhmakeparser *pMakefile): m_pMakefile(pMakefile)
+ rule(mhmakefileparser *pMakefile): m_pMakefile(pMakefile)
{
}
@@ -56,11 +56,11 @@ public:
{
return m_Stem;
}
- void SetMakefile(mhmakeparser *pMakefile)
+ void SetMakefile(mhmakefileparser *pMakefile)
{
m_pMakefile=pMakefile;
}
- mhmakeparser *GetMakefile()
+ mhmakefileparser *GetMakefile()
{
return m_pMakefile;
}
@@ -76,11 +76,29 @@ public:
class IMPLICITRULE
{
+ static set<rule*> m_ImplicitRuleRecurseDetStack;
static vector<pair<fileinfo *, vector<pair< fileinfo *,refptr<rule> > > > > m_ImplicitRules; // Use a vector and not a map because the order of the implicit rules is important
public:
static void AddImplicitRule(fileinfo *pTarget,const vector<fileinfo*> &Deps,refptr<rule> pRule);
static void SearchImplicitRule(const fileinfo *pTarget,vector< pair<fileinfo*,refptr<rule> > >&Result);
static void PrintImplicitRules();
+ static bool PushRule(rule *pRule)
+ {
+ set<rule*>::iterator pFound=m_ImplicitRuleRecurseDetStack.find(pRule);
+ if (pFound==m_ImplicitRuleRecurseDetStack.end())
+ {
+ m_ImplicitRuleRecurseDetStack.insert(pRule);
+ return false;
+ }
+ else
+ {
+ return true;
+ }
+ }
+ static void PopRule(rule *pRule)
+ {
+ m_ImplicitRuleRecurseDetStack.erase(pRule);
+ }
};
extern refptr<rule> NullRule;
diff --git a/tools/mhmake/src/stdafx.h b/tools/mhmake/src/stdafx.h
index 3a6bbb946..5d1ffedfb 100644
--- a/tools/mhmake/src/stdafx.h
+++ b/tools/mhmake/src/stdafx.h
@@ -36,6 +36,7 @@
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
#include <iostream>
+#include <fstream>
#include <string>
#include <vector>
#include <queue>
diff --git a/tools/mhmake/src/util.cpp b/tools/mhmake/src/util.cpp
index 2e26cf2e7..63bdb767b 100644
--- a/tools/mhmake/src/util.cpp
+++ b/tools/mhmake/src/util.cpp
@@ -470,7 +470,7 @@ loadedmakefile::loadedmakefile(const fileinfo *pDir, vector<string> &Args,const
break;
case 'C':
#ifdef _DEBUG
- if ((*ArgIt)[2]=='D')
+ if (ArgIt->size()>2 && (*ArgIt)[2]=='D')
{
g_CheckCircularDeps=true;
break;
@@ -593,7 +593,7 @@ void loadedmakefile::LoadMakefile()
cout << "Loading makefile "<<m_Makefile->GetQuotedFullFileName()<<endl;
#endif
- m_pParser=refptr<mhmakeparser>(new mhmakeparser(m_CommandLineVars));
+ m_pParser=refptr<mhmakefileparser>(new mhmakeparser(m_CommandLineVars));
// Add the MAKECMDGOALS environment variable
string MakeCmdGoals;
diff --git a/tools/mhmake/src/util.h b/tools/mhmake/src/util.h
index ff1fac9aa..60809cd85 100644
--- a/tools/mhmake/src/util.h
+++ b/tools/mhmake/src/util.h
@@ -50,7 +50,7 @@
#define PLATFORM "linux"
#endif
-#define MHMAKEVER "2.2.9"
+#define MHMAKEVER "2.3.15"
class makecommand
{
@@ -170,7 +170,7 @@ struct loadedmakefile : public refbase
map<string,string> m_CommandLineVars;
vector<string> m_CommandLineTargets;
- refptr<mhmakeparser> m_pParser;
+ refptr<mhmakefileparser> m_pParser;
loadedmakefile(const fileinfo *pDir, vector<string> &Args,const string &Makefile=g_EmptyString);